ing
This commit is contained in:
parent
6ae1c8b7bd
commit
4b595bdc79
1
general.pid
Normal file
1
general.pid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
60000
|
|
@ -1,5 +1,8 @@
|
||||||
package com.loafle.overflow.container.general;
|
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 com.loafle.overflow.container.general.server.GeneralContainerServer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
@ -13,12 +16,16 @@ public class GeneralContainer {
|
||||||
}
|
}
|
||||||
String pidFilePath = args[0];
|
String pidFilePath = args[0];
|
||||||
|
|
||||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
|
||||||
"com.loafle.overflow")) {
|
context.getBeanFactory().registerSingleton(Container.PIDFILE_PATH, pidFilePath);
|
||||||
|
context.register(ContainerConfiguration.class, GeneralContainerConfiguration.class);
|
||||||
|
context.refresh();
|
||||||
context.registerShutdownHook();
|
context.registerShutdownHook();
|
||||||
context.getBeanFactory().registerSingleton("pidFilePath", pidFilePath);
|
|
||||||
GeneralContainerServer server = context.getBean(GeneralContainerServer.class);
|
GeneralContainerServer server = context.getBean(GeneralContainerServer.class);
|
||||||
|
//server.setPidFilePath(pidFilePath);
|
||||||
server.start();
|
server.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public abstract class Crawlers {
|
||||||
crawlers.put(name, crawler);
|
crawlers.put(name, crawler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Crawler> getCrawlers() {
|
public static Map<String, Crawler> getCrawlers() {
|
||||||
return Crawlers.crawlers;
|
return Crawlers.crawlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<ChannelHandler> pipelineChannelHandlers() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(Container.CRAWLERS)
|
||||||
|
public Map<String, Crawler> crawlers() {
|
||||||
|
return Crawlers.getCrawlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
2
src/main/resources/netty.properties
Normal file
2
src/main/resources/netty.properties
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
server.netty.thread.count.boss=1
|
||||||
|
server.netty.thread.count.worker=10
|
|
@ -2,15 +2,12 @@ package com.loafle.overflow.container.general.crawler.impl.database;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.loafle.overflow.container.general.crawler.CrawlerTest;
|
import com.loafle.overflow.container.general.crawler.CrawlerTest;
|
||||||
import com.loafle.overflow.model.sensorconfig.ResultSet;
|
|
||||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class DatabaseCrawlerTest extends CrawlerTest {
|
public abstract class DatabaseCrawlerTest extends CrawlerTest {
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.loafle.overflow.container.general.crawler.impl.database.mysql;
|
package com.loafle.overflow.container.general.crawler.impl.database.mysql;
|
||||||
|
|
||||||
import com.loafle.overflow.container.general.crawler.impl.database.DatabaseCrawlerTest;
|
import com.loafle.overflow.container.general.crawler.impl.database.DatabaseCrawlerTest;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MySQLCrawlerTest extends DatabaseCrawlerTest {
|
public class MySQLCrawlerTest extends DatabaseCrawlerTest {
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testMySQL() throws Exception {
|
public void testMySQL() throws Exception {
|
||||||
Map<String, String> result = new MySQLCrawler().get(getSensorConfig("config/mysql/mysql-test.json"));
|
Map<String, String> result = new MySQLCrawler().get(getSensorConfig("config/mysql/mysql-test.json"));
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.loafle.overflow.container.general.crawler.impl.database.DatabaseCrawl
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SQLServerCrawlerTest extends DatabaseCrawlerTest {
|
public class SQLServerCrawlerTest extends DatabaseCrawlerTest {
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
System.out.println(buf.toString());
|
System.out.println(buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testWMI() throws Exception {
|
public void testWMI() throws Exception {
|
||||||
WMICrawler wmiCrawler = new WMICrawler();
|
WMICrawler wmiCrawler = new WMICrawler();
|
||||||
|
@ -90,6 +91,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testOS() {
|
public void testOS() {
|
||||||
System.out.println(System.getProperty("os.name"));
|
System.out.println(System.getProperty("os.name"));
|
||||||
|
@ -207,6 +209,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testInt() {
|
public void testInt() {
|
||||||
|
|
||||||
|
@ -223,6 +226,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testString() {
|
public void testString() {
|
||||||
|
|
||||||
|
@ -240,6 +244,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testReplace() {
|
public void testReplace() {
|
||||||
|
|
||||||
|
@ -254,6 +259,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testMap() {
|
public void testMap() {
|
||||||
|
|
||||||
|
@ -275,6 +281,7 @@ public class WMICrawlerTest extends CrawlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testRes() throws IOException {
|
public void testRes() throws IOException {
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user