com.xxl.job.core.handler.IJobHandler Java Examples
The following examples show how to use
com.xxl.job.core.handler.IJobHandler.
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: XxlJobSpringExecutor.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
private void initJobHandlerRepository(ApplicationContext applicationContext) { if (applicationContext == null) { return; } // init job handler action Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class); if (serviceBeanMap != null && serviceBeanMap.size() > 0) { for (Object serviceBean : serviceBeanMap.values()) { if (serviceBean instanceof IJobHandler) { String name = serviceBean.getClass().getAnnotation(JobHandler.class).value(); IJobHandler handler = (IJobHandler) serviceBean; if (loadJobHandler(name) != null) { throw new RuntimeException("xxl-job jobhandler naming conflicts. name = " + name); } registJobHandler(name, handler); } } } }
Example #2
Source File: GlueFactory.java From open-capacity-platform with Apache License 2.0 | 6 votes |
public IJobHandler loadNewInstance(String codeSource) throws Exception{ if (codeSource!=null && codeSource.trim().length()>0) { Class<?> clazz = groovyClassLoader.parseClass(codeSource); if (clazz != null) { Object instance = clazz.newInstance(); if (instance!=null) { if (instance instanceof IJobHandler) { this.injectService(instance); return (IJobHandler) instance; } else { throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, " + "cannot convert from instance["+ instance.getClass() +"] to IJobHandler"); } } } } throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"); }
Example #3
Source File: GlueFactory.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
/** * load new instance, prototype * * @param codeSource * @return * @throws Exception */ public IJobHandler loadNewInstance(String codeSource) throws Exception { if (codeSource != null && codeSource.trim().length() > 0) { Class<?> clazz = groovyClassLoader.parseClass(codeSource); if (clazz != null) { Object instance = clazz.newInstance(); if (instance != null) { if (instance instanceof IJobHandler) { this.injectService(instance); return (IJobHandler) instance; } else { throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, " + "cannot convert from instance[" + instance.getClass() + "] to IJobHandler"); } } } } throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"); }
Example #4
Source File: GlueFactory.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
/** * load new instance, prototype * * @param codeSource * @return * @throws Exception */ public IJobHandler loadNewInstance(String codeSource) throws Exception { if (codeSource != null && codeSource.trim().length() > 0) { Class<?> clazz = groovyClassLoader.parseClass(codeSource); if (clazz != null) { Object instance = clazz.newInstance(); if (instance != null) { if (instance instanceof IJobHandler) { this.injectService(instance); return (IJobHandler) instance; } else { throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, " + "cannot convert from instance[" + instance.getClass() + "] to IJobHandler"); } } } } throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"); }
Example #5
Source File: XxlJobExecutor.java From open-capacity-platform with Apache License 2.0 | 6 votes |
private static void initJobHandlerRepository(ApplicationContext applicationContext){ if (applicationContext == null) { return; } // init job handler action Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class); if (serviceBeanMap!=null && serviceBeanMap.size()>0) { for (Object serviceBean : serviceBeanMap.values()) { if (serviceBean instanceof IJobHandler){ String name = serviceBean.getClass().getAnnotation(JobHandler.class).value(); IJobHandler handler = (IJobHandler) serviceBean; if (loadJobHandler(name) != null) { throw new RuntimeException("xxl-job jobhandler naming conflicts."); } registJobHandler(name, handler); } } } }
Example #6
Source File: XxlJobSpringExecutor.java From microservices-platform with Apache License 2.0 | 6 votes |
private void initJobHandlerRepository(ApplicationContext applicationContext){ if (applicationContext == null) { return; } // init job handler action Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class); if (serviceBeanMap!=null && serviceBeanMap.size()>0) { for (Object serviceBean : serviceBeanMap.values()) { if (serviceBean instanceof IJobHandler){ String name = serviceBean.getClass().getAnnotation(JobHandler.class).value(); IJobHandler handler = (IJobHandler) serviceBean; if (loadJobHandler(name) != null) { throw new RuntimeException("xxl-job jobhandler naming conflicts."); } registJobHandler(name, handler); } } } }
Example #7
Source File: GlueFactory.java From microservices-platform with Apache License 2.0 | 6 votes |
/** * load new instance, prototype * * @param codeSource * @return * @throws Exception */ public IJobHandler loadNewInstance(String codeSource) throws Exception{ if (codeSource!=null && codeSource.trim().length()>0) { Class<?> clazz = groovyClassLoader.parseClass(codeSource); if (clazz != null) { Object instance = clazz.newInstance(); if (instance!=null) { if (instance instanceof IJobHandler) { this.injectService(instance); return (IJobHandler) instance; } else { throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, " + "cannot convert from instance["+ instance.getClass() +"] to IJobHandler"); } } } } throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"); }
Example #8
Source File: XxlJobSpringExecutor.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
private void initJobHandlerRepository(ApplicationContext applicationContext) { if (applicationContext == null) { return; } // init job handler action Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class); if (serviceBeanMap != null && serviceBeanMap.size() > 0) { for (Object serviceBean : serviceBeanMap.values()) { if (serviceBean instanceof IJobHandler) { String name = serviceBean.getClass().getAnnotation(JobHandler.class).value(); IJobHandler handler = (IJobHandler) serviceBean; if (loadJobHandler(name) != null) { throw new RuntimeException("xxl-job jobhandler naming conflicts. name = " + name); } registJobHandler(name, handler); } } } }
Example #9
Source File: GlueFactory.java From xxl-job with GNU General Public License v3.0 | 6 votes |
/** * load new instance, prototype * * @param codeSource * @return * @throws Exception */ public IJobHandler loadNewInstance(String codeSource) throws Exception{ if (codeSource!=null && codeSource.trim().length()>0) { Class<?> clazz = getCodeSourceClass(codeSource); if (clazz != null) { Object instance = clazz.newInstance(); if (instance!=null) { if (instance instanceof IJobHandler) { this.injectService(instance); return (IJobHandler) instance; } else { throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, " + "cannot convert from instance["+ instance.getClass() +"] to IJobHandler"); } } } } throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"); }
Example #10
Source File: XxlJobExecutor.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason) { JobThread newJobThread = new JobThread(jobId, handler); newJobThread.start(); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); oldJobThread.interrupt(); } return newJobThread; }
Example #11
Source File: XxlJobExecutor.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason) { JobThread newJobThread = new JobThread(jobId, handler); newJobThread.start(); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); oldJobThread.interrupt(); } return newJobThread; }
Example #12
Source File: AdminBizImpl.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) { for (HandleCallbackParam handleCallbackParam : callbackParamList) { ReturnT<String> callbackResult = callback(handleCallbackParam); logger.info(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}", (callbackResult.getCode() == IJobHandler.SUCCESS.getCode() ? "success" : "fail"), handleCallbackParam, callbackResult); } return ReturnT.SUCCESS; }
Example #13
Source File: AdminBizImpl.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) { for (HandleCallbackParam handleCallbackParam : callbackParamList) { ReturnT<String> callbackResult = callback(handleCallbackParam); logger.info(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}", (callbackResult.getCode() == IJobHandler.SUCCESS.getCode() ? "success" : "fail"), handleCallbackParam, callbackResult); } return ReturnT.SUCCESS; }
Example #14
Source File: AdminBizImpl.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) { for (HandleCallbackParam handleCallbackParam: callbackParamList) { ReturnT<String> callbackResult = callback(handleCallbackParam); logger.info(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}", (callbackResult.getCode()==IJobHandler.SUCCESS.getCode()?"success":"fail"), handleCallbackParam, callbackResult); } return ReturnT.SUCCESS; }
Example #15
Source File: XxlJobExecutor.java From microservices-platform with Apache License 2.0 | 5 votes |
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){ JobThread newJobThread = new JobThread(jobId, handler); newJobThread.start(); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); oldJobThread.interrupt(); } return newJobThread; }
Example #16
Source File: ScriptJobHandler.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> execute(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType["+ glueType +"] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat("/") .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); ScriptUtil.markScriptFile(scriptFileName, gluesource); // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:"+ scriptFileName +" -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); ReturnT<String> result = (exitValue==0)?IJobHandler.SUCCESS:new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); return result; }
Example #17
Source File: AdminBizImpl.java From xxl-job with GNU General Public License v3.0 | 5 votes |
@Override public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) { for (HandleCallbackParam handleCallbackParam: callbackParamList) { ReturnT<String> callbackResult = callback(handleCallbackParam); logger.debug(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}", (callbackResult.getCode()==IJobHandler.SUCCESS.getCode()?"success":"fail"), handleCallbackParam, callbackResult); } return ReturnT.SUCCESS; }
Example #18
Source File: XxlJobExecutor.java From xxl-job with GNU General Public License v3.0 | 5 votes |
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){ JobThread newJobThread = new JobThread(jobId, handler); newJobThread.start(); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); oldJobThread.interrupt(); } return newJobThread; }
Example #19
Source File: AdminBizImpl.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) { for (HandleCallbackParam handleCallbackParam: callbackParamList) { ReturnT<String> callbackResult = callback(handleCallbackParam); logger.info(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}", (callbackResult.getCode()==IJobHandler.SUCCESS.getCode()?"success":"fail"), handleCallbackParam, callbackResult); } return ReturnT.SUCCESS; }
Example #20
Source File: XxlJobExecutor.java From open-capacity-platform with Apache License 2.0 | 5 votes |
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){ JobThread newJobThread = new JobThread(jobId, handler); newJobThread.start(); logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler}); JobThread oldJobThread = JobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!! if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); oldJobThread.interrupt(); } return newJobThread; }
Example #21
Source File: JobThread.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public JobThread(int jobId, IJobHandler handler) { this.jobId = jobId; this.handler = handler; this.triggerQueue = new LinkedBlockingQueue<TriggerParam>(); this.triggerLogIdSet = Collections.synchronizedSet(new HashSet<Integer>()); }
Example #22
Source File: AdminBizImpl.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
private ReturnT<String> callback(HandleCallbackParam handleCallbackParam) { // valid log item XxlJobLog log = xxlJobLogDao.load(handleCallbackParam.getLogId()); if (log == null) { return new ReturnT<String>(ReturnT.FAIL_CODE, "log item not found."); } if (log.getHandleCode() > 0) { return new ReturnT<String>(ReturnT.FAIL_CODE, "log repeate callback."); // avoid repeat callback, trigger child job etc } // trigger success, to trigger child job String callbackMsg = null; if (IJobHandler.SUCCESS.getCode() == handleCallbackParam.getExecuteResult().getCode()) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId()); if (xxlJobInfo != null && StringUtils.isNotBlank(xxlJobInfo.getChildJobId())) { callbackMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>"; String[] childJobIds = xxlJobInfo.getChildJobId().split(","); for (int i = 0; i < childJobIds.length; i++) { int childJobId = (StringUtils.isNotBlank(childJobIds[i]) && StringUtils.isNumeric(childJobIds[i])) ? Integer.valueOf(childJobIds[i]) : -1; if (childJobId > 0) { JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null); ReturnT<String> triggerChildResult = ReturnT.SUCCESS; // add msg callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"), (i + 1), childJobIds.length, childJobIds[i], (triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")), triggerChildResult.getMsg()); } else { callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"), (i + 1), childJobIds.length, childJobIds[i]); } } } } // handle msg StringBuffer handleMsg = new StringBuffer(); if (log.getHandleMsg() != null) { handleMsg.append(log.getHandleMsg()).append("<br>"); } if (handleCallbackParam.getExecuteResult().getMsg() != null) { handleMsg.append(handleCallbackParam.getExecuteResult().getMsg()); } if (callbackMsg != null) { handleMsg.append(callbackMsg); } // success, save log log.setHandleTime(new Date()); log.setHandleCode(handleCallbackParam.getExecuteResult().getCode()); log.setHandleMsg(handleMsg.toString()); xxlJobLogDao.updateHandleInfo(log); return ReturnT.SUCCESS; }
Example #23
Source File: JobFailMonitorHelper.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public void start() { monitorThread = new Thread(new Runnable() { @Override public void run() { // monitor while (!toStop) { try { List<Integer> jobLogIdList = new ArrayList<Integer>(); //一次性从BlockingQueue获取所有可用的数据对象(还可以指定获取数据的个数), // 通过该方法,可以提升获取数据效率;不需要多次分批加锁或释放锁。 int drainToNum = JobFailMonitorHelper.instance.queue.drainTo(jobLogIdList); if (CollectionUtils.isNotEmpty(jobLogIdList)) { for (Integer jobLogId : jobLogIdList) { if (jobLogId == null || jobLogId == 0) { continue; } XxlJobLog log = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().load(jobLogId); if (log == null) { continue; } /* 判断执行成功的字段有2个,xxl_job_qrtz_trigger_log 表的TriggerCode=调度器调度状态 、HandleCode=执行器执行状态 */ if (IJobHandler.SUCCESS.getCode() == log.getTriggerCode() && log.getHandleCode() == 0) { // job running JobFailMonitorHelper.monitor(jobLogId); logger.debug(">>>>>>>>>>> job monitor, job running, JobLogId:{}", jobLogId); } else if (IJobHandler.SUCCESS.getCode() == log.getHandleCode()) { // job success, pass logger.info(">>>>>>>>>>> job monitor, job success, JobLogId:{}", jobLogId); } else /*if (IJobHandler.FAIL.getCode() == log.getTriggerCode() || IJobHandler.FAIL.getCode() == log.getHandleCode() || IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() )*/ { // job fail, // 1、fail retry XxlJobInfo info = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(log.getJobId()); if (log.getExecutorFailRetryCount() > 0) { JobTriggerPoolHelper.trigger(log.getJobId(), TriggerTypeEnum.RETRY, (log.getExecutorFailRetryCount() - 1), log.getExecutorShardingParam(), null); String retryMsg = "<br><br><span style=\"color:#F39C12;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_type_retry") + "<<<<<<<<<<< </span><br>"; log.setTriggerMsg(log.getTriggerMsg() + retryMsg); XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateTriggerInfo(log); } // 2、fail alarm failAlarm(info, log); logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId); }/* else { JobFailMonitorHelper.monitor(jobLogId); logger.info(">>>>>>>>>>> job monitor, job status unknown, JobLogId:{}", jobLogId); }*/ } } TimeUnit.SECONDS.sleep(10); } catch (Exception e) { logger.error("job monitor error:{}", e); } } // monitor all clear List<Integer> jobLogIdList = new ArrayList<Integer>(); int drainToNum = getInstance().queue.drainTo(jobLogIdList); if (jobLogIdList != null && jobLogIdList.size() > 0) { for (Integer jobLogId : jobLogIdList) { XxlJobLog log = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().load(jobLogId); if (ReturnT.FAIL_CODE == log.getTriggerCode() || ReturnT.FAIL_CODE == log.getHandleCode()) { // job fail, XxlJobInfo info = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(log.getJobId()); failAlarm(info, log); logger.info(">>>>>>>>>>> job monitor last, job fail, JobLogId:{}", jobLogId); } } } } }); monitorThread.setDaemon(true);//守护线程 monitorThread.start(); }
Example #24
Source File: XxlJobExecutor.java From xxl-job with GNU General Public License v3.0 | 4 votes |
public static IJobHandler loadJobHandler(String name){ return jobHandlerRepository.get(name); }
Example #25
Source File: ScriptJobHandler.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
@Override public ReturnT<String> execute2(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType[" + glueType + "] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobFileAppender.contextHolder.get(); // script params:0=param、1=分片序号、2=分片总数 ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(shardingVO.getIndex()); scriptParams[2] = String.valueOf(shardingVO.getTotal()); // invoke XxlJobLogger.log("----------- script file:" + scriptFileName + " -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value(" + exitValue + ") is failed"); } }
Example #26
Source File: GlueJobHandler.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public GlueJobHandler(IJobHandler jobHandler, long glueUpdatetime) { this.jobHandler = jobHandler; this.glueUpdatetime = glueUpdatetime; }
Example #27
Source File: XxlJobExecutor.java From xxl-job with GNU General Public License v3.0 | 4 votes |
public static IJobHandler registJobHandler(String name, IJobHandler jobHandler){ logger.info(">>>>>>>>>>> xxl-job register jobhandler success, name:{}, jobHandler:{}", name, jobHandler); return jobHandlerRepository.put(name, jobHandler); }
Example #28
Source File: ScriptJobHandler.java From xxl-job with GNU General Public License v3.0 | 4 votes |
@Override public ReturnT<String> execute(String param) throws Exception { if (!glueType.isScript()) { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "glueType["+ glueType +"] invalid."); } // cmd String cmd = glueType.getCmd(); // make script file String scriptFileName = XxlJobFileAppender.getGlueSrcPath() .concat(File.separator) .concat(String.valueOf(jobId)) .concat("_") .concat(String.valueOf(glueUpdatetime)) .concat(glueType.getSuffix()); File scriptFile = new File(scriptFileName); if (!scriptFile.exists()) { ScriptUtil.markScriptFile(scriptFileName, gluesource); } // log file String logFileName = XxlJobContext.getXxlJobContext().getJobLogFileName(); // script params:0=param、1=分片序号、2=分片总数 String[] scriptParams = new String[3]; scriptParams[0] = param; scriptParams[1] = String.valueOf(XxlJobContext.getXxlJobContext().getShardIndex()); scriptParams[2] = String.valueOf(XxlJobContext.getXxlJobContext().getShardTotal()); // invoke XxlJobLogger.log("----------- script file:"+ scriptFileName +" -----------"); int exitValue = ScriptUtil.execToFile(cmd, scriptFileName, logFileName, scriptParams); if (exitValue == 0) { return IJobHandler.SUCCESS; } else { return new ReturnT<String>(IJobHandler.FAIL.getCode(), "script exit value("+exitValue+") is failed"); } }
Example #29
Source File: JobThread.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public IJobHandler getHandler() { return handler; }
Example #30
Source File: XxlJobExecutor.java From zuihou-admin-cloud with Apache License 2.0 | 4 votes |
public static IJobHandler registJobHandler(String name, IJobHandler jobHandler) { logger.info(">>>>>>>>>>> xxl-job register jobhandler success, name:{}, jobHandler:{}", name, jobHandler); return jobHandlerRepository.put(name, jobHandler); }