use of com.vip.saturn.job.console.domain.container.vo.ContainerScaleJobVo in project Saturn by vipshop.
the class MarathonServiceImpl method getContainerScaleJobVos.
private List<ContainerScaleJobVo> getContainerScaleJobVos(String namespace, String taskId, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) throws SaturnJobConsoleException {
List<ContainerScaleJobVo> containerScaleJobVos = new ArrayList<>();
String dcosTaskScaleJobsNodePath = ContainerNodePath.getDcosTaskScaleJobsNodePath(taskId);
if (curatorFrameworkOp.checkExists(dcosTaskScaleJobsNodePath)) {
List<String> jobs = curatorFrameworkOp.getChildren(dcosTaskScaleJobsNodePath);
if (jobs != null) {
for (String job : jobs) {
ContainerScaleJobVo containerScaleJobVo = getContainerScaleJobVo(namespace, taskId, job);
if (containerScaleJobVo != null) {
containerScaleJobVos.add(containerScaleJobVo);
}
}
}
}
Collections.sort(containerScaleJobVos, new Comparator<ContainerScaleJobVo>() {
@Override
public int compare(ContainerScaleJobVo o1, ContainerScaleJobVo o2) {
return o1.getJobName().compareTo(o2.getJobName());
}
});
return containerScaleJobVos;
}
use of com.vip.saturn.job.console.domain.container.vo.ContainerScaleJobVo in project Saturn by vipshop.
the class MarathonServiceImpl method removeContainer.
@Override
public void removeContainer(String namespace, String taskId) throws SaturnJobConsoleException {
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
String dcosTaskIdNodePath = ContainerNodePath.getDcosTaskIdNodePath(taskId);
if (!curatorFrameworkOp.checkExists(dcosTaskIdNodePath)) {
throw new SaturnJobConsoleException("The taskId already exists");
}
List<ContainerScaleJobVo> containerScaleJobVos = getContainerScaleJobVos(namespace, taskId, curatorFrameworkOp);
List<String> allUnSystemJobs = jobService.getUnSystemJobNames(namespace);
for (String job : allUnSystemJobs) {
String preferListNodePath = JobNodePath.getConfigNodePath(job, "preferList");
if (curatorFrameworkOp.checkExists(preferListNodePath)) {
String preferList = curatorFrameworkOp.getData(preferListNodePath);
if (null == preferList) {
continue;
}
String[] split = preferList.trim().split(",");
for (String tmp : split) {
if (tmp.trim().equals("@" + taskId)) {
throw new SaturnJobConsoleException("Cannot destroy the container, because it's binding a job");
}
}
}
}
for (ContainerScaleJobVo containerScaleJobVo : containerScaleJobVos) {
deleteContainerScaleJob(namespace, taskId, containerScaleJobVo.getJobName());
}
ContainerToken containerToken = getContainerToken(namespace);
MarathonRestClient.destroy(containerToken.getUserName(), containerToken.getPassword(), taskId);
curatorFrameworkOp.deleteRecursive(dcosTaskIdNodePath);
}
Aggregations