From 56b219316205a12b4ce95a82b10b527798df9e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E6=97=A0=E4=B8=A4=E4=B8=B6?= <442367943@qq.com> Date: Tue, 6 Nov 2018 17:16:21 +0800 Subject: [PATCH] Add 'forks' config into xml config (#2568) * Add forks into xml config. * Add forks into xml config. * Add forks into xml config. --- .../apache/dubbo/config/AbstractMethodConfig.java | 13 +++++++++++++ .../dubbo/config/AbstractMethodConfigTest.java | 7 +++++++ .../src/main/resources/META-INF/compat/dubbo.xsd | 10 ++++++++++ .../src/main/resources/META-INF/dubbo.xsd | 10 ++++++++++ .../org/apache/dubbo/config/spring/ConfigTest.java | 14 ++++++++++++++ 5 files changed, 54 insertions(+) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java index a4acce86c93..a2c3de65312 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java @@ -64,6 +64,19 @@ public abstract class AbstractMethodConfig extends AbstractConfig { // customized parameters protected Map parameters; + /** + * forks for forking cluster + */ + protected Integer forks; + + public Integer getForks() { + return forks; + } + + public void setForks(Integer forks) { + this.forks = forks; + } + public Integer getTimeout() { return timeout; } diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java index 41549e3ef9b..063a2e3408a 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java @@ -35,6 +35,13 @@ public void testTimeout() throws Exception { assertThat(methodConfig.getTimeout(), equalTo(10)); } + @Test + public void testForks() throws Exception { + MethodConfig methodConfig = new MethodConfig(); + methodConfig.setForks(10); + assertThat(methodConfig.getForks(), equalTo(10)); + } + @Test public void testRetries() throws Exception { MethodConfig methodConfig = new MethodConfig(); diff --git a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd index 92d7bd27056..902bae8fb1b 100644 --- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd +++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd @@ -101,6 +101,11 @@ + + + + + @@ -492,6 +497,11 @@ + + + + + diff --git a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd index 88fe25fccb1..9b21ba247d6 100644 --- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd +++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd @@ -101,6 +101,11 @@ + + + + + @@ -486,6 +491,11 @@ + + + + + diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java index ca9cc94b6c8..d36fedc5831 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java @@ -147,6 +147,20 @@ public void testToString() { assertTrue(str.endsWith(" />")); } + @Test + public void testForks() { + ReferenceConfig reference = new ReferenceConfig(); + reference.setApplication(new ApplicationConfig("consumer")); + reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); + reference.setInterface(DemoService.class); + reference.setUrl("dubbo://127.0.0.1:20881"); + + int forks = 10; + reference.setForks(forks); + String str = reference.toString(); + assertTrue(str.contains("forks=\"" + forks + "\"")); + } + @Test public void testMultiProtocol() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");