use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class JobOperationRestApiController method create.
@Audit(type = AuditType.REST)
@RequestMapping(value = "/{namespace}/jobs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> create(@PathVariable("namespace") String namespace, @RequestBody Map<String, Object> reqParams) throws SaturnJobConsoleException {
try {
JobConfig jobConfig = constructJobConfigOfCreate(namespace, reqParams);
restApiService.createJob(namespace, jobConfig);
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 JobOperationRestApiController method query.
@Audit(type = AuditType.REST)
@RequestMapping(value = "/all/jobs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> query(@RequestParam("queue") String queue) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("queue", queue);
List<JobConfig4DB> jobInfo = jobService.getJobsByQueue(queue);
return new ResponseEntity<Object>(jobInfo, 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 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.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 = 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);
}
}
use of com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException in project Saturn by vipshop.
the class RestApiServiceImplTest method testStopAtOnceFailForJavaJobAsNoExecutor.
@Test
public void testStopAtOnceFailForJavaJobAsNoExecutor() throws SaturnJobConsoleException {
// prepare
String jobName = "testJob";
when(jobService.getJobStatus(TEST_NAME_SPACE_NAME, jobName)).thenReturn(JobStatus.STOPPING);
List<JobServer> servers = Lists.newArrayList();
when(jobService.getJobServers(TEST_NAME_SPACE_NAME, jobName)).thenReturn(servers);
// run
try {
restApiService.stopJobAtOnce(TEST_NAME_SPACE_NAME, jobName);
} catch (SaturnJobConsoleHttpException e) {
assertEquals("status code is not 400", 400, e.getStatusCode());
assertEquals("error message is not equals", "no executor found for this job", e.getMessage());
}
}
Aggregations