Search in sources :

Example 1 with ExportJobConfigPageStatus

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

the class JobConfigInitializationServiceImpl method exportAllToDb.

@Override
public void exportAllToDb(final String userName) throws SaturnJobConsoleException {
    final ExportJobConfigPageStatus exportJobConfigPageStatus = new ExportJobConfigPageStatus();
    temporarySharedStatusService.delete(ShareStatusModuleNames.EXPORT_JOB_CONFIG_PAGE_STATUS);
    temporarySharedStatusService.create(ShareStatusModuleNames.EXPORT_JOB_CONFIG_PAGE_STATUS, gson.toJson(exportJobConfigPageStatus));
    executorService.execute(new Runnable() {

        @Override
        public void run() {
            log.info("start to export all to db");
            try {
                log.info("start to delete all from table job_config");
                deleteAll();
                log.info("delete all from table job_config successfully");
                Collection<ZkCluster> zkClusters = registryCenterService.getZkClusterList();
                if (zkClusters != null) {
                    for (ZkCluster tmp : zkClusters) {
                        exportToDbByZkCluster(userName, tmp, exportJobConfigPageStatus);
                    }
                }
                exportJobConfigPageStatus.setSuccess(true);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                exportJobConfigPageStatus.setSuccess(false);
            } finally {
                exportJobConfigPageStatus.setExported(true);
                temporarySharedStatusService.update(ShareStatusModuleNames.EXPORT_JOB_CONFIG_PAGE_STATUS, gson.toJson(exportJobConfigPageStatus));
            }
        }
    });
}
Also used : ExportJobConfigPageStatus(com.vip.saturn.job.console.domain.ExportJobConfigPageStatus) Collection(java.util.Collection) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException)

Example 2 with ExportJobConfigPageStatus

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

the class JobConfigController method getExportStatus.

@RequestMapping(value = "jobconfig/getExportStatus", method = RequestMethod.GET)
@ResponseBody
public RequestResult getExportStatus(HttpServletRequest request) {
    RequestResult requestResult = new RequestResult();
    LOGGER.info("getExportStatus");
    try {
        ExportJobConfigPageStatus exportJobConfigPageStatus = jobConfigInitializationService.getStatus();
        requestResult.setSuccess(true);
        requestResult.setObj(exportJobConfigPageStatus);
    } 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) ExportJobConfigPageStatus(com.vip.saturn.job.console.domain.ExportJobConfigPageStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with ExportJobConfigPageStatus

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

the class JobConfigController method exportAllConfigToDb.

@RequestMapping(value = "jobconfig/exportAllConfigToDb", method = RequestMethod.POST)
@ResponseBody
public RequestResult exportAllConfigToDb(HttpServletRequest request) {
    LOGGER.info("exportAllConfigToDb");
    RequestResult requestResult = new RequestResult();
    try {
        ExportJobConfigPageStatus exportJobConfigPageStatus = jobConfigInitializationService.getStatus();
        if (exportJobConfigPageStatus != null && exportJobConfigPageStatus.isExported() == false) {
            requestResult.setSuccess(false);
            requestResult.setMessage("正在导出配置中,如有必要,请稍后再试!");
            return requestResult;
        }
        jobConfigInitializationService.exportAllToDb(null);
        requestResult.setSuccess(true);
    } 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) ExportJobConfigPageStatus(com.vip.saturn.job.console.domain.ExportJobConfigPageStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ExportJobConfigPageStatus (com.vip.saturn.job.console.domain.ExportJobConfigPageStatus)3 RequestResult (com.vip.saturn.job.console.domain.RequestResult)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)1 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)1 Collection (java.util.Collection)1