com.xxl.job.core.biz.model.TriggerParam Java Examples

The following examples show how to use com.xxl.job.core.biz.model.TriggerParam. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XxlJobTrigger.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * run executor
 *
 * @param triggerParam
 * @param address
 * @return
 */
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address) {
    ReturnT<String> runResult = null;
    try {
        ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
        runResult = executorBiz.run(triggerParam);
    } catch (Exception e) {
        logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
        runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));
    }

    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
    runResultSB.append("<br>address:").append(address);
    runResultSB.append("<br>code:").append(runResult.getCode());
    runResultSB.append("<br>msg:").append(runResult.getMsg());

    runResult.setMsg(runResultSB.toString());
    return runResult;
}
 
Example #2
Source File: XxlJobTrigger.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * run executor 向执行器发送指令都是从这个方法中执行的
 * @param triggerParam
 * @param address
 * @return  ReturnT.content: final address
 */
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){
    ReturnT<String> runResult = null;
    try {
        //创建一个ExcutorBiz 的对象,重点在这个方法里面
        ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
        // 这个run 方法不会最终执行,仅仅只是为了触发 proxy object 的 invoke方法,同时将目标的类型传送给服务端, 因为在代理对象的invoke的方法里面没有执行目标对象的方法
        runResult = executorBiz.run(triggerParam);
    } catch (Exception e) {
        logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
        runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
    }

    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
    runResultSB.append("<br>address:").append(address);
    runResultSB.append("<br>code:").append(runResult.getCode());
    runResultSB.append("<br>msg:").append(runResult.getMsg());

    runResult.setMsg(runResultSB.toString());
    runResult.setContent(address);
    return runResult;
}
 
Example #3
Source File: XxlJobTrigger.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
/**
 * run executor
 *
 * @param triggerParam
 * @param address
 * @return
 */
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address) {
    ReturnT<String> runResult = null;
    try {
        ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
        runResult = executorBiz.run(triggerParam);
    } catch (Exception e) {
        logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
        runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));
    }

    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
    runResultSB.append("<br>address:").append(address);
    runResultSB.append("<br>code:").append(runResult.getCode());
    runResultSB.append("<br>msg:").append(runResult.getMsg());

    runResult.setMsg(runResultSB.toString());
    return runResult;
}
 
Example #4
Source File: XxlJobTrigger.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * run executor
 * @param triggerParam
 * @param address
 * @return
 */
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){
    ReturnT<String> runResult = null;
    try {
        ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
        runResult = executorBiz.run(triggerParam);
    } catch (Exception e) {
        logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
        runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));
    }

    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
    runResultSB.append("<br>address:").append(address);
    runResultSB.append("<br>code:").append(runResult.getCode());
    runResultSB.append("<br>msg:").append(runResult.getMsg());

    runResult.setMsg(runResultSB.toString());
    return runResult;
}
 
Example #5
Source File: XxlJobTrigger.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
/**
 * run executor
 * @param triggerParam
 * @param address
 * @return
 */
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){
    ReturnT<String> runResult = null;
    try {
        ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
        runResult = executorBiz.run(triggerParam);
    } catch (Exception e) {
        logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
        runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));
    }

    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
    runResultSB.append("<br>address:").append(address);
    runResultSB.append("<br>code:").append(runResult.getCode());
    runResultSB.append("<br>msg:").append(runResult.getMsg());

    runResult.setMsg(runResultSB.toString());
    return runResult;
}
 
Example #6
Source File: ExecutorRouteFirst.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #7
Source File: JobThread.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
    * new trigger to queue
    *
    * @param triggerParam
    * @return
    */
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
	// avoid repeat
	if (triggerLogIdSet.contains(triggerParam.getLogId())) {
		logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
		return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
	}

	triggerLogIdSet.add(triggerParam.getLogId());
	triggerQueue.add(triggerParam);
       return ReturnT.SUCCESS;
}
 
Example #8
Source File: ExecutorRouteConsistentHash.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {
    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #9
Source File: ExecutorRouteFailover.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    StringBuffer beatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> beatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            beatResult = executorBiz.beat();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_beat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(beatResult.getCode())
                .append("<br>msg:").append(beatResult.getMsg());

        // beat success
        if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

            ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
            beatResultSB.append("<br><br>").append(runResult.getMsg());

            // result
            runResult.setMsg(beatResultSB.toString());
            runResult.setContent(address);
            return runResult;
        }
    }
    return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString());

}
 
Example #10
Source File: ExecutorRouteRandom.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {
    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #11
Source File: ExecutorRouteBusyover.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    StringBuffer idleBeatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> idleBeatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        idleBeatResultSB.append( (idleBeatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_idleBeat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(idleBeatResult.getCode())
                .append("<br>msg:").append(idleBeatResult.getMsg());

        // beat success
        if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {

            ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
            idleBeatResultSB.append("<br><br>").append(runResult.getMsg());

            // result
            runResult.setMsg(idleBeatResultSB.toString());
            runResult.setContent(address);
            return runResult;
        }
    }

    return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString());
}
 
Example #12
Source File: ExecutorRouteLast.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {
    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #13
Source File: ExecutorRouteRound.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #14
Source File: ExecutorRouteBusyover.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    StringBuffer idleBeatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> idleBeatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
            idleBeatResult = executorBiz.idleBeat(new IdleBeatParam(triggerParam.getJobId()));
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        idleBeatResultSB.append( (idleBeatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_idleBeat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(idleBeatResult.getCode())
                .append("<br>msg:").append(idleBeatResult.getMsg());

        // beat success
        if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
            idleBeatResult.setMsg(idleBeatResultSB.toString());
            idleBeatResult.setContent(address);
            return idleBeatResult;
        }
    }

    return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString());
}
 
Example #15
Source File: JobThread.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
/**
    * new trigger to queue
    *
    * @param triggerParam
    * @return
    */
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
	// avoid repeat
	if (triggerLogIdSet.contains(triggerParam.getLogId())) {
		logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
		return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
	}

	triggerLogIdSet.add(triggerParam.getLogId());
	triggerQueue.add(triggerParam);
       return ReturnT.SUCCESS;
}
 
Example #16
Source File: JobThread.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
/**
 * new trigger to queue
 *
 * @param triggerParam
 * @return
 */
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
    // avoid repeat
    if (triggerLogIdSet.contains(triggerParam.getLogId())) {
        logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
        return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
    }

    triggerLogIdSet.add(triggerParam.getLogId());
    triggerQueue.add(triggerParam);
    return ReturnT.SUCCESS;
}
 
Example #17
Source File: ExecutorRouteLFU.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #18
Source File: ExecutorRouteLRU.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> routeRun(TriggerParam triggerParam, ArrayList<String> addressList) {

    // address
    String address = route(triggerParam.getJobId(), addressList);

    // run executor
    ReturnT<String> runResult = XxlJobTrigger.runExecutor(triggerParam, address);
    runResult.setContent(address);
    return runResult;
}
 
Example #19
Source File: ExecutorRouteFailover.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {

    StringBuffer beatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> beatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
            beatResult = executorBiz.beat();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_beat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(beatResult.getCode())
                .append("<br>msg:").append(beatResult.getMsg());

        // beat success
        if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

            beatResult.setMsg(beatResultSB.toString());
            beatResult.setContent(address);
            return beatResult;
        }
    }
    return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString());

}
 
Example #20
Source File: ExecutorRouteFailover.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {

    StringBuffer beatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> beatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            beatResult = executorBiz.beat();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
        }
        beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "")
                .append(I18nUtil.getString("jobconf_beat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(beatResult.getCode())
                .append("<br>msg:").append(beatResult.getMsg());

        // beat success
        if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

            beatResult.setMsg(beatResultSB.toString());
            beatResult.setContent(address);
            return beatResult;
        }
    }
    return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString());

}
 
Example #21
Source File: ExecutorRouteFailover.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {

    StringBuffer beatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> beatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            beatResult = executorBiz.beat();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_beat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(beatResult.getCode())
                .append("<br>msg:").append(beatResult.getMsg());

        // beat success
        if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

            beatResult.setMsg(beatResultSB.toString());
            beatResult.setContent(address);
            return beatResult;
        }
    }
    return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString());

}
 
Example #22
Source File: ExecutorRouteBusyover.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    StringBuffer idleBeatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> idleBeatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
        }
        idleBeatResultSB.append( (idleBeatResultSB.length()>0)?"<br><br>":"")
                .append(I18nUtil.getString("jobconf_idleBeat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(idleBeatResult.getCode())
                .append("<br>msg:").append(idleBeatResult.getMsg());

        // beat success
        if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
            idleBeatResult.setMsg(idleBeatResultSB.toString());
            idleBeatResult.setContent(address);
            return idleBeatResult;
        }
    }

    return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString());
}
 
Example #23
Source File: ExecutorRouteBusyover.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    StringBuffer idleBeatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> idleBeatResult = null;
        try {
            //
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
        }
        //空闲检测:
        //address:
        //code:
        //msg:
        idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "")
                .append(I18nUtil.getString("jobconf_idleBeat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(idleBeatResult.getCode())
                .append("<br>msg:").append(idleBeatResult.getMsg());

        // beat success
        if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
            idleBeatResult.setMsg(idleBeatResultSB.toString());
            idleBeatResult.setContent(address);
            return idleBeatResult;
        }
    }

    return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString());
}
 
Example #24
Source File: JobThread.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
/**
    * new trigger to queue
    *
    * @param triggerParam
    * @return
    */
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
	// avoid repeat
	if (triggerLogIdSet.contains(triggerParam.getLogId())) {
		logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
		return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
	}

	triggerLogIdSet.add(triggerParam.getLogId());
	triggerQueue.add(triggerParam);
       return ReturnT.SUCCESS;
}
 
Example #25
Source File: ExecutorRouteBusyover.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    StringBuffer idleBeatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> idleBeatResult = null;
        try {
            //
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            idleBeatResult = executorBiz.idleBeat(triggerParam.getJobId());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
        }
        //空闲检测:
        //address:
        //code:
        //msg:
        idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "")
                .append(I18nUtil.getString("jobconf_idleBeat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(idleBeatResult.getCode())
                .append("<br>msg:").append(idleBeatResult.getMsg());

        // beat success
        if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
            idleBeatResult.setMsg(idleBeatResultSB.toString());
            idleBeatResult.setContent(address);
            return idleBeatResult;
        }
    }

    return new ReturnT<String>(ReturnT.FAIL_CODE, idleBeatResultSB.toString());
}
 
Example #26
Source File: ExecutorBizTest.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * run jobhandler
 *
 * @param jobHandler
 * @param params
 */
private static void runTest(String jobHandler, String params) throws Exception {
    // trigger data
    TriggerParam triggerParam = new TriggerParam();
    triggerParam.setJobId(1);
    triggerParam.setExecutorHandler(jobHandler);
    triggerParam.setExecutorParams(params);
    triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name());
    triggerParam.setGlueType(GlueTypeEnum.BEAN.name());
    triggerParam.setGlueSource(null);
    triggerParam.setGlueUpdatetime(System.currentTimeMillis());
    triggerParam.setLogId(1);
    triggerParam.setLogDateTim(System.currentTimeMillis());

    // do remote trigger
    String accessToken = null;
    ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            ExecutorBiz.class,
            null,
            10000,
            "127.0.0.1:9999",
            null,
            null,
            null).getObject();

    ReturnT<String> runResult = executorBiz.run(triggerParam);

    System.out.println(runResult);
    XxlRpcInvokerFactory.getInstance().stop();
}
 
Example #27
Source File: JobThread.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * new trigger to queue
 *
 * @param triggerParam
 * @return
 */
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
    // avoid repeat
    if (triggerLogIdSet.contains(triggerParam.getLogId())) {
        logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
        return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
    }

    triggerLogIdSet.add(triggerParam.getLogId());
    triggerQueue.add(triggerParam);
    return ReturnT.SUCCESS;
}
 
Example #28
Source File: ExecutorRouteFailover.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {

    StringBuffer beatResultSB = new StringBuffer();
    for (String address : addressList) {
        // beat
        ReturnT<String> beatResult = null;
        try {
            ExecutorBiz executorBiz = XxlJobDynamicScheduler.getExecutorBiz(address);
            beatResult = executorBiz.beat();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
        }
        beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "")
                .append(I18nUtil.getString("jobconf_beat") + ":")
                .append("<br>address:").append(address)
                .append("<br>code:").append(beatResult.getCode())
                .append("<br>msg:").append(beatResult.getMsg());

        // beat success
        if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

            beatResult.setMsg(beatResultSB.toString());
            beatResult.setContent(address);
            return beatResult;
        }
    }
    return new ReturnT<String>(ReturnT.FAIL_CODE, beatResultSB.toString());

}
 
Example #29
Source File: ExecutorRouteRound.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    String address = addressList.get(count(triggerParam.getJobId()) % addressList.size());
    return new ReturnT<String>(address);
}
 
Example #30
Source File: ExecutorRouteLast.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
    return new ReturnT<String>(addressList.get(addressList.size() - 1));
}