Skip to content

Commit 56b2193

Browse files
carryxyhbeiwei30
authored andcommitted
Add 'forks' config into xml config (#2568)
* Add forks into xml config. * Add forks into xml config. * Add forks into xml config.
1 parent aed0102 commit 56b2193

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

dubbo-config/dubbo-config-api/src/main/java/org/apache/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/org/apache/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">
105110
<xsd:annotation>
106111
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
@@ -492,6 +497,11 @@
492497
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
493498
</xsd:annotation>
494499
</xsd:attribute>
500+
<xsd:attribute name="forks" type="xsd:string">
501+
<xsd:annotation>
502+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
503+
</xsd:annotation>
504+
</xsd:attribute>
495505
<xsd:attribute name="group" type="xsd:string">
496506
<xsd:annotation>
497507
<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">
105110
<xsd:annotation>
106111
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
@@ -486,6 +491,11 @@
486491
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
487492
</xsd:annotation>
488493
</xsd:attribute>
494+
<xsd:attribute name="forks" type="xsd:string">
495+
<xsd:annotation>
496+
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
497+
</xsd:annotation>
498+
</xsd:attribute>
489499
<xsd:attribute name="group" type="xsd:string">
490500
<xsd:annotation>
491501
<xsd:documentation><![CDATA[ The registry group. ]]></xsd:documentation>

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java

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

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

0 commit comments

Comments
 (0)