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;
}
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;
}
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;
}
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;
}
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()));
}
}
Aggregations