|
|
@ -114,76 +114,82 @@ public class RemoteHttpJobBean extends QuartzJobBean {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// trigger remote executor
|
|
|
|
// executor route strategy
|
|
|
|
if (addressList.size() == 1) {
|
|
|
|
ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null);
|
|
|
|
String address = addressList.get(0);
|
|
|
|
if (executorRouteStrategyEnum == null) {
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
triggerSb.append("<br>----------------------<br>").append("调度失败:").append("执行器路由策略为空");
|
|
|
|
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
}
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
triggerSb.append("<br>路由策略:").append(executorRouteStrategyEnum.name() + "-" + executorRouteStrategyEnum.getTitle());
|
|
|
|
|
|
|
|
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
// trigger remote executor
|
|
|
|
} else {
|
|
|
|
if (executorRouteStrategyEnum == ExecutorRouteStrategyEnum.FAILOVER) {
|
|
|
|
// executor route strategy
|
|
|
|
for (String address : addressList) {
|
|
|
|
ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null);
|
|
|
|
// beat
|
|
|
|
triggerSb.append("<br>路由策略:").append(executorRouteStrategyEnum!=null?(executorRouteStrategyEnum.name() + "-" + executorRouteStrategyEnum.getTitle()):null);
|
|
|
|
ReturnT<String> beatResult = null;
|
|
|
|
if (executorRouteStrategyEnum == null) {
|
|
|
|
try {
|
|
|
|
triggerSb.append("<br>----------------------<br>").append("调度失败:").append("执行器路由策略为空");
|
|
|
|
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address).getObject();
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
beatResult = executorBiz.beat();
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.error("", e);
|
|
|
|
|
|
|
|
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
triggerSb.append("<br>----------------------<br>")
|
|
|
|
|
|
|
|
.append("心跳检测:")
|
|
|
|
|
|
|
|
.append("<br>address:").append(address)
|
|
|
|
|
|
|
|
.append("<br>code:").append(beatResult.getCode())
|
|
|
|
|
|
|
|
.append("<br>msg:").append(beatResult.getMsg());
|
|
|
|
|
|
|
|
|
|
|
|
if (executorRouteStrategyEnum != ExecutorRouteStrategyEnum.FAILOVER) {
|
|
|
|
// beat success
|
|
|
|
// get address
|
|
|
|
if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
|
|
|
String address = executorRouteStrategyEnum.getRouter().route(jobInfo.getId(), addressList);
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// run
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
for (String address : addressList) {
|
|
|
|
}
|
|
|
|
// beat
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
ReturnT<String> beatResult = beatExecutor(address);
|
|
|
|
} else if (executorRouteStrategyEnum == ExecutorRouteStrategyEnum.BUSYOVER) {
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(beatResult.getMsg());
|
|
|
|
for (String address : addressList) {
|
|
|
|
|
|
|
|
// beat
|
|
|
|
|
|
|
|
ReturnT<String> idleBeatResult = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address).getObject();
|
|
|
|
|
|
|
|
idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.error("", e);
|
|
|
|
|
|
|
|
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
triggerSb.append("<br>----------------------<br>")
|
|
|
|
|
|
|
|
.append("空闲检测:")
|
|
|
|
|
|
|
|
.append("<br>address:").append(address)
|
|
|
|
|
|
|
|
.append("<br>code:").append(idleBeatResult.getCode())
|
|
|
|
|
|
|
|
.append("<br>msg:").append(idleBeatResult.getMsg());
|
|
|
|
|
|
|
|
|
|
|
|
if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
|
|
|
// beat success
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
|
|
|
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
|
|
|
|
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
|
|
|
|
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, triggerSb.toString());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// get address
|
|
|
|
/**
|
|
|
|
String address = executorRouteStrategyEnum.getRouter().route(jobInfo.getId(), addressList);
|
|
|
|
* run executor
|
|
|
|
jobLog.setExecutorAddress(address);
|
|
|
|
* @param address
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public ReturnT<String> beatExecutor(String address){
|
|
|
|
|
|
|
|
ReturnT<String> beatResult = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address).getObject();
|
|
|
|
|
|
|
|
beatResult = executorBiz.beat();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.error("", e);
|
|
|
|
|
|
|
|
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer("心跳检测:");
|
|
|
|
// run
|
|
|
|
sb.append("<br>address:").append(address);
|
|
|
|
ReturnT<String> runResult = runExecutor(triggerParam, address);
|
|
|
|
sb.append("<br>code:").append(beatResult.getCode());
|
|
|
|
triggerSb.append("<br>----------------------<br>").append(runResult.getMsg());
|
|
|
|
sb.append("<br>msg:").append(beatResult.getMsg());
|
|
|
|
|
|
|
|
beatResult.setMsg(sb.toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return beatResult;
|
|
|
|
return new ReturnT<String>(runResult.getCode(), triggerSb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|