Search in sources :

Example 16 with RequestResult

use of com.vip.saturn.job.console.domain.RequestResult 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)

Example 17 with RequestResult

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

Example 18 with RequestResult

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

Example 19 with RequestResult

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

Example 20 with RequestResult

use of com.vip.saturn.job.console.domain.RequestResult in project Saturn by vipshop.

the class ZKDBDiffController method diffByCluster.

/**
 * 按照zk集群,对比zk和db的数据差异。<br> 如果console和zk集群不是在同一机房,则会将调用zk所属机房的console rest api去进行对比,如果对比失败,则继续在本机房进行对比;
 *
 * @param request
 * @param zkCluster
 * @return
 */
@RequestMapping(value = "zk_db_diff/diffByCluster", method = RequestMethod.GET)
@ResponseBody
public RequestResult diffByCluster(HttpServletRequest request, String zkCluster) {
    RequestResult requestResult = new RequestResult();
    List<JobDiffInfo> resultList = null;
    try {
        if (!ZkClusterMappingUtils.isCurrentConsoleInTheSameIdc(systemConfigService, zkCluster)) {
            resultList = relayDiffIfPossible(zkCluster);
        } else {
            resultList = zkDBDiffService.diffByCluster(zkCluster);
        }
        requestResult.setSuccess(true);
        requestResult.setObj(resultList);
    } catch (Exception e) {
        requestResult.setSuccess(false);
        requestResult.setMessage(e.toString());
    }
    return requestResult;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) JobDiffInfo(com.vip.saturn.job.console.domain.JobDiffInfo) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RequestResult (com.vip.saturn.job.console.domain.RequestResult)49 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)45 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)38 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 ParseException (java.text.ParseException)11 IOException (java.io.IOException)3 ExecutorProvided (com.vip.saturn.job.console.domain.ExecutorProvided)2 ExportJobConfigPageStatus (com.vip.saturn.job.console.domain.ExportJobConfigPageStatus)2 JobDiffInfo (com.vip.saturn.job.console.domain.JobDiffInfo)2 JobMigrateInfo (com.vip.saturn.job.console.domain.JobMigrateInfo)2 SystemConfig (com.vip.saturn.job.console.mybatis.entity.SystemConfig)2 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 Gson (com.google.gson.Gson)1 JobBriefInfo (com.vip.saturn.job.console.domain.JobBriefInfo)1 JobConfig (com.vip.saturn.job.console.domain.JobConfig)1 MoveNamespaceBatchStatus (com.vip.saturn.job.console.domain.MoveNamespaceBatchStatus)1 NamespaceZkClusterMappingVo (com.vip.saturn.job.console.domain.NamespaceZkClusterMappingVo)1 RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)1 SaturnJunkData (com.vip.saturn.job.console.domain.SaturnJunkData)1