Skip to content

Commit e88ab47

Browse files
committed
Merge branch '2.0' into 2.1
2 parents a514589 + f5c549b commit e88ab47

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

driver-core/src/main/java/com/datastax/driver/core/Cluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class Cluster implements Closeable {
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

driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ public class PoolingOptions {
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 @@ public int getCoreConnectionsPerHost(HostDistance distance) {
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 @@ public int getMaxConnectionsPerHost(HostDistance distance) {
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

driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,47 @@ public void should_parse_UDT_definitions_when_using_default_protocol_version() {
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

0 commit comments

Comments
 (0)