From f1cf6e4aaa671f43b7656a200f260927f984508f Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 7 Nov 2018 16:32:52 +0800 Subject: [PATCH] Add forks support for ForkingCluster. --- .../alibaba/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 ++++++++++ .../com/alibaba/dubbo/config/spring/ConfigTest.java | 13 +++++++++++++ 5 files changed, 53 insertions(+) diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractMethodConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractMethodConfig.java index 92df4a1d3f7..aa8b7ea3925 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractMethodConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/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/com/alibaba/dubbo/config/AbstractMethodConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/AbstractMethodConfigTest.java index 2a1a890f670..d5463fe9a62 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/AbstractMethodConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/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 2dbdde18e54..c48e2c3deab 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 @@ + + + + + @@ -480,6 +485,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 0c17e24771f..40a7ac6c723 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 @@ + + + + + @@ -480,6 +485,11 @@ + + + + + diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java index 2415de4f8f7..69f716b25cc 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java @@ -148,6 +148,19 @@ 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");