master
xuxueli 5 years ago
parent 77bcfd65e0
commit 4d44822efa
  1. 9
      doc/XXL-JOB官方文档.md
  2. 3
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
  3. 3
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/strategy/ExecutorRouteBusyover.java
  4. 9
      xxl-job-admin/src/test/java/com/xxl/job/executorbiz/ExecutorBizTest.java
  5. 13
      xxl-job-core/src/main/java/com/xxl/job/core/biz/ExecutorBiz.java
  6. 13
      xxl-job-core/src/main/java/com/xxl/job/core/biz/client/ExecutorBizClient.java
  7. 15
      xxl-job-core/src/main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java
  8. 28
      xxl-job-core/src/main/java/com/xxl/job/core/biz/model/IdleBeatParam.java
  9. 28
      xxl-job-core/src/main/java/com/xxl/job/core/biz/model/KillParam.java
  10. 2
      xxl-job-core/src/main/java/com/xxl/job/core/biz/model/LogParam.java
  11. 2
      xxl-job-core/src/main/java/com/xxl/job/core/biz/model/LogResult.java
  12. 20
      xxl-job-core/src/main/java/com/xxl/job/core/server/EmbedServer.java

@ -1406,7 +1406,9 @@ Header:
XXL-JOB-ACCESS-TOKEN : {请求令牌}
请求数据格式如下,放置在 RequestBody 中,JSON格式:
1 // 任务ID
{
"jobId":1 // 任务ID
}
响应数据格式:
{
@ -1459,7 +1461,10 @@ Header:
XXL-JOB-ACCESS-TOKEN : {请求令牌}
请求数据格式如下,放置在 RequestBody 中,JSON格式:
1 // 任务ID
{
"jobId":1 // 任务ID
}
响应数据格式:
{

@ -10,6 +10,7 @@ import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.KillParam;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
@ -172,7 +173,7 @@ public class JobLogController {
ReturnT<String> runResult = null;
try {
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(log.getExecutorAddress());
runResult = executorBiz.kill(jobInfo.getId());
runResult = executorBiz.kill(new KillParam(jobInfo.getId()));
} catch (Exception e) {
logger.error(e.getMessage(), e);
runResult = new ReturnT<String>(500, e.getMessage());

@ -4,6 +4,7 @@ import com.xxl.job.admin.core.scheduler.XxlJobScheduler;
import com.xxl.job.admin.core.route.ExecutorRouter;
import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.IdleBeatParam;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
@ -22,7 +23,7 @@ public class ExecutorRouteBusyover extends ExecutorRouter {
ReturnT<String> idleBeatResult = null;
try {
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
idleBeatResult = executorBiz.idleBeat(new IdleBeatParam(triggerParam.getJobId()));
} catch (Exception e) {
logger.error(e.getMessage(), e);
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );

@ -2,10 +2,7 @@ package com.xxl.job.executorbiz;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.client.ExecutorBizClient;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.biz.model.*;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.job.core.glue.GlueTypeEnum;
import org.junit.Assert;
@ -42,7 +39,7 @@ public class ExecutorBizTest {
final int jobId = 0;
// Act
final ReturnT<String> retval = executorBiz.idleBeat(jobId);
final ReturnT<String> retval = executorBiz.idleBeat(new IdleBeatParam(jobId));
// Assert result
Assert.assertNotNull(retval);
@ -81,7 +78,7 @@ public class ExecutorBizTest {
final int jobId = 0;
// Act
final ReturnT<String> retval = executorBiz.kill(jobId);
final ReturnT<String> retval = executorBiz.kill(new KillParam(jobId));
// Assert result
Assert.assertNotNull(retval);

@ -1,9 +1,6 @@
package com.xxl.job.core.biz;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.biz.model.*;
/**
* Created by xuxueli on 17/3/1.
@ -19,10 +16,10 @@ public interface ExecutorBiz {
/**
* idle beat
*
* @param jobId
* @param idleBeatParam
* @return
*/
public ReturnT<String> idleBeat(int jobId);
public ReturnT<String> idleBeat(IdleBeatParam idleBeatParam);
/**
* run
@ -33,10 +30,10 @@ public interface ExecutorBiz {
/**
* kill
* @param jobId
* @param killParam
* @return
*/
public ReturnT<String> kill(int jobId);
public ReturnT<String> kill(KillParam killParam);
/**
* log

@ -1,10 +1,7 @@
package com.xxl.job.core.biz.client;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.biz.model.*;
import com.xxl.job.core.util.XxlJobRemotingUtil;
/**
@ -37,8 +34,8 @@ public class ExecutorBizClient implements ExecutorBiz {
}
@Override
public ReturnT<String> idleBeat(int jobId){
return XxlJobRemotingUtil.postBody(addressUrl+"idleBeat", accessToken, timeout, jobId, String.class);
public ReturnT<String> idleBeat(IdleBeatParam idleBeatParam){
return XxlJobRemotingUtil.postBody(addressUrl+"idleBeat", accessToken, timeout, idleBeatParam, String.class);
}
@Override
@ -47,8 +44,8 @@ public class ExecutorBizClient implements ExecutorBiz {
}
@Override
public ReturnT<String> kill(int jobId) {
return XxlJobRemotingUtil.postBody(addressUrl + "kill", accessToken, timeout, jobId, String.class);
public ReturnT<String> kill(KillParam killParam) {
return XxlJobRemotingUtil.postBody(addressUrl + "kill", accessToken, timeout, killParam, String.class);
}
@Override

@ -1,10 +1,7 @@
package com.xxl.job.core.biz.impl;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.biz.model.*;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.job.core.executor.XxlJobExecutor;
import com.xxl.job.core.glue.GlueFactory;
@ -31,11 +28,11 @@ public class ExecutorBizImpl implements ExecutorBiz {
}
@Override
public ReturnT<String> idleBeat(int jobId) {
public ReturnT<String> idleBeat(IdleBeatParam idleBeatParam) {
// isRunningOrHasQueue
boolean isRunningOrHasQueue = false;
JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
JobThread jobThread = XxlJobExecutor.loadJobThread(idleBeatParam.getJobId());
if (jobThread != null && jobThread.isRunningOrHasQueue()) {
isRunningOrHasQueue = true;
}
@ -152,11 +149,11 @@ public class ExecutorBizImpl implements ExecutorBiz {
}
@Override
public ReturnT<String> kill(int jobId) {
public ReturnT<String> kill(KillParam killParam) {
// kill handlerThread, and create new one
JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
JobThread jobThread = XxlJobExecutor.loadJobThread(killParam.getJobId());
if (jobThread != null) {
XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job.");
XxlJobExecutor.removeJobThread(killParam.getJobId(), "scheduling center kill job.");
return ReturnT.SUCCESS;
}

@ -0,0 +1,28 @@
package com.xxl.job.core.biz.model;
import java.io.Serializable;
/**
* @author xuxueli 2020-04-11 22:27
*/
public class IdleBeatParam implements Serializable {
private static final long serialVersionUID = 42L;
public IdleBeatParam() {
}
public IdleBeatParam(int jobId) {
this.jobId = jobId;
}
private int jobId;
public int getJobId() {
return jobId;
}
public void setJobId(int jobId) {
this.jobId = jobId;
}
}

@ -0,0 +1,28 @@
package com.xxl.job.core.biz.model;
import java.io.Serializable;
/**
* @author xuxueli 2020-04-11 22:27
*/
public class KillParam implements Serializable {
private static final long serialVersionUID = 42L;
public KillParam() {
}
public KillParam(int jobId) {
this.jobId = jobId;
}
private int jobId;
public int getJobId() {
return jobId;
}
public void setJobId(int jobId) {
this.jobId = jobId;
}
}

@ -8,6 +8,8 @@ import java.io.Serializable;
public class LogParam implements Serializable {
private static final long serialVersionUID = 42L;
public LogParam() {
}
public LogParam(long logDateTim, long logId, int fromLineNum) {
this.logDateTim = logDateTim;
this.logId = logId;

@ -8,6 +8,8 @@ import java.io.Serializable;
public class LogResult implements Serializable {
private static final long serialVersionUID = 42L;
public LogResult() {
}
public LogResult(int fromLineNum, int toLineNum, String logContent, boolean isEnd) {
this.fromLineNum = fromLineNum;
this.toLineNum = toLineNum;

@ -2,9 +2,7 @@ package com.xxl.job.core.server;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.impl.ExecutorBizImpl;
import com.xxl.job.core.biz.model.LogParam;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.biz.model.*;
import com.xxl.job.core.thread.ExecutorRegistryThread;
import com.xxl.job.core.util.GsonTool;
import com.xxl.job.core.util.ThrowableUtil;
@ -169,18 +167,18 @@ public class EmbedServer {
if ("/beat".equals(uri)) {
return executorBiz.beat();
} else if ("/idleBeat".equals(uri)) {
int jobId = GsonTool.fromJson(requestData, Integer.class);
return executorBiz.idleBeat(jobId);
IdleBeatParam idleBeatParam = GsonTool.fromJson(requestData, IdleBeatParam.class);
return executorBiz.idleBeat(idleBeatParam);
} else if ("/run".equals(uri)) {
TriggerParam triggerParam = GsonTool.fromJson(requestData, TriggerParam.class);
return executorBiz.run(triggerParam);
} else if ("/kill".equals(uri)) {
int jobId = GsonTool.fromJson(requestData, Integer.class);
return executorBiz.kill(jobId);
KillParam killParam = GsonTool.fromJson(requestData, KillParam.class);
return executorBiz.kill(killParam);
} else if ("/log".equals(uri)) {
LogParam logParam = GsonTool.fromJson(requestData, LogParam.class);
return executorBiz.log(logParam);
} else if ("/run".equals(uri)) {
TriggerParam triggerParam = GsonTool.fromJson(requestData, TriggerParam.class);
return executorBiz.run(triggerParam);
} else {
} else {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
}
} catch (Exception e) {

Loading…
Cancel
Save