Skip to content

Commit ef4ecdf

Browse files
authored
Add forks support for ForkingCluster. (#2751)
Add forks support for ForkingCluster.
1 parent 5da01b1 commit ef4ecdf

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractMethodConfig.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ public abstract class AbstractMethodConfig extends AbstractConfig {
6464
// customized parameters
6565
protected Map<String, String> parameters;
6666

67+
/**
68+
* forks for forking cluster
69+
*/
70+
protected Integer forks;
71+
72+
public Integer getForks() {
73+
return forks;
74+
}
75+
76+
public void setForks(Integer forks) {
77+
this.forks = forks;
78+
}
79+
6780
public Integer getTimeout() {
6881
return timeout;
6982
}

dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/AbstractMethodConfigTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public void testTimeout() throws Exception {
3535
assertThat(methodConfig.getTimeout(), equalTo(10));
3636
}
3737

38+
@Test
39+
public void testForks() throws Exception {
40+
MethodConfig methodConfig = new MethodConfig();
41+
methodConfig.setForks(10);
42+
assertThat(methodConfig.getForks(), equalTo(10));
43+
}
44+
3845
@Test
3946
public void testRetries() throws Exception {
4047
MethodConfig methodConfig = new MethodConfig();

dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<xsd:documentation><![CDATA[ Use cluster strategy. ]]></xsd:documentation>
102102
</xsd:annotation>
103103
</xsd:attribute>
104+
<xsd:attribute name="forks" type="xsd:string">
105+
<xsd:annotation>
106+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
107+
</xsd:annotation>
108+
</xsd:attribute>
104109
<xsd:attribute name="filter" type="xsd:string" use="optional">
105110
<xsd:annotation>
106111
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
@@ -480,6 +485,11 @@
480485
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
481486
</xsd:annotation>
482487
</xsd:attribute>
488+
<xsd:attribute name="forks" type="xsd:string">
489+
<xsd:annotation>
490+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
491+
</xsd:annotation>
492+
</xsd:attribute>
483493
<xsd:attribute name="group" type="xsd:string" use="optional">
484494
<xsd:annotation>
485495
<xsd:documentation><![CDATA[ The registry group. ]]></xsd:documentation>

dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<xsd:documentation><![CDATA[ Use cluster strategy. ]]></xsd:documentation>
102102
</xsd:annotation>
103103
</xsd:attribute>
104+
<xsd:attribute name="forks" type="xsd:string">
105+
<xsd:annotation>
106+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
107+
</xsd:annotation>
108+
</xsd:attribute>
104109
<xsd:attribute name="filter" type="xsd:string" use="optional">
105110
<xsd:annotation>
106111
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
@@ -480,6 +485,11 @@
480485
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
481486
</xsd:annotation>
482487
</xsd:attribute>
488+
<xsd:attribute name="forks" type="xsd:string">
489+
<xsd:annotation>
490+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
491+
</xsd:annotation>
492+
</xsd:attribute>
483493
<xsd:attribute name="group" type="xsd:string" use="optional">
484494
<xsd:annotation>
485495
<xsd:documentation><![CDATA[ The registry group. ]]></xsd:documentation>

dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ public void testToString() {
148148
assertTrue(str.endsWith(" />"));
149149
}
150150

151+
@Test
152+
public void testForks() {
153+
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
154+
reference.setApplication(new ApplicationConfig("consumer"));
155+
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
156+
reference.setInterface(DemoService.class);
157+
reference.setUrl("dubbo://127.0.0.1:20881");
158+
int forks = 10;
159+
reference.setForks(forks);
160+
String str = reference.toString();
161+
assertTrue(str.contains("forks=\"" + forks + "\""));
162+
}
163+
151164
@Test
152165
public void testMultiProtocol() {
153166
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");

0 commit comments

Comments
 (0)