use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class NamespaceZkClusterMappingController method getZkClusterListWithOnline.
@RequestMapping(value = "getZkClusterListWithOnline", method = RequestMethod.GET)
public RequestResult getZkClusterListWithOnline(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
List<String> zkClusterListWithOnlineFromCfg = namespaceZkClusterMappingService.getZkClusterListWithOnline();
requestResult.setObj(zkClusterListWithOnlineFromCfg);
requestResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
} catch (Throwable t) {
LOGGER.error(t.getMessage(), 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 NamespaceZkClusterMappingController method getNamespaceZkclusterMappingList.
@RequestMapping(value = "getNamespaceZkclusterMappingList", method = RequestMethod.GET)
public RequestResult getNamespaceZkclusterMappingList(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
List<NamespaceZkClusterMappingVo> namespaceZkclusterMappingList = namespaceZkClusterMappingService.getNamespaceZkClusterMappingList();
requestResult.setObj(namespaceZkclusterMappingList);
requestResult.setSuccess(true);
} catch (SaturnJobConsoleException e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
} catch (Throwable t) {
LOGGER.error(t.getMessage(), 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 SaturnJunkDataController method deleteRunningNode.
@ResponseBody
@RequestMapping(value = "junkData/deleteRunningNode", method = RequestMethod.POST)
public RequestResult deleteRunningNode(String namespace, String jobName, Integer item) {
RequestResult requestResult = new RequestResult();
try {
if (namespace == null || namespace.trim().isEmpty()) {
throw new SaturnJobConsoleException("The namespace can not be null or empty");
}
if (jobName == null || jobName.trim().isEmpty()) {
throw new SaturnJobConsoleException("The jobName can not be null or empty");
}
if (item == null) {
throw new SaturnJobConsoleException("The item can not be null");
}
saturnJunkDataService.deleteRunningNode(namespace, jobName, item);
LOGGER.info("do junkData/deleteRunningNode success, namespace is {}, jobName is {}, item is {}", namespace, jobName, item);
requestResult.setSuccess(true);
} catch (Throwable t) {
requestResult.setSuccess(false);
if (t instanceof SaturnJobConsoleException) {
requestResult.setMessage(t.getMessage());
} else {
requestResult.setMessage(t.toString());
}
LOGGER.error(t.getMessage(), t);
}
return requestResult;
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.
the class ZkTreeController method convertFileToZkTree.
@RequestMapping(value = "convertFileToZkTree", method = RequestMethod.POST)
public RequestResult convertFileToZkTree(MultipartHttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
Iterator<String> fileNames = request.getFileNames();
MultipartFile file = null;
while (fileNames.hasNext()) {
if (file != null) {
requestResult.setSuccess(false);
requestResult.setMessage("仅支持单文件导入");
return requestResult;
}
file = request.getFile(fileNames.next());
}
if (file == null) {
requestResult.setSuccess(false);
requestResult.setMessage("请选择导入的文件");
return requestResult;
}
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || !originalFilename.endsWith(".json")) {
requestResult.setSuccess(false);
requestResult.setMessage("仅支持.json文件导入");
return requestResult;
}
ZkTree zkTree = zkTreeService.convertInputStreamToZkTree(file.getInputStream());
requestResult.setObj(zkTree);
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 SaturnConsoleUtils method exportExcelFile.
public static void exportExcelFile(HttpServletResponse response, InputStream inputStream, String exportFileName) throws SaturnJobConsoleException {
try {
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment; filename=" + new String(exportFileName.getBytes("UTF-8"), "ISO8859-1"));
try (BufferedInputStream bis = new BufferedInputStream(inputStream);
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream())) {
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
}
} catch (Exception e) {
throw new SaturnJobConsoleException(e);
}
}
Aggregations