From 7608a7d35c4c6f5a92678d5e724ec226ae0800e7 Mon Sep 17 00:00:00 2001 From: haocao Date: Tue, 7 Jun 2016 12:31:02 +0800 Subject: [PATCH] fix #107 --- README.md | 2 +- README_en.md | 2 +- .../job/internal/config/ConfigurationNode.java | 6 +++--- .../internal/monitor/MonitorServiceEnableTest.java | 2 +- .../FooStreamingBatchSequenceDataFlowElasticJob.java | 7 +++++-- ...ooStreamingBatchThroughputDataFlowElasticJob.java | 7 +++++-- ...ooUnstreamingBatchSequenceDataFlowElasticJob.java | 7 +++++-- ...UnstreamingBatchThroughputDataFlowElasticJob.java | 7 +++++-- elastic-job-doc/content/post/dump.md | 2 +- elastic-job-doc/content/post/release_notes.md | 1 + elastic-job-doc/content/post/user_guide.md | 12 ++++++------ .../src/main/resources/META-INF/withNamespace.xml | 6 +++--- .../resources/META-INF/withNamespaceAndListener.xml | 2 +- .../constants/BaseJobBeanDefinitionParserTag.java | 2 ++ .../common/AbstractJobBeanDefinitionParser.java | 3 ++- .../namespace/PlaceholderBeanDefinitionParser.java | 2 +- .../src/main/resources/META-INF/namespace/job.xsd | 2 +- .../src/main/resources/META-INF/namespace/reg.xsd | 2 +- .../test/resources/META-INF/job/withNamespace.xml | 4 ++-- .../META-INF/job/withNamespaceAndListener.xml | 4 ++-- .../job/withNamespaceAndListenerAndCglib.xml | 4 ++-- .../withNamespaceAndListenerAndJdkDynamicProxy.xml | 4 ++-- .../test/resources/META-INF/reg/withNamespace.xml | 4 ++-- 23 files changed, 55 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 5cb10a0463..b92438db73 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,6 @@ public class MyElasticJob extends AbstractSimpleElasticJob { - + ``` diff --git a/README_en.md b/README_en.md index aac426e2ec..a6635dcc9d 100644 --- a/README_en.md +++ b/README_en.md @@ -116,6 +116,6 @@ public class MyElasticJob extends AbstractThroughputDataFlowElasticJob { - + ``` 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 95de2080e7..97d7e9cd33 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 @@ -24,7 +24,7 @@ * * @author zhangliang */ -final class ConfigurationNode { +public final class ConfigurationNode { private static final String ROOT = "config"; @@ -66,7 +66,7 @@ final class ConfigurationNode { private final JobNodePath jobNodePath; - ConfigurationNode(final String jobName) { + public ConfigurationNode(final String jobName) { jobNodePath = new JobNodePath(jobName); } @@ -106,7 +106,7 @@ public boolean isFailoverPath(final String path) { * @param path 节点路径 * @return 是否为作业调度配置路径 */ - boolean isCronPath(final String path) { + public boolean isCronPath(final String path) { return jobNodePath.getFullPath(CRON).equals(path); } } diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/monitor/MonitorServiceEnableTest.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/monitor/MonitorServiceEnableTest.java index 9fab46a2e0..17acc05a04 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/monitor/MonitorServiceEnableTest.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/internal/monitor/MonitorServiceEnableTest.java @@ -31,7 +31,7 @@ public final class MonitorServiceEnableTest extends AbstractBaseStdJobTest { private static final int MONITOR_PORT = 9000; public MonitorServiceEnableTest() { - super(TestJob.class, -1); + super(TestJob.class, MONITOR_PORT); } @Test diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchSequenceDataFlowElasticJob.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchSequenceDataFlowElasticJob.java index 71987b8b40..aca787e7ab 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchSequenceDataFlowElasticJob.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchSequenceDataFlowElasticJob.java @@ -37,8 +37,11 @@ public List fetchData(final JobExecutionSingleShardingContext shardingCo public int processData(final JobExecutionSingleShardingContext shardingContext, final List data) { int result = 0; for (Object each : data) { - if (jobCaller.processData(each)) { - result++; + try { + if (jobCaller.processData(each)) { + result++; + } + } catch (final NullPointerException ex) { } } return result; diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchThroughputDataFlowElasticJob.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchThroughputDataFlowElasticJob.java index 953a628dc7..8cd51248d7 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchThroughputDataFlowElasticJob.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooStreamingBatchThroughputDataFlowElasticJob.java @@ -37,8 +37,11 @@ public List fetchData(final JobExecutionMultipleShardingContext sharding public int processData(final JobExecutionMultipleShardingContext shardingContext, final List data) { int result = 0; for (Object each : data) { - if (jobCaller.processData(each)) { - result++; + try { + if (jobCaller.processData(each)) { + result++; + } + } catch (final NullPointerException ex) { } } return result; diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchSequenceDataFlowElasticJob.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchSequenceDataFlowElasticJob.java index db0ce863f6..89ea5c0eff 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchSequenceDataFlowElasticJob.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchSequenceDataFlowElasticJob.java @@ -37,8 +37,11 @@ public List fetchData(final JobExecutionSingleShardingContext shardingCo public int processData(final JobExecutionSingleShardingContext shardingContext, final List data) { int result = 0; for (Object each : data) { - if (jobCaller.processData(each)) { - result++; + try { + if (jobCaller.processData(each)) { + result++; + } + } catch (final NullPointerException ex) { } } return result; diff --git a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchThroughputDataFlowElasticJob.java b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchThroughputDataFlowElasticJob.java index 2d6dd59788..3396e89ee0 100644 --- a/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchThroughputDataFlowElasticJob.java +++ b/elastic-job-core/src/test/java/com/dangdang/ddframe/job/plugin/job/type/fixture/FooUnstreamingBatchThroughputDataFlowElasticJob.java @@ -38,8 +38,11 @@ public List fetchData(final JobExecutionMultipleShardingContext sharding public int processData(final JobExecutionMultipleShardingContext shardingContext, final List data) { int result = 0; for (Object each : data) { - if (jobCaller.processData(each)) { - result++; + try { + if (jobCaller.processData(each)) { + result++; + } + } catch (final NullPointerException ex) { } } return result; diff --git a/elastic-job-doc/content/post/dump.md b/elastic-job-doc/content/post/dump.md index 7e24b38132..f2229cd11f 100644 --- a/elastic-job-doc/content/post/dump.md +++ b/elastic-job-doc/content/post/dump.md @@ -33,7 +33,7 @@ weight=13 - + ``` diff --git a/elastic-job-doc/content/post/release_notes.md b/elastic-job-doc/content/post/release_notes.md index 95e0aa9a03..5dd73689a4 100644 --- a/elastic-job-doc/content/post/release_notes.md +++ b/elastic-job-doc/content/post/release_notes.md @@ -15,6 +15,7 @@ weight=1 1. [ISSUE #104](https://github.com/dangdangdotcom/elastic-job/issues/104) 移除@Deprecated代码 1. [ISSUE #105](https://github.com/dangdangdotcom/elastic-job/issues/105) 重构Spring命名空间驼峰式定义 1. [ISSUE #106](https://github.com/dangdangdotcom/elastic-job/issues/106) isStreaming配置化 +1. [ISSUE #107](https://github.com/dangdangdotcom/elastic-job/issues/107) reg-center更名为registry-center-ref ## 1.0.8 diff --git a/elastic-job-doc/content/post/user_guide.md b/elastic-job-doc/content/post/user_guide.md index e660ed6360..9a1b57583f 100644 --- a/elastic-job-doc/content/post/user_guide.md +++ b/elastic-job-doc/content/post/user_guide.md @@ -215,16 +215,16 @@ public class JobMain { - + - + - + - + @@ -237,7 +237,7 @@ public class JobMain { | -----------------------------------|:------|:-------|:----|:---------------------------------------------------------------------------| |id |String |`是` | | 作业名称 | |class |String |否 | | 作业实现类,需实现`ElasticJob`接口,脚本型作业不需要配置 | -|reg-center |String |`是` | | 注册中心`Bean`的引用,需引用`reg:zookeeper`的声明 | +|registry-center-ref |String |`是` | | 注册中心`Bean`的引用,需引用`reg:zookeeper`的声明 | |cron |String |`是` | | `cron`表达式,用于配置作业触发时间 | |sharding-total-count |int |`是` | | 作业分片总数 | |sharding-item-parameters |String |否 | | 分片序列号和参数用等号分隔,多个键值对用逗号分隔
分片序列号从`0`开始,不可大于或等于作业分片总数
如:
`0=a,1=b,2=c`| @@ -286,7 +286,7 @@ job:script命名空间拥有job:simple命名空间的全部属性,以下仅列 | 属性名 |类型 |是否必填|缺省值|描述 | | ------------------------------ |:------|:------|:----|:--------------------------------------------------------------------------------------------------| |id |String |`是` | | 注册中心在`Spring`容器中的主键 | -|serverLists |String |`是` | | 连接`Zookeeper`服务器的列表
包括IP地址和端口号
多个地址用逗号分隔
如: host1:2181,host2:2181| +|server-lists |String |`是` | | 连接`Zookeeper`服务器的列表
包括IP地址和端口号
多个地址用逗号分隔
如: host1:2181,host2:2181| |namespace |String |`是` | | `Zookeeper`的命名空间 | |base-sleep-time-milliseconds |int |否 |1000 | 等待重试的间隔时间的初始值
单位:毫秒 | |max-sleep-time-milliseconds |int |否 |3000 | 等待重试的间隔时间的最大值
单位:毫秒 | 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 a9f9faf49d..21ed1d6d65 100644 --- a/elastic-job-example/src/main/resources/META-INF/withNamespace.xml +++ b/elastic-job-example/src/main/resources/META-INF/withNamespace.xml @@ -18,7 +18,7 @@ - - - + + + diff --git a/elastic-job-example/src/main/resources/META-INF/withNamespaceAndListener.xml b/elastic-job-example/src/main/resources/META-INF/withNamespaceAndListener.xml index 4a80a7a5e3..0251feafb2 100644 --- a/elastic-job-example/src/main/resources/META-INF/withNamespaceAndListener.xml +++ b/elastic-job-example/src/main/resources/META-INF/withNamespaceAndListener.xml @@ -18,7 +18,7 @@ - + diff --git a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/constants/BaseJobBeanDefinitionParserTag.java b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/constants/BaseJobBeanDefinitionParserTag.java index 64ca124546..2d49ac88dc 100644 --- a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/constants/BaseJobBeanDefinitionParserTag.java +++ b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/constants/BaseJobBeanDefinitionParserTag.java @@ -29,6 +29,8 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class BaseJobBeanDefinitionParserTag { + public static final String REGISTRY_CENTER_REF_ATTRIBUTE = "registry-center-ref"; + public static final String CLASS_ATTRIBUTE = "class"; public static final String CRON_ATTRIBUTE = "cron"; diff --git a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/parser/common/AbstractJobBeanDefinitionParser.java b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/parser/common/AbstractJobBeanDefinitionParser.java index 61ca9c1519..bae4664d63 100644 --- a/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/parser/common/AbstractJobBeanDefinitionParser.java +++ b/elastic-job-spring/src/main/java/com/dangdang/ddframe/job/spring/namespace/parser/common/AbstractJobBeanDefinitionParser.java @@ -47,6 +47,7 @@ import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.MONITOR_EXECUTION_ATTRIBUTE; import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.MONITOR_PORT_ATTRIBUTE; import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.OVERWRITE_ATTRIBUTE; +import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE; import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.SHARDING_ITEM_PARAMETERS_ATTRIBUTE; import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.SHARDING_TOTAL_COUNT_ATTRIBUTE; import static com.dangdang.ddframe.job.spring.namespace.constants.BaseJobBeanDefinitionParserTag.STARTED_TIMEOUT_MILLISECONDS_ATTRIBUTE; @@ -64,7 +65,7 @@ public abstract class AbstractJobBeanDefinitionParser extends AbstractBeanDefini protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) { BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(SpringJobScheduler.class); factory.setInitMethodName("init"); - factory.addConstructorArgReference(element.getAttribute("reg-center")); + factory.addConstructorArgReference(element.getAttribute(REGISTRY_CENTER_REF_ATTRIBUTE)); factory.addConstructorArgReference(createJobConfiguration(element, parserContext)); factory.addConstructorArgValue(createJobListeners(element)); return factory.getBeanDefinition(); diff --git a/elastic-job-spring/src/main/java/com/dangdang/ddframe/reg/spring/namespace/PlaceholderBeanDefinitionParser.java b/elastic-job-spring/src/main/java/com/dangdang/ddframe/reg/spring/namespace/PlaceholderBeanDefinitionParser.java index f0f88895f5..28c2d6f074 100644 --- a/elastic-job-spring/src/main/java/com/dangdang/ddframe/reg/spring/namespace/PlaceholderBeanDefinitionParser.java +++ b/elastic-job-spring/src/main/java/com/dangdang/ddframe/reg/spring/namespace/PlaceholderBeanDefinitionParser.java @@ -40,7 +40,7 @@ protected AbstractBeanDefinition parseInternal(final Element element, final Pars BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(PropertySourcesPlaceholderConfigurer.class); factory.addPropertyValue("ignoreUnresolvablePlaceholders", true); BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(RegistryPropertySources.class); - definitionBuilder.addConstructorArgReference(element.getAttribute("registerRef")); + definitionBuilder.addConstructorArgReference(element.getAttribute("registry-center-ref")); factory.addPropertyValue("propertySources", definitionBuilder.getBeanDefinition()); return factory.getBeanDefinition(); } 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 a15a57a287..e904b2e4be 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 @@ -22,7 +22,7 @@ - + diff --git a/elastic-job-spring/src/main/resources/META-INF/namespace/reg.xsd b/elastic-job-spring/src/main/resources/META-INF/namespace/reg.xsd index ad5e435a0b..04acc9b4e2 100644 --- a/elastic-job-spring/src/main/resources/META-INF/namespace/reg.xsd +++ b/elastic-job-spring/src/main/resources/META-INF/namespace/reg.xsd @@ -30,7 +30,7 @@ - + diff --git a/elastic-job-spring/src/test/resources/META-INF/job/withNamespace.xml b/elastic-job-spring/src/test/resources/META-INF/job/withNamespace.xml index ef38525486..fdf193154d 100644 --- a/elastic-job-spring/src/test/resources/META-INF/job/withNamespace.xml +++ b/elastic-job-spring/src/test/resources/META-INF/job/withNamespace.xml @@ -8,7 +8,7 @@ http://www.dangdang.com/schema/ddframe/job/job.xsd "> - - + diff --git a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListener.xml b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListener.xml index 9de4fd185d..944aa3533f 100644 --- a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListener.xml +++ b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListener.xml @@ -8,9 +8,9 @@ http://www.dangdang.com/schema/ddframe/job/job.xsd "> - + - + diff --git a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndCglib.xml b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndCglib.xml index 3c52f67258..deec947767 100644 --- a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndCglib.xml +++ b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndCglib.xml @@ -16,8 +16,8 @@ - + - + diff --git a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndJdkDynamicProxy.xml b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndJdkDynamicProxy.xml index c0f0d77e55..d543a77f26 100644 --- a/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndJdkDynamicProxy.xml +++ b/elastic-job-spring/src/test/resources/META-INF/job/withNamespaceAndListenerAndJdkDynamicProxy.xml @@ -16,8 +16,8 @@ - + - + diff --git a/elastic-job-spring/src/test/resources/META-INF/reg/withNamespace.xml b/elastic-job-spring/src/test/resources/META-INF/reg/withNamespace.xml index 62e48aa82d..e967e65912 100644 --- a/elastic-job-spring/src/test/resources/META-INF/reg/withNamespace.xml +++ b/elastic-job-spring/src/test/resources/META-INF/reg/withNamespace.xml @@ -15,8 +15,8 @@ - - + +