use of com.vip.saturn.job.console.domain.RestApiJobInfo in project Saturn by vipshop.
the class RestApiServiceImpl method constructJobInfo.
private RestApiJobInfo constructJobInfo(CuratorRepository.CuratorFrameworkOp curatorFrameworkOp, String job) {
RestApiJobInfo restApiJobInfo = new RestApiJobInfo();
restApiJobInfo.setJobName(job);
// 设置作业配置信息
setJobConfig(curatorFrameworkOp, restApiJobInfo, job);
// 设置运行状态
setRunningStatus(curatorFrameworkOp, restApiJobInfo, job);
// 设置统计信息
RestApiJobStatistics restApiJobStatistics = new RestApiJobStatistics();
setStatics(curatorFrameworkOp, restApiJobStatistics, job);
restApiJobInfo.setStatistics(restApiJobStatistics);
return restApiJobInfo;
}
use of com.vip.saturn.job.console.domain.RestApiJobInfo in project Saturn by vipshop.
the class JobOperationRestApiController method queryAll.
@RequestMapping(value = "/{namespace}/jobs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> queryAll(@PathVariable("namespace") String namespace) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
List<RestApiJobInfo> restApiJobInfos = restApiService.getRestApiJobInfos(namespace);
return new ResponseEntity<Object>(restApiJobInfos, 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.domain.RestApiJobInfo in project Saturn by vipshop.
the class JobOperationRestApiController method query.
@RequestMapping(value = "/{namespace}/jobs/{jobName}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> query(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
checkMissingParameter("jobName", jobName);
RestApiJobInfo restAPIJobInfo = restApiService.getRestAPIJobInfo(namespace, jobName);
return new ResponseEntity<Object>(restAPIJobInfo, 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.domain.RestApiJobInfo in project Saturn by vipshop.
the class JobOperationRestApiControllerTest method testQuerySuccessfully.
@Test
public void testQuerySuccessfully() throws Exception {
String jobName = "job1";
RestApiJobInfo jobInfo = constructJobInfo("domain", jobName);
given(restApiService.getRestAPIJobInfo("domain", jobName)).willReturn(jobInfo);
MvcResult result = mvc.perform(get("/rest/v1/domain/jobs/" + jobName)).andExpect(status().isOk()).andReturn();
String body = result.getResponse().getContentAsString();
Map<String, Object> resultMap = JSONObject.parseObject(body, Map.class);
assertEquals("jobname not equal", jobName, resultMap.get("jobName"));
assertEquals("description not equal", jobInfo.getDescription(), resultMap.get("description"));
Map<String, Object> jobConfigMap = (Map<String, Object>) resultMap.get("jobConfig");
assertEquals("cron not equal", jobInfo.getJobConfig().getCron(), jobConfigMap.get("cron"));
Map<String, Object> statisticsMap = (Map<String, Object>) resultMap.get("statistics");
assertEquals("nextFireTime not equal", jobInfo.getStatistics().getNextFireTime(), new Long((Integer) statisticsMap.get("nextFireTime")));
}
use of com.vip.saturn.job.console.domain.RestApiJobInfo in project Saturn by vipshop.
the class JobOperationRestApiControllerTest method constructJobInfo.
private RestApiJobInfo constructJobInfo(String domain, String jobName) {
RestApiJobInfo jobInfo = new RestApiJobInfo();
jobInfo.setJobName(jobName);
jobInfo.setEnabled(true);
jobInfo.setDescription("this is a decription of " + jobName);
RestApiJobConfig jobConfig = new RestApiJobConfig();
jobConfig.setCron("0 */1 * * * ?");
jobInfo.setJobConfig(jobConfig);
RestApiJobStatistics statistics = new RestApiJobStatistics();
statistics.setNextFireTime(1234567L);
jobInfo.setStatistics(statistics);
return jobInfo;
}
Aggregations