diff --git a/general.pid b/general.pid new file mode 100644 index 0000000..51b0e76 --- /dev/null +++ b/general.pid @@ -0,0 +1 @@ +60000 \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/container/general/GeneralContainer.java b/src/main/java/com/loafle/overflow/container/general/GeneralContainer.java index 19e05ba..6ad8eac 100644 --- a/src/main/java/com/loafle/overflow/container/general/GeneralContainer.java +++ b/src/main/java/com/loafle/overflow/container/general/GeneralContainer.java @@ -1,5 +1,8 @@ package com.loafle.overflow.container.general; +import com.loafle.overflow.container.Container; +import com.loafle.overflow.container.configuration.ContainerConfiguration; +import com.loafle.overflow.container.general.server.GeneralContainerConfiguration; import com.loafle.overflow.container.general.server.GeneralContainerServer; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -13,12 +16,16 @@ public class GeneralContainer { } String pidFilePath = args[0]; - try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - "com.loafle.overflow")) { + try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { + context.getBeanFactory().registerSingleton(Container.PIDFILE_PATH, pidFilePath); + context.register(ContainerConfiguration.class, GeneralContainerConfiguration.class); + context.refresh(); context.registerShutdownHook(); - context.getBeanFactory().registerSingleton("pidFilePath", pidFilePath); GeneralContainerServer server = context.getBean(GeneralContainerServer.class); + //server.setPidFilePath(pidFilePath); server.start(); } } } + + diff --git a/src/main/java/com/loafle/overflow/container/general/crawler/Crawlers.java b/src/main/java/com/loafle/overflow/container/general/crawler/Crawlers.java index 5a61e43..6cdebe0 100644 --- a/src/main/java/com/loafle/overflow/container/general/crawler/Crawlers.java +++ b/src/main/java/com/loafle/overflow/container/general/crawler/Crawlers.java @@ -35,7 +35,7 @@ public abstract class Crawlers { crawlers.put(name, crawler); } - public Map getCrawlers() { + public static Map getCrawlers() { return Crawlers.crawlers; } diff --git a/src/main/java/com/loafle/overflow/container/general/server/GeneralContainerConfiguration.java b/src/main/java/com/loafle/overflow/container/general/server/GeneralContainerConfiguration.java new file mode 100644 index 0000000..c8e18a2 --- /dev/null +++ b/src/main/java/com/loafle/overflow/container/general/server/GeneralContainerConfiguration.java @@ -0,0 +1,34 @@ +package com.loafle.overflow.container.general.server; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.loafle.overflow.container.Container; +import com.loafle.overflow.container.general.crawler.Crawlers; +import com.loafle.overflow.crawler.Crawler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import io.netty.channel.ChannelHandler; + +/** + * GeneralContainerConfiguration + */ +@Configuration +@ComponentScan(basePackages = { "com.loafle.overflow" }) +public class GeneralContainerConfiguration { + + @Bean(Container.PIPELINE_CHANNEL_HANDLERS) + public List pipelineChannelHandlers() { + return new ArrayList<>(); + } + + @Bean(Container.CRAWLERS) + public Map crawlers() { + return Crawlers.getCrawlers(); + } + +} \ No newline at end of file diff --git a/src/main/resources/netty.properties b/src/main/resources/netty.properties new file mode 100644 index 0000000..d59d276 --- /dev/null +++ b/src/main/resources/netty.properties @@ -0,0 +1,2 @@ +server.netty.thread.count.boss=1 +server.netty.thread.count.worker=10 \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/DatabaseCrawlerTest.java b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/DatabaseCrawlerTest.java index 712724e..801df72 100644 --- a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/DatabaseCrawlerTest.java +++ b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/DatabaseCrawlerTest.java @@ -2,15 +2,12 @@ package com.loafle.overflow.container.general.crawler.impl.database; import com.google.gson.Gson; import com.loafle.overflow.container.general.crawler.CrawlerTest; -import com.loafle.overflow.model.sensorconfig.ResultSet; import com.loafle.overflow.model.sensorconfig.SensorConfig; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.List; import java.util.Map; public abstract class DatabaseCrawlerTest extends CrawlerTest { diff --git a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/mysql/MySQLCrawlerTest.java b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/mysql/MySQLCrawlerTest.java index 9d36102..dc238ec 100644 --- a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/mysql/MySQLCrawlerTest.java +++ b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/mysql/MySQLCrawlerTest.java @@ -1,11 +1,14 @@ package com.loafle.overflow.container.general.crawler.impl.database.mysql; import com.loafle.overflow.container.general.crawler.impl.database.DatabaseCrawlerTest; + +import org.junit.Ignore; import org.junit.Test; import java.util.Map; public class MySQLCrawlerTest extends DatabaseCrawlerTest { + @Ignore @Test public void testMySQL() throws Exception { Map result = new MySQLCrawler().get(getSensorConfig("config/mysql/mysql-test.json")); diff --git a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/sqlserver/SQLServerCrawlerTest.java b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/sqlserver/SQLServerCrawlerTest.java index 1813ab2..2091249 100644 --- a/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/sqlserver/SQLServerCrawlerTest.java +++ b/src/test/java/com/loafle/overflow/container/general/crawler/impl/database/sqlserver/SQLServerCrawlerTest.java @@ -4,7 +4,6 @@ import com.loafle.overflow.container.general.crawler.impl.database.DatabaseCrawl import org.junit.Ignore; import org.junit.Test; -import java.util.List; import java.util.Map; public class SQLServerCrawlerTest extends DatabaseCrawlerTest { diff --git a/src/test/java/com/loafle/overflow/container/general/crawler/impl/wmi/WMICrawlerTest.java b/src/test/java/com/loafle/overflow/container/general/crawler/impl/wmi/WMICrawlerTest.java index d5efa0e..03cc24b 100644 --- a/src/test/java/com/loafle/overflow/container/general/crawler/impl/wmi/WMICrawlerTest.java +++ b/src/test/java/com/loafle/overflow/container/general/crawler/impl/wmi/WMICrawlerTest.java @@ -52,6 +52,7 @@ public class WMICrawlerTest extends CrawlerTest { System.out.println(buf.toString()); } + @Ignore @Test public void testWMI() throws Exception { WMICrawler wmiCrawler = new WMICrawler(); @@ -90,6 +91,7 @@ public class WMICrawlerTest extends CrawlerTest { } + @Ignore @Test public void testOS() { System.out.println(System.getProperty("os.name")); @@ -207,6 +209,7 @@ public class WMICrawlerTest extends CrawlerTest { return retList; } + @Ignore @Test public void testInt() { @@ -223,6 +226,7 @@ public class WMICrawlerTest extends CrawlerTest { } + @Ignore @Test public void testString() { @@ -240,6 +244,7 @@ public class WMICrawlerTest extends CrawlerTest { } + @Ignore @Test public void testReplace() { @@ -254,6 +259,7 @@ public class WMICrawlerTest extends CrawlerTest { } + @Ignore @Test public void testMap() { @@ -275,6 +281,7 @@ public class WMICrawlerTest extends CrawlerTest { } + @Ignore @Test public void testRes() throws IOException { ClassLoader classLoader = getClass().getClassLoader();