kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | ab7df558141e40ba9c4ff223a9065d6d8f01a4b29d099118cf733b18d16d7075 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-24 12:04 -05:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-08-28 11:24 +02:00 |
| Parents | 3ddbf39029e8 |
2 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +8 −1
| @@ -2448,8 +2448,15 @@ | ||
| 2448 | 2448 | break; |
| 2449 | 2449 | case ADDED: |
| 2450 | 2450 | Host newHost = metadata.add(address); |
| 2451 | - if (newHost != null) | |
| 2451 | + if (newHost != null) { | |
| 2452 | 2452 | futures.add(schedule(hostAdded(newHost))); |
| 2453 | + } else { | |
| 2454 | + // If host already existed, retrieve it and check its state, if it's not up schedule a | |
| 2455 | + // hostUp event. | |
| 2456 | + Host existingHost = metadata.getHost(address); | |
| 2457 | + if(!existingHost.isUp()) | |
| 2458 | + futures.add(schedule(hostUp(existingHost))); | |
| 2459 | + } | |
| 2453 | 2460 | break; |
| 2454 | 2461 | case DOWN: |
| 2455 | 2462 | // Note that there is a slight risk we can receive the event late and thus |
modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +5 −5
| @@ -69,7 +69,7 @@ | ||
| 69 | 69 | ccm.start(2); |
| 70 | 70 | ccm.waitForUp(2); |
| 71 | 71 | |
| 72 | - assertThat(cluster).host(2).comesUpWithin(120, SECONDS); | |
| 72 | + assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS); | |
| 73 | 73 | |
| 74 | 74 | // Give the control connection a few moments to reconnect |
| 75 | 75 | TimeUnit.MILLISECONDS.sleep(reconnectionDelay * 2); |
| @@ -128,7 +128,7 @@ | ||
| 128 | 128 | authProvider.setPassword("cassandra"); |
| 129 | 129 | |
| 130 | 130 | // The driver should eventually reconnect to the node |
| 131 | - assertThat(cluster).host(1).comesUpWithin(120, SECONDS); | |
| 131 | + assertThat(cluster).host(1).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS); | |
| 132 | 132 | } finally { |
| 133 | 133 | if (cluster != null) |
| 134 | 134 | cluster.close(); |
| @@ -168,7 +168,7 @@ | ||
| 168 | 168 | ccm.waitForUp(2); |
| 169 | 169 | |
| 170 | 170 | // The driver should now see the node as UP again |
| 171 | - assertThat(cluster).host(2).comesUpWithin(120, SECONDS); | |
| 171 | + assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS); | |
| 172 | 172 | |
| 173 | 173 | } finally { |
| 174 | 174 | if (cluster != null) |
| @@ -229,7 +229,7 @@ | ||
| 229 | 229 | // Trigger another one-time reconnection attempt (this will succeed). The |
| 230 | 230 | // host should be back up. |
| 231 | 231 | host1.tryReconnectOnce(); |
| 232 | - assertThat(cluster).host(1).comesUpWithin(120, SECONDS); | |
| 232 | + assertThat(cluster).host(1).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS); | |
| 233 | 233 | } finally { |
| 234 | 234 | if (cluster != null) |
| 235 | 235 | cluster.close(); |
| @@ -285,7 +285,7 @@ | ||
| 285 | 285 | // Reset the spy and count the number of connections attempts for 1 reconnect |
| 286 | 286 | reset(socketOptions); |
| 287 | 287 | host1.tryReconnectOnce(); |
| 288 | - assertThat(cluster).host(1).comesUpWithin(120, SECONDS); | |
| 288 | + assertThat(cluster).host(1).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS); | |
| 289 | 289 | // Expect 1 connection from the reconnection attempt 3 for the pools (we need 4 |
| 290 | 290 | // but the one from the reconnection attempt gets reused). |
| 291 | 291 | verify(socketOptions, times(4)).getKeepAlive(); |