DATACASS-347 - Support NettyOptions configuration in XML-based configuration.

We now support `NettyOptions` bean references in XML-based configuration.

<bean id="nettyOptions" class="…" />

<cass:cluster contact-points="…" netty-options-ref="nettyOptions" />
This commit is contained in:
Mark Paluch
2016-10-12 11:47:07 +02:00
parent 45d77ff73e
commit add4cab01b
12 changed files with 59 additions and 26 deletions

View File

@@ -263,6 +263,24 @@ LoadBalancingPolicy implementation.
<xsd:union memberTypes="xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="netty-options-ref" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
NettyOptions implementation reference.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to
type="com.datastax.driver.core.NettyOptions" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="max-queue-size" type="xsd:string" default="256" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[

View File

@@ -44,6 +44,7 @@ import org.w3c.dom.NodeList;
* Test suite of Unit tests testing the contract and functionality of the {@link CassandraCqlClusterParser}.
*
* @author John Blum
* @author Mark Paluch
*/
// TODO add more tests!
@RunWith(MockitoJUnitRunner.class)
@@ -92,6 +93,7 @@ public class CassandraCqlClusterParserUnitTests {
when(mockElement.getAttribute("host-state-listener-ref")).thenReturn("testHostStateListener");
when(mockElement.getAttribute("latency-tracker-ref")).thenReturn("testLatencyTracker");
when(mockElement.getAttribute("load-balancing-policy-ref")).thenReturn("testLoadBalancingPolicy");
when(mockElement.getAttribute("netty-options-ref")).thenReturn("testNettyOptions");
when(mockElement.getAttribute("reconnection-policy-ref")).thenReturn("testReconnectionPolicy");
when(mockElement.getAttribute("retry-policy-ref")).thenReturn("testRetryPolicy");
when(mockElement.getAttribute("speculative-execution-policy-ref")).thenReturn("testSpeculativeExecutionPolicy");
@@ -129,6 +131,7 @@ public class CassandraCqlClusterParserUnitTests {
assertThat(getPropertyValueAsString(beanDefinition, "hostStateListener"), is(equalTo("testHostStateListener")));
assertThat(getPropertyValueAsString(beanDefinition, "latencyTracker"), is(equalTo("testLatencyTracker")));
assertThat(getPropertyValueAsString(beanDefinition, "loadBalancingPolicy"), is(equalTo("testLoadBalancingPolicy")));
assertThat(getPropertyValueAsString(beanDefinition, "nettyOptions"), is(equalTo("testNettyOptions")));
assertThat(getPropertyValueAsString(beanDefinition, "reconnectionPolicy"), is(equalTo("testReconnectionPolicy")));
assertThat(getPropertyValueAsString(beanDefinition, "retryPolicy"), is(equalTo("testRetryPolicy")));
assertThat(getPropertyValueAsString(beanDefinition, "speculativeExecutionPolicy"), is(equalTo("testSpeculativeExecutionPolicy")));
@@ -152,6 +155,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq("host-state-listener-ref"));
verify(mockElement).getAttribute(eq("latency-tracker-ref"));
verify(mockElement).getAttribute(eq("load-balancing-policy-ref"));
verify(mockElement).getAttribute(eq("netty-options-ref"));
verify(mockElement).getAttribute(eq("reconnection-policy-ref"));
verify(mockElement).getAttribute(eq("retry-policy-ref"));
verify(mockElement).getAttribute(eq("speculative-execution-policy-ref"));

View File

@@ -10,7 +10,9 @@
<context:property-placeholder
location="classpath:/config/cassandra-connection.properties,classpath:/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.properties" />
<cass:cluster port="${build.cassandra.native_transport_port}" compression="LZ4">
<bean id="nettyOptions" class="org.springframework.cassandra.test.integration.support.FastShutdownNettyOptions" />
<cass:cluster port="${build.cassandra.native_transport_port}" compression="LZ4" netty-options-ref="nettyOptions">
<cass:keyspace action="CREATE_DROP" durable-writes="true"
name="full1">
<cass:replication class="SIMPLE_STRATEGY">

View File

@@ -23,6 +23,8 @@
<bean name="testTimestampGenerator" class="com.datastax.driver.core.AtomicMonotonicTimestampGenerator"/>
<bean id="nettyOptions" class="org.springframework.cassandra.test.integration.support.FastShutdownNettyOptions" />
<cassandra:cluster
cluster-name="skynet" contact-points="localhost" port="${build.cassandra.native_transport_port}"
address-translator-ref="testAddressTranslator"
@@ -33,7 +35,9 @@
max-schema-agreement-wait-seconds="2"
pool-timeout-milliseconds="15000"
speculative-execution-policy-ref="testSpeculativeExecutionPolicy"
timestamp-generator-ref="testTimestampGenerator">
timestamp-generator-ref="testTimestampGenerator"
netty-options-ref="nettyOptions"
>
<cassandra:local-pooling-options
core-connections="2"

View File

@@ -272,6 +272,24 @@ LoadBalancingPolicy implementation.
<xsd:union memberTypes="xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="netty-options-ref" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
NettyOptions implementation reference.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:assignable-to
type="com.datastax.driver.core.NettyOptions" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="max-queue-size" type="xsd:string" default="256" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[

View File

@@ -13,6 +13,8 @@
<constructor-arg value="#{T(org.springframework.cassandra.support.RandomKeySpaceName).create()}"/>
</bean>
<bean id="nettyOptions" class="org.springframework.cassandra.test.integration.support.FastShutdownNettyOptions" />
<context:property-placeholder location="classpath:/config/cassandra-connection.properties"/>
<cass:converter mapping-ref="cassandraMapping"/>

View File

@@ -4,15 +4,16 @@
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/cassandra http://www.springframework.org/schema/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="nettyOptions" class="org.springframework.cassandra.test.integration.support.FastShutdownNettyOptions" />
<context:property-placeholder
location="classpath:/config/cassandra-connection.properties,classpath:/org/springframework/data/cassandra/config/xml/cassandra.properties" />
<cass:cluster contact-points="${build.cassandra.host}"
port="${build.cassandra.native_transport_port}" compression="SNAPPY">
port="${build.cassandra.native_transport_port}" compression="SNAPPY" netty-options-ref="nettyOptions">
<cass:local-pooling-options
min-simultaneous-requests="26" max-simultaneous-requests="101"
core-connections="3" max-connections="9" />

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cass="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<import resource="classpath:/config/spring-data-cassandra-basic.xml" />
@@ -19,7 +15,7 @@
</cass:entity>
</cass:mapping>
<cass:cluster port="${build.cassandra.native_transport_port}">
<cass:cluster port="${build.cassandra.native_transport_port}" netty-options-ref="nettyOptions">
<cass:keyspace name="CommentRepositoryXmlConfigIntegrationTests"
action="CREATE_DROP" durable-writes="true">
</cass:keyspace>

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cass="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<import resource="classpath:/config/spring-data-cassandra-basic.xml" />
@@ -30,7 +26,7 @@
</cass:entity>
</cass:mapping>
<cass:cluster port="${build.cassandra.native_transport_port}">
<cass:cluster port="${build.cassandra.native_transport_port}" netty-options-ref="nettyOptions">
<cass:keyspace name="#{randomKeyspaceName}"
action="CREATE_DROP" durable-writes="true">
</cass:keyspace>

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cass="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<import resource="classpath:/config/spring-data-cassandra-basic.xml" />
@@ -40,7 +36,7 @@
</cass:entity>
</cass:mapping>
<cass:cluster port="${build.cassandra.native_transport_port}">
<cass:cluster port="${build.cassandra.native_transport_port}" netty-options-ref="nettyOptions">
<cass:keyspace name="ForceQuoteRepositoryXmlConfigIntegrationTests"
action="CREATE_DROP" durable-writes="true">
</cass:keyspace>

View File

@@ -16,7 +16,7 @@
</cass:entity>
</cass:mapping>
<cass:cluster port="${build.cassandra.native_transport_port}">
<cass:cluster port="${build.cassandra.native_transport_port}" netty-options-ref="nettyOptions">
<cass:keyspace name="#{randomKeyspaceName}"
action="CREATE_DROP" durable-writes="true">
</cass:keyspace>

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cass="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<import resource="classpath:/config/spring-data-cassandra-basic.xml" />
@@ -15,7 +11,7 @@
<cass:mapping
entity-base-packages="org.springframework.data.cassandra.test.integration.xmlentityscanning" />
<cass:cluster port="${build.cassandra.native_transport_port}">
<cass:cluster port="${build.cassandra.native_transport_port}" netty-options-ref="nettyOptions">
<cass:keyspace name="#{randomKeyspaceName}"
action="CREATE_DROP" durable-writes="true">
</cass:keyspace>