From 3b8a9dc434862d065c09c10f181f8a13022b236d Mon Sep 17 00:00:00 2001 From: terrymanu Date: Thu, 15 Oct 2015 13:35:10 +0800 Subject: [PATCH] Check time diff between job server and register center #6 --- .../job/console/domain/JobSettings.java | 2 ++ .../service/impl/JobDimensionServiceImpl.java | 2 ++ .../src/main/webapp/js/job_detail.js | 4 ++- .../src/main/webapp/templates/job_detail.ftl | 7 ++++ .../ddframe/job/api/AbstractElasticJob.java | 1 + .../ddframe/job/api/JobConfiguration.java | 10 ++++++ .../TimeDiffIntolerableException.java | 34 +++++++++++++++++++ .../internal/config/ConfigurationNode.java | 2 ++ .../internal/config/ConfigurationService.java | 16 +++++++++ .../job/internal/storage/JobNodeStorage.java | 9 +++++ .../ddframe/reg/base/RegistryCenter.java | 8 +++++ .../zookeeper/ZookeeperRegistryCenter.java | 16 +++++++++ .../config/ConfigurationServiceTest.java | 21 ++++++++++++ .../ZookeeperRegistryCenterTest.java | 6 ++++ elastic-job-example/pom.xml | 24 +++++++++++++ .../main/resources/META-INF/withNamespace.xml | 2 +- .../resources/META-INF/withoutNamespace.xml | 1 + .../src/main/resources/conf/job.properties | 1 + .../src/main/resources/logback.xml | 20 +++++++++++ .../namespace/JobBeanDefinitionParser.java | 1 + .../main/resources/META-INF/namespace/job.xsd | 1 + 21 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 elastic-job-core/src/main/java/com/dangdang/ddframe/job/exception/TimeDiffIntolerableException.java create mode 100644 elastic-job-example/src/main/resources/logback.xml diff --git a/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/domain/JobSettings.java b/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/domain/JobSettings.java index b19f6ca00d..9573db26b8 100644 --- a/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/domain/JobSettings.java +++ b/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/domain/JobSettings.java @@ -48,6 +48,8 @@ public final class JobSettings implements Serializable { private int fetchDataCount; + private int maxTimeDiffSeconds; + private boolean failover; private boolean misfire; diff --git a/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/service/impl/JobDimensionServiceImpl.java b/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/service/impl/JobDimensionServiceImpl.java index 3c5e7d0df4..508997a9ab 100644 --- a/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/service/impl/JobDimensionServiceImpl.java +++ b/elastic-job-console/src/main/java/com/dangdang/ddframe/job/console/service/impl/JobDimensionServiceImpl.java @@ -97,6 +97,7 @@ public JobSettings getJobSettings(final String jobName) { result.setProcessCountIntervalSeconds(Integer.parseInt(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "processCountIntervalSeconds")))); result.setConcurrentDataProcessThreadCount(Integer.parseInt(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "concurrentDataProcessThreadCount")))); result.setFetchDataCount(Integer.parseInt(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "fetchDataCount")))); + result.setMaxTimeDiffSeconds(Integer.parseInt(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "maxTimeDiffSeconds")))); result.setFailover(Boolean.valueOf(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "failover")))); result.setMisfire(Boolean.valueOf(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "misfire")))); result.setJobShardingStrategyClass(curatorRepository.getData(JobNodePath.getConfigNodePath(jobName, "jobShardingStrategyClass"))); @@ -114,6 +115,7 @@ public void updateJobSettings(final JobSettings jobSettings) { updateIfchanged(jobSettings.getJobName(), "processCountIntervalSeconds", jobSettings.getProcessCountIntervalSeconds()); updateIfchanged(jobSettings.getJobName(), "concurrentDataProcessThreadCount", jobSettings.getConcurrentDataProcessThreadCount()); updateIfchanged(jobSettings.getJobName(), "fetchDataCount", jobSettings.getFetchDataCount()); + updateIfchanged(jobSettings.getJobName(), "maxTimeDiffSeconds", jobSettings.getMaxTimeDiffSeconds()); updateIfchanged(jobSettings.getJobName(), "failover", jobSettings.isFailover()); updateIfchanged(jobSettings.getJobName(), "misfire", jobSettings.isMisfire()); updateIfchanged(jobSettings.getJobName(), "jobShardingStrategyClass", jobSettings.getJobShardingStrategyClass()); diff --git a/elastic-job-console/src/main/webapp/js/job_detail.js b/elastic-job-console/src/main/webapp/js/job_detail.js index 9b9bbc6b3a..5d779c59ab 100644 --- a/elastic-job-console/src/main/webapp/js/job_detail.js +++ b/elastic-job-console/src/main/webapp/js/job_detail.js @@ -29,6 +29,7 @@ function renderSettings() { $("#processCountIntervalSeconds").attr("value", data.processCountIntervalSeconds); $("#concurrentDataProcessThreadCount").attr("value", data.concurrentDataProcessThreadCount); $("#fetchDataCount").attr("value", data.fetchDataCount); + $("#maxTimeDiffSeconds").attr("value", data.maxTimeDiffSeconds); $("#jobShardingStrategyClass").attr("value", data.jobShardingStrategyClass); $("#description").text(data.description); if (!data.monitorExecution) { @@ -48,13 +49,14 @@ function bindSubmitJobSettingsForm() { var concurrentDataProcessThreadCount = $("#concurrentDataProcessThreadCount").val(); var processCountIntervalSeconds = $("#processCountIntervalSeconds").val(); var fetchDataCount = $("#fetchDataCount").val(); + var maxTimeDiffSeconds = $("#maxTimeDiffSeconds").val(); var monitorExecution = $("#monitorExecution").prop("checked"); var failover = $("#failover").prop("checked"); var misfire = $("#misfire").prop("checked"); var shardingItemParameters = $("#shardingItemParameters").val(); var jobShardingStrategyClass = $("#jobShardingStrategyClass").val(); var description = $("#description").val(); - $.post("job/settings", {jobName: jobName, jobClass : jobClass, shardingTotalCount: shardingTotalCount, jobParameter: jobParameter, cron: cron, concurrentDataProcessThreadCount: concurrentDataProcessThreadCount, processCountIntervalSeconds: processCountIntervalSeconds, fetchDataCount: fetchDataCount, monitorExecution: monitorExecution, failover: failover, misfire: misfire, shardingItemParameters: shardingItemParameters, jobShardingStrategyClass: jobShardingStrategyClass, description: description}, function(data) { + $.post("job/settings", {jobName: jobName, jobClass : jobClass, shardingTotalCount: shardingTotalCount, jobParameter: jobParameter, cron: cron, concurrentDataProcessThreadCount: concurrentDataProcessThreadCount, processCountIntervalSeconds: processCountIntervalSeconds, fetchDataCount: fetchDataCount, maxTimeDiffSeconds: maxTimeDiffSeconds, monitorExecution: monitorExecution, failover: failover, misfire: misfire, shardingItemParameters: shardingItemParameters, jobShardingStrategyClass: jobShardingStrategyClass, description: description}, function(data) { showSuccessDialog(); if (monitorExecution) { $("#execution_info_tab").removeClass("disabled"); diff --git a/elastic-job-console/src/main/webapp/templates/job_detail.ftl b/elastic-job-console/src/main/webapp/templates/job_detail.ftl index 4cc65f1c00..fe7ec93bdd 100644 --- a/elastic-job-console/src/main/webapp/templates/job_detail.ftl +++ b/elastic-job-console/src/main/webapp/templates/job_detail.ftl @@ -50,6 +50,13 @@ +
+ +
+ +
+
+
diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/AbstractElasticJob.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/AbstractElasticJob.java index 9a0a379e87..fc53bba085 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/AbstractElasticJob.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/AbstractElasticJob.java @@ -67,6 +67,7 @@ public abstract class AbstractElasticJob implements ElasticJob { @Override public final void execute(final JobExecutionContext context) throws JobExecutionException { log.debug("Elastic job: job execute begin, job execution context:{}.", context); + configService.checkMaxTimeDiffSecondsTolerable(); shardingService.shardingIfNecessary(); JobExecutionMultipleShardingContext shardingContext = executionContextService.getJobExecutionShardingContext(); if (executionService.misfireIfNecessary(shardingContext.getShardingItems())) { diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/JobConfiguration.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/JobConfiguration.java index ee13e39609..99271b255e 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/JobConfiguration.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/api/JobConfiguration.java @@ -110,6 +110,16 @@ public class JobConfiguration { */ private int fetchDataCount = 1; + /** + * 最大容忍的本机与注册中心的时间误差秒数. + * + *

+ * 如果时间误差超过配置秒数则作业启动时将抛异常. + * 配置为-1表示不检查时间误差. + *

+ */ + private int maxTimeDiffSeconds = -1; + /** * 是否开启失效转移. * diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/exception/TimeDiffIntolerableException.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/exception/TimeDiffIntolerableException.java new file mode 100644 index 0000000000..e6b6d1addc --- /dev/null +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/exception/TimeDiffIntolerableException.java @@ -0,0 +1,34 @@ +/** + * Copyright 1999-2015 dangdang.com. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *

+ */ + +package com.dangdang.ddframe.job.exception; + +/** + * 本机与注册中心的时间误差超过容忍范围抛出的异常. + * + * @author zhangliang + */ +public final class TimeDiffIntolerableException extends JobException { + + private static final long serialVersionUID = -6287464997081326084L; + + private static final String ERROR_MSG = "Time different between job server and register center exceed [%s] seconds, max time different is [%s] seconds."; + + public TimeDiffIntolerableException(final int timeDiffSeconds, final int maxTimeDiffSeconds) { + super(ERROR_MSG, timeDiffSeconds, maxTimeDiffSeconds); + } +} diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationNode.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationNode.java index e5b48e42df..925395fe66 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationNode.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationNode.java @@ -46,6 +46,8 @@ public final class ConfigurationNode { static final String FETCH_DATA_COUNT = ROOT + "/fetchDataCount"; + static final String MAX_TIME_DIFF_SECONDS = ROOT + "/maxTimeDiffSeconds"; + static final String FAILOVER = ROOT + "/failover"; static final String MISFIRE = ROOT + "/misfire"; diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationService.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationService.java index 021bd0d96d..337dde256c 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationService.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/config/ConfigurationService.java @@ -24,6 +24,7 @@ import com.dangdang.ddframe.job.api.JobConfiguration; import com.dangdang.ddframe.job.exception.JobConflictException; import com.dangdang.ddframe.job.exception.ShardingItemParametersException; +import com.dangdang.ddframe.job.exception.TimeDiffIntolerableException; import com.dangdang.ddframe.job.internal.storage.JobNodeStorage; import com.dangdang.ddframe.reg.base.CoordinatorRegistryCenter; import com.google.common.base.Strings; @@ -69,6 +70,7 @@ private void registerJobInfo() { jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.PROCESS_COUNT_INTERVAL_SECONDS, jobNodeStorage.getJobConfiguration().getProcessCountIntervalSeconds()); jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.CONCURRENT_DATA_PROCESS_THREAD_COUNT, jobNodeStorage.getJobConfiguration().getConcurrentDataProcessThreadCount()); jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.FETCH_DATA_COUNT, jobNodeStorage.getJobConfiguration().getFetchDataCount()); + jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.MAX_TIME_DIFF_SECONDS, jobNodeStorage.getJobConfiguration().getMaxTimeDiffSeconds()); jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.FAILOVER, jobNodeStorage.getJobConfiguration().isFailover()); jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.MISFIRE, jobNodeStorage.getJobConfiguration().isMisfire()); jobNodeStorage.fillJobNodeIfNullOrOverwrite(ConfigurationNode.JOB_SHARDING_STRATEGY_CLASS, jobNodeStorage.getJobConfiguration().getJobShardingStrategyClass()); @@ -164,6 +166,20 @@ public int getFetchDataCount() { return Integer.parseInt(jobNodeStorage.getJobNodeData(ConfigurationNode.FETCH_DATA_COUNT)); } + /** + * 检查本机与注册中心的时间误差秒数是否在允许范围. + */ + public void checkMaxTimeDiffSecondsTolerable() { + int maxTimeDiffSeconds = Integer.parseInt(jobNodeStorage.getJobNodeData(ConfigurationNode.MAX_TIME_DIFF_SECONDS)); + if (-1 == maxTimeDiffSeconds) { + return; + } + long timeDiff = Math.abs(System.currentTimeMillis() - jobNodeStorage.getRegistryCenterTime()); + if (timeDiff > maxTimeDiffSeconds * 1000L) { + throw new TimeDiffIntolerableException(Long.valueOf(timeDiff / 1000).intValue(), maxTimeDiffSeconds); + } + } + /** * 获取是否开启失效转移. * diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/storage/JobNodeStorage.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/storage/JobNodeStorage.java index 811da27a42..b70f33f150 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/storage/JobNodeStorage.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/job/internal/storage/JobNodeStorage.java @@ -199,4 +199,13 @@ public void addDataListener(final TreeCacheListener listener) { TreeCache cache = (TreeCache) coordinatorRegistryCenter.getRawCache(); cache.getListenable().addListener(listener); } + + /** + * 获取注册中心当前时间. + * + * @return 注册中心当前时间 + */ + public long getRegistryCenterTime() { + return coordinatorRegistryCenter.getRegistryCenterTime(jobNodePath.getFullPath("systemTime/current")); + } } diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/base/RegistryCenter.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/base/RegistryCenter.java index 4f90182053..d032231402 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/base/RegistryCenter.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/base/RegistryCenter.java @@ -73,6 +73,14 @@ public interface RegistryCenter { */ void remove(String key); + /** + * 获取注册中心当前时间. + * + * @param key 用于获取时间的键 + * @return 注册中心当前时间 + */ + long getRegistryCenterTime(String key); + /** * 直接获取操作注册中心的原生客户端. * 如:Zookeeper或Redis等原生客户端. diff --git a/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenter.java b/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenter.java index e3e7fb52b8..ec9bdc56f7 100644 --- a/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenter.java +++ b/elastic-job-core/src/main/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenter.java @@ -44,6 +44,7 @@ import com.dangdang.ddframe.reg.base.CoordinatorRegistryCenter; import com.dangdang.ddframe.reg.exception.LocalPropertiesFileNotFoundException; import com.dangdang.ddframe.reg.exception.RegExceptionHandler; +import com.google.common.base.Preconditions; import com.google.common.base.Strings; /** @@ -268,6 +269,21 @@ public void remove(final String key) { } } + @Override + public long getRegistryCenterTime(final String key) { + long result = 0L; + try { + String path = client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(key); + result = client.checkExists().forPath(path).getCtime(); + //CHECKSTYLE:OFF + } catch (final Exception ex) { + //CHECKSTYLE:ON + RegExceptionHandler.handleException(ex); + } + Preconditions.checkArgument(0L != result, "Cannot get registry center time."); + return result; + } + @Override public Object getRawClient() { return client; diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/config/ConfigurationServiceTest.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/config/ConfigurationServiceTest.java index e934e68e4c..7cb0aed69d 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/config/ConfigurationServiceTest.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/config/ConfigurationServiceTest.java @@ -38,6 +38,7 @@ import com.dangdang.ddframe.job.api.JobExecutionMultipleShardingContext; import com.dangdang.ddframe.job.exception.JobConflictException; import com.dangdang.ddframe.job.exception.ShardingItemParametersException; +import com.dangdang.ddframe.job.exception.TimeDiffIntolerableException; import com.dangdang.ddframe.job.internal.AbstractBaseJobTest; import com.dangdang.ddframe.job.internal.sharding.strategy.JobShardingStrategy; @@ -191,6 +192,26 @@ public void assertGetFetchDataCount() { assertThat(configService.getFetchDataCount(), is(1)); } + @Test + public void assertIsMaxTimeDiffSecondsTolerableWithDefaultValue() { + configService.persistJobConfiguration(); + configService.checkMaxTimeDiffSecondsTolerable(); + } + + @Test + public void assertIsMaxTimeDiffSecondsTolerable() { + getJobConfig().setMaxTimeDiffSeconds(60); + configService.persistJobConfiguration(); + configService.checkMaxTimeDiffSecondsTolerable(); + } + + @Test(expected = TimeDiffIntolerableException.class) + public void assertIsNotMaxTimeDiffSecondsTolerable() { + getJobConfig().setMaxTimeDiffSeconds(-60); + configService.persistJobConfiguration(); + configService.checkMaxTimeDiffSecondsTolerable(); + } + @Test public void assertIsNotFailoverWhenNotMonitorExecution() { getJobConfig().setMonitorExecution(false); diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenterTest.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenterTest.java index ed84e402b9..0b0caa72ce 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenterTest.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenterTest.java @@ -208,6 +208,12 @@ public void remove() { assertFalse(zkRegCenter.isExisted("/test")); } + @Test + public void getRegistryCenterTime() { + zkRegCenter.init(); + assertTrue(zkRegCenter.getRegistryCenterTime("/_systemTime/current") <= System.currentTimeMillis()); + } + @Test public void getRawClient() { zkRegCenter.init(); diff --git a/elastic-job-example/pom.xml b/elastic-job-example/pom.xml index 4559228bd4..9a324b7efb 100644 --- a/elastic-job-example/pom.xml +++ b/elastic-job-example/pom.xml @@ -14,6 +14,9 @@ 1.0.2-SNAPSHOT + 1.7.7 + 1.1.2 + 4.12 3.3 @@ -35,6 +38,27 @@ ${elastic-job.version} + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + log4j-over-slf4j + ${slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + junit junit diff --git a/elastic-job-example/src/main/resources/META-INF/withNamespace.xml b/elastic-job-example/src/main/resources/META-INF/withNamespace.xml index 401f1585df..5425f20dac 100644 --- a/elastic-job-example/src/main/resources/META-INF/withNamespace.xml +++ b/elastic-job-example/src/main/resources/META-INF/withNamespace.xml @@ -20,5 +20,5 @@ - + diff --git a/elastic-job-example/src/main/resources/META-INF/withoutNamespace.xml b/elastic-job-example/src/main/resources/META-INF/withoutNamespace.xml index 4e4123d64a..60f110d375 100644 --- a/elastic-job-example/src/main/resources/META-INF/withoutNamespace.xml +++ b/elastic-job-example/src/main/resources/META-INF/withoutNamespace.xml @@ -72,6 +72,7 @@ + diff --git a/elastic-job-example/src/main/resources/conf/job.properties b/elastic-job-example/src/main/resources/conf/job.properties index 81b1fda0c0..80d8c8277c 100644 --- a/elastic-job-example/src/main/resources/conf/job.properties +++ b/elastic-job-example/src/main/resources/conf/job.properties @@ -21,6 +21,7 @@ perpetualElasticJob.overwrite=true sequencePerpetualElasticJob.cron=0/5 * * * * ? sequencePerpetualElasticJob.shardingTotalCount=10 sequencePerpetualElasticJob.shardingItemParameters=0=A,1=B,2=C,3=D,4=E,5=F,6=G,7=H,8=I,9=J +sequencePerpetualElasticJob.maxTimeDiffSeconds=-1 sequencePerpetualElasticJob.monitorExecution=true sequencePerpetualElasticJob.failover=true sequencePerpetualElasticJob.processCountIntervalSeconds=10 diff --git a/elastic-job-example/src/main/resources/logback.xml b/elastic-job-example/src/main/resources/logback.xml new file mode 100644 index 0000000000..b6450e274d --- /dev/null +++ b/elastic-job-example/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + + + + ${log.context.name} + + + + ${log.pattern} + + + + + + + + diff --git a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/JobBeanDefinitionParser.java b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/JobBeanDefinitionParser.java index 7a551a4231..4d3977a194 100644 --- a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/JobBeanDefinitionParser.java +++ b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/JobBeanDefinitionParser.java @@ -58,6 +58,7 @@ private String createJobConfiguration(final Element element, final ParserContext addPropertyValueIfNotEmpty("processCountIntervalSeconds", element, factory); addPropertyValueIfNotEmpty("concurrentDataProcessThreadCount", element, factory); addPropertyValueIfNotEmpty("fetchDataCount", element, factory); + addPropertyValueIfNotEmpty("maxTimeDiffSeconds", element, factory); addPropertyValueIfNotEmpty("failover", element, factory); addPropertyValueIfNotEmpty("misfire", element, factory); addPropertyValueIfNotEmpty("jobShardingStrategyClass", element, factory); diff --git a/elastic-job-spring/src/main/resources/META-INF/namespace/job.xsd b/elastic-job-spring/src/main/resources/META-INF/namespace/job.xsd index 693bb232c7..4c24eadf4a 100644 --- a/elastic-job-spring/src/main/resources/META-INF/namespace/job.xsd +++ b/elastic-job-spring/src/main/resources/META-INF/namespace/job.xsd @@ -21,6 +21,7 @@ +