Elffuss BraidHub

kikocis/java-driver public

Handle case where [UP, ADDED] are coalesced together.
Changesetab7df558141e40ba9c4ff223a9065d6d8f01a4b29d099118cf733b18d16d7075
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-24 12:04 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2015-08-28 11:24 +02:00
Parents3ddbf39029e8

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +8 −1
@@ -2448,8 +2448,15 @@
24482448 break;
24492449 case ADDED:
24502450 Host newHost = metadata.add(address);
2451- if (newHost != null)
2451+ if (newHost != null) {
24522452 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+ }
24532460 break;
24542461 case DOWN:
24552462 // 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 @@
6969 ccm.start(2);
7070 ccm.waitForUp(2);
7171
72- assertThat(cluster).host(2).comesUpWithin(120, SECONDS);
72+ assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS);
7373
7474 // Give the control connection a few moments to reconnect
7575 TimeUnit.MILLISECONDS.sleep(reconnectionDelay * 2);
@@ -128,7 +128,7 @@
128128 authProvider.setPassword("cassandra");
129129
130130 // 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);
132132 } finally {
133133 if (cluster != null)
134134 cluster.close();
@@ -168,7 +168,7 @@
168168 ccm.waitForUp(2);
169169
170170 // 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);
172172
173173 } finally {
174174 if (cluster != null)
@@ -229,7 +229,7 @@
229229 // Trigger another one-time reconnection attempt (this will succeed). The
230230 // host should be back up.
231231 host1.tryReconnectOnce();
232- assertThat(cluster).host(1).comesUpWithin(120, SECONDS);
232+ assertThat(cluster).host(1).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS);
233233 } finally {
234234 if (cluster != null)
235235 cluster.close();
@@ -285,7 +285,7 @@
285285 // Reset the spy and count the number of connections attempts for 1 reconnect
286286 reset(socketOptions);
287287 host1.tryReconnectOnce();
288- assertThat(cluster).host(1).comesUpWithin(120, SECONDS);
288+ assertThat(cluster).host(1).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS*2, SECONDS);
289289 // Expect 1 connection from the reconnection attempt 3 for the pools (we need 4
290290 // but the one from the reconnection attempt gets reused).
291291 verify(socketOptions, times(4)).getKeepAlive();