Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.0' into 2.1
Changeset7c922ee2062093c1ca3eb3f806134985117a1a0ddd5000c9d47aafdc16d7cd09
Authorolim7t <omichallat+github@gmail.com> · 2014-12-22 23:01 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-12-22 23:01 +01:00
Parentsff3be4539708, 2f7ab0de2ec4

Browse the files at this changeset

3 files changed

modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +1 −1
@@ -74,7 +74,7 @@
7474
7575 private static final int DEFAULT_THREAD_KEEP_ALIVE = 30;
7676
77- private static final int NOTIF_LOCK_TIMEOUT_SECONDS = 60;
77+ private static final int NOTIF_LOCK_TIMEOUT_SECONDS = SystemProperties.getInt("com.datastax.driver.NOTIF_LOCK_TIMEOUT_SECONDS", 60);
7878
7979 final Manager manager;
8080
modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java +18 −2
@@ -35,6 +35,12 @@
3535 * reclaimed if the use of opened connections drops below the
3636 * configured threshold ({@link #getMinSimultaneousRequestsPerConnectionThreshold}).
3737 * <p>
38+ * Due to known issues with the current {@code ProtocolVersion#V2} pool implementation (see
39+ * <a href="https://datastax-oss.atlassian.net/browse/JAVA-419">JAVA-419</a>),
40+ * it is <b>strongly recommended</b> to use a fixed-size pool (core connections =
41+ * max connections).
42+ * The default values respect this (8 for local hosts, 2 for remote hosts).
43+ * <p>
3844 * <b>With {@code ProtocolVersion#V3} or above:</b>
3945 * the driver uses a single connection for each {@code LOCAL} or {@code REMOTE}
4046 * host. This connection can handle a larger amount of simultaneous requests,
@@ -49,8 +55,8 @@
4955 private static final int DEFAULT_MIN_REQUESTS_PER_CONNECTION = 25;
5056 private static final int DEFAULT_MAX_REQUESTS_PER_CONNECTION = 100;
5157
52- private static final int DEFAULT_CORE_POOL_LOCAL = 2;
53- private static final int DEFAULT_CORE_POOL_REMOTE = 1;
58+ private static final int DEFAULT_CORE_POOL_LOCAL = 8;
59+ private static final int DEFAULT_CORE_POOL_REMOTE = 2;
5460
5561 private static final int DEFAULT_MAX_POOL_LOCAL = 8;
5662 private static final int DEFAULT_MAX_POOL_REMOTE = 2;
@@ -192,6 +198,11 @@
192198 * Sets the core number of connections per host.
193199 * <p>
194200 * This option is only used with {@code ProtocolVersion#V2} or below.
201+ * <p>
202+ * Due to known issues with the current pool implementation (see
203+ * <a href="https://datastax-oss.atlassian.net/browse/JAVA-419">JAVA-419</a>),
204+ * it is <b>strongly recommended</b> to use a fixed-size pool (core connections =
205+ * max connections).
195206 *
196207 * @param distance the {@code HostDistance} for which to set this threshold.
197208 * @param newCoreConnections the value to set
@@ -231,6 +242,11 @@
231242 * Sets the maximum number of connections per host.
232243 * <p>
233244 * This option is only used with {@code ProtocolVersion#V2} or below.
245+ * <p>
246+ * Due to known issues with the current pool implementation (see
247+ * <a href="https://datastax-oss.atlassian.net/browse/JAVA-419">JAVA-419</a>),
248+ * it is <b>strongly recommended</b> to use a fixed-size pool (core connections =
249+ * max connections).
234250 *
235251 * @param distance the {@code HostDistance} for which to set this threshold.
236252 * @param newMaxConnections the value to set
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +41 −0
@@ -101,6 +101,47 @@
101101 ccm.remove();
102102 }
103103 }
104+
105+ /**
106+ * Ensures that if the host that the Control Connection is connected to is removed/decommissioned that the
107+ * Control Connection is reestablished to another host.
108+ *
109+ * @since 2.0.9
110+ * @jira_ticket JAVA-597
111+ * @expected_result Control Connection is reestablished to another host.
112+ * @test_category control_connection
113+ */
114+ @Test(groups = "long")
115+ public void should_reestablish_if_control_node_decommissioned() throws InterruptedException {
116+ CCMBridge ccm = null;
117+ Cluster cluster = null;
118+
119+ try {
120+ ccm = CCMBridge.create("test", 3);
121+
122+ cluster = Cluster.builder()
123+ .addContactPoint(CCMBridge.ipOfNode(1))
124+ .build();
125+ cluster.init();
126+
127+ // Ensure the control connection host is that of the first node.
128+ String controlHost = cluster.manager.controlConnection.connectedHost().getAddress().getHostAddress();
129+ assertThat(controlHost).isEqualTo(CCMBridge.ipOfNode(1));
130+
131+ // Decommission the node.
132+ ccm.decommissionNode(1);
133+
134+ // Ensure that the new control connection is not null and it's host is not equal to the decommissioned node.
135+ Host newHost = cluster.manager.controlConnection.connectedHost();
136+ assertThat(newHost).isNotNull();
137+ assertThat(newHost.getAddress().getHostAddress()).isNotEqualTo(controlHost);
138+ } finally {
139+ if (cluster != null)
140+ cluster.close();
141+ if (ccm != null)
142+ ccm.remove();
143+ }
144+ }
104145
105146 static class QueryPlanCountingPolicy extends DelegatingLoadBalancingPolicy {
106147