Search in sources :

Example 31 with SaturnJobConsoleException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.

the class JobOperationRestApiController method disable.

@RequestMapping(value = { "/{namespace}/{jobName}/disable", "/{namespace}/jobs/{jobName}/disable" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> disable(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
    HttpHeaders httpHeaders = new HttpHeaders();
    try {
        checkMissingParameter("namespace", namespace);
        checkMissingParameter("jobName", jobName);
        restApiService.disableJob(namespace, jobName);
        return new ResponseEntity<>(httpHeaders, HttpStatus.OK);
    } catch (SaturnJobConsoleException e) {
        throw e;
    } catch (Exception e) {
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with SaturnJobConsoleException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleException 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);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) RestApiJobInfo(com.vip.saturn.job.console.domain.RestApiJobInfo) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with SaturnJobConsoleException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.

the class JobOperationRestApiController method updateJobCron.

@RequestMapping(value = { "/{namespace}/{jobName}/cron", "/{namespace}/jobs/{jobName}/cron" }, method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> updateJobCron(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName, @RequestBody Map<String, String> params, HttpServletRequest request) throws SaturnJobConsoleException {
    HttpHeaders httpHeaders = new HttpHeaders();
    try {
        checkMissingParameter("namespace", namespace);
        checkMissingParameter("jobName", jobName);
        String cron = params.remove("cron");
        checkMissingParameter("cron", cron);
        restApiService.updateJobCron(namespace, jobName, cron, params);
        return new ResponseEntity<>(httpHeaders, HttpStatus.OK);
    } catch (SaturnJobConsoleException e) {
        throw e;
    } catch (Exception e) {
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 34 with SaturnJobConsoleException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.

the class JobOperationRestApiController method stop.

@RequestMapping(value = "/{namespace}/jobs/{jobName}/stop", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> stop(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
    try {
        checkMissingParameter("namespace", namespace);
        checkMissingParameter("jobName", jobName);
        restApiService.stopJobAtOnce(namespace, jobName);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    } catch (SaturnJobConsoleException e) {
        throw e;
    } catch (Exception e) {
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
    }
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with SaturnJobConsoleException

use of com.vip.saturn.job.console.exception.SaturnJobConsoleException in project Saturn by vipshop.

the class NamespaceZkClusterMappingController method getMoveNamespaceBatchStatus.

@RequestMapping(value = "getMoveNamespaceBatchStatus", method = RequestMethod.GET)
public RequestResult getMoveNamespaceBatchStatus(HttpServletRequest request) {
    RequestResult requestResult = new RequestResult();
    try {
        Thread.sleep(400L);
        MoveNamespaceBatchStatus moveNamespaceBatchStatus = namespaceZkClusterMappingService.getMoveNamespaceBatchStatus();
        if (moveNamespaceBatchStatus == null) {
            throw new SaturnJobConsoleException("The MoveNamespaceBatchStatus is not existing in db");
        }
        requestResult.setSuccess(true);
        requestResult.setObj(moveNamespaceBatchStatus);
    } catch (Throwable t) {
        LOGGER.error(t.getMessage(), t);
        requestResult.setSuccess(false);
        requestResult.setMessage(t.toString());
    }
    return requestResult;
}
Also used : MoveNamespaceBatchStatus(com.vip.saturn.job.console.domain.MoveNamespaceBatchStatus) RequestResult(com.vip.saturn.job.console.domain.RequestResult) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)190 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)56 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)56 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)39 RequestResult (com.vip.saturn.job.console.domain.RequestResult)31 ParseException (java.text.ParseException)28 ResponseEntity (org.springframework.http.ResponseEntity)26 Transactional (org.springframework.transaction.annotation.Transactional)23 JobConfig4DB (com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)22 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)22 IOException (java.io.IOException)19 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)19 StatusLine (org.apache.http.StatusLine)18 HttpEntity (org.apache.http.HttpEntity)16 Audit (com.vip.saturn.job.console.aop.annotation.Audit)13 JobConfig (com.vip.saturn.job.console.domain.JobConfig)11 HttpHeaders (org.springframework.http.HttpHeaders)11 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)9 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)8 ArrayList (java.util.ArrayList)8