@Test public void testGetJobConfigFromZK() throws SaturnJobConsoleException { when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp); when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))) .thenReturn(JobType.SHELL_JOB.name()); when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT))) .thenReturn("1"); when(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS))) .thenReturn("100"); when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS))) .thenReturn("100"); assertNotNull(jobService.getJobConfigFromZK(namespace, jobName)); }
@Override public JobConfig getJobConfigFromZK(String namespace, String jobName) throws SaturnJobConsoleException { CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService .getCuratorFrameworkOp(namespace); JobConfig result = new JobConfig(); result.setJobName(jobName); result.setJobType(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))); result.setJobClass(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))); if (StringUtils.isBlank(result.getJobType())) { if (result.getJobClass().indexOf("script") >= 0) { result.setJobType(JobType.SHELL_JOB.name()); } else { result.setJobType(JobType.JAVA_JOB.name()); } } result.setShardingTotalCount(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT)))); String timeZone = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE)); if (Strings.isNullOrEmpty(timeZone)) { result.setTimeZone(SaturnConstants.TIME_ZONE_ID_DEFAULT); } else { result.setTimeZone(timeZone); } result.setCron(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))); result.setPausePeriodDate( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE))); result.setPausePeriodTime( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME))); result.setShardingItemParameters(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))); result.setJobParameter( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER))); result.setProcessCountIntervalSeconds(Integer.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS)))); String timeout4AlarmSecondsStr = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS)); if (Strings.isNullOrEmpty(timeout4AlarmSecondsStr)) { result.setTimeout4AlarmSeconds(0); } else { result.setTimeout4AlarmSeconds(Integer.valueOf(timeout4AlarmSecondsStr)); } result.setTimeoutSeconds(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS)))); String lv = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL)); if (Strings.isNullOrEmpty(lv)) { result.setLoadLevel(1); } else { result.setLoadLevel(Integer.valueOf(lv)); } String jobDegree = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE)); if (Strings.isNullOrEmpty(jobDegree)) { result.setJobDegree(0); } else { result.setJobDegree(Integer.valueOf(jobDegree)); } result.setEnabled(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)))); result.setPreferList( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST))); String useDispreferList = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST)); if (Strings.isNullOrEmpty(useDispreferList)) { result.setUseDispreferList(null); } else { result.setUseDispreferList(Boolean.valueOf(useDispreferList)); } result.setLocalMode(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE)))); result.setDependencies( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES))); result.setGroups(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS))); result.setDescription( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION))); result.setJobMode(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_JOB_MODE))); result.setUseSerial(Boolean.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_USE_SERIAL)))); result.setQueueName(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))); result.setChannelName( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME))); if (!curatorFrameworkOp .checkExists(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_SHOW_NORMAL_LOG))) { curatorFrameworkOp.create(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)); } String enabledReport = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT)); Boolean enabledReportValue = Boolean.valueOf(enabledReport); if (Strings.isNullOrEmpty(enabledReport)) { enabledReportValue = true; } result.setEnabledReport(enabledReportValue); result.setShowNormalLog(Boolean.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)))); return result; }
JobServiceImpl implements JobService { @Override public JobConfig getJobConfigFromZK(String namespace, String jobName) throws SaturnJobConsoleException { CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService .getCuratorFrameworkOp(namespace); JobConfig result = new JobConfig(); result.setJobName(jobName); result.setJobType(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))); result.setJobClass(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))); if (StringUtils.isBlank(result.getJobType())) { if (result.getJobClass().indexOf("script") >= 0) { result.setJobType(JobType.SHELL_JOB.name()); } else { result.setJobType(JobType.JAVA_JOB.name()); } } result.setShardingTotalCount(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT)))); String timeZone = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE)); if (Strings.isNullOrEmpty(timeZone)) { result.setTimeZone(SaturnConstants.TIME_ZONE_ID_DEFAULT); } else { result.setTimeZone(timeZone); } result.setCron(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))); result.setPausePeriodDate( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE))); result.setPausePeriodTime( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME))); result.setShardingItemParameters(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))); result.setJobParameter( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER))); result.setProcessCountIntervalSeconds(Integer.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS)))); String timeout4AlarmSecondsStr = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS)); if (Strings.isNullOrEmpty(timeout4AlarmSecondsStr)) { result.setTimeout4AlarmSeconds(0); } else { result.setTimeout4AlarmSeconds(Integer.valueOf(timeout4AlarmSecondsStr)); } result.setTimeoutSeconds(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS)))); String lv = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL)); if (Strings.isNullOrEmpty(lv)) { result.setLoadLevel(1); } else { result.setLoadLevel(Integer.valueOf(lv)); } String jobDegree = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE)); if (Strings.isNullOrEmpty(jobDegree)) { result.setJobDegree(0); } else { result.setJobDegree(Integer.valueOf(jobDegree)); } result.setEnabled(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)))); result.setPreferList( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST))); String useDispreferList = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST)); if (Strings.isNullOrEmpty(useDispreferList)) { result.setUseDispreferList(null); } else { result.setUseDispreferList(Boolean.valueOf(useDispreferList)); } result.setLocalMode(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE)))); result.setDependencies( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES))); result.setGroups(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS))); result.setDescription( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION))); result.setJobMode(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_JOB_MODE))); result.setUseSerial(Boolean.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_USE_SERIAL)))); result.setQueueName(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))); result.setChannelName( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME))); if (!curatorFrameworkOp .checkExists(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_SHOW_NORMAL_LOG))) { curatorFrameworkOp.create(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)); } String enabledReport = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT)); Boolean enabledReportValue = Boolean.valueOf(enabledReport); if (Strings.isNullOrEmpty(enabledReport)) { enabledReportValue = true; } result.setEnabledReport(enabledReportValue); result.setShowNormalLog(Boolean.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)))); return result; } }
JobServiceImpl implements JobService { @Override public JobConfig getJobConfigFromZK(String namespace, String jobName) throws SaturnJobConsoleException { CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService .getCuratorFrameworkOp(namespace); JobConfig result = new JobConfig(); result.setJobName(jobName); result.setJobType(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))); result.setJobClass(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))); if (StringUtils.isBlank(result.getJobType())) { if (result.getJobClass().indexOf("script") >= 0) { result.setJobType(JobType.SHELL_JOB.name()); } else { result.setJobType(JobType.JAVA_JOB.name()); } } result.setShardingTotalCount(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT)))); String timeZone = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE)); if (Strings.isNullOrEmpty(timeZone)) { result.setTimeZone(SaturnConstants.TIME_ZONE_ID_DEFAULT); } else { result.setTimeZone(timeZone); } result.setCron(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))); result.setPausePeriodDate( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE))); result.setPausePeriodTime( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME))); result.setShardingItemParameters(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))); result.setJobParameter( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER))); result.setProcessCountIntervalSeconds(Integer.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS)))); String timeout4AlarmSecondsStr = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS)); if (Strings.isNullOrEmpty(timeout4AlarmSecondsStr)) { result.setTimeout4AlarmSeconds(0); } else { result.setTimeout4AlarmSeconds(Integer.valueOf(timeout4AlarmSecondsStr)); } result.setTimeoutSeconds(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS)))); String lv = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL)); if (Strings.isNullOrEmpty(lv)) { result.setLoadLevel(1); } else { result.setLoadLevel(Integer.valueOf(lv)); } String jobDegree = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE)); if (Strings.isNullOrEmpty(jobDegree)) { result.setJobDegree(0); } else { result.setJobDegree(Integer.valueOf(jobDegree)); } result.setEnabled(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)))); result.setPreferList( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST))); String useDispreferList = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST)); if (Strings.isNullOrEmpty(useDispreferList)) { result.setUseDispreferList(null); } else { result.setUseDispreferList(Boolean.valueOf(useDispreferList)); } result.setLocalMode(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE)))); result.setDependencies( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES))); result.setGroups(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS))); result.setDescription( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION))); result.setJobMode(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_JOB_MODE))); result.setUseSerial(Boolean.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_USE_SERIAL)))); result.setQueueName(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))); result.setChannelName( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME))); if (!curatorFrameworkOp .checkExists(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_SHOW_NORMAL_LOG))) { curatorFrameworkOp.create(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)); } String enabledReport = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT)); Boolean enabledReportValue = Boolean.valueOf(enabledReport); if (Strings.isNullOrEmpty(enabledReport)) { enabledReportValue = true; } result.setEnabledReport(enabledReportValue); result.setShowNormalLog(Boolean.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)))); return result; }  }
JobServiceImpl implements JobService { @Override public JobConfig getJobConfigFromZK(String namespace, String jobName) throws SaturnJobConsoleException { CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService .getCuratorFrameworkOp(namespace); JobConfig result = new JobConfig(); result.setJobName(jobName); result.setJobType(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))); result.setJobClass(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))); if (StringUtils.isBlank(result.getJobType())) { if (result.getJobClass().indexOf("script") >= 0) { result.setJobType(JobType.SHELL_JOB.name()); } else { result.setJobType(JobType.JAVA_JOB.name()); } } result.setShardingTotalCount(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT)))); String timeZone = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE)); if (Strings.isNullOrEmpty(timeZone)) { result.setTimeZone(SaturnConstants.TIME_ZONE_ID_DEFAULT); } else { result.setTimeZone(timeZone); } result.setCron(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))); result.setPausePeriodDate( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE))); result.setPausePeriodTime( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME))); result.setShardingItemParameters(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))); result.setJobParameter( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER))); result.setProcessCountIntervalSeconds(Integer.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS)))); String timeout4AlarmSecondsStr = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS)); if (Strings.isNullOrEmpty(timeout4AlarmSecondsStr)) { result.setTimeout4AlarmSeconds(0); } else { result.setTimeout4AlarmSeconds(Integer.valueOf(timeout4AlarmSecondsStr)); } result.setTimeoutSeconds(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS)))); String lv = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL)); if (Strings.isNullOrEmpty(lv)) { result.setLoadLevel(1); } else { result.setLoadLevel(Integer.valueOf(lv)); } String jobDegree = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE)); if (Strings.isNullOrEmpty(jobDegree)) { result.setJobDegree(0); } else { result.setJobDegree(Integer.valueOf(jobDegree)); } result.setEnabled(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)))); result.setPreferList( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST))); String useDispreferList = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST)); if (Strings.isNullOrEmpty(useDispreferList)) { result.setUseDispreferList(null); } else { result.setUseDispreferList(Boolean.valueOf(useDispreferList)); } result.setLocalMode(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE)))); result.setDependencies( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES))); result.setGroups(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS))); result.setDescription( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION))); result.setJobMode(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_JOB_MODE))); result.setUseSerial(Boolean.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_USE_SERIAL)))); result.setQueueName(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))); result.setChannelName( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME))); if (!curatorFrameworkOp .checkExists(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_SHOW_NORMAL_LOG))) { curatorFrameworkOp.create(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)); } String enabledReport = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT)); Boolean enabledReportValue = Boolean.valueOf(enabledReport); if (Strings.isNullOrEmpty(enabledReport)) { enabledReportValue = true; } result.setEnabledReport(enabledReportValue); result.setShowNormalLog(Boolean.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)))); return result; }  @Override List<String> getGroups(String namespace); @Transactional(rollbackFor = Exception.class) @Override void enableJob(String namespace, String jobName, String updatedBy); @Transactional(rollbackFor = Exception.class) @Override void disableJob(String namespace, String jobName, String updatedBy); @Transactional(rollbackFor = Exception.class) @Override void removeJob(String namespace, String jobName); @Override List<ExecutorProvided> getCandidateExecutors(String namespace, String jobName); @Transactional(rollbackFor = Exception.class) @Override void setPreferList(String namespace, String jobName, String preferList, String updatedBy); @Override List<String> getCandidateUpStream(String namespace); @Override List<String> getCandidateDownStream(String namespace); @Transactional(rollbackFor = Exception.class) @Override void addJob(String namespace, JobConfig jobConfig, String createdBy); @Transactional(rollbackFor = Exception.class) @Override void copyJob(String namespace, JobConfig jobConfig, String jobNameCopied, String createdBy); @Override int getMaxJobNum(); @Override boolean jobIncExceeds(String namespace, int maxJobNum, int inc); @Override List<JobConfig> getUnSystemJobs(String namespace); @Override List<JobConfig4DB> getUnSystemJobsWithCondition(String namespace, Map<String, Object> condition, int page,
			int size); @Override int countUnSystemJobsWithCondition(String namespace, Map<String, Object> condition); @Override int countEnabledUnSystemJobs(String namespace); @Override List<String> getUnSystemJobNames(String namespace); @Override List<String> getJobNames(String namespace); @Override void persistJobFromDB(String namespace, JobConfig jobConfig); @Override void persistJobFromDB(JobConfig jobConfig, CuratorFrameworkOp curatorFrameworkOp); @Override List<BatchJobResult> importJobs(String namespace, MultipartFile file, String createdBy); @Override File exportJobs(String namespace); @Override File exportSelectedJobs(String namespace, List<String> jobList); @Override ArrangeLayout getArrangeLayout(String namespace); @Override JobConfig getJobConfigFromZK(String namespace, String jobName); @Override JobConfig getJobConfig(String namespace, String jobName); @Override JobStatus getJobStatus(String namespace, String jobName); @Override JobStatus getJobStatus(String namespace, JobConfig jobConfig); @Override boolean isJobShardingAllocatedExecutor(String namespace, String jobName); @Override List<String> getJobServerList(String namespace, String jobName); @Override GetJobConfigVo getJobConfigVo(String namespace, String jobName); @Transactional(rollbackFor = Exception.class) @Override void updateJobConfig(String namespace, JobConfig jobConfig, String updatedBy); @Override List<String> getAllJobNamesFromZK(String namespace); @Transactional(rollbackFor = Exception.class) @Override void updateJobCron(String namespace, String jobName, String cron, Map<String, String> customContext,
			String updatedBy); @Override List<JobServer> getJobServers(String namespace, String jobName); @Override List<JobServerStatus> getJobServersStatus(String namespace, String jobName); @Override void runAtOnce(String namespace, String jobName); @Override void stopAtOnce(String namespace, String jobName); @Override List<ExecutionInfo> getExecutionStatus(String namespace, String jobName); @Override String getExecutionLog(String namespace, String jobName, String jobItem); @Override List<JobConfig4DB> getJobsByQueue(String queue); @Transactional(rollbackFor = Exception.class) @Override void batchSetGroups(String namespace, List<String> jobNames, List<String> oldGroupNames,
			List<String> newGroupNames, String userName); }
JobServiceImpl implements JobService { @Override public JobConfig getJobConfigFromZK(String namespace, String jobName) throws SaturnJobConsoleException { CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService .getCuratorFrameworkOp(namespace); JobConfig result = new JobConfig(); result.setJobName(jobName); result.setJobType(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))); result.setJobClass(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))); if (StringUtils.isBlank(result.getJobType())) { if (result.getJobClass().indexOf("script") >= 0) { result.setJobType(JobType.SHELL_JOB.name()); } else { result.setJobType(JobType.JAVA_JOB.name()); } } result.setShardingTotalCount(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT)))); String timeZone = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE)); if (Strings.isNullOrEmpty(timeZone)) { result.setTimeZone(SaturnConstants.TIME_ZONE_ID_DEFAULT); } else { result.setTimeZone(timeZone); } result.setCron(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))); result.setPausePeriodDate( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_DATE))); result.setPausePeriodTime( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PAUSE_PERIOD_TIME))); result.setShardingItemParameters(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))); result.setJobParameter( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_PARAMETER))); result.setProcessCountIntervalSeconds(Integer.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS)))); String timeout4AlarmSecondsStr = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS)); if (Strings.isNullOrEmpty(timeout4AlarmSecondsStr)) { result.setTimeout4AlarmSeconds(0); } else { result.setTimeout4AlarmSeconds(Integer.valueOf(timeout4AlarmSecondsStr)); } result.setTimeoutSeconds(Integer.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIMEOUT_SECONDS)))); String lv = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL)); if (Strings.isNullOrEmpty(lv)) { result.setLoadLevel(1); } else { result.setLoadLevel(Integer.valueOf(lv)); } String jobDegree = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_DEGREE)); if (Strings.isNullOrEmpty(jobDegree)) { result.setJobDegree(0); } else { result.setJobDegree(Integer.valueOf(jobDegree)); } result.setEnabled(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)))); result.setPreferList( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_PREFER_LIST))); String useDispreferList = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_USE_DISPREFER_LIST)); if (Strings.isNullOrEmpty(useDispreferList)) { result.setUseDispreferList(null); } else { result.setUseDispreferList(Boolean.valueOf(useDispreferList)); } result.setLocalMode(Boolean .valueOf(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE)))); result.setDependencies( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DEPENDENCIES))); result.setGroups(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_GROUPS))); result.setDescription( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_DESCRIPTION))); result.setJobMode(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_JOB_MODE))); result.setUseSerial(Boolean.valueOf(curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_USE_SERIAL)))); result.setQueueName(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))); result.setChannelName( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CHANNEL_NAME))); if (!curatorFrameworkOp .checkExists(JobNodePath.getConfigNodePath(jobName, JobServiceImpl.CONFIG_ITEM_SHOW_NORMAL_LOG))) { curatorFrameworkOp.create(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)); } String enabledReport = curatorFrameworkOp .getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED_REPORT)); Boolean enabledReportValue = Boolean.valueOf(enabledReport); if (Strings.isNullOrEmpty(enabledReport)) { enabledReportValue = true; } result.setEnabledReport(enabledReportValue); result.setShowNormalLog(Boolean.valueOf( curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHOW_NORMAL_LOG)))); return result; }  @Override List<String> getGroups(String namespace); @Transactional(rollbackFor = Exception.class) @Override void enableJob(String namespace, String jobName, String updatedBy); @Transactional(rollbackFor = Exception.class) @Override void disableJob(String namespace, String jobName, String updatedBy); @Transactional(rollbackFor = Exception.class) @Override void removeJob(String namespace, String jobName); @Override List<ExecutorProvided> getCandidateExecutors(String namespace, String jobName); @Transactional(rollbackFor = Exception.class) @Override void setPreferList(String namespace, String jobName, String preferList, String updatedBy); @Override List<String> getCandidateUpStream(String namespace); @Override List<String> getCandidateDownStream(String namespace); @Transactional(rollbackFor = Exception.class) @Override void addJob(String namespace, JobConfig jobConfig, String createdBy); @Transactional(rollbackFor = Exception.class) @Override void copyJob(String namespace, JobConfig jobConfig, String jobNameCopied, String createdBy); @Override int getMaxJobNum(); @Override boolean jobIncExceeds(String namespace, int maxJobNum, int inc); @Override List<JobConfig> getUnSystemJobs(String namespace); @Override List<JobConfig4DB> getUnSystemJobsWithCondition(String namespace, Map<String, Object> condition, int page,
			int size); @Override int countUnSystemJobsWithCondition(String namespace, Map<String, Object> condition); @Override int countEnabledUnSystemJobs(String namespace); @Override List<String> getUnSystemJobNames(String namespace); @Override List<String> getJobNames(String namespace); @Override void persistJobFromDB(String namespace, JobConfig jobConfig); @Override void persistJobFromDB(JobConfig jobConfig, CuratorFrameworkOp curatorFrameworkOp); @Override List<BatchJobResult> importJobs(String namespace, MultipartFile file, String createdBy); @Override File exportJobs(String namespace); @Override File exportSelectedJobs(String namespace, List<String> jobList); @Override ArrangeLayout getArrangeLayout(String namespace); @Override JobConfig getJobConfigFromZK(String namespace, String jobName); @Override JobConfig getJobConfig(String namespace, String jobName); @Override JobStatus getJobStatus(String namespace, String jobName); @Override JobStatus getJobStatus(String namespace, JobConfig jobConfig); @Override boolean isJobShardingAllocatedExecutor(String namespace, String jobName); @Override List<String> getJobServerList(String namespace, String jobName); @Override GetJobConfigVo getJobConfigVo(String namespace, String jobName); @Transactional(rollbackFor = Exception.class) @Override void updateJobConfig(String namespace, JobConfig jobConfig, String updatedBy); @Override List<String> getAllJobNamesFromZK(String namespace); @Transactional(rollbackFor = Exception.class) @Override void updateJobCron(String namespace, String jobName, String cron, Map<String, String> customContext,
			String updatedBy); @Override List<JobServer> getJobServers(String namespace, String jobName); @Override List<JobServerStatus> getJobServersStatus(String namespace, String jobName); @Override void runAtOnce(String namespace, String jobName); @Override void stopAtOnce(String namespace, String jobName); @Override List<ExecutionInfo> getExecutionStatus(String namespace, String jobName); @Override String getExecutionLog(String namespace, String jobName, String jobItem); @Override List<JobConfig4DB> getJobsByQueue(String queue); @Transactional(rollbackFor = Exception.class) @Override void batchSetGroups(String namespace, List<String> jobNames, List<String> oldGroupNames,
			List<String> newGroupNames, String userName); static final String CONFIG_ITEM_LOAD_LEVEL; static final String CONFIG_ITEM_ENABLED; static final String CONFIG_ITEM_DESCRIPTION; static final String CONFIG_ITEM_CUSTOM_CONTEXT; static final String CONFIG_ITEM_JOB_TYPE; static final String CONFIG_ITEM_JOB_MODE; static final String CONFIG_ITEM_SHARDING_ITEM_PARAMETERS; static final String CONFIG_ITEM_JOB_PARAMETER; static final String CONFIG_ITEM_QUEUE_NAME; static final String CONFIG_ITEM_CHANNEL_NAME; static final String CONFIG_ITEM_FAILOVER; static final String CONFIG_ITEM_MONITOR_EXECUTION; static final String CONFIG_ITEM_TIMEOUT_4_ALARM_SECONDS; static final String CONFIG_ITEM_TIMEOUT_SECONDS; static final String CONFIG_ITEM_TIME_ZONE; static final String CONFIG_ITEM_CRON; static final String CONFIG_ITEM_PAUSE_PERIOD_DATE; static final String CONFIG_ITEM_PAUSE_PERIOD_TIME; static final String CONFIG_ITEM_PROCESS_COUNT_INTERVAL_SECONDS; static final String CONFIG_ITEM_SHARDING_TOTAL_COUNT; static final String CONFIG_ITEM_SHOW_NORMAL_LOG; static final String CONFIG_ITEM_JOB_DEGREE; static final String CONFIG_ITEM_ENABLED_REPORT; static final String CONFIG_ITEM_PREFER_LIST; static final String CONFIG_ITEM_USE_DISPREFER_LIST; static final String CONFIG_ITEM_LOCAL_MODE; static final String CONFIG_ITEM_USE_SERIAL; static final String CONFIG_ITEM_DEPENDENCIES; static final String CONFIG_ITEM_GROUPS; static final String CONFIG_ITEM_JOB_CLASS; static final String CONFIG_ITEM_RERUN; static final String CONFIG_ITEM_DOWNSTREAM; static final String CONFIG_ITEM_UPSTREAM; }