diff --git a/src/main/java/com/loafle/overflow/container/service/CrawlerService.java b/src/main/java/com/loafle/overflow/container/service/ContainerCrawlerService.java similarity index 78% rename from src/main/java/com/loafle/overflow/container/service/CrawlerService.java rename to src/main/java/com/loafle/overflow/container/service/ContainerCrawlerService.java index a88b537..b977886 100644 --- a/src/main/java/com/loafle/overflow/container/service/CrawlerService.java +++ b/src/main/java/com/loafle/overflow/container/service/ContainerCrawlerService.java @@ -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,59 +20,60 @@ 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 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 authInfoMap) throws OverflowException { Crawler crawler = this.crawlers.get(crawlerName); if (null == crawler) { throw new OverflowException(String.format("There is no crawler[%s]", crawlerName), null); } - + crawler.auth(authInfoMap); } - + + @Override public Map Get(String sensorConfigID) throws OverflowException { SensorConfig sensorConfig = this.sensorConfigService.getSensorConfig(sensorConfigID); if (null == sensorConfig) { throw new OverflowException(String.format("There is no sensor config for id[%s]", sensorConfigID), null); } - + String crawlerName = sensorConfig.getCrawler().getName(); Crawler crawler = this.crawlers.get(crawlerName); if (null == crawler) { throw new OverflowException(String.format("There is no crawler[%s] for id[%s]", crawlerName, sensorConfigID), null); } - + return crawler.get(sensorConfig); } } - diff --git a/src/main/java/com/loafle/overflow/container/service/ProbeService.java b/src/main/java/com/loafle/overflow/container/service/ContainerProbeService.java similarity index 81% rename from src/main/java/com/loafle/overflow/container/service/ProbeService.java rename to src/main/java/com/loafle/overflow/container/service/ContainerProbeService.java index 6272c78..5553e7b 100644 --- a/src/main/java/com/loafle/overflow/container/service/ProbeService.java +++ b/src/main/java/com/loafle/overflow/container/service/ContainerProbeService.java @@ -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 { diff --git a/src/main/java/com/loafle/overflow/container/service/SensorConfigService.java b/src/main/java/com/loafle/overflow/container/service/ContainerSensorConfigService.java similarity index 84% rename from src/main/java/com/loafle/overflow/container/service/SensorConfigService.java rename to src/main/java/com/loafle/overflow/container/service/ContainerSensorConfigService.java index 5127435..1e25b8b 100644 --- a/src/main/java/com/loafle/overflow/container/service/SensorConfigService.java +++ b/src/main/java/com/loafle/overflow/container/service/ContainerSensorConfigService.java @@ -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 sensorConfigs; @@ -45,6 +46,7 @@ public class SensorConfigService implements Service { return this.sensorConfigs.get(configID); } + @Override public void InitConfig(List 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); }