diff --git a/README.md b/README.md
index 546594322..28b36c3aa 100644
--- a/README.md
+++ b/README.md
@@ -352,26 +352,35 @@ class JobRunnerB implements JobRunner {
}
```
##TaskTracker的JobRunner测试
-一般在编写TaskTracker的时候,只需要测试JobRunner的实现逻辑是否正确,又不想启动LTS进行远程测试。为了方便测试,LTS提供了JobRunner的快捷测试方法。自己的测试类集成`com.github.ltsopensource.tasktracker.runner.JobRunnerTester`即可,并实现`initContext`和`newJobRunner`方法即可。如`lts-example`中的例子:
+一般在编写TaskTracker的时候,只需要测试JobRunner的实现逻辑是否正确,又不想启动LTS进行远程测试。为了方便测试,LTS提供了JobRunner的快捷测试方法。自己的测试类集成`com.github.ltsopensource.tasktracker.runner.JobRunnerTester`即可,并实现`initContext`和`newJobRunner`方法即可。如[lts-examples](https://github.com/ltsopensource/lts-examples)中的例子:
```java
public class TestJobRunnerTester extends JobRunnerTester {
-
+
public static void main(String[] args) throws Throwable {
- // 1. Mock Job 数据
+ // Mock Job 数据
Job job = new Job();
job.setTaskId("2313213");
- // 2. 运行测试
+
+ JobContext jobContext = new JobContext();
+ jobContext.setJob(job);
+
+ JobExtInfo jobExtInfo = new JobExtInfo();
+ jobExtInfo.setRetry(false);
+
+ jobContext.setJobExtInfo(jobExtInfo);
+
+ // 运行测试
TestJobRunnerTester tester = new TestJobRunnerTester();
- Result result = tester.run(job);
- System.out.println(JSONUtils.toJSONString(result));
+ Result result = tester.run(jobContext);
+ System.out.println(JSON.toJSONString(result));
}
-
+
@Override
protected void initContext() {
- // TODO 初始化Spring容器等
+ // TODO 初始化Spring容器
}
-
+
@Override
protected JobRunner newJobRunner() {
return new TestJobRunner();
@@ -407,13 +416,9 @@ public class Application {
剩下的就只是在application.properties中添加相应的配置就行了, 具体见lts-example中的`com.github.ltsopensource.examples.springboot`包下的例子
-
##多网卡选择问题
当机器有内网两个网卡的时候,有时候,用户想让LTS的流量走外网网卡,那么需要在host中,把主机名称的映射地址改为外网网卡地址即可,内网同理。
-##打包成独立jar
-请在`lts-parent/lts` 下install即可,会在 `lts-parent/lts/target` 下生成`lts-{version}.jar`
-
##关于节点标识问题
如果在节点启动的时候设置节点标识,LTS会默认设置一个UUID为节点标识,可读性会比较差,但是能保证每个节点的唯一性,如果用户能自己保证节点标识的唯一性,可以通过 `setIdentity` 来设置,譬如如果每个节点都是部署在一台机器(一个虚拟机)上,那么可以将identity设置为主机名称
diff --git a/lts-example/pom.xml b/lts-example/pom.xml
deleted file mode 100644
index 8b7cca2aa..000000000
--- a/lts-example/pom.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-
-
-
- lts-parent
- com.github.ltsopensource
- 1.6.8-SNAPSHOT
-
- 4.0.0
- lts-example
-
-
- com.github.ltsopensource
- lts-jobtracker
- ${project.version}
-
-
- com.github.ltsopensource
- lts-tasktracker
- ${project.version}
-
-
- com.github.ltsopensource
- lts-jobclient
- ${project.version}
-
-
- com.github.ltsopensource
- lts-monitor
- ${project.version}
-
-
- com.github.ltsopensource
- lts-spring
- ${project.version}
-
-
- log4j
- log4j
-
-
- com.github.sgroschupf
- zkclient
-
-
- org.apache.curator
- curator-recipes
-
-
- redis.clients
- jedis
-
-
- com.sleepycat
- je
-
-
- org.rocksdb
- rocksdbjni
-
-
- org.fusesource.leveldbjni
- leveldbjni-all
-
-
- junit
- junit
- test
-
-
- org.springframework
- spring-core
- ${springframework.version}
-
-
- org.springframework
- spring-beans
- ${springframework.version}
-
-
- org.springframework
- spring-context
- ${springframework.version}
-
-
- org.springframework
- spring-context-support
- ${springframework.version}
-
-
- org.springframework
- spring-tx
- ${springframework.version}
-
-
- org.apache.mina
- mina-core
-
-
- io.netty
- netty-all
-
-
- com.caucho
- hessian
-
-
- org.mapdb
- mapdb
-
-
- com.alibaba
- fastjson
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- org.mongodb.morphia
- morphia
-
-
- org.mongodb
- mongo-java-driver
-
-
- mysql
- mysql-connector-java
-
-
- com.alibaba
- druid
-
-
- org.quartz-scheduler
- quartz
- 2.2.2
-
-
- org.springframework.boot
- spring-boot
-
-
- org.springframework.boot
- spring-boot-autoconfigure
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/api/JobClientTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/api/JobClientTest.java
deleted file mode 100644
index 0e1c96e2b..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/api/JobClientTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.github.ltsopensource.example.api;
-
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.example.support.BaseJobClientTest;
-import com.github.ltsopensource.example.support.JobCompletedHandlerImpl;
-import com.github.ltsopensource.example.support.MasterChangeListenerImpl;
-import com.github.ltsopensource.jobclient.JobClient;
-import com.github.ltsopensource.jobclient.JobClientBuilder;
-import com.github.ltsopensource.jobclient.RetryJobClient;
-import com.github.ltsopensource.jobclient.domain.Response;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/13/14.
- */
-@SuppressWarnings("rawtypes")
-public class JobClientTest extends BaseJobClientTest {
-
- public static void main(String[] args) throws IOException {
-// submitWidthReplaceOnExist();
- console();
-// testProtector();
-// cancelJob();
-// submitWidthNonRelyOnPrevCycle();
- }
-
- public static void submitWidthReplaceOnExist() throws IOException {
- JobClient jobClient = new JobClientBuilder()
- .setPropertiesConfigure(new String[]{"application.properties"})
- .setJobCompletedHandler(new JobCompletedHandlerImpl())
-// .addMasterChangeListener(new MasterChangeListenerImpl())
- .build();
- jobClient.start();
-
- Job job = new Job();
- job.setTaskId("t_555");
- job.setParam("shopId", "1122222221");
- job.setTaskTrackerNodeGroup("test_trade_TaskTracker");
- job.setNeedFeedback(true);
- job.setReplaceOnExist(true); // 当任务队列中存在这个任务的时候,是否替换更新
- job.setCronExpression("0 0/1 * * * ?");
-// job.setTriggerTime(DateUtils.addDay(new Date(), 1));
- Response response = jobClient.submitJob(job);
- System.out.println(response);
- }
-
- public static void submitWidthNonRelyOnPrevCycle() throws IOException {
- // 推荐使用RetryJobClient
- JobClient jobClient = new RetryJobClient();
- jobClient.setNodeGroup("test_jobClient");
- jobClient.setClusterName("test_cluster");
- jobClient.setRegistryAddress("zookeeper://127.0.0.1:2181");
- jobClient.setJobCompletedHandler(new JobCompletedHandlerImpl());
- jobClient.start();
-
- Job job = new Job();
- job.setTaskId("t_test_344444");
- job.setParam("shopId", "1122222221");
- job.setTaskTrackerNodeGroup("test_trade_TaskTracker");
- job.setNeedFeedback(false);
- job.setCronExpression("0/30 * * * * ?");
-// job.setRepeatInterval(30 * 1000L);
-// job.setRepeatCount(25);
- job.setRelyOnPrevCycle(false);
-// job.setTriggerTime(DateUtils.addDay(new Date(), 1));
- Response response = jobClient.submitJob(job);
- System.out.println(response);
- }
-
- public static void cancelJob() {
- JobClient jobClient = new JobClientBuilder()
- .setPropertiesConfigure(new String[]{"application.properties"})
- .setJobCompletedHandler(new JobCompletedHandlerImpl())
-// .addMasterChangeListener(new MasterChangeListenerImpl())
- .build();
- jobClient.start();
-
- jobClient.cancelJob("t_4", "test_trade_TaskTracker");
- }
-
-
- public static void console() throws IOException {
-
- JobClient jobClient = new JobClientBuilder()
- .setPropertiesConfigure(new String[]{"application.properties"})
- .setJobCompletedHandler(new JobCompletedHandlerImpl())
- .addMasterChangeListener(new MasterChangeListenerImpl())
- .build();
- jobClient.start();
-
- JobClientTest jobClientTest = new JobClientTest();
- jobClientTest.jobClient = jobClient;
- jobClientTest.startConsole();
- }
-
-}
\ No newline at end of file
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/api/JobTrackerTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/api/JobTrackerTest.java
deleted file mode 100644
index 168aa563e..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/api/JobTrackerTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.github.ltsopensource.example.api;
-
-import com.github.ltsopensource.example.support.MasterChangeListenerImpl;
-import com.github.ltsopensource.jobtracker.JobTracker;
-import com.github.ltsopensource.jobtracker.JobTrackerBuilder;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/13/14.
- */
-public class JobTrackerTest {
-
- public static void main(String[] args) {
- testMysqlQueue();
- }
-
- /**
- * 使用mysql做任务队列
- */
- public static void testMysqlQueue() {
-
- final JobTracker jobTracker = new JobTrackerBuilder()
- .setPropertiesConfigure("application.properties")
- .addMasterChangeListener(new MasterChangeListenerImpl())
- .build();
-
- jobTracker.start();
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- jobTracker.stop();
- }
- }));
-
- }
-
-}
\ No newline at end of file
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/api/TaskTrackerTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/api/TaskTrackerTest.java
deleted file mode 100644
index fa836c688..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/api/TaskTrackerTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.github.ltsopensource.example.api;
-
-import com.github.ltsopensource.tasktracker.TaskTracker;
-import com.github.ltsopensource.tasktracker.TaskTrackerBuilder;
-
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/19/14.
- */
-public class TaskTrackerTest {
-
- public static void main(String[] args) {
-
- final TaskTracker taskTracker = new TaskTrackerBuilder()
- .setPropertiesConfigure("application.properties")
- .build();
- taskTracker.start();
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- taskTracker.stop();
- }
- }));
- }
-}
\ No newline at end of file
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringAnnotationTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringAnnotationTest.java
deleted file mode 100644
index e1a5542dd..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringAnnotationTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import com.github.ltsopensource.core.commons.utils.Assert;
-import com.github.ltsopensource.jobclient.JobClient;
-import com.github.ltsopensource.jobtracker.JobTracker;
-import com.github.ltsopensource.tasktracker.TaskTracker;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/23/15.
- */
-@SuppressWarnings({"rawtypes","resource"})
-public class SpringAnnotationTest {
-
- public static void main(String[] args) throws IOException {
-
- ApplicationContext context = new ClassPathXmlApplicationContext("spring/lts-annotation.xml");
-
- JobTracker jobTracker = (JobTracker) context.getBean("jobTracker");
- Assert.notNull(jobTracker);
- jobTracker.start();
-
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ignore) {
- }
-
- TaskTracker taskTracker = (TaskTracker) context.getBean("taskTracker");
- Assert.notNull(taskTracker);
- taskTracker.start();
-
- JobClient jobClient = (JobClient) context.getBean("jobClient");
- Assert.notNull(jobClient);
- jobClient.start();
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobClientTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobClientTest.java
deleted file mode 100644
index 4a619f18a..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobClientTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import com.github.ltsopensource.example.support.BaseJobClientTest;
-import com.github.ltsopensource.jobclient.JobClient;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-@SuppressWarnings({"rawtypes","resource"})
-public class SpringJobClientTest extends BaseJobClientTest {
-
- public static void main(String[] args) throws IOException {
-
- ApplicationContext context = new ClassPathXmlApplicationContext("/spring/lts-jobclient.xml");
-
- JobClient jobClient = (JobClient) context.getBean("jobClient");
-
- jobClient.start();
-
- SpringJobClientTest jobClientTest = new SpringJobClientTest();
- jobClientTest.jobClient = jobClient;
- jobClientTest.startConsole();
-
- System.in.read();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobTrackerTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobTrackerTest.java
deleted file mode 100644
index 51f31c05d..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringJobTrackerTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-public class SpringJobTrackerTest {
-
- public static void main(String[] args) throws IOException {
- new ClassPathXmlApplicationContext("/spring/lts-jobtracker.xml");
- System.in.read();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardAnnotationTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardAnnotationTest.java
deleted file mode 100644
index c50e2d40d..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardAnnotationTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-public class SpringTaskTrackerShardAnnotationTest {
-
- public static void main(String[] args) throws IOException {
-
- new ClassPathXmlApplicationContext("/spring/lts-tasktracker-shard-annotaion.xml");
- System.in.read();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardXmlTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardXmlTest.java
deleted file mode 100644
index b35332f1c..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerShardXmlTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-public class SpringTaskTrackerShardXmlTest {
-
- public static void main(String[] args) throws IOException {
-
- new ClassPathXmlApplicationContext("/spring/lts-tasktracker-shard-xml.xml");
- System.in.read();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerTest.java
deleted file mode 100644
index 62a36f7dd..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/SpringTaskTrackerTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.github.ltsopensource.example.spring;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.IOException;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-public class SpringTaskTrackerTest {
-
- public static void main(String[] args) throws IOException {
-
- new ClassPathXmlApplicationContext("/spring/lts-tasktracker.xml");
- System.in.read();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/JobScheduler.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/JobScheduler.java
deleted file mode 100644
index bb5b58124..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/JobScheduler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.github.ltsopensource.example.spring.jobrunner;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.example.support.SpringBean;
-import com.github.ltsopensource.spring.tasktracker.JobRunnerItem;
-import com.github.ltsopensource.spring.tasktracker.LTS;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Robert HG (254963746@qq.com) on 10/20/15.
- */
-@LTS
-public class JobScheduler {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JobScheduler.class);
-
- @Autowired
- SpringBean springBean;
-
- @JobRunnerItem(shardValue = "111")
- public Result runJob1(Job job) throws Throwable {
- try {
- Thread.sleep(1000L);
-
- springBean.hello();
-
- LOGGER.info("runJob1 我要执行:" + job);
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_LATER, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-
- @JobRunnerItem(shardValue = "222")
- public void runJob2() throws Throwable {
- try {
- springBean.hello();
-
- LOGGER.info("runJob2 我要执行");
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- }
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/XmlJobScheduler.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/XmlJobScheduler.java
deleted file mode 100644
index ce451a8da..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/jobrunner/XmlJobScheduler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.github.ltsopensource.example.spring.jobrunner;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.example.support.SpringBean;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Robert HG (254963746@qq.com)on 12/21/15.
- */
-public class XmlJobScheduler {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JobScheduler.class);
-
- @Autowired
- SpringBean springBean;
-
- public Result runJob1(Job job) throws Throwable {
- try {
- Thread.sleep(1000L);
-
- springBean.hello();
-
- LOGGER.info("runJob1 我要执行:" + job);
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_LATER, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-
- public Result runJob2() throws Throwable {
- try {
- springBean.hello();
-
- LOGGER.info("runJob2 我要执行");
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_LATER, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/NativeQuartzTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/NativeQuartzTest.java
deleted file mode 100644
index a92ddf579..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/NativeQuartzTest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.github.ltsopensource.example.spring.quartz;
-
-import com.github.ltsopensource.core.support.AliveKeeping;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/16/16.
- */
-public class NativeQuartzTest {
-
- public static void main(String[] args) {
-
- ApplicationContext context = new ClassPathXmlApplicationContext("/spring/lts-quartz.xml");
-
- AliveKeeping.start();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTest.java
deleted file mode 100644
index 291d1a507..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.github.ltsopensource.example.spring.quartz;
-
-import com.github.ltsopensource.core.commons.utils.DateUtils;
-
-import java.util.Date;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/16/16.
- */
-public class QuartzTest {
-
- public void autoRun() throws InterruptedException {
- System.out.println(DateUtils.formatYMD_HMS(new Date()) + " 我开始执行了...");
-// Thread.sleep(6000);
-// System.out.println(DateUtils.formatYMD_HMS(new Date()) + " 我执行完了...");
-
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTestJob.java b/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTestJob.java
deleted file mode 100644
index 09b2ed81b..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/spring/quartz/QuartzTestJob.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.github.ltsopensource.example.spring.quartz;
-
-import com.github.ltsopensource.core.commons.utils.DateUtils;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.scheduling.quartz.QuartzJobBean;
-
-import java.util.Date;
-import java.util.Map;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/16/16.
- */
-public class QuartzTestJob extends QuartzJobBean {
-
- @Override
- protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
-
- for (Map.Entry entry : context.getMergedJobDataMap().entrySet()) {
- System.out.println(entry.getKey() + ":" + entry.getValue());
- }
- System.out.println(DateUtils.formatYMD_HMS(new Date()) + " 我开始执行了...");
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/Application.java b/lts-example/src/main/java/com/github/ltsopensource/example/springboot/Application.java
deleted file mode 100644
index bccff34ba..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/Application.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.github.ltsopensource.example.springboot;
-
-import com.github.ltsopensource.spring.boot.annotation.EnableJobClient;
-import com.github.ltsopensource.spring.boot.annotation.EnableJobTracker;
-import com.github.ltsopensource.spring.boot.annotation.EnableMonitor;
-import com.github.ltsopensource.spring.boot.annotation.EnableTaskTracker;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
-import org.springframework.context.annotation.ComponentScan;
-
-/**
- * @author Robert HG (254963746@qq.com) on 4/9/16.
- */
-@SpringBootApplication
-@EnableJobTracker
-@EnableJobClient
-@EnableTaskTracker
-@EnableMonitor
-// 因为示例里面引入了mongo的包,所以要把这个排查, 自己的工程如果不用mongo做任务队列的时候,就不用写这个排除了
-@EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class})
-@ComponentScan("com.github.ltsopensource.example")
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobClientReferenceBean.java b/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobClientReferenceBean.java
deleted file mode 100644
index c4590b0ff..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobClientReferenceBean.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.github.ltsopensource.example.springboot;
-
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.jobclient.JobClient;
-import com.github.ltsopensource.jobclient.domain.Response;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author Robert HG (254963746@qq.com) on 4/9/16.
- */
-@Component
-public class JobClientReferenceBean implements InitializingBean {
-
- @Autowired
- private JobClient jobClient;
-
- @Override
- public void afterPropertiesSet() throws Exception {
-
- Job job = new Job();
- job.setTaskId("t_555");
- job.setParam("shopId", "1122222221");
- job.setTaskTrackerNodeGroup("test_trade_TaskTracker");
- job.setNeedFeedback(true);
- job.setReplaceOnExist(true); // 当任务队列中存在这个任务的时候,是否替换更新
- job.setCronExpression("0 0/1 * * * ?");
-// job.setTriggerTime(DateUtils.addDay(new Date(), 1));
- Response response = jobClient.submitJob(job);
- System.out.println(response);
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobCompletedHandlerImpl.java b/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobCompletedHandlerImpl.java
deleted file mode 100644
index 347d9704e..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobCompletedHandlerImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.github.ltsopensource.example.springboot;
-
-import com.github.ltsopensource.core.commons.utils.CollectionUtils;
-import com.github.ltsopensource.core.domain.JobResult;
-import com.github.ltsopensource.jobclient.support.JobCompletedHandler;
-import com.github.ltsopensource.spring.boot.annotation.JobCompletedHandler4JobClient;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Robert HG (254963746@qq.com) on 4/9/16.
- */
-@JobCompletedHandler4JobClient
-public class JobCompletedHandlerImpl implements JobCompletedHandler {
- @Override
- public void onComplete(List jobResults) {
- // 任务执行反馈结果处理
- if (CollectionUtils.isNotEmpty(jobResults)) {
- for (JobResult jobResult : jobResults) {
- System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " 任务执行完成:" + jobResult);
- }
- }
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobRunnerImpl.java b/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobRunnerImpl.java
deleted file mode 100644
index 829387a92..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/JobRunnerImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.github.ltsopensource.example.springboot;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.spring.boot.annotation.JobRunner4TaskTracker;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-
-/**
- * @author Robert HG (254963746@qq.com) on 4/9/16.
- */
-@JobRunner4TaskTracker
-public class JobRunnerImpl implements JobRunner {
- private static final Logger LOGGER = LoggerFactory.getLogger(JobRunnerImpl.class);
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- try {
- BizLogger bizLogger = jobContext.getBizLogger();
-
- // TODO 业务逻辑
- LOGGER.info("我要执行:" + jobContext);
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_FAILED, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java b/lts-example/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java
deleted file mode 100644
index 2ca9aa2da..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.github.ltsopensource.example.springboot;
-
-import com.github.ltsopensource.example.support.MasterChangeListenerImpl;
-import com.github.ltsopensource.spring.boot.annotation.MasterNodeListener;
-
-/**
- * @author Robert HG (254963746@qq.com) on 4/9/16.
- */
-@MasterNodeListener
-public class MasterNodeChangeListener extends MasterChangeListenerImpl {
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/BaseJobClientTest.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/BaseJobClientTest.java
deleted file mode 100644
index 8885e9d34..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/BaseJobClientTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.commons.utils.StringUtils;
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.core.exception.JobSubmitException;
-import com.github.ltsopensource.jobclient.JobClient;
-import com.github.ltsopensource.jobclient.domain.Response;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/6/15.
- */
-public class BaseJobClientTest {
-
- private static int mode = 2;
-
- protected JobClient jobClient;
-
- public void startConsole() throws IOException {
-
- BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
-
- String help = "命令参数: \n" +
- "\t1:cronExpression模式,如 0 0/1 * * * ?(一分钟执行一次), \n\t2:指定时间模式 yyyy-MM-dd HH:mm:ss,在执行时间模式下,如果字符串now,表示立即执行 \n" +
- "\tquit:退出\n" +
- "\thelp:帮助";
- System.out.println(help);
- System.out.println("指定时间模式:");
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- jobClient.stop();
- }
- }));
-
- String input;
- while (!"quit".equals(input = buffer.readLine())) {
- try {
- if ("now".equals(input)) {
- input = "";
- }
- if ("help".equals(input)) {
- System.out.println(help);
- } else if ("1".equals(input)) {
- mode = 1;
- } else if ("2".equals(input)) {
- mode = 2;
- } else {
- if (mode == 1) {
- submitWithCronExpression(jobClient, input);
- } else if (mode == 2) {
- submitWithTrigger(jobClient, input);
- }
- }
-
- if (mode == 1) {
- System.out.print("cronExpression模式:");
- } else if (mode == 2) {
- System.out.print("指定时间模式:");
- }
-
- } catch (Exception e) {
- System.out.println("输入错误");
- }
- }
- System.exit(0);
- }
-
- public void submitWithCronExpression(final JobClient jobClient, String cronExpression) throws ParseException, JobSubmitException {
- Job job = new Job();
- // 必填,尽量taskId 有一定规律性,能让自己识别
- job.setTaskId(StringUtils.generateUUID());
- // 任务的参数,value必须为字符串
- job.setParam("shopId", "111");
- // 执行节点的group名称
- job.setTaskTrackerNodeGroup("test_trade_TaskTracker");
- // 是否接收执行反馈消息 jobClient.setJobCompletedHandler(new JobFinishedHandlerImpl()); 中接受
- job.setNeedFeedback(true);
- // 这个是 cron expression 和 quartz 一样,可选
- job.setCronExpression(cronExpression);
- // 这个是指定执行时间,可选
- // job.setTriggerTime(new Date());
- // 当 cronExpression 和 triggerTime 都不设置的时候,默认是立即执行任务
- // response 返回提交成功还是失败
- Response response = jobClient.submitJob(job);
-
-
- System.out.println(response);
- }
-
- public void submitWithTrigger(final JobClient jobClient, String triggerTime) throws ParseException, JobSubmitException {
- Job job = new Job();
- job.setTaskId(StringUtils.generateUUID());
- job.setParam("shopId", "111");
-// job.setMaxRetryTimes(5);
- job.setTaskTrackerNodeGroup("test_trade_TaskTracker");
- job.setNeedFeedback(true);
- if (triggerTime != null && !"".equals(triggerTime.trim())) {
- job.setTriggerTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(triggerTime).getTime());
- }
- Response response = jobClient.submitJob(job);
- System.out.println(response);
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/JobCompletedHandlerImpl.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/JobCompletedHandlerImpl.java
deleted file mode 100644
index c031daf0d..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/JobCompletedHandlerImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.commons.utils.CollectionUtils;
-import com.github.ltsopensource.core.domain.JobResult;
-import com.github.ltsopensource.jobclient.support.JobCompletedHandler;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/6/15.
- */
-public class JobCompletedHandlerImpl implements JobCompletedHandler {
-
- @Override
- public void onComplete(List jobResults) {
- // 任务执行反馈结果处理
- if (CollectionUtils.isNotEmpty(jobResults)) {
- for (JobResult jobResult : jobResults) {
- System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " 任务执行完成:" + jobResult);
- }
- }
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/JobRunnerDispatcher.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/JobRunnerDispatcher.java
deleted file mode 100644
index 09b23991d..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/JobRunnerDispatcher.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 总入口,在 taskTracker.setJobRunnerClass(JobRunnerDispatcher.class)
- * JobClient 提交 任务时指定 Job 类型 job.setParam("type", "aType")
- * @author Robert HG (254963746@qq.com) on 8/19/14.
- */
-public class JobRunnerDispatcher implements JobRunner {
-
- private static final ConcurrentHashMap
- JOB_RUNNER_MAP = new ConcurrentHashMap();
-
- static {
- JOB_RUNNER_MAP.put("aType", new JobRunnerA()); // 也可以从Spring中拿
- JOB_RUNNER_MAP.put("bType", new JobRunnerB());
- }
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- Job job = jobContext.getJob();
- String type = job.getParam("type");
- return JOB_RUNNER_MAP.get(type).run(jobContext);
- }
-}
-
-class JobRunnerA implements JobRunner {
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- // TODO A类型Job的逻辑
- return null;
- }
-}
-
-class JobRunnerB implements JobRunner {
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- // TODO B类型Job的逻辑
- return null;
- }
-}
\ No newline at end of file
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/LTSSpringConfig.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/LTSSpringConfig.java
deleted file mode 100644
index 4d2e5dc56..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/LTSSpringConfig.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.jobclient.JobClient;
-import com.github.ltsopensource.jobtracker.JobTracker;
-import com.github.ltsopensource.spring.JobClientFactoryBean;
-import com.github.ltsopensource.spring.JobTrackerFactoryBean;
-import com.github.ltsopensource.spring.TaskTrackerAnnotationFactoryBean;
-import com.github.ltsopensource.tasktracker.TaskTracker;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 下面是给的参考示例,
- * 在其他Spring Bean 中就直接可以使用注解 @Autowired 注入使用了
- * 这里为了方便起见写在一起的,一般这三种节点是分开的,注意单独写
- *
- * @author Robert HG (254963746@qq.com) on 8/22/15.
- */
-@Configuration
-public class LTSSpringConfig implements ApplicationContextAware {
-
- private ApplicationContext applicationContext;
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- @Bean(name = "jobClient")
- public JobClient getJobClient() throws Exception {
- JobClientFactoryBean factoryBean = new JobClientFactoryBean();
- factoryBean.setMasterChangeListeners(new MasterChangeListenerImpl());
- factoryBean.setLocations("application.properties");
- factoryBean.afterPropertiesSet();
-// factoryBean.start();
- return factoryBean.getObject();
- }
-
- @Bean(name = "jobTracker")
- public JobTracker getJobTracker() throws Exception {
- JobTrackerFactoryBean factoryBean = new JobTrackerFactoryBean();
- factoryBean.setLocations("application.properties");
- factoryBean.afterPropertiesSet();
-// factoryBean.start();
- return factoryBean.getObject();
- }
-
- @Bean(name = "taskTracker")
- public TaskTracker getTaskTracker() throws Exception {
- TaskTrackerAnnotationFactoryBean factoryBean = new TaskTrackerAnnotationFactoryBean();
- factoryBean.setApplicationContext(applicationContext);
- factoryBean.setJobRunnerClass(SpringAnnotationJobRunner.class);
- factoryBean.setLocations("application.properties");
- factoryBean.afterPropertiesSet();
-// factoryBean.start();
-
- return factoryBean.getObject();
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/MasterChangeListenerImpl.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/MasterChangeListenerImpl.java
deleted file mode 100644
index 00b016338..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/MasterChangeListenerImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.cluster.Node;
-import com.github.ltsopensource.core.commons.utils.StringUtils;
-import com.github.ltsopensource.core.listener.MasterChangeListener;
-
-/**
- * @author Robert HG (254963746@qq.com) on 3/6/15.
- */
-public class MasterChangeListenerImpl implements MasterChangeListener {
-
- /**
- * master 为 master节点
- * isMaster 表示当前节点是不是master节点
- *
- * @param master
- * @param isMaster
- */
- @Override
- public void change(Node master, boolean isMaster) {
-
- // 一个节点组master节点变化后的处理 , 譬如我多个JobClient, 但是有些事情只想只有一个节点能做。
- if(isMaster){
- System.out.println("我变成了节点组中的master节点了, 恭喜, 我要放大招了");
- }else{
- System.out.println(StringUtils.format("master节点变成了{},不是我,我不能放大招,要猥琐", master));
- }
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/NoopJobRunner.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/NoopJobRunner.java
deleted file mode 100644
index 009048bdd..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/NoopJobRunner.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.support.SystemClock;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/13/15.
- */
-public class NoopJobRunner implements JobRunner {
-
- static volatile long start = 0;
- static AtomicInteger num = new AtomicInteger(0);
-
- public NoopJobRunner() {
- if (start == 0) {
- start = System.currentTimeMillis();
- }
- }
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- System.out.println(num.incrementAndGet() + " time : " + (SystemClock.now() - start) + "ms");
- return new Result(Action.EXECUTE_SUCCESS);
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringAnnotationJobRunner.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringAnnotationJobRunner.java
deleted file mode 100644
index 830bda29e..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringAnnotationJobRunner.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/19/14.
- */
-public class SpringAnnotationJobRunner implements JobRunner {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SpringAnnotationJobRunner.class);
-
- @Autowired
- SpringBean springBean;
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- try {
- Thread.sleep(1000L);
-
- springBean.hello();
-
- // TODO 业务逻辑
- LOGGER.info("我要执行:" + jobContext);
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_LATER, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringBean.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringBean.java
deleted file mode 100644
index 45da8e90c..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringBean.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import org.springframework.stereotype.Component;
-
-/**
- * 测试bean 注入
- * @author Robert HG (254963746@qq.com) on 8/4/15.
- */
-@Component
-public class SpringBean {
-
- public void hello(){
- System.out.println("我是SpringBean,我执行了");
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringXmlJobRunner.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringXmlJobRunner.java
deleted file mode 100644
index e1cd91aaf..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/SpringXmlJobRunner.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/19/14.
- */
-public class SpringXmlJobRunner implements JobRunner {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SpringXmlJobRunner.class);
-
- SpringBean springBean;
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- try {
- Thread.sleep(1000L);
-
- springBean.hello();
-
- // TODO 业务逻辑
- LOGGER.info("我要执行:" + jobContext);
- BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_LATER, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-
- public void setSpringBean(SpringBean springBean) {
- this.springBean = springBean;
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunner.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunner.java
deleted file mode 100644
index 17b33649c..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunner.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.domain.Action;
-import com.github.ltsopensource.core.logger.Logger;
-import com.github.ltsopensource.core.logger.LoggerFactory;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.logger.BizLogger;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-
-/**
- * @author Robert HG (254963746@qq.com) on 8/19/14.
- */
-public class TestJobRunner implements JobRunner {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TestJobRunner.class);
-
- @Override
- public Result run(JobContext jobContext) throws Throwable {
- try {
-// BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
- BizLogger bizLogger = jobContext.getBizLogger();
-// Thread.sleep(1000L);
-//
-// if (job.getRetryTimes() > 5) {
-// return new Result(Action.EXECUTE_FAILED, "重试次数超过5次了,放过你吧!");
-// }
-//
-// if (SystemClock.now() % 2 == 1) {
-// return new Result(Action.EXECUTE_LATER, "稍后执行");
-// }
-
- // TODO 业务逻辑
- LOGGER.info("我要执行:" + jobContext);
- // 会发送到 LTS (JobTracker上)
- bizLogger.info("测试,业务日志啊啊啊啊啊");
-
-// Thread.sleep(60 * 1000);
-
- } catch (Exception e) {
- LOGGER.info("Run job failed!", e);
- return new Result(Action.EXECUTE_FAILED, e.getMessage());
- }
- return new Result(Action.EXECUTE_SUCCESS, "执行成功了,哈哈");
- }
-}
diff --git a/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunnerTester.java b/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunnerTester.java
deleted file mode 100644
index 5ec3bdd0e..000000000
--- a/lts-example/src/main/java/com/github/ltsopensource/example/support/TestJobRunnerTester.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.github.ltsopensource.example.support;
-
-import com.github.ltsopensource.core.json.JSON;
-import com.github.ltsopensource.core.domain.Job;
-import com.github.ltsopensource.tasktracker.Result;
-import com.github.ltsopensource.tasktracker.runner.JobContext;
-import com.github.ltsopensource.tasktracker.runner.JobExtInfo;
-import com.github.ltsopensource.tasktracker.runner.JobRunner;
-import com.github.ltsopensource.tasktracker.runner.JobRunnerTester;
-
-/**
- * @author Robert HG (254963746@qq.com) on 9/13/15.
- */
-public class TestJobRunnerTester extends JobRunnerTester {
-
- public static void main(String[] args) throws Throwable {
- // Mock Job 数据
- Job job = new Job();
- job.setTaskId("2313213");
-
- JobContext jobContext = new JobContext();
- jobContext.setJob(job);
-
- JobExtInfo jobExtInfo = new JobExtInfo();
- jobExtInfo.setRetry(false);
-
- jobContext.setJobExtInfo(jobExtInfo);
-
- // 运行测试
- TestJobRunnerTester tester = new TestJobRunnerTester();
- Result result = tester.run(jobContext);
- System.out.println(JSON.toJSONString(result));
- }
-
- @Override
- protected void initContext() {
- // TODO 初始化Spring容器
- }
-
- @Override
- protected JobRunner newJobRunner() {
- return new TestJobRunner();
- }
-}
diff --git a/lts-example/src/main/resources/application.properties b/lts-example/src/main/resources/application.properties
deleted file mode 100644
index decdc8652..000000000
--- a/lts-example/src/main/resources/application.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-lts.jobtracker.cluster-name=test_cluster
-lts.jobtracker.listen-port=35001
-lts.jobtracker.registry-address=zookeeper://127.0.0.1:2181
-lts.jobtracker.configs.job.logger=mysql
-lts.jobtracker.configs.job.queue=mysql
-lts.jobtracker.configs.jdbc.url=jdbc:mysql://127.0.0.1:3306/lts
-lts.jobtracker.configs.jdbc.username=root
-lts.jobtracker.configs.jdbc.password=root
-
-lts.jobclient.cluster-name=test_cluster
-lts.jobclient.registry-address=zookeeper://127.0.0.1:2181
-lts.jobclient.node-group=test_jobClient
-lts.jobclient.use-retry-client=false
-lts.jobclient.configs.job.fail.store=mapdb
-
-lts.tasktracker.cluster-name=test_cluster
-lts.tasktracker.registry-address=zookeeper://127.0.0.1:2181
-#lts.tasktracker.work-threads=64
-lts.tasktracker.node-group=test_trade_TaskTracker
-lts.tasktracker.dispatch-runner.enable=true
-lts.tasktracker.dispatch-runner.shard-value=taskId
-#lts.tasktracker.job-runner-class=com.github.ltsopensource.example.support.TestJobRunner
-
-lts.monitor.cluster-name=test_cluster
-lts.monitor.registry-address=zookeeper://127.0.0.1:2181
-lts.monitor.configs.job.logger=mysql
-lts.monitor.configs.job.queue=mysql
-lts.monitor.configs.jdbc.url=jdbc:mysql://127.0.0.1:3306/lts
-lts.monitor.configs.jdbc.username=root
-lts.monitor.configs.jdbc.password=root
diff --git a/lts-example/src/main/resources/log4j.properties b/lts-example/src/main/resources/log4j.properties
deleted file mode 100644
index 4e3c103a1..000000000
--- a/lts-example/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-
-log4j.rootLogger=INFO,stdout
-
-log4j.appender.stdout.Threshold=INFO
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%-5p] [%d{HH:mm:ss}] %c - %m%n
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-annotation.xml b/lts-example/src/main/resources/spring/lts-annotation.xml
deleted file mode 100644
index bd7f3ce4e..000000000
--- a/lts-example/src/main/resources/spring/lts-annotation.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-jobclient.xml b/lts-example/src/main/resources/spring/lts-jobclient.xml
deleted file mode 100644
index b4ff8b2eb..000000000
--- a/lts-example/src/main/resources/spring/lts-jobclient.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- leveldb
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-jobtracker.xml b/lts-example/src/main/resources/spring/lts-jobtracker.xml
deleted file mode 100644
index 31c89b2e8..000000000
--- a/lts-example/src/main/resources/spring/lts-jobtracker.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-quartz.xml b/lts-example/src/main/resources/spring/lts-quartz.xml
deleted file mode 100644
index 0b60ef940..000000000
--- a/lts-example/src/main/resources/spring/lts-quartz.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-tasktracker-shard-annotaion.xml b/lts-example/src/main/resources/spring/lts-tasktracker-shard-annotaion.xml
deleted file mode 100644
index dff0015d7..000000000
--- a/lts-example/src/main/resources/spring/lts-tasktracker-shard-annotaion.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- leveldb
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-tasktracker-shard-xml.xml b/lts-example/src/main/resources/spring/lts-tasktracker-shard-xml.xml
deleted file mode 100644
index 4f1e2eb39..000000000
--- a/lts-example/src/main/resources/spring/lts-tasktracker-shard-xml.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- leveldb
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lts-example/src/main/resources/spring/lts-tasktracker.xml b/lts-example/src/main/resources/spring/lts-tasktracker.xml
deleted file mode 100644
index 4c5c86e17..000000000
--- a/lts-example/src/main/resources/spring/lts-tasktracker.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- leveldb
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 629fd1f60..93f528e5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,6 @@
lts-jobtracker
lts-tasktracker
lts-jobclient
- lts-example
lts-admin
lts-spring
lts-startup