Search in sources :

Example 1 with ContainerVo

use of com.vip.saturn.job.console.domain.container.vo.ContainerVo in project Saturn by vipshop.

the class ContainerServiceImpl method getContainerVos.

@Override
public List<ContainerVo> getContainerVos() throws SaturnJobConsoleException {
    List<ContainerVo> containerVos = new ArrayList<>();
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = curatorRepository.inSessionClient();
    List<String> allUnSystemJobs = jobDimensionService.getAllUnSystemJobs(curatorFrameworkOp);
    Map<String, List<String>> taskBindJobNames = getTaskBindJobNames(curatorFrameworkOp, allUnSystemJobs);
    ContainerToken containerToken = getContainerToken();
    List<String> tasks = getTasks(curatorFrameworkOp);
    Map<String, List<ContainerExecutorVo>> containerExecutors = getContainerExecutors(curatorFrameworkOp, allUnSystemJobs);
    if (tasks != null && !tasks.isEmpty()) {
        for (String task : tasks) {
            ContainerVo containerVo = new ContainerVo();
            containerVo.setTaskId(task);
            containerVo.setContainerExecutorVos(containerExecutors.get(task));
            containerVo.setBindingJobNames(changeTypeOfBindingJobNames(taskBindJobNames.get(task)));
            containerVo.setContainerStatus(changeTypeOfContainerStatus(containerToken, task));
            ContainerConfig containerConfig = getContainerConfig(curatorFrameworkOp, task);
            containerVo.setContainerConfig(changeTypeOfContainerConfig(containerConfig));
            containerVo.setCreateTime(changeTypeOfCreateTime(containerConfig));
            containerVo.setContainerScaleJobVos(getContainerScaleJobVos(task));
            containerVo.setInstancesConfigured(String.valueOf(containerConfig.getInstances()));
            containerVos.add(containerVo);
        }
    }
    return containerVos;
}
Also used : ContainerVo(com.vip.saturn.job.console.domain.container.vo.ContainerVo) CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)

Example 2 with ContainerVo

use of com.vip.saturn.job.console.domain.container.vo.ContainerVo in project Saturn by vipshop.

the class ContainerController method getContainerVos.

@RequestMapping(value = "/getContainerVos", method = RequestMethod.GET)
public RequestResult getContainerVos(HttpServletRequest request) {
    RequestResult requestResult = new RequestResult();
    try {
        List<ContainerVo> containerVos = containerService.getContainerVos();
        requestResult.setSuccess(true);
        requestResult.setObj(containerVos);
    } catch (SaturnJobConsoleException e) {
        requestResult.setSuccess(false);
        requestResult.setMessage(e.getMessage());
    } catch (Throwable t) {
        requestResult.setSuccess(false);
        requestResult.setMessage(t.toString());
    }
    return requestResult;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) ContainerVo(com.vip.saturn.job.console.domain.container.vo.ContainerVo) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ContainerVo

use of com.vip.saturn.job.console.domain.container.vo.ContainerVo in project Saturn by vipshop.

the class MarathonServiceImpl method getContainerVos.

@Override
public List<ContainerVo> getContainerVos(String namespace) throws SaturnJobConsoleException {
    List<ContainerVo> containerVos = new ArrayList<>();
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
    List<String> allUnSystemJobs = jobService.getUnSystemJobNames(namespace);
    Map<String, List<String>> taskBindJobNames = getTaskBindJobNames(curatorFrameworkOp, allUnSystemJobs);
    ContainerToken containerToken = getContainerToken(namespace);
    List<String> tasks = getTasks(curatorFrameworkOp);
    Map<String, List<ContainerExecutorVo>> containerExecutors = getContainerExecutors(curatorFrameworkOp, allUnSystemJobs);
    if (!tasks.isEmpty()) {
        for (String task : tasks) {
            ContainerVo containerVo = new ContainerVo();
            containerVo.setTaskId(task);
            containerVo.setContainerExecutorVos(containerExecutors.get(task));
            containerVo.setBindingJobNames(changeTypeOfBindingJobNames(taskBindJobNames.get(task)));
            containerVo.setContainerStatus(changeTypeOfContainerStatus(containerToken, task));
            ContainerConfig containerConfig = JSON.parseObject(curatorFrameworkOp.getData(ContainerNodePath.getDcosTaskConfigNodePath(task)), ContainerConfig.class);
            containerVo.setContainerConfig(changeTypeOfContainerConfig(containerConfig));
            containerVo.setCreateTime(changeTypeOfCreateTime(containerConfig));
            containerVo.setContainerScaleJobVos(getContainerScaleJobVos(namespace, task, curatorFrameworkOp));
            containerVo.setInstancesConfigured(String.valueOf(containerConfig.getInstances()));
            containerVos.add(containerVo);
        }
    }
    return containerVos;
}
Also used : ContainerVo(com.vip.saturn.job.console.domain.container.vo.ContainerVo) CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)

Aggregations

ContainerVo (com.vip.saturn.job.console.domain.container.vo.ContainerVo)3 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)2 RequestResult (com.vip.saturn.job.console.domain.RequestResult)1 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1