Search in sources :

Example 11 with RequestResult

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;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) JobMigrateInfo(com.vip.saturn.job.console.domain.JobMigrateInfo) ParseException(java.text.ParseException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with 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;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) ParseException(java.text.ParseException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with 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;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) ParseException(java.text.ParseException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with 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;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) JobMigrateInfo(com.vip.saturn.job.console.domain.JobMigrateInfo) ParseException(java.text.ParseException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with 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;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) JobBriefInfo(com.vip.saturn.job.console.domain.JobBriefInfo) ParseException(java.text.ParseException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestResult (com.vip.saturn.job.console.domain.RequestResult)49 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)45 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)38 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 ParseException (java.text.ParseException)11 IOException (java.io.IOException)3 ExecutorProvided (com.vip.saturn.job.console.domain.ExecutorProvided)2 ExportJobConfigPageStatus (com.vip.saturn.job.console.domain.ExportJobConfigPageStatus)2 JobDiffInfo (com.vip.saturn.job.console.domain.JobDiffInfo)2 JobMigrateInfo (com.vip.saturn.job.console.domain.JobMigrateInfo)2 SystemConfig (com.vip.saturn.job.console.mybatis.entity.SystemConfig)2 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 Gson (com.google.gson.Gson)1 JobBriefInfo (com.vip.saturn.job.console.domain.JobBriefInfo)1 JobConfig (com.vip.saturn.job.console.domain.JobConfig)1 MoveNamespaceBatchStatus (com.vip.saturn.job.console.domain.MoveNamespaceBatchStatus)1 NamespaceZkClusterMappingVo (com.vip.saturn.job.console.domain.NamespaceZkClusterMappingVo)1 RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)1 SaturnJunkData (com.vip.saturn.job.console.domain.SaturnJunkData)1