Search in sources :

Example 6 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class DashboardServiceImpl method versionExecutorNumberByAllZkCluster.

@Override
public Map<String, Long> versionExecutorNumberByAllZkCluster() throws SaturnJobConsoleException {
    Map<String, Long> versionExecutorNumberMap = new HashMap<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getOnlineZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        String zkAddr = zkCluster.getZkAddr();
        Map<String, Long> temp = versionExecutorNumber(zkAddr);
        if (temp == null) {
            continue;
        }
        Iterator<Entry<String, Long>> iterator = temp.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, Long> next = iterator.next();
            String version = next.getKey();
            Long executorNumber = next.getValue();
            if (version != null && executorNumber != null) {
                if (versionExecutorNumberMap.containsKey(version)) {
                    versionExecutorNumberMap.put(version, versionExecutorNumberMap.get(version) + executorNumber);
                } else {
                    versionExecutorNumberMap.put(version, executorNumber);
                }
            }
        }
    }
    return versionExecutorNumberMap;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 7 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class DashboardServiceImpl method loadJobRankDistributionByAllZkCluster.

@Override
public Map<Integer, Integer> loadJobRankDistributionByAllZkCluster() throws SaturnJobConsoleException {
    Map<Integer, Integer> jobDegreeCountMap = new HashMap<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getOnlineZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        String zkAddr = zkCluster.getZkAddr();
        Map<Integer, Integer> temp = loadJobRankDistribution(zkAddr);
        if (temp == null) {
            continue;
        }
        Iterator<Entry<Integer, Integer>> iterator = temp.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<Integer, Integer> next = iterator.next();
            Integer jobDegree = next.getKey();
            Integer count = next.getValue();
            if (jobDegree != null && count != null) {
                if (jobDegreeCountMap.containsKey(jobDegree)) {
                    jobDegreeCountMap.put(jobDegree, jobDegreeCountMap.get(jobDegree) + count);
                } else {
                    jobDegreeCountMap.put(jobDegree, count);
                }
            }
        }
    }
    return jobDegreeCountMap;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 8 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class DashboardServiceImpl method versionDomainNumberByAllZkCluster.

@Override
public Map<String, Long> versionDomainNumberByAllZkCluster() throws SaturnJobConsoleException {
    Map<String, Long> versionDomainNumberMap = new HashMap<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getOnlineZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        String zkAddr = zkCluster.getZkAddr();
        Map<String, Long> temp = versionDomainNumber(zkAddr);
        if (temp == null) {
            continue;
        }
        Iterator<Entry<String, Long>> iterator = temp.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, Long> next = iterator.next();
            String version = next.getKey();
            Long domainNumber = next.getValue();
            if (version != null && domainNumber != null) {
                if (versionDomainNumberMap.containsKey(version)) {
                    versionDomainNumberMap.put(version, versionDomainNumberMap.get(version) + domainNumber);
                } else {
                    versionDomainNumberMap.put(version, domainNumber);
                }
            }
        }
    }
    return versionDomainNumberMap;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 9 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class DashboardServiceImpl method loadDomainRankDistributionByAllZkCluster.

@Override
public Map<String, Integer> loadDomainRankDistributionByAllZkCluster() throws SaturnJobConsoleException {
    Map<String, Integer> domainMap = new HashMap<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getOnlineZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        ArrayList<RegistryCenterConfiguration> regCenterConfList = zkCluster.getRegCenterConfList();
        if (regCenterConfList != null) {
            for (RegistryCenterConfiguration config : regCenterConfList) {
                String degree = config.getDegree();
                if (degree != null) {
                    Integer count = domainMap.get(degree);
                    domainMap.put(degree, count == null ? 1 : count + 1);
                }
            }
        }
    }
    return domainMap;
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) HashMap(java.util.HashMap) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 10 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class RestApiServiceImpl method createNamespace.

@Transactional(rollbackFor = { Exception.class })
@Override
public void createNamespace(NamespaceDomainInfo namespaceDomainInfo) throws SaturnJobConsoleException {
    String namespace = namespaceDomainInfo.getNamespace();
    String zkClusterKey = namespaceDomainInfo.getZkCluster();
    ZkCluster currentCluster = registryCenterService.getZkCluster(zkClusterKey);
    if (currentCluster == null) {
        throw new SaturnJobConsoleHttpException(HttpStatus.BAD_REQUEST.value(), String.format(ERR_MSG_TEMPLATE_FAIL_TO_CREATE, namespace, "not found zkcluster" + zkClusterKey));
    }
    if (checkNamespaceExists(namespace)) {
        throw new SaturnJobConsoleHttpException(HttpStatus.BAD_REQUEST.value(), String.format(ERR_MSG_NS_ALREADY_EXIST, namespace));
    }
    try {
        // 创建 namespaceInfo
        NamespaceInfo namespaceInfo = constructNamespaceInfo(namespaceDomainInfo);
        namespaceInfoService.create(namespaceInfo);
        // 创建 zkcluster 和 namespaceInfo 关系
        namespaceZkClusterMapping4SqlService.insert(namespace, "", zkClusterKey, NAMESPACE_CREATOR_NAME);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), String.format(ERR_MSG_TEMPLATE_FAIL_TO_CREATE, namespace, e.getMessage()));
    }
}
Also used : ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) NamespaceInfo(com.vip.saturn.job.console.mybatis.entity.NamespaceInfo) ReportAlarmException(com.vip.saturn.job.integrate.exception.ReportAlarmException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)37 SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)11 ApiResponses (io.swagger.annotations.ApiResponses)11 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)9 SaturnStatistics (com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)8 Entry (java.util.Map.Entry)8 RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)7 HashMap (java.util.HashMap)5 Transactional (org.springframework.transaction.annotation.Transactional)5 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)4 ArrayList (java.util.ArrayList)4 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)3 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)2 NamespaceInfo (com.vip.saturn.job.console.mybatis.entity.NamespaceInfo)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Audit (com.vip.saturn.job.console.aop.annotation.Audit)1 ExportJobConfigPageStatus (com.vip.saturn.job.console.domain.ExportJobConfigPageStatus)1 JobSettings (com.vip.saturn.job.console.domain.JobSettings)1 TreeNode (com.vip.saturn.job.console.domain.TreeNode)1