use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.
the class RestApiServiceImpl method getNamespace.
@Override
public NamespaceDomainInfo getNamespace(String namespace) throws SaturnJobConsoleException {
if (namespaceInfoService.selectByNamespace(namespace) == null) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), ERR_MSG_NS_NOT_FOUND);
}
String zkClusterKey = namespaceZkClusterMapping4SqlService.getZkClusterKey(namespace);
if (StringUtils.isBlank(zkClusterKey)) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), ERR_MSG_NS_NOT_FOUND);
}
NamespaceDomainInfo namespaceDomainInfo = new NamespaceDomainInfo();
namespaceDomainInfo.setNamespace(namespace);
namespaceDomainInfo.setZkCluster(zkClusterKey);
return namespaceDomainInfo;
}
use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.
the class NamespaceManagementRestApiController method constructNamespaceDomainInfo.
private NamespaceDomainInfo constructNamespaceDomainInfo(Map<String, Object> reqParams) throws SaturnJobConsoleException {
NamespaceDomainInfo namespaceInfo = new NamespaceDomainInfo();
namespaceInfo.setNamespace(checkAndGetParametersValueAsString(reqParams, "namespace", true));
namespaceInfo.setZkCluster(checkAndGetParametersValueAsString(reqParams, "zkCluster", true));
return namespaceInfo;
}
use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.
the class RegistryCenterServiceImpl method getNamespace.
@Override
public NamespaceDomainInfo getNamespace(String namespace) throws SaturnJobConsoleException {
if (namespaceInfoService.selectByNamespace(namespace) == null) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), ERR_MSG_NS_NOT_FOUND);
}
String zkClusterKey = namespaceZkClusterMapping4SqlService.getZkClusterKey(namespace);
if (StringUtils.isBlank(zkClusterKey)) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), ERR_MSG_NS_NOT_FOUND);
}
NamespaceDomainInfo namespaceDomainInfo = new NamespaceDomainInfo();
namespaceDomainInfo.setNamespace(namespace);
namespaceDomainInfo.setZkCluster(zkClusterKey);
return namespaceDomainInfo;
}
use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.
the class NamespaceAndJobServiceImpl method createNamespaceAndCloneJobs.
@Override
public void createNamespaceAndCloneJobs(String srcNamespace, String namespace, String zkClusterName, String createBy) throws SaturnJobConsoleException {
logger.info("start createNamespaceAndCloneJobs, srcNamespace: {}, namespace: {}, zkClusterName: {}", srcNamespace, namespace, zkClusterName);
NamespaceZkClusterMapping mapping = namespaceZkClusterMappingRepository.selectByNamespace(srcNamespace);
if (mapping == null) {
throw new SaturnJobConsoleException("no zkCluster mapping is not found");
}
NamespaceDomainInfo namespaceInfo = new NamespaceDomainInfo();
namespaceInfo.setNamespace(namespace);
namespaceInfo.setZkCluster(zkClusterName);
namespaceInfo.setContent("");
try {
registryCenterService.createNamespace(namespaceInfo);
registryCenterService.refreshRegistryCenterForNamespace(zkClusterName, srcNamespace);
} catch (SaturnJobConsoleHttpException e) {
if (StringUtils.equals(String.format(ERR_MSG_NS_ALREADY_EXIST, namespace), e.getMessage())) {
logger.warn("namespace already exists, ignore this exception and move on");
} else {
throw e;
}
}
namespaceService.importJobsFromNamespaceToNamespace(srcNamespace, namespace, createBy);
logger.info("finish createNamespaceAndCloneJobs, srcNamespace: {}, namespace: {}, zkClusterName: {}", srcNamespace, namespace, zkClusterName);
}
use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.
the class NamespaceManagementRestApiController method query.
@RequestMapping(value = "/namespaces/{namespace:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> query(@PathVariable("namespace") String namespace) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
NamespaceDomainInfo namespaceDomainInfo = registryCenterService.getNamespace(namespace);
return new ResponseEntity<Object>(namespaceDomainInfo, httpHeaders, HttpStatus.OK);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
Aggregations