parent
5db77de4ae
commit
73c2256f81
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>xxl-job</artifactId>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<version>2.4.2-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>wanhua-executor-plugins</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>wanhua-frameless-stationv3-collector-plugin</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>wanhua-executor-plugins</artifactId>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<version>2.4.2-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>wanhua-frameless-stationv3-collector-plugin</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- slf4j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>${slf4j-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${junit-jupiter.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- xxl-job-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<artifactId>xxl-job-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.wanhua.frameless.stationv3;
|
||||||
|
|
||||||
|
import com.wanhua.frameless.stationv3.config.StationV3CollectorJobConfig;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuxueli 2018-10-31 19:05:43
|
||||||
|
*/
|
||||||
|
public class FramelessStationV3CollectorApplication {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(FramelessStationV3CollectorApplication.class);
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// start
|
||||||
|
StationV3CollectorJobConfig.getInstance().initXxlJobExecutor();
|
||||||
|
|
||||||
|
// Blocks until interrupted
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
TimeUnit.HOURS.sleep(1);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
// destroy
|
||||||
|
StationV3CollectorJobConfig.getInstance().destroyXxlJobExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.wanhua.frameless.stationv3.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xxl.job.core.executor.impl.XxlJobSimpleExecutor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import com.wanhua.frameless.stationv3.jobhandler.StationV3CollectorJob;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuxueli 2018-10-31 19:05:43
|
||||||
|
*/
|
||||||
|
public class StationV3CollectorJobConfig {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(StationV3CollectorJobConfig.class);
|
||||||
|
|
||||||
|
|
||||||
|
private static StationV3CollectorJobConfig instance = new StationV3CollectorJobConfig();
|
||||||
|
public static StationV3CollectorJobConfig getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private XxlJobSimpleExecutor xxlJobExecutor = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* init
|
||||||
|
*/
|
||||||
|
public void initXxlJobExecutor() {
|
||||||
|
|
||||||
|
// load executor prop
|
||||||
|
Properties xxlJobProp = loadProperties("xxl-job-executor.properties");
|
||||||
|
|
||||||
|
// init executor
|
||||||
|
xxlJobExecutor = new XxlJobSimpleExecutor();
|
||||||
|
xxlJobExecutor.setAdminAddresses(xxlJobProp.getProperty("xxl.job.admin.addresses"));
|
||||||
|
xxlJobExecutor.setAccessToken(xxlJobProp.getProperty("xxl.job.accessToken"));
|
||||||
|
xxlJobExecutor.setAppname(xxlJobProp.getProperty("xxl.job.executor.appname"));
|
||||||
|
xxlJobExecutor.setAddress(xxlJobProp.getProperty("xxl.job.executor.address"));
|
||||||
|
xxlJobExecutor.setIp(xxlJobProp.getProperty("xxl.job.executor.ip"));
|
||||||
|
xxlJobExecutor.setPort(Integer.valueOf(xxlJobProp.getProperty("xxl.job.executor.port")));
|
||||||
|
xxlJobExecutor.setLogPath(xxlJobProp.getProperty("xxl.job.executor.logpath"));
|
||||||
|
xxlJobExecutor.setLogRetentionDays(Integer.valueOf(xxlJobProp.getProperty("xxl.job.executor.logretentiondays")));
|
||||||
|
|
||||||
|
// registry job bean
|
||||||
|
xxlJobExecutor.setXxlJobBeanList(Arrays.asList(new StationV3CollectorJob()));
|
||||||
|
|
||||||
|
// start executor
|
||||||
|
try {
|
||||||
|
xxlJobExecutor.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* destroy
|
||||||
|
*/
|
||||||
|
public void destroyXxlJobExecutor() {
|
||||||
|
if (xxlJobExecutor != null) {
|
||||||
|
xxlJobExecutor.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Properties loadProperties(String propertyFileName) {
|
||||||
|
InputStreamReader in = null;
|
||||||
|
try {
|
||||||
|
ClassLoader loder = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
in = new InputStreamReader(loder.getResourceAsStream(propertyFileName), "UTF-8");;
|
||||||
|
if (in != null) {
|
||||||
|
Properties prop = new Properties();
|
||||||
|
prop.load(in);
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("load {} error!", propertyFileName);
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("close {} error!", propertyFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" threshold="null" debug="null">
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
||||||
|
<param name="Target" value="System.out" />
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-frameless [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="file" value="/data/applogs/xxl-job/xxl-job-executor-sample-frameless.log"/>
|
||||||
|
<param name="append" value="true"/>
|
||||||
|
<param name="encoding" value="UTF-8"/>
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-frameless [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<level value="INFO" />
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
@ -0,0 +1,17 @@
|
|||||||
|
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
|
||||||
|
xxl.job.admin.addresses=https://10.201.1.101:8082/internal/etl/xxl-job-admin
|
||||||
|
|
||||||
|
### xxl-job, access token
|
||||||
|
xxl.job.accessToken=default_token
|
||||||
|
|
||||||
|
### xxl-job executor appname
|
||||||
|
xxl.job.executor.appname=gsmsv3_collect
|
||||||
|
### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
|
||||||
|
xxl.job.executor.address=
|
||||||
|
### xxl-job executor server-info
|
||||||
|
xxl.job.executor.ip=
|
||||||
|
xxl.job.executor.port=19998
|
||||||
|
### xxl-job executor log-path
|
||||||
|
xxl.job.executor.logpath=logs/xxl-job/jobhandler
|
||||||
|
### xxl-job executor log-retention-days
|
||||||
|
xxl.job.executor.logretentiondays=30
|
Loading…
Reference in new issue