/** * Find the job detail * @param id the job id * @return the job detail response */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) public JsonResponse findJobDetail(@PathVariable("id") Long id){ Response<JobDetail> findResp = jobService.findJobDetailById(id); if(!findResp.isSuccess()){ return JsonResponse.notOk(messages.get(findResp.getErr())); } return JsonResponse.ok(findResp.getData()); }
public Boolean scheduleJob(Long jobId) { Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find job detail when schedule job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } scheduleJob(findResp.getData()); return Boolean.TRUE; }
/** * Reload the job to be scheduled * @param jobId the job id * @return return true if reload successfully, or not */ public Boolean reloadJob(Long jobId) { Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find job detail when remove job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } return reloadJob(findResp.getData()); }
/** * Resume the job schedule * @param jobId the job id */ public Boolean resumeJob(Long jobId){ Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find job detail when resume job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } return resumeJob(findResp.getData()); }
/** * Pause the job * @param jobId the job id */ public Boolean pauseJob(Long jobId){ Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find job detail when pause job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } return pauseJob(findResp.getData()); }
/** * Trigger the job immediately * @param jobId the job id * @param triggerType the trigger type * @see JobTriggerType */ public Boolean triggerJob(Long jobId, JobTriggerType triggerType){ Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find job detail when trigger job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } return triggerJob(findResp.getData(), triggerType); }
private void checkJobState(Long jobId, JobState expectState, JobState targetState) { Response<JobDetail> jobResp = jobService.findJobDetailById(jobId); if(!jobResp.isSuccess()){ throw new JobFindException(); } JobDetail jobDetail = jobResp.getData(); if (jobDetail == null){ Logs.warn("The job(id={}) isn't exist.", jobId); throw new JobNotExistException(jobId); } String appName = jobDetail.getApp().getAppName(); String jobClass = jobDetail.getJob().getClazz(); jobSupport.checkJobStateOperate(appName, jobClass, expectState, targetState); }
/** * Remove the job from the pool, and will delete the job from zk * @param jobId the job id */ public Boolean removeJob(Long jobId){ Response<JobDetail> findResp = jobService.findJobDetailById(jobId); if (!findResp.isSuccess()){ Logs.error("failed to find the job detail when remove job(id={}), cause: {}", jobId, findResp.getErr()); return Boolean.TRUE; } if (removeJob(findResp.getData())){ // unbind the job from the server Response<Boolean> unbindResp = jobService.unbindJobServer(serverHost.get(), jobId); if (!unbindResp.isSuccess() || !unbindResp.getData()){ return Boolean.FALSE; } return Boolean.TRUE; } return Boolean.FALSE; }
Response<JobDetail> findResp = jobService.findJobDetailById(e.getJobId()); if (!findResp.isSuccess()){ Logs.error("failed to find job detail(event={}), cause: {}", e, findResp.getErr());