use of com.vip.saturn.job.integrate.entity.JobConfigInfo in project Saturn by vipshop.
the class UpdateJobConfigServiceImpl method batchUpdatePreferList.
@Override
public void batchUpdatePreferList(List<JobConfigInfo> jobConfigInfos) throws UpdateJobConfigException {
if (CollectionUtils.isEmpty(jobConfigInfos)) {
return;
}
List<JobConfig4DB> currentJobConfigs = new ArrayList<JobConfig4DB>();
JobConfig4DB currentJobConfig = null;
for (JobConfigInfo jobConfigInfo : jobConfigInfos) {
currentJobConfig = new JobConfig4DB();
currentJobConfig.setNamespace(jobConfigInfo.getNamespace());
currentJobConfig.setJobName(jobConfigInfo.getJobName());
currentJobConfig.setPreferList(jobConfigInfo.getPerferList());
currentJobConfigs.add(currentJobConfig);
}
try {
currentJobConfigService.batchUpdatePreferList(currentJobConfigs);
} catch (SaturnJobConsoleException e) {
throw new UpdateJobConfigException(e);
}
}
use of com.vip.saturn.job.integrate.entity.JobConfigInfo in project Saturn by vipshop.
the class ExecutorCleanService method clean.
/**
* delete $SaturnExecutors/executors/xxx<br> delete $Jobs/job/servers/xxx<br> delete $Jobs/job/config/preferList
* content about xxx
*/
public void clean(String executorName) {
List<JobConfigInfo> jobConfigInfos = new ArrayList<>();
try {
String cleanNodePath = SaturnExecutorsNode.getExecutorCleanNodePath(executorName);
byte[] cleanNodeBytes = curatorFramework.getData().forPath(cleanNodePath);
if (cleanNodeBytes == null || cleanNodeBytes.length == 0) {
return;
}
String cleanNodeData = new String(cleanNodeBytes, "UTF-8");
if (!Boolean.parseBoolean(cleanNodeData)) {
return;
}
if (curatorFramework.checkExists().forPath(SaturnExecutorsNode.getExecutorIpNodePath(executorName)) == null) {
log.info("Clean the executor {}", executorName);
// delete $SaturnExecutors/executors/xxx
deleteExecutor(executorName);
List<String> jobs = getJobList();
for (String jobName : jobs) {
// delete $Jobs/job/servers/xxx
deleteJobServerExecutor(jobName, executorName);
// delete $Jobs/job/config/preferList content about xxx
String preferList = updateJobConfigPreferListContentToRemoveDeletedExecutor(jobName, executorName);
if (preferList != null) {
JobConfigInfo jobConfigInfo = new JobConfigInfo(curatorFramework.getNamespace(), jobName, preferList);
jobConfigInfos.add(jobConfigInfo);
}
}
} else {
log.info("The executor {} is online now, no necessary to clean", executorName);
}
} catch (NoNodeException e) {
log.debug("No clean node found for executor:" + executorName, e);
} catch (Exception e) {
log.error("Clean the executor " + executorName + " error", e);
} finally {
updatePreferListQuietly(jobConfigInfos);
}
}
Aggregations