use of com.vip.saturn.job.console.domain.JobDiffInfo in project Saturn by vipshop.
the class ZKDBDiffRestApiController method diff.
@RequestMapping(value = "/diff", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public ResponseEntity<Object> diff(String zkcluster, HttpServletRequest request) throws SaturnJobConsoleHttpException {
try {
checkMissingParameter("zkcluster", zkcluster);
List<JobDiffInfo> resultList = zkDBDiffService.diffByCluster(zkcluster);
return new ResponseEntity<Object>(resultList, HttpStatus.OK);
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of com.vip.saturn.job.console.domain.JobDiffInfo in project Saturn by vipshop.
the class ZkDBDiffServiceImpl method getJobNamesWhichInZKOnly.
private List<JobDiffInfo> getJobNamesWhichInZKOnly(String namespace, CuratorRepository.CuratorFrameworkOp zkClient, Set<String> jobNamesInDb) throws SaturnJobConsoleException {
List<JobDiffInfo> jobsOnlyInZK = Lists.newArrayList();
List<String> jobNamesInZk = jobDimensionService.getAllJobs(zkClient);
for (String name : jobNamesInZk) {
if (jobNamesInDb == null || jobNamesInDb.isEmpty() || !jobNamesInDb.contains(name)) {
jobsOnlyInZK.add(new JobDiffInfo(namespace, name, JobDiffInfo.DiffType.ZK_ONLY, Lists.<JobDiffInfo.ConfigDiffInfo>newArrayList()));
}
}
return jobsOnlyInZK;
}
use of com.vip.saturn.job.console.domain.JobDiffInfo in project Saturn by vipshop.
the class ZkDBDiffServiceImpl method getJobNamesWhichInZKOnly.
private List<JobDiffInfo> getJobNamesWhichInZKOnly(String namespace, Set<String> jobNamesInDb) throws SaturnJobConsoleException {
List<JobDiffInfo> jobsOnlyInZK = Lists.newArrayList();
List<String> jobNamesInZk = jobService.getAllJobNamesFromZK(namespace);
for (String name : jobNamesInZk) {
if (jobNamesInDb == null || jobNamesInDb.isEmpty() || !jobNamesInDb.contains(name)) {
jobsOnlyInZK.add(new JobDiffInfo(namespace, name, JobDiffInfo.DiffType.ZK_ONLY, Lists.<JobDiffInfo.ConfigDiffInfo>newArrayList()));
}
}
return jobsOnlyInZK;
}
use of com.vip.saturn.job.console.domain.JobDiffInfo 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