use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class JobServiceImpl method getJobConfigVo.
@Override
public GetJobConfigVo getJobConfigVo(String namespace, String jobName) throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
if (jobConfig4DB == null) {
throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, String.format("该作业(%s)不存在", jobName));
}
GetJobConfigVo getJobConfigVo = new GetJobConfigVo();
JobConfig jobConfig = new JobConfig();
SaturnBeanUtils.copyProperties(jobConfig4DB, jobConfig);
jobConfig.setDefaultValues();
getJobConfigVo.copyFrom(jobConfig);
getJobConfigVo.setTimeZonesProvided(Arrays.asList(TimeZone.getAvailableIDs()));
getJobConfigVo.setPreferListProvided(getCandidateExecutors(namespace, jobName));
getJobConfigVo.setUpStreamProvided(getCandidateUpStream(namespace, jobConfig));
getJobConfigVo.setDownStreamProvided(getCandidateDownStream(namespace, jobConfig));
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
getJobConfigVo.setStatus(getJobStatus(getJobConfigVo.getJobName(), curatorFrameworkOp, getJobConfigVo.getEnabled()));
return getJobConfigVo;
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class JobServiceImpl method updateJobConfigToZk.
private void updateJobConfigToZk(JobConfig jobConfig, Set<JobConfig> streamChangedJobs, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) throws SaturnJobConsoleException {
try {
String jobName = jobConfig.getJobName();
// 当关闭上报时,要清理execution节点
if (jobConfig.getEnabledReport() == Boolean.FALSE) {
log.info("the switch of enabledReport set to false, now deleting the execution zk node");
String executionNodePath = JobNodePath.getExecutionNodePath(jobName);
if (curatorFrameworkOp.checkExists(executionNodePath)) {
curatorFrameworkOp.deleteRecursive(executionNodePath);
}
}
CuratorFrameworkOp.CuratorTransactionOp curatorTransactionOp = curatorFrameworkOp.inTransaction();
// 数据库有可能有重复作业的数据,去重,zk无需更新两次
Collection<JobConfig> streamChangedJobsNew = removeDuplicateByJobName(streamChangedJobs);
// 更新关联作业的上下游
for (JobConfig streamChangedJob : streamChangedJobsNew) {
String changedJobName = streamChangedJob.getJobName();
if (!curatorFrameworkOp.checkExists(JobNodePath.getConfigNodePath(changedJobName))) {
// 数据库存在该作业,但是zk不存在该作业,为垃圾数据
log.warn("the job({}) config node is not existing in ZK", changedJobName);
continue;
}
curatorTransactionOp.replaceIfChanged(JobNodePath.getConfigNodePath(changedJobName, CONFIG_ITEM_UPSTREAM), streamChangedJob.getUpStream()).replaceIfChanged(JobNodePath.getConfigNodePath(changedJobName, CONFIG_ITEM_DOWNSTREAM), streamChangedJob.getDownStream());
}
// 更新作业
curatorTransactionOp.replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED), jobConfig.getEnabled()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION), jobConfig.getDescription()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CUSTOM_CONTEXT), jobConfig.getCustomContext()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE), jobConfig.getJobType()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_MODE), jobConfig.getJobMode()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS), jobConfig.getShardingItemParameters()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER), jobConfig.getJobParameter()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME), jobConfig.getQueueName()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME), jobConfig.getChannelName()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_FAILOVER), jobConfig.getFailover()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_MONITOR_EXECUTION), "true").replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS), jobConfig.getTimeout4AlarmSeconds()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS), jobConfig.getTimeoutSeconds()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE), jobConfig.getTimeZone()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON), jobConfig.getCron()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE), jobConfig.getPausePeriodDate()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME), jobConfig.getPausePeriodTime()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS), jobConfig.getProcessCountIntervalSeconds()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT), jobConfig.getShardingTotalCount()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG), jobConfig.getShowNormalLog()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL), jobConfig.getLoadLevel()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE), jobConfig.getJobDegree()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT), jobConfig.getEnabledReport()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST), jobConfig.getPreferList()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST), jobConfig.getUseDispreferList()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE), jobConfig.getLocalMode()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_SERIAL), jobConfig.getUseSerial()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES), jobConfig.getDependencies()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS), jobConfig.getGroups()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_RERUN), jobConfig.getRerun()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_UPSTREAM), jobConfig.getUpStream()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DOWNSTREAM), jobConfig.getDownStream()).replaceIfChanged(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS), jobConfig.getJobClass());
// 提交事务
curatorTransactionOp.commit();
} catch (Exception e) {
log.error("update job to zk failed", e);
throw new SaturnJobConsoleException(e);
}
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class JobServiceImpl method getExecutionLog.
@Override
public String getExecutionLog(String namespace, String jobName, String jobItem) throws SaturnJobConsoleException {
CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
String jobLogNodePath = JobNodePath.getExecutionNodePath(jobName, jobItem, "jobLog");
Stat stat = curatorFrameworkOp.getStat(jobLogNodePath);
if (stat.getDataLength() > getMaxZnodeDataLength()) {
log.warn("job log of job={} item={} exceed max length, will not display the original log", jobName, jobItem);
return ERR_MSG_TOO_LONG_TO_DISPLAY;
}
return curatorFrameworkOp.getData(jobLogNodePath);
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class DashboardServiceImpl method cleanAllJobExecutorCount.
@Override
public void cleanAllJobExecutorCount(String namespace) throws SaturnJobConsoleException {
CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
List<String> jobs = jobService.getUnSystemJobNames(namespace);
for (String job : jobs) {
resetOneJobExecutorCount(job, curatorFrameworkOp);
updateResetValue(curatorFrameworkOp, job, ResetCountType.RESET_SERVERS);
}
asyncForceRefreshStatistics(namespace);
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class DashboardServiceImpl method cleanOneJobExecutorCount.
@Override
public void cleanOneJobExecutorCount(String namespace, String jobName) throws SaturnJobConsoleException {
CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
updateResetValue(curatorFrameworkOp, jobName, ResetCountType.RESET_SERVERS);
resetOneJobExecutorCount(jobName, curatorFrameworkOp);
asyncForceRefreshStatistics(namespace);
}
Aggregations