use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class NamespaceManagementRestApiController method create.
@RequestMapping(value = "/namespaces", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> create(@RequestBody Map<String, Object> reqParams, HttpServletRequest request) throws SaturnJobConsoleException {
try {
NamespaceDomainInfo namespaceInfo = constructNamespaceDomainInfo(reqParams);
restApiService.createNamespace(namespaceInfo);
// TODO: 改成异步
registryCenterService.refreshRegCenter();
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException 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 = restApiService.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);
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class NamespaceZkClusterMappingRestApiController method discoverZk.
@RequestMapping(value = "/discoverZk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> discoverZk(String namespace, HttpServletRequest request) throws SaturnJobConsoleException {
HttpHeaders headers = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
String zkClusterKey = namespaceZkclusterMapping4SqlService.getZkClusterKey(namespace);
if (zkClusterKey == null) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), "The NamespaceZkClusterMapping is not configured in db for " + namespace);
}
ZkClusterInfo zkClusterInfo = zkClusterInfoService.getByClusterKey(zkClusterKey);
if (zkClusterInfo == null) {
throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), "The clusterKey(" + zkClusterKey + ") is not configured in db for " + namespace);
}
return new ResponseEntity<Object>(zkClusterInfo.getConnectString(), headers, HttpStatus.OK);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class ZKDBDiffRestApiController method diff.
@RequestMapping(value = "/diff", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public ResponseEntity<Object> diff(String zkcluster, HttpServletRequest request) throws SaturnJobConsoleHttpException {
try {
checkMissingParameter("zkcluster", zkcluster);
List<JobDiffInfo> resultList = zkDBDiffService.diffByCluster(zkcluster);
return new ResponseEntity<Object>(resultList, HttpStatus.OK);
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class AlarmRestApiController method raise.
@Audit(type = AuditType.REST)
@RequestMapping(value = "/raise", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> raise(@PathVariable("namespace") String namespace, @RequestBody Map<String, Object> reqParams) throws SaturnJobConsoleException {
try {
String jobName = checkAndGetParametersValueAsString(reqParams, "jobName", true);
String executorName = checkAndGetParametersValueAsString(reqParams, "executorName", true);
Integer shardItem = checkAndGetParametersValueAsInteger(reqParams, "shardItem", false);
AlarmInfo alarmInfo = constructAlarmInfo(reqParams);
log.info("try to raise alarm: {}, job: {}, executor: {}, item: {}", alarmInfo.toString(), jobName, executorName, shardItem);
// (since 2.1.4) 如果alarm title是Executor_Restart,而且系统配置ALARM_RAISED_ON_EXECUTOR_RESTART=false, 只记录日志不发送告警
boolean isExecutorRestartAlarmEvent = isExecutorRestartAlarmEvent(alarmInfo);
if (isExecutorRestartAlarmEvent) {
restApiService.raiseExecutorRestartAlarm(namespace, executorName, alarmInfo);
} else {
if (StringUtils.isBlank(jobName)) {
throw new SaturnJobConsoleHttpException(HttpStatus.BAD_REQUEST.value(), "Invalid request. Missing parameter: jobName");
}
restApiService.raiseAlarm(namespace, jobName, executorName, shardItem, alarmInfo);
}
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
Aggregations