SGF-322 - Add support for the newly added, retro 'max-connections' attribute on the <gfe:gateway-hub> element in the SDG XML namespace (XSD).

This commit is contained in:
John Blum
2015-02-25 18:32:52 -08:00
parent 4e3e8aa177
commit 17c9358547
7 changed files with 30 additions and 40 deletions

View File

@@ -48,22 +48,6 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
return GatewayHubFactoryBean.class;
}
/*
<xsd:attribute name="max-connections" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum number of Gateway connections allowed.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-time-between-pings" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum amount of time between client pings.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
*/
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
@@ -72,7 +56,7 @@ Sets the maximum amount of time between client pings.
ParsingUtils.setPropertyValue(element, builder, "bind-address");
ParsingUtils.setPropertyValue(element, builder, "manual-start");
//ParsingUtils.setPropertyValue(element, builder, "max-connections");
ParsingUtils.setPropertyValue(element, builder, "max-connections");
ParsingUtils.setPropertyValue(element, builder, "max-time-between-pings", "maximumTimeBetweenPings");
ParsingUtils.setPropertyValue(element, builder, "port");
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");

View File

@@ -48,7 +48,7 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
private GatewayHub gatewayHub;
//private Integer maxConnections;
private Integer maxConnections;
private Integer maximumTimeBetweenPings;
private Integer port;
private Integer socketBufferSize;
@@ -92,7 +92,7 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
gatewayHub.setBindAddress(getBindAddress());
gatewayHub.setManualStart(isManualStart(GatewayHub.DEFAULT_MANUAL_START));
//gatewayHub.setMaxConnections(getMaxConnections());
gatewayHub.setMaxConnections(getMaxConnections());
gatewayHub.setMaximumTimeBetweenPings(getMaximumTimeBetweenPings());
gatewayHub.setSocketBufferSize(getSocketBufferSize());
gatewayHub.setStartupPolicy(getStartupPolicy().getName());
@@ -173,7 +173,6 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
return (manualStart != null ? manualStart : defaultManualStart);
}
/*
public void setMaxConnections(Integer maxConnections) {
this.maxConnections = maxConnections;
}
@@ -182,7 +181,6 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
Integer getMaxConnections() {
return (maxConnections != null ? maxConnections : GatewayHub.DEFAULT_MAX_CONNECTIONS);
}
*/
public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) {
this.maximumTimeBetweenPings = maximumTimeBetweenPings;

View File

@@ -2986,6 +2986,20 @@ Specifies if the gateway hub is manually (true) or automatically(false) started
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-connections" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum number of Gateway connections allowed.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-time-between-pings" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Sets the maximum amount of time between client pings.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="socket-buffer-size" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
@@ -3008,12 +3022,9 @@ Specifies the startup policy (primary,secondary, none) for the gateway hub
Deprecated as of Gemfire 7
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="endpoint-id" type="xsd:string" use="required">
</xsd:attribute>
<xsd:attribute name="host" type="xsd:string" use="required">
</xsd:attribute>
<xsd:attribute name="port" type="xsd:string" use="required">
</xsd:attribute>
<xsd:attribute name="endpoint-id" type="xsd:string" use="required"/>
<xsd:attribute name="host" type="xsd:string" use="required"/>
<xsd:attribute name="port" type="xsd:string" use="required"/>
</xsd:complexType>
<!-- -->
<xsd:complexType name="gatewayQueueType">
@@ -3097,8 +3108,7 @@ An gateway event listener definition for the gateway
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:any namespace="##other" processContents="skip"
minOccurs="0" maxOccurs="unbounded">
<xsd:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Inner bean definition of the gateway event listener

View File

@@ -94,6 +94,7 @@ public class GatewayHubNamespaceTest {
assertEquals("localhost", gatewayHub.getBindAddress());
assertEquals("TestGatewayHub", gatewayHub.getId());
assertTrue(gatewayHub.getManualStart());
assertEquals(125, gatewayHub.getMaxConnections());
assertEquals(5000, gatewayHub.getMaximumTimeBetweenPings());
assertEquals(45123, gatewayHub.getPort());
assertEquals(16384, gatewayHub.getSocketBufferSize());

View File

@@ -51,7 +51,7 @@ public class MockGatewayHubFactory extends AbstractMockerySupport {
private Boolean manualStart = GatewayHub.DEFAULT_MANUAL_START;
//private Integer maximumConnections = GatewayHub.DEFAULT_MAXIMUM_CONNECTIONS;
private Integer maximumConnections = GatewayHub.DEFAULT_MAX_CONNECTIONS;
private Integer maximumTimeBetweenPings = GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS;
private Integer socketBufferSize = GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE;
@@ -94,20 +94,18 @@ public class MockGatewayHubFactory extends AbstractMockerySupport {
}
});
/*
doAnswer(new Answer<Void>() {
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
maximumConnections = invocation.getArgumentAt(0, Integer.class);
return null;
}
}).when(mockGatewayHub).setMaximumConnections(anyInt());
}).when(mockGatewayHub).setMaxConnections(anyInt());
when(mockGatewayHub.getMaximumConnections()).thenAnswer(new Answer<Integer>() {
when(mockGatewayHub.getMaxConnections()).thenAnswer(new Answer<Integer>() {
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
return maximumConnections;
}
});
*/
doAnswer(new Answer<Void>() {
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {

View File

@@ -97,7 +97,6 @@ public class GatewayHubFactoryBeanTest {
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
}
/*
@Test
public void testSetAndGetMaxConnections() {
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
@@ -106,7 +105,6 @@ public class GatewayHubFactoryBeanTest {
factoryBean.setMaxConnections(null);
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
}
*/
@Test
public void testSetAndGetMaximumTimeBetweenPings() {
@@ -225,7 +223,7 @@ public class GatewayHubFactoryBeanTest {
factoryBean.setBindAddress("10.124.210.42");
factoryBean.setGateways(Arrays.asList(gatewayProxy));
factoryBean.setManualStart(false);
//factoryBean.setMaxConnections(50);
factoryBean.setMaxConnections(50);
factoryBean.setMaximumTimeBetweenPings(20480);
factoryBean.setName(gatewayHubName);
factoryBean.setPort(8484);
@@ -235,7 +233,7 @@ public class GatewayHubFactoryBeanTest {
verify(mockGatewayHub, times(1)).setBindAddress(eq("10.124.210.42"));
verify(mockGatewayHub, times(1)).setManualStart(eq(false));
//verify(mockGatewayHub, times(1)).setMaxConnections(eq(50));
verify(mockGatewayHub, times(1)).setMaxConnections(eq(50));
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(20480));
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(4096));
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(StartupPolicyType.PRIMARY.getName()));
@@ -305,6 +303,7 @@ public class GatewayHubFactoryBeanTest {
verify(mockGatewayHub, times(1)).setBindAddress(eq(GatewayHub.DEFAULT_BIND_ADDRESS));
verify(mockGatewayHub, times(1)).setManualStart(eq(GatewayHub.DEFAULT_MANUAL_START));
verify(mockGatewayHub, times(1)).setMaxConnections(GatewayHub.DEFAULT_MAX_CONNECTIONS);
verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS));
verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE));
verify(mockGatewayHub, times(1)).setStartupPolicy(eq(GatewayHub.DEFAULT_STARTUP_POLICY));

View File

@@ -26,8 +26,8 @@
<bean name="ListenerTwo" class="org.springframework.data.gemfire.config.GatewayHubNamespaceTest.TestGatewayListener" p:name="ListenerTwo"/>
<gfe:gateway-hub id="TestGatewayHub" bind-address="localhost" manual-start="true" max-time-between-pings="5000"
port="45123" socket-buffer-size="16384" startup-policy="primary">
<gfe:gateway-hub id="TestGatewayHub" bind-address="localhost" manual-start="true" max-connections="125"
max-time-between-pings="5000" port="45123" socket-buffer-size="16384" startup-policy="primary">
<gfe:gateway gateway-id="gateway1" concurrency-level="8" order-policy="thread" socket-buffer-size="65536"
socket-read-timeout="75000">
<gfe:gateway-listener>