This commit is contained in:
crusader 2018-04-24 22:23:44 +09:00
parent 37cac2b0d3
commit a5330571f9
3 changed files with 38 additions and 30 deletions

View File

@ -10,6 +10,7 @@ import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.interfaces.Service;
import com.loafle.overflow.crawler.Crawler;
import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.service.container.CrawlerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,37 +20,38 @@ import org.springframework.beans.factory.annotation.Autowired;
* CrawlerService
*/
@RPCService("CrawlerService")
public class CrawlerService implements Service {
private static final Logger logger = LoggerFactory.getLogger(CrawlerService.class);
public class ContainerCrawlerService implements Service, CrawlerService {
private static final Logger logger = LoggerFactory.getLogger(ContainerCrawlerService.class);
@Autowired
private SensorConfigService sensorConfigService;
@Resource(name=Container.CRAWLERS)
@Resource(name = Container.CRAWLERS)
private Map<String, Crawler> crawlers;
@Override
public void initService() throws Exception {
if (null == this.crawlers) {
@Override
public void initService() throws Exception {
if (null == this.crawlers) {
throw new Exception("Crawlers is not set");
}
}
@Override
public void startService() throws Exception {
}
@Override
public void stopService() {
}
}
@Override
public void destroyService() {
public void startService() throws Exception {
}
}
@Override
public void stopService() {
}
@Override
public void destroyService() {
}
@Override
public void Auth(String crawlerName, Map<String, Object> authInfoMap) throws OverflowException {
Crawler crawler = this.crawlers.get(crawlerName);
if (null == crawler) {
@ -59,6 +61,7 @@ public class CrawlerService implements Service {
crawler.auth(authInfoMap);
}
@Override
public Map<String, String> Get(String sensorConfigID) throws OverflowException {
SensorConfig sensorConfig = this.sensorConfigService.getSensorConfig(sensorConfigID);
if (null == sensorConfig) {
@ -74,4 +77,3 @@ public class CrawlerService implements Service {
return crawler.get(sensorConfig);
}
}

View File

@ -3,12 +3,13 @@ package com.loafle.overflow.container.service;
import com.loafle.overflow.core.annotation.RPCService;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.interfaces.Service;
import com.loafle.overflow.service.container.ProbeService;
/**
* ProbeService
*/
@RPCService("ProbeService")
public class ProbeService implements Service {
public class ContainerProbeService implements Service, ProbeService {
@Override
public void initService() throws Exception {

View File

@ -8,6 +8,7 @@ import com.loafle.overflow.core.annotation.RPCService;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.interfaces.Service;
import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.service.container.SensorConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,8 +17,8 @@ import org.slf4j.LoggerFactory;
* SensorConfigService
*/
@RPCService("SensorConfigService")
public class SensorConfigService implements Service {
private static final Logger logger = LoggerFactory.getLogger(SensorConfigService.class);
public class ContainerSensorConfigService implements Service, SensorConfigService {
private static final Logger logger = LoggerFactory.getLogger(ContainerSensorConfigService.class);
private Map<String, SensorConfig> sensorConfigs;
@ -45,6 +46,7 @@ public class SensorConfigService implements Service {
return this.sensorConfigs.get(configID);
}
@Override
public void InitConfig(List<SensorConfig> sensorConfigs) throws OverflowException {
if (null == sensorConfigs || 0 == sensorConfigs.size()) {
return;
@ -56,6 +58,7 @@ public class SensorConfigService implements Service {
logger.debug("Sensor configs[%d] were added", sensorConfigs.size());
}
@Override
public void AddConfig(SensorConfig sensorConfig) throws OverflowException {
if (null == sensorConfig) {
throw new OverflowException("Sensor config is not valid", null);
@ -71,7 +74,8 @@ public class SensorConfigService implements Service {
logger.debug("Sensor config[%s] was added", configID);
}
public void UddConfig(SensorConfig sensorConfig) throws OverflowException {
@Override
public void UpdateConfig(SensorConfig sensorConfig) throws OverflowException {
if (null == sensorConfig) {
throw new OverflowException("Sensor config is not valid", null);
}
@ -87,7 +91,8 @@ public class SensorConfigService implements Service {
logger.debug("Sensor config[%s] was updated", configID);
}
public void RddConfig(String configID) throws OverflowException {
@Override
public void RemoveConfig(String configID) throws OverflowException {
if (!this.sensorConfigs.containsKey(configID)) {
throw new OverflowException(String.format("Sensor config[%s] is not exist", configID), null);
}