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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations