kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 7c922ee2062093c1ca3eb3f806134985117a1a0ddd5000c9d47aafdc16d7cd09 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-22 23:01 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-22 23:01 +01:00 |
| Parents | ff3be4539708, 2f7ab0de2ec4 |
3 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +1 −1
| @@ -74,7 +74,7 @@ | ||
| 74 | 74 | |
| 75 | 75 | private static final int DEFAULT_THREAD_KEEP_ALIVE = 30; |
| 76 | 76 | |
| 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); | |
| 78 | 78 | |
| 79 | 79 | final Manager manager; |
| 80 | 80 |
modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java +18 −2
| @@ -35,6 +35,12 @@ | ||
| 35 | 35 | * reclaimed if the use of opened connections drops below the |
| 36 | 36 | * configured threshold ({@link #getMinSimultaneousRequestsPerConnectionThreshold}). |
| 37 | 37 | * <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> | |
| 38 | 44 | * <b>With {@code ProtocolVersion#V3} or above:</b> |
| 39 | 45 | * the driver uses a single connection for each {@code LOCAL} or {@code REMOTE} |
| 40 | 46 | * host. This connection can handle a larger amount of simultaneous requests, |
| @@ -49,8 +55,8 @@ | ||
| 49 | 55 | private static final int DEFAULT_MIN_REQUESTS_PER_CONNECTION = 25; |
| 50 | 56 | private static final int DEFAULT_MAX_REQUESTS_PER_CONNECTION = 100; |
| 51 | 57 | |
| 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; | |
| 54 | 60 | |
| 55 | 61 | private static final int DEFAULT_MAX_POOL_LOCAL = 8; |
| 56 | 62 | private static final int DEFAULT_MAX_POOL_REMOTE = 2; |
| @@ -192,6 +198,11 @@ | ||
| 192 | 198 | * Sets the core number of connections per host. |
| 193 | 199 | * <p> |
| 194 | 200 | * 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). | |
| 195 | 206 | * |
| 196 | 207 | * @param distance the {@code HostDistance} for which to set this threshold. |
| 197 | 208 | * @param newCoreConnections the value to set |
| @@ -231,6 +242,11 @@ | ||
| 231 | 242 | * Sets the maximum number of connections per host. |
| 232 | 243 | * <p> |
| 233 | 244 | * 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). | |
| 234 | 250 | * |
| 235 | 251 | * @param distance the {@code HostDistance} for which to set this threshold. |
| 236 | 252 | * @param newMaxConnections the value to set |
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +41 −0
| @@ -101,6 +101,47 @@ | ||
| 101 | 101 | ccm.remove(); |
| 102 | 102 | } |
| 103 | 103 | } |
| 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 | + } | |
| 104 | 145 | |
| 105 | 146 | static class QueryPlanCountingPolicy extends DelegatingLoadBalancingPolicy { |
| 106 | 147 |