Search in sources :

Example 86 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class RestApiServiceImplTest method buildJobConfig4DB.

private JobConfig4DB buildJobConfig4DB(String namespace, String jobName) {
    JobConfig4DB config = new JobConfig4DB();
    config.setNamespace(namespace);
    config.setJobName(jobName);
    config.setEnabled(false);
    config.setEnabledReport(true);
    config.setJobType(JobType.JAVA_JOB.toString());
    return config;
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)

Example 87 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImpl method saveCronToDb.

private void saveCronToDb(String jobName, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp, String newCustomContextStr, String newCron, String updatedBy) throws SaturnJobConsoleException {
    String namespace = curatorFrameworkOp.getCuratorFramework().getNamespace();
    JobConfig4DB jobConfig4DB = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
    if (jobConfig4DB == null) {
        String errorMsg = "在DB找不到该作业的配置, namespace:" + namespace + " jobName:" + jobName;
        log.error(errorMsg);
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMsg);
    }
    JobConfig4DB newJobConfig4DB = new JobConfig4DB();
    SaturnBeanUtils.copyProperties(jobConfig4DB, newJobConfig4DB);
    if (newCustomContextStr != null) {
        newJobConfig4DB.setCustomContext(newCustomContextStr);
    }
    if (newCron != null) {
        newJobConfig4DB.setCron(newCron);
    }
    currentJobConfigService.updateNewAndSaveOld2History(newJobConfig4DB, jobConfig4DB, updatedBy);
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)

Example 88 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImpl method constructJobConfig4DB.

private JobConfig4DB constructJobConfig4DB(String namespace, JobConfig jobConfig, String createdBy, String updatedBy) {
    JobConfig4DB jobConfig4DB = new JobConfig4DB();
    SaturnBeanUtils.copyProperties(jobConfig, jobConfig4DB);
    Date now = new Date();
    if (StringUtils.isNotBlank(createdBy)) {
        jobConfig4DB.setCreateTime(now);
        jobConfig4DB.setCreateBy(createdBy);
    }
    jobConfig4DB.setLastUpdateTime(now);
    jobConfig4DB.setLastUpdateBy(updatedBy);
    jobConfig4DB.setNamespace(namespace);
    return jobConfig4DB;
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)

Example 89 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImpl method getJobConfigVo.

@Override
public GetJobConfigVo getJobConfigVo(String namespace, String jobName) throws SaturnJobConsoleException {
    JobConfig4DB jobConfig4DB = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
    if (jobConfig4DB == null) {
        throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, String.format("该作业(%s)不存在", jobName));
    }
    GetJobConfigVo getJobConfigVo = new GetJobConfigVo();
    JobConfig jobConfig = new JobConfig();
    SaturnBeanUtils.copyProperties(jobConfig4DB, jobConfig);
    jobConfig.setDefaultValues();
    getJobConfigVo.copyFrom(jobConfig);
    getJobConfigVo.setTimeZonesProvided(Arrays.asList(TimeZone.getAvailableIDs()));
    getJobConfigVo.setPreferListProvided(getCandidateExecutors(namespace, jobName));
    getJobConfigVo.setUpStreamProvided(getCandidateUpStream(namespace, jobConfig));
    getJobConfigVo.setDownStreamProvided(getCandidateDownStream(namespace, jobConfig));
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
    getJobConfigVo.setStatus(getJobStatus(getJobConfigVo.getJobName(), curatorFrameworkOp, getJobConfigVo.getEnabled()));
    return getJobConfigVo;
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp) JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) GetJobConfigVo(com.vip.saturn.job.console.vo.GetJobConfigVo)

Example 90 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImpl method getUnSystemJobs.

@Override
public List<JobConfig> getUnSystemJobs(String namespace) throws SaturnJobConsoleException {
    List<JobConfig> unSystemJobs = new ArrayList<>();
    List<JobConfig4DB> jobConfig4DBList = currentJobConfigService.findConfigsByNamespace(namespace);
    if (jobConfig4DBList != null) {
        for (JobConfig4DB jobConfig4DB : jobConfig4DBList) {
            if (!isSystemJob(jobConfig4DB)) {
                JobConfig jobConfig = new JobConfig();
                SaturnBeanUtils.copyProperties(jobConfig4DB, jobConfig);
                unSystemJobs.add(jobConfig);
            }
        }
    }
    return unSystemJobs;
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)

Aggregations

JobConfig4DB (com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)103 Test (org.junit.Test)70 File (java.io.File)28 FileInputStream (java.io.FileInputStream)28 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)28 MultipartFile (org.springframework.web.multipart.MultipartFile)28 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)23 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)11 Transactional (org.springframework.transaction.annotation.Transactional)10 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)8 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)5 Stat (org.apache.zookeeper.data.Stat)4 JobConfig (com.vip.saturn.job.console.domain.JobConfig)2 JobDiffInfo (com.vip.saturn.job.console.domain.JobDiffInfo)2 ParseException (java.text.ParseException)2 Audit (com.vip.saturn.job.console.aop.annotation.Audit)1 GetJobConfigVo (com.vip.saturn.job.console.vo.GetJobConfigVo)1 JobConfigInfo (com.vip.saturn.job.integrate.entity.JobConfigInfo)1 UpdateJobConfigException (com.vip.saturn.job.integrate.exception.UpdateJobConfigException)1 Boolean (java.lang.Boolean)1