Skip to content

Commit 3b0062a

Browse files
committed
增加spring 支持
1 parent 8aa4fc5 commit 3b0062a

File tree

46 files changed

+302
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+302
-245
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ LTS 轻量级分布式任务调度框架(Light Task Schedule)
4949
运行 job-example模块中的例子
5050
分别执行 JobTrackerTest TaskTrackerTest JobClientTest
5151

52-
这里给出的是java API(设置配置)方式启动,也可以使用配置文件中。
52+
这里给出的是java API(设置配置)方式启动, 也可以使用spring启动默认不启用spring,需引入job-ext-spring包
5353

5454
## JobTracker 端
5555
```java
@@ -59,7 +59,7 @@ LTS 轻量级分布式任务调度框架(Light Task Schedule)
5959
// jobTracker.setListenPort(35001); // 默认 35001
6060
// jobTracker.setClusterName("QN");
6161

62-
// mongo 配置 (也可以配置在 mongo.properties中)
62+
// mongo 配置
6363
Config config = new Config();
6464
config.setAddresses(new String[]{"localhost:27017"});
6565
config.setUsername("lts");

job-client/src/main/java/com/lts/job/client/RetryJobClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44
import com.lts.job.client.domain.ResponseCode;
55
import com.lts.job.core.domain.Job;
66
import com.lts.job.client.domain.Response;
7-
import com.lts.job.core.file.FileException;
8-
import com.lts.job.core.file.Line;
97
import com.lts.job.core.support.RetryScheduler;
10-
import com.lts.job.core.util.JSONUtils;
11-
import com.lts.job.core.util.StringUtils;
128

13-
import java.util.ArrayList;
149
import java.util.Arrays;
1510
import java.util.List;
1611

job-client/src/main/resources/job-config-ext.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.

job-core/src/main/java/com/lts/job/core/cluster/AbstractClientNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lts.job.core.cluster;
22

3+
import com.lts.job.core.constant.Constants;
34
import com.lts.job.core.remoting.HeartBeatMonitor;
45
import com.lts.job.core.remoting.RemotingClientDelegate;
56
import com.lts.job.core.support.Application;
@@ -52,7 +53,7 @@ protected void nodeStop() {
5253

5354
public void setWorkThreads(int workThreads) {
5455
config.setWorkThreads(workThreads);
55-
Application.setAttribute(Application.KEY_AVAILABLE_THREADS, config.getWorkThreads());
56+
Application.setAttribute(Constants.KEY_AVAILABLE_THREADS, config.getWorkThreads());
5657
}
5758

5859
/**

job-core/src/main/java/com/lts/job/core/cluster/AbstractJobNode.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.lts.job.core.cluster;
22

3-
import com.lts.job.core.AppConfigure;
43
import com.lts.job.core.constant.Constants;
54
import com.lts.job.core.domain.JobNodeConfig;
65
import com.lts.job.core.listener.MasterNodeChangeListener;
@@ -28,15 +27,15 @@ public abstract class AbstractJobNode<T extends Node> implements JobNode {
2827
public AbstractJobNode() {
2928
config = new JobNodeConfig();
3029
config.setIdentity(StringUtils.generateUUID());
31-
config.setWorkThreads(AppConfigure.getInteger(Constants.PropertiesKey.KEY_JOB_WORK_THREADS, Constants.AVAILABLE_PROCESSOR));
32-
config.setNodeGroup(AppConfigure.getString(Constants.PropertiesKey.KEY_JOB_NODE_GROUP));
33-
config.setZookeeperAddress(AppConfigure.getString(Constants.PropertiesKey.KEY_JOB_ZOOKEEPER_ADDRESS));
34-
config.setInvokeTimeoutMillis(AppConfigure.getInteger(Constants.PropertiesKey.KEY_JOB_INVOKE_TIMEOUT_MILLIS, 1000 * 6));
35-
config.setListenPort(AppConfigure.getInteger(Constants.PropertiesKey.KEY_JOB_LISTEN_PORT, 0));
36-
config.setJobInfoSavePath(AppConfigure.getString(Constants.PropertiesKey.KEY_JOB_INFO_SAVE_PATH, Constants.USER_HOME + "/.job"));
37-
config.setClusterName(AppConfigure.getString(Constants.PropertiesKey.KEY_JOB_CLUSTER_NAME, Constants.DEFAULT_CLUSTER_NAME));
30+
config.setWorkThreads(Constants.AVAILABLE_PROCESSOR);
31+
config.setNodeGroup("lts");
32+
config.setZookeeperAddress("localhost:2181");
33+
config.setInvokeTimeoutMillis(1000 * 6);
34+
config.setListenPort(0);
35+
config.setJobInfoSavePath(Constants.USER_HOME + "/.job");
36+
config.setClusterName(Constants.DEFAULT_CLUSTER_NAME);
3837
// 可用的线程数
39-
Application.setAttribute(Application.KEY_AVAILABLE_THREADS, config.getWorkThreads());
38+
Application.setAttribute(Constants.KEY_AVAILABLE_THREADS, config.getWorkThreads());
4039

4140
Application.Config = config;
4241

job-core/src/main/java/com/lts/job/core/constant/Constants.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ public interface Constants {
2424
// 默认TaskTracker节点组
2525
public static final String DEFAULT_NODE_TASK_TRACKER_GROUP = "TASK_TRACKER_GROUP";
2626

27-
public static interface PropertiesKey{
28-
public static final String KEY_JOB_WORK_THREADS = "app.job.work.threads";
29-
public static final String KEY_JOB_NODE_GROUP = "p.job.node.group";
30-
public static final String KEY_JOB_ZOOKEEPER_ADDRESS = "app.job.zookeeper.address";
31-
public static final String KEY_JOB_INVOKE_TIMEOUT_MILLIS = "invoke.timeout.millis";
32-
public static final String KEY_JOB_LISTEN_PORT = "app.job.listen.port";
33-
public static final String KEY_JOB_INFO_SAVE_PATH = "app.job.info.save.path";
34-
public static final String KEY_JOB_CLUSTER_NAME = "app.job.cluster.name";
35-
}
27+
public static final String KEY_AVAILABLE_THREADS = "availableThreads";
28+
29+
public static final String JOB_RUNNING_CLASS = "JOB_RUNNING_CLASS";
30+
31+
public static final String RUNNER_FACTORY = "RUNNER_FACTORY";
32+
3633
}

job-core/src/main/java/com/lts/job/core/domain/KVPair.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.lts.job.core.domain;
22

33
/**
4-
* Created by hugui on 3/6/15.
4+
* Created by Robert HG (254963746@qq.com) on 3/6/15.
55
*/
66
public class KVPair<Key, Value> {
77
private Key key;

job-core/src/main/java/com/lts/job/core/exception/JobInfoException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* 这个异常不会打印堆栈信息
5-
* Created by hugui on 1/8/15.
5+
* Created by Robert HG (254963746@qq.com) on 1/8/15.
66
*/
77
public class JobInfoException extends Exception {
88

job-core/src/main/java/com/lts/job/core/file/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.io.IOException;
55

66
/**
7-
* Created by hugui on 3/6/15.
7+
* Created by Robert HG (254963746@qq.com) on 3/6/15.
88
*/
99
public class FileUtils {
1010

job-core/src/main/java/com/lts/job/core/protocol/command/AbstractCommandBody.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lts.job.core.protocol.command;
22

3+
import com.lts.job.core.constant.Constants;
34
import com.lts.job.core.support.Application;
45
import com.lts.job.remoting.CommandBody;
56
import com.lts.job.remoting.annotation.NotNull;
@@ -46,7 +47,7 @@ public AbstractCommandBody() {
4647
this.nodeGroup = Application.Config.getNodeGroup();
4748
this.nodeType = Application.Config.getNodeType().name();
4849
this.identity = Application.Config.getIdentity();
49-
this.availableThreads = Application.getAttribute(Application.KEY_AVAILABLE_THREADS);
50+
this.availableThreads = Application.getAttribute(Constants.KEY_AVAILABLE_THREADS);
5051
}
5152

5253
public Integer getAvailableThreads() {

0 commit comments

Comments
 (0)