Skip to content

Commit

Permalink
Add forks support for ForkingCluster. (#2751)
Browse files Browse the repository at this point in the history
Add forks support for ForkingCluster.
  • Loading branch information
carryxyh authored Nov 7, 2018
1 parent 5da01b1 commit ef4ecdf
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ public abstract class AbstractMethodConfig extends AbstractConfig {
// customized parameters
protected Map<String, String> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<xsd:documentation><![CDATA[ Use cluster strategy. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="forks" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filter" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
Expand Down Expand Up @@ -480,6 +485,11 @@
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="forks" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="group" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The registry group. ]]></xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<xsd:documentation><![CDATA[ Use cluster strategy. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="forks" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filter" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The filter. ]]></xsd:documentation>
Expand Down Expand Up @@ -480,6 +485,11 @@
<xsd:documentation><![CDATA[ The registry cluster type. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="forks" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ ForkingCluster forks. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="group" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The registry group. ]]></xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ public void testToString() {
assertTrue(str.endsWith(" />"));
}

@Test
public void testForks() {
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
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");
Expand Down

0 comments on commit ef4ecdf

Please sign in to comment.