use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ContainerController method getRegistryCatalog.
@RequestMapping(value = "/getRegistryCatalog", method = RequestMethod.GET)
public RequestResult getRegistryCatalog(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
String registryCatalog = containerService.getRegistryCatalog();
requestResult.setSuccess(true);
requestResult.setObj(registryCatalog);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
} catch (Throwable t) {
requestResult.setSuccess(false);
requestResult.setMessage(t.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ContainerController method removeContainer.
@RequestMapping(value = "/removeContainer", method = RequestMethod.POST)
public RequestResult removeContainer(String taskId, HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
if (taskId == null) {
throw new SaturnJobConsoleException("The taskId cannot be null");
}
containerService.removeContainer(taskId);
requestResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
} catch (Throwable t) {
requestResult.setSuccess(false);
requestResult.setMessage(t.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ContainerController method deleteContainerScaleJob.
@RequestMapping(value = "/deleteContainerScaleJob", method = RequestMethod.POST)
public RequestResult deleteContainerScaleJob(String taskId, String jobName, HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
if (taskId == null) {
throw new SaturnJobConsoleException("The taskId cannot be null");
}
if (jobName == null) {
throw new SaturnJobConsoleException("The jobName cannot be null");
}
containerService.deleteContainerScaleJob(taskId, jobName);
requestResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
} catch (Throwable t) {
requestResult.setSuccess(false);
requestResult.setMessage(t.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class DashboardRefreshController method handleResponse.
private void handleResponse(String url, CloseableHttpResponse httpResponse) throws IOException, SaturnJobConsoleException {
StatusLine statusLine = httpResponse.getStatusLine();
Integer statusCode = statusLine != null ? statusLine.getStatusCode() : null;
LOGGER.info("the statusCode of remote request is:" + statusCode);
if (statusLine != null && statusCode == HttpStatus.SC_OK) {
String takeTime = IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8");
LOGGER.info("forwardDashboardRefreshToRemote Url " + url + ", spend time:" + takeTime);
return;
}
if (statusCode >= HttpStatus.SC_BAD_REQUEST && statusCode <= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
String responseBody = EntityUtils.toString(httpResponse.getEntity());
if (StringUtils.isNotBlank(responseBody)) {
String errMsg = JSONObject.parseObject(responseBody).getString("message");
throw new SaturnJobConsoleException(errMsg);
} else {
throw new SaturnJobConsoleException("internal server error");
}
} else {
throw new SaturnJobConsoleException("unexpected status returned from Saturn Server.");
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class DashboardRefreshController method forwardDashboardRefreshToRemote.
private void forwardDashboardRefreshToRemote(String zkClusterKey) throws SaturnJobConsoleException {
CloseableHttpClient httpClient = null;
String url = null;
try {
String domain = ZkClusterMappingUtils.getConsoleDomainByZkClusterKey(systemConfigService, zkClusterKey);
if (StringUtils.isBlank(domain)) {
throw new SaturnJobConsoleException(String.format("The console domain is not found by zkClusterKey(%s)", zkClusterKey));
}
url = domain + "/rest/v1/dashboard/refresh?zkClusterKey=" + zkClusterKey;
httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = createHttpRequest(url);
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
handleResponse(url, httpResponse);
} catch (SaturnJobConsoleException se) {
throw se;
} catch (Exception e) {
throw new SaturnJobConsoleException("Fail to execute forwardDashboardRefreshToRemote, Url: " + url, e);
} finally {
IOUtils.closeQuietly(httpClient);
}
}
Aggregations