Elffuss BraidHub

kikocis/java-driver public

Update listener in comesUpWithin to also check for onAdd events.

This fixes PoolingOptionsTest#should_refresh_single_connected hosts.
This test was previously failing on jenkins as the Host is not always
marked up as soon as waitForUp completes as establishing the pool takes
just long enough in a constrained environment to cause the Host not to
be in an 'UP' state when comesUpWithin is called.  This would be fine
except that sometimes Cassandra inconsistently doesn't sent an 'UP'
topology status change event for new nodes (< 2.1 versions), so 'onUp'
is never called in the listener.  Checking for onAdd fixes this as well,
and we can be assured that the Host is actually up when this happens as
onAdd is invoked as soon as the pools are established.
Changeseta5cf2157144a121c73c408ab9224d270ba496b4ca05eac952bb64c47b11b4299
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-01-30 17:17 -06:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-02-13 07:23 -06:00
Parents988a52e52aee

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +9 −0
@@ -35,9 +35,18 @@
3535 public HostAssert comesUpWithin(long duration, TimeUnit unit) {
3636 final CountDownLatch upSignal = new CountDownLatch(1);
3737 StateListener upListener = new StateListenerBase() {
38+
39+ @Override
3840 public void onUp(Host host) {
3941 upSignal.countDown();
4042 }
43+
44+ @Override
45+ public void onAdd(Host host) {
46+ // Special case, cassandra will sometimes not send an 'UP' topology change event
47+ // for a new node, because of this we also listen for add events.
48+ upSignal.countDown();
49+ }
4150 };
4251 cluster.register(upListener);
4352 try {