Elffuss BraidHub

kikocis/java-driver public

Relax isNotReconnectingFromDown for JAVA-970.

JAVA-970 is not critical enough to justify the risk of a fix, therefore
relax this assertion to check for up to 30 seconds for a down host to
not be attempting a reconnect.
Changesete64fa6054060286785a223794421f7981120e4a65541b5aa0673e30e7166e7e5
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-04-26 13:37 -05:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-04-26 13:37 -05:00
Parentsd76375dddc36

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +14 −3
@@ -20,9 +20,11 @@
2020 import com.datastax.driver.core.policies.LoadBalancingPolicy;
2121 import org.assertj.core.api.AbstractAssert;
2222
23+import java.util.concurrent.Callable;
2324 import java.util.concurrent.CountDownLatch;
2425 import java.util.concurrent.TimeUnit;
2526
27+import static com.datastax.driver.core.ConditionChecker.check;
2628 import static org.assertj.core.api.Assertions.assertThat;
2729 import static org.assertj.core.api.Assertions.fail;
2830
@@ -72,9 +74,18 @@
7274 }
7375
7476 public HostAssert isNotReconnectingFromDown() {
75- assertThat(actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone())
76- .isFalse();
77- return this;
77+ // Ensure that host is not attempting a reconnect. Because of JAVA-970 we cannot
78+ // be sure that there is a race and another pool is created before the host is marked down so we
79+ // check to see it stops after 30 seconds.
80+ // TODO: Change this to check only once if JAVA-970 is fixed.
81+ check().before(30, TimeUnit.SECONDS).that(new Callable<Boolean>() {
82+ @Override
83+ public Boolean call() throws Exception {
84+ // Whether or not host is down and reconnection attempt is in progress.
85+ return actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone();
86+ }
87+ }).becomesFalse();
88+ return this.isDown();
7889 }
7990
8091 public HostAssert comesUpWithin(long duration, TimeUnit unit) {