-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd8eb38
commit e383285
Showing
58 changed files
with
820 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lts-example-jobclient/lts-example-jobclient-java/src/main/resources/lts.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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=true | ||
lts.jobclient.configs.job.fail.store=mapdb | ||
|
||
|
||
#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=true | ||
#LTS.JOBCLIENT.CONFIGS.job.fail.store=mapdb |
37 changes: 37 additions & 0 deletions
37
lts-example-jobclient/lts-example-jobclient-spring-annotation/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?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>lts-example-jobclient</artifactId> | ||
<groupId>com.github.ltsopensource</groupId> | ||
<version>1.6.8-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>lts-example-jobclient-spring-annotation</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>${springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>${springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>${springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
<version>${springframework.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
...ent-spring-annotation/src/main/java/com/github/ltsopensource/example/JobClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.ltsopensource.example; | ||
|
||
import com.github.ltsopensource.jobclient.JobClient; | ||
import com.github.ltsopensource.spring.JobClientFactoryBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author Robert HG ([email protected]) on 4/22/16. | ||
*/ | ||
@Configuration | ||
public class JobClientConfig { | ||
|
||
@Bean(name = "jobClient") | ||
public JobClient getJobClient() throws Exception { | ||
JobClientFactoryBean factoryBean = new JobClientFactoryBean(); | ||
factoryBean.setLocations("lts.properties"); | ||
factoryBean.afterPropertiesSet(); | ||
factoryBean.start(); | ||
return factoryBean.getObject(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ng-annotation/src/main/java/com/github/ltsopensource/example/JobCompletedHandlerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.ltsopensource.example; | ||
|
||
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 ([email protected]) on 4/17/16. | ||
*/ | ||
public class JobCompletedHandlerImpl implements JobCompletedHandler { | ||
|
||
@Override | ||
public void onComplete(List<JobResult> jobResults) { | ||
// 任务执行反馈结果处理 | ||
if (CollectionUtils.isNotEmpty(jobResults)) { | ||
for (JobResult jobResult : jobResults) { | ||
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " 任务执行完成:" + jobResult); | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...mple-jobclient-spring-annotation/src/main/java/com/github/ltsopensource/example/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.github.ltsopensource.example; | ||
|
||
import com.github.ltsopensource.core.domain.Job; | ||
import com.github.ltsopensource.jobclient.JobClient; | ||
import com.github.ltsopensource.jobclient.domain.Response; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
/** | ||
* @author Robert HG ([email protected]) on 4/22/16. | ||
*/ | ||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
ApplicationContext context = new ClassPathXmlApplicationContext("/lts-jobclient.xml"); | ||
|
||
JobClient jobClient = (JobClient) context.getBean("jobClient"); | ||
|
||
Job job = new Job(); | ||
job.setTaskId("t_realtime_5556666"); | ||
job.setParam("shopId", "1122222221"); | ||
job.setTaskTrackerNodeGroup("test_trade_TaskTracker"); | ||
job.setNeedFeedback(true); | ||
job.setReplaceOnExist(true); // 当任务队列中存在这个任务的时候,是否替换更新 | ||
Response response = jobClient.submitJob(job); | ||
System.out.println(response); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...ple-jobclient/lts-example-jobclient-spring-annotation/src/main/resources/log4j.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
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 |
14 changes: 14 additions & 0 deletions
14
...le-jobclient/lts-example-jobclient-spring-annotation/src/main/resources/lts-jobclient.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-4.0.xsd" | ||
> | ||
|
||
<context:component-scan base-package="com.github.ltsopensource.example"/> | ||
<context:annotation-config/> | ||
|
||
</beans> |
12 changes: 12 additions & 0 deletions
12
...ample-jobclient/lts-example-jobclient-spring-annotation/src/main/resources/lts.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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=true | ||
lts.jobclient.configs.job.fail.store=mapdb | ||
|
||
|
||
#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=true | ||
#LTS.JOBCLIENT.CONFIGS.job.fail.store=mapdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lts-example-jobclient/lts-example-jobclient-spring-xml/src/main/resources/lts.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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=true | ||
lts.jobclient.configs.job.fail.store=mapdb | ||
|
||
|
||
#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=true | ||
#LTS.JOBCLIENT.CONFIGS.job.fail.store=mapdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 20 additions & 14 deletions
34
...lts-example-jobtracker-java/src/main/java/com/github/ltsopensource/example/java/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
package com.github.ltsopensource.example.java; | ||
|
||
import com.github.ltsopensource.jobtracker.JobTracker; | ||
import com.github.ltsopensource.jobtracker.JobTrackerBuilder; | ||
|
||
/** | ||
* @author Robert HG ([email protected]) on 4/17/16. | ||
*/ | ||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
final JobTracker jobTracker = new JobTracker(); | ||
// 节点信息配置 | ||
jobTracker.setRegistryAddress("zookeeper://127.0.0.1:2181"); | ||
// jobTracker.setRegistryAddress("redis://127.0.0.1:6379"); | ||
jobTracker.setListenPort(35001); // 默认 35001 | ||
jobTracker.setClusterName("test_cluster"); | ||
// final JobTracker jobTracker = new JobTracker(); | ||
// // 节点信息配置 | ||
// jobTracker.setRegistryAddress("zookeeper://127.0.0.1:2181"); | ||
//// jobTracker.setRegistryAddress("redis://127.0.0.1:6379"); | ||
// jobTracker.setListenPort(35001); // 默认 35001 | ||
// jobTracker.setClusterName("test_cluster"); | ||
// | ||
//// // 设置业务日志记录 mysql | ||
//// jobTracker.addConfig("job.logger", "mysql"); | ||
//// // 任务队列用mysql | ||
//// jobTracker.addConfig("job.queue", "mysql"); | ||
// // mysql 配置 | ||
// jobTracker.addConfig("jdbc.url", "jdbc:mysql://127.0.0.1:3306/lts"); | ||
// jobTracker.addConfig("jdbc.username", "root"); | ||
// jobTracker.addConfig("jdbc.password", "root"); | ||
|
||
final JobTracker jobTracker = new JobTrackerBuilder() | ||
.setPropertiesConfigure("lts.properties") | ||
.build(); | ||
|
||
// // 设置业务日志记录 mysql | ||
// jobTracker.addConfig("job.logger", "mysql"); | ||
// // 任务队列用mysql | ||
// jobTracker.addConfig("job.queue", "mysql"); | ||
// mysql 配置 | ||
jobTracker.addConfig("jdbc.url", "jdbc:mysql://127.0.0.1:3306/lts"); | ||
jobTracker.addConfig("jdbc.username", "root"); | ||
jobTracker.addConfig("jdbc.password", "root"); | ||
// 启动节点 | ||
jobTracker.start(); | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
lts-example-jobtracker/lts-example-jobtracker-java/src/main/resources/lts.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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 |
Oops, something went wrong.