use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImpl method getJobConfig.
@Override
public JobConfig getJobConfig(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));
}
JobConfig jobConfig = new JobConfig();
SaturnBeanUtils.copyProperties(jobConfig4DB, jobConfig);
return jobConfig;
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class HistoryJobConfigServiceImpl method selectPage.
@Transactional
@Override
public List<JobConfig4DB> selectPage(JobConfig4DB historyjobconfig, Pageable pageable) throws SaturnJobConsoleException {
List<JobConfig4DB> historyJobConfigs = historyJobConfigRepo.selectPage(historyjobconfig, pageable);
if (historyJobConfigs != null) {
int i = 1;
for (JobConfig4DB historyJobConfig : historyJobConfigs) {
historyJobConfig.setRownum(i++);
historyJobConfig.setDefaultValues();
}
}
return historyJobConfigs;
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobOverviewController method updateJobOverviewDetail.
private List<JobOverviewJobVo> updateJobOverviewDetail(String namespace, List<JobConfig4DB> unSystemJobs, JobStatus jobStatus) {
List<JobOverviewJobVo> result = Lists.newArrayList();
for (JobConfig4DB jobConfig : unSystemJobs) {
try {
jobConfig.setDefaultValues();
JobOverviewJobVo jobOverviewJobVo = new JobOverviewJobVo();
SaturnBeanUtils.copyProperties(jobConfig, jobOverviewJobVo);
updateJobTypesInOverview(jobConfig, jobOverviewJobVo);
if (jobStatus == null) {
jobOverviewJobVo.setStatus(jobService.getJobStatus(namespace, jobConfig));
} else {
jobOverviewJobVo.setStatus(jobStatus);
}
result.add(jobOverviewJobVo);
} catch (Exception e) {
log.error("list job " + jobConfig.getJobName() + " error", e);
}
}
return result;
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class RestApiServiceImpl method runDownStream.
@Override
public List<BatchJobResult> runDownStream(final String namespace, final String jobName, final Map<String, Object> triggeredData) throws SaturnJobConsoleException {
return ReuseUtils.reuse(namespace, jobName, registryCenterService, curatorRepository, new ReuseCallBack<List<BatchJobResult>>() {
@Override
public List<BatchJobResult> call(CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) throws SaturnJobConsoleException {
JobConfig4DB jobConfig = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
if (jobConfig == null) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), "不能触发该作业(" + jobName + ")的下游,因为该作业不存在");
}
List<BatchJobResult> batchJobResultList = new ArrayList<>();
String downStream = jobConfig.getDownStream();
if (StringUtils.isBlank(downStream)) {
return batchJobResultList;
}
// Maybe should validate downStream, but it seems unnecessary, because it's validated when add/copy/import/update job
String[] split = downStream.split(",");
for (String childName : split) {
String childNameTrim = childName.trim();
if (childNameTrim.isEmpty()) {
continue;
}
BatchJobResult batchJobResult = new BatchJobResult();
batchJobResult.setJobName(childNameTrim);
try {
runJobAtOnce(namespace, childNameTrim, triggeredData);
batchJobResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
batchJobResult.setSuccess(false);
batchJobResult.setMessage(e.getMessage());
} finally {
batchJobResultList.add(batchJobResult);
}
}
return batchJobResultList;
}
});
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class ZkDBDiffServiceImpl method diffByJob.
@Override
public JobDiffInfo diffByJob(String namespace, String jobName) throws SaturnJobConsoleException {
CuratorRepository.CuratorFrameworkOp zkClient;
try {
zkClient = initCuratorClient(namespace);
if (zkClient == null) {
return null;
}
log.info("start to diff job:{}", jobName);
JobConfig4DB dbJobConfig = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
JobConfig zkJobConfig = jobService.getJobConfigFromZK(namespace, jobName);
if (dbJobConfig == null) {
if (zkJobConfig != null) {
return new JobDiffInfo(namespace, jobName, JobDiffInfo.DiffType.ZK_ONLY, Lists.<JobDiffInfo.ConfigDiffInfo>newArrayList());
} else {
return null;
}
}
if (zkJobConfig == null) {
return new JobDiffInfo(namespace, jobName, JobDiffInfo.DiffType.DB_ONLY, Lists.<JobDiffInfo.ConfigDiffInfo>newArrayList());
}
// diff only when dbJobConfig and zkJobConfig both not null
return diff(namespace, dbJobConfig, zkJobConfig, true);
} catch (Exception e) {
log.error("exception throws during diff by namespace [{}] and job [{}]", namespace, jobName, e);
throw new SaturnJobConsoleException(e);
}
}
Aggregations