Skip to content

Commit 9f9225d

Browse files
author
Ansj
committed
fix update ioc.js or maven.pom app despon
1 parent 33474ab commit 9f9225d

19 files changed

+320
-804
lines changed

src/main/java/org/nlpcn/jcoder/controller/TaskAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.nlpcn.jcoder.run.CodeException;
1111
import org.nlpcn.jcoder.run.java.JavaRunner;
1212
import org.nlpcn.jcoder.scheduler.TaskException;
13-
import org.nlpcn.jcoder.scheduler.ThreadManager;
13+
import org.nlpcn.jcoder.scheduler.TaskRunManager;
1414
import org.nlpcn.jcoder.service.GroupService;
1515
import org.nlpcn.jcoder.service.ProxyService;
1616
import org.nlpcn.jcoder.service.TaskService;
@@ -681,7 +681,7 @@ public Restful __cron__(@Param("groupName") String groupName, @Param("taskName")
681681
}
682682

683683
try {
684-
ThreadManager.run(task);
684+
TaskRunManager.run(task);
685685
} catch (TaskException e) {
686686
e.printStackTrace();
687687
return Restful.fail().code(ApiException.ServerException).msg("task run fail " + taskName + e.getMessage());

src/main/java/org/nlpcn/jcoder/controller/ThreadAction.java

Lines changed: 48 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@
44
import com.google.common.collect.ImmutableMap;
55
import org.nlpcn.jcoder.domain.TaskInfo;
66
import org.nlpcn.jcoder.filter.AuthoritiesManager;
7+
import org.nlpcn.jcoder.scheduler.QuartzSchedulerManager;
78
import org.nlpcn.jcoder.scheduler.TaskException;
8-
import org.nlpcn.jcoder.scheduler.ThreadManager;
9+
import org.nlpcn.jcoder.scheduler.TaskRunManager;
910
import org.nlpcn.jcoder.service.ProxyService;
1011
import org.nlpcn.jcoder.util.ApiException;
1112
import org.nlpcn.jcoder.util.Restful;
1213
import org.nlpcn.jcoder.util.StaticValue;
1314
import org.nlpcn.jcoder.util.StringUtil;
1415
import org.nlpcn.jcoder.util.dao.BasicDao;
15-
import org.nutz.http.Response;
1616
import org.nutz.ioc.loader.annotation.Inject;
1717
import org.nutz.ioc.loader.annotation.IocBean;
1818
import org.nutz.mvc.annotation.*;
1919
import org.slf4j.Logger;
2020
import org.slf4j.LoggerFactory;
2121

22-
import javax.xml.transform.Result;
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.List;
2625
import java.util.Map;
27-
import java.util.concurrent.ArrayBlockingQueue;
28-
import java.util.concurrent.BlockingQueue;
29-
import java.util.concurrent.LinkedBlockingDeque;
3026
import java.util.stream.Collectors;
3127

3228
@IocBean
@@ -75,7 +71,7 @@ public Restful list(@Param("hostPorts[]") String[] hostPorts, @Param("groupName"
7571
for (Map.Entry<String, Restful> entry : post.entrySet()) {
7672
Restful ref = entry.getValue();
7773
if (!ref.isOk()) {
78-
LOG.error(entry.getKey()+":"+entry.getValue().toJsonString());
74+
LOG.error(entry.getKey() + ":" + entry.getValue().toJsonString());
7975
continue;
8076
}
8177
JSONObject jsonObject = ref.obj2JsonObject();
@@ -105,22 +101,22 @@ public Restful list(@Param("hostPorts[]") String[] hostPorts, @Param("groupName"
105101
if (StringUtil.isNotBlank(type)) {
106102
switch (type) {
107103
case "threads":
108-
threads = ThreadManager.getAllThread();
104+
threads = TaskRunManager.getAllThread();
109105
break;
110106
case "schedulers":
111-
schedulers = ThreadManager.getAllScheduler();
107+
schedulers = QuartzSchedulerManager.getAllScheduler();
112108
break;
113109
case "actions":
114-
actions = ThreadManager.getAllAction();
110+
actions = TaskRunManager.getAllAction();
115111
break;
116112
default:
117113
throw new ApiException(500, "err type " + type);
118114
}
119115

120116
} else {
121-
threads = ThreadManager.getAllThread();
122-
schedulers = ThreadManager.getAllScheduler();
123-
actions = ThreadManager.getAllAction();
117+
threads = TaskRunManager.getAllThread();
118+
schedulers = QuartzSchedulerManager.getAllScheduler();
119+
actions = TaskRunManager.getAllAction();
124120
}
125121

126122
final String gn = groupName;
@@ -132,11 +128,11 @@ public Restful list(@Param("hostPorts[]") String[] hostPorts, @Param("groupName"
132128

133129
JSONObject json = new JSONObject();
134130

135-
json.put("threads", threads);
136-
json.put("schedulers", schedulers);
137-
json.put("actions", actions);
131+
json.put("threads", threads);
132+
json.put("schedulers", schedulers);
133+
json.put("actions", actions);
138134

139-
return Restful.ok().obj(json);
135+
return Restful.ok().obj(json);
140136
}
141137
}
142138

@@ -146,52 +142,41 @@ public Restful list(@Param("hostPorts[]") String[] hostPorts, @Param("groupName"
146142
* 停止一个运行的action,或者task
147143
*/
148144
@At
149-
public Restful stop(@Param("hostPort") String hostPort, @Param("key") String key,@Param(value = "first", df = "true") boolean first ) throws Exception {
150-
if (first) {
151-
JSONObject json = new JSONObject();
152-
Map<String, Restful> post = proxyService.post(new String[]{hostPort}, "/admin/thread/stop", ImmutableMap.of("key", key,"first",false), 100000);
153-
for (Map.Entry<String, Restful> entry : post.entrySet()) {
154-
Restful ref = entry.getValue();
155-
if (!ref.isOk()) {
156-
LOG.error(entry.getKey()+":"+entry.getValue().toJsonString());
157-
continue;
158-
}
159-
JSONObject jsonObject = ref.obj2JsonObject();
160-
json.put("msg",jsonObject.getString("msg"));
161-
json.put("flag",ref.isOk());
162-
return Restful.ok().obj(json);
163-
}
164-
}else{
165-
boolean flag = false;
166-
String msg = "";
167-
JSONObject json = new JSONObject();
168-
try {
169-
flag = ThreadManager.stop(key);
170-
msg = "停止任务成功!";
171-
json.put("msg",msg);
172-
return Restful.ok().obj(json);
173-
} catch (TaskException e) {
174-
e.printStackTrace();
175-
flag = false;
176-
msg = "停止任务失败!";
177-
LOG.error("stop action err", e);
178-
json.put("msg",msg);
179-
return Restful.fail().obj(json);
180-
}
181-
}
182-
return null;
183-
}
184-
185-
/**
186-
* 停止一个运行的job的所有实例线程
187-
*/
188-
@At
189-
public void stopAllJob(String groupName, String taskName) throws Exception {
190-
try {
191-
ThreadManager.stopAllJob(groupName, taskName);
192-
} catch (Exception e) {
193-
LOG.error("author err", e);
194-
throw e;
145+
public Restful stop(@Param("hostPort") String hostPort, @Param("key") String key, @Param(value = "first", df = "true") boolean first) throws Exception {
146+
if (first) {
147+
JSONObject json = new JSONObject();
148+
Map<String, Restful> post = proxyService.post(new String[]{hostPort}, "/admin/thread/stop", ImmutableMap.of("key", key, "first", false), 100000);
149+
for (Map.Entry<String, Restful> entry : post.entrySet()) {
150+
Restful ref = entry.getValue();
151+
if (!ref.isOk()) {
152+
LOG.error(entry.getKey() + ":" + entry.getValue().toJsonString());
153+
continue;
154+
}
155+
return Restful.instance(ref.isOk(),ref.getMessage()) ;
156+
}
157+
} else {
158+
try {
159+
TaskRunManager.stop(key);
160+
return Restful.ok().msg("停止任务成功!");
161+
} catch (TaskException e) {
162+
e.printStackTrace();
163+
LOG.error("stop action err", e);
164+
return Restful.fail().msg("停止任务失败!");
165+
}
195166
}
167+
return null;
196168
}
169+
170+
// /**
171+
// * 停止一个运行的job的所有实例线程
172+
// */
173+
// @At
174+
// public void stopAllJob(String groupName, String taskName) throws Exception {
175+
// try {
176+
// TaskRunManager.stopAll(groupName, taskName);
177+
// } catch (Exception e) {
178+
// LOG.error("author err", e);
179+
// throw e;
180+
// }
181+
// }
197182
}

src/main/java/org/nlpcn/jcoder/job/MasterCleanTokenJob.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.nlpcn.jcoder.job;
22

33
import org.nlpcn.jcoder.domain.Token;
4-
import org.nlpcn.jcoder.scheduler.ThreadManager;
54
import org.nlpcn.jcoder.util.StaticValue;
65
import org.nlpcn.jcoder.util.ZKMap;
76
import org.slf4j.Logger;
@@ -27,7 +26,6 @@ private MasterCleanTokenJob() {
2726
*/
2827
public synchronized static void startJob() {
2928
stopJob();
30-
ThreadManager.startScheduler();
3129
thread = new Thread(new MasterCleanTokenJob());
3230
thread.start();
3331
}
@@ -36,7 +34,6 @@ public synchronized static void startJob() {
3634
* 当失去master时候调用此方法
3735
*/
3836
public synchronized static void stopJob() {
39-
ThreadManager.stopScheduler();
4037
if (thread != null) {
4138
try {
4239
thread.interrupt();

src/main/java/org/nlpcn/jcoder/job/MasterGitPullJob.java

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

src/main/java/org/nlpcn/jcoder/job/MasterRunTaskJob.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import com.google.common.collect.ImmutableMap;
44
import org.nlpcn.jcoder.constant.Api;
55
import org.nlpcn.jcoder.domain.KeyValue;
6-
import org.nlpcn.jcoder.scheduler.ThreadManager;
76
import org.nlpcn.jcoder.service.GroupService;
87
import org.nlpcn.jcoder.service.ProxyService;
98
import org.nlpcn.jcoder.util.StaticValue;
109
import org.nlpcn.jcoder.util.StringUtil;
1110
import org.nutz.http.Response;
11+
import org.quartz.SchedulerException;
1212
import org.slf4j.Logger;
1313
import org.slf4j.LoggerFactory;
1414

@@ -33,18 +33,16 @@ private MasterRunTaskJob() {
3333
/**
3434
* 当竞选为master时候调用此方法
3535
*/
36-
public synchronized static void startJob() {
36+
public synchronized static void startJob() {
3737
stopJob();
38-
ThreadManager.startScheduler();
3938
thread = new Thread(new MasterRunTaskJob());
4039
thread.start();
4140
}
4241

4342
/**
4443
* 当失去master时候调用此方法
4544
*/
46-
public synchronized static void stopJob() {
47-
ThreadManager.stopScheduler();
45+
public synchronized static void stopJob(){
4846
if (thread != null) {
4947
try {
5048
thread.interrupt();

0 commit comments

Comments
 (0)