use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ExecutorServiceImpl method dump.
@Override
public void dump(String namespace, String executorName) throws SaturnJobConsoleException {
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
String version = curatorFrameworkOp.getData(ExecutorNodePath.getExecutorVersionNodePath(executorName));
if (!isVersionSupportedDump(version)) {
throw new SaturnJobConsoleException(SaturnJobConsoleException.ERROR_CODE_BAD_REQUEST, "Saturn executor版本低于3.0.0无法进行一键dump");
}
String dumpNodePath = ExecutorNodePath.getExecutorDumpNodePath(executorName);
curatorFrameworkOp.delete(dumpNodePath);
curatorFrameworkOp.create(dumpNodePath);
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ReuseUtils method reuse.
public static void reuse(String namespace, RegistryCenterService registryCenterService, CuratorRepository curatorRepository, ReuseCallBackWithoutReturn callBack) throws SaturnJobConsoleException {
try {
RegistryCenterConfiguration registryCenterConfiguration = registryCenterService.findConfigByNamespace(namespace);
if (registryCenterConfiguration == null) {
throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, String.format(NAMESPACE_NOT_EXIST_TEMPLATE, namespace));
}
RegistryCenterClient registryCenterClient = registryCenterService.connectByNamespace(namespace);
if (registryCenterClient != null && registryCenterClient.isConnected()) {
CuratorFramework curatorClient = registryCenterClient.getCuratorClient();
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = curatorRepository.newCuratorFrameworkOp(curatorClient);
ThreadLocalCuratorClient.setCuratorClient(curatorClient);
callBack.call(curatorFrameworkOp);
} else {
throw new SaturnJobConsoleException("Connect zookeeper failed");
}
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Throwable t) {
log.error(t.getMessage(), t);
throw new SaturnJobConsoleException(t);
} finally {
ThreadLocalCuratorClient.clear();
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class AuthenticationServiceImpl method authenticate.
@Transactional(readOnly = true)
@Override
public User authenticate(String username, String password) throws SaturnJobConsoleException {
if (StringUtils.isEmpty(password)) {
throw new SaturnJobConsoleException(SaturnJobConsoleException.ERROR_CODE_AUTHN_FAIL, "密码不能为空");
}
User user = userRepository.select(username);
if (user == null) {
throw new SaturnJobConsoleException(SaturnJobConsoleException.ERROR_CODE_AUTHN_FAIL, "用户名不存在");
}
PasswordUtils.validate(password, user.getPassword(), hashMethod);
return user;
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class NamespaceManagementRestApiController method delete.
@Audit(type = AuditType.REST)
@RequestMapping(value = "/namespaces/{namespace:.+}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> delete(@PathVariable("namespace") String namespace) throws SaturnJobConsoleException {
try {
checkMissingParameter("namespace", namespace);
namespaceService.deleteNamespace(namespace);
return new ResponseEntity<>(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.SaturnJobConsoleException 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