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));
}
}
});
}
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;
}
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;
}
Aggregations