use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.
the class JobController method batchTasksMigrateEnabled.
@RequestMapping(value = "batchTasksMigrateEnabled", method = RequestMethod.GET)
public RequestResult batchTasksMigrateEnabled(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
JobMigrateInfo jobMigrateInfo = jobDimensionService.getAllJobMigrateInfo();
requestResult.setSuccess(true);
requestResult.setObj(jobMigrateInfo);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.
the class JobController method batchSetPreferExecutors.
@RequestMapping(value = "batchSetPreferExecutors", method = RequestMethod.POST)
public RequestResult batchSetPreferExecutors(final String jobNames, final String newPreferExecutors, HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
if (jobNames == null) {
throw new SaturnJobConsoleException("The jobNames cannot be null");
}
if (newPreferExecutors == null) {
throw new SaturnJobConsoleException("The new prefer executors cannot be null");
}
if (jobNames.trim().length() == 0) {
throw new SaturnJobConsoleException("The jobNames cannot be empty string");
}
jobDimensionService.batchSetPreferExecutors(jobNames.trim(), newPreferExecutors.trim());
requestResult.setSuccess(true);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.
the class JobController method migrateJobNewTask.
@RequestMapping(value = "migrateJobNewTask", method = RequestMethod.POST)
public RequestResult migrateJobNewTask(final String jobName, final String newTask, HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
if (jobName == null) {
throw new SaturnJobConsoleException("The jobName cannot be null");
}
if (newTask == null) {
throw new SaturnJobConsoleException("The new task cannot be null");
}
if (jobName.trim().length() == 0) {
throw new SaturnJobConsoleException("The jobName cannot be empty string");
}
if (newTask.trim().length() == 0) {
throw new SaturnJobConsoleException("The new task cannot be empty string");
}
jobDimensionService.migrateJobNewTask(jobName.trim(), newTask.trim());
requestResult.setSuccess(true);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.
the class JobController method tasksMigrateEnabled.
@RequestMapping(value = "tasksMigrateEnabled", method = RequestMethod.GET)
public RequestResult tasksMigrateEnabled(final String jobName, HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
JobMigrateInfo jobMigrateInfo = jobDimensionService.getJobMigrateInfo(jobName);
requestResult.setSuccess(true);
requestResult.setObj(jobMigrateInfo);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.
the class JobController method updateJobSettings.
@RequestMapping(value = "settings", method = RequestMethod.POST)
public RequestResult updateJobSettings(final JobSettings jobSettings, HttpServletRequest request) {
RequestResult result = new RequestResult();
if (!JobStatus.STOPPED.equals(jobDimensionService.getJobStatus(jobSettings.getJobName()))) {
result.setSuccess(false);
result.setMessage("The job is not stopped, cannot update it's settings");
return result;
}
JobBriefInfo.JobType jobType = JobBriefInfo.JobType.getJobType(jobSettings.getJobType());
if (jobType == JobBriefInfo.JobType.JAVA_JOB || jobType == JobBriefInfo.JobType.SHELL_JOB) {
String cron = jobSettings.getCron();
if (cron != null && !cron.trim().isEmpty()) {
try {
CronExpression.validateExpression(cron.trim());
} catch (ParseException e) {
result.setSuccess(false);
result.setMessage("Cron expression is not valid");
result.setObj(jobDimensionService.getJobSettings(jobSettings.getJobName(), getActivatedConfigInSession(request.getSession())));
return result;
}
} else {
result.setSuccess(false);
result.setMessage("The cron cannot be null or empty for cron-job");
result.setObj(jobDimensionService.getJobSettings(jobSettings.getJobName(), getActivatedConfigInSession(request.getSession())));
return result;
}
}
if (jobSettings.getJobMode() != null && jobSettings.getJobMode().startsWith(JobMode.SYSTEM_PREFIX)) {
result.setSuccess(false);
result.setMessage("The jobMode cannot be start with " + JobMode.SYSTEM_PREFIX);
result.setObj(jobDimensionService.getJobSettings(jobSettings.getJobName(), getActivatedConfigInSession(request.getSession())));
return result;
}
String returnMsg = jobDimensionService.updateJobSettings(jobSettings, getActivatedConfigInSession(request.getSession()));
if (Strings.isNullOrEmpty(returnMsg)) {
result.setSuccess(true);
result.setMessage("update success");
result.setObj(jobSettings);
} else {
result.setSuccess(false);
result.setMessage(returnMsg);
result.setObj(jobDimensionService.getJobSettings(jobSettings.getJobName(), getActivatedConfigInSession(request.getSession())));
}
return result;
}
Aggregations