Elffuss BraidHub

kikocis/java-driver public

Merge 2.1 bugfixes to 3.0.x

This commit merges the following commits from 2.1:

5228a2a - Merge pull request #647 from datastax/java1152
77dcf91 - Merge pull request #659 from datastax/various-test-fixes
Changeset6639672315a23ed09bde06e8e145a9e2d9a978c444bf617f22e08658b610437a
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-05-02 15:03 +02:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-05-02 15:03 +02:00
Parents6d192516fada, 9c9a5537845d

Browse the files at this changeset

4 files changed

modified changelog/README.md +1 −0
@@ -40,6 +40,7 @@
4040 - [bug] JAVA-1005: DowngradingConsistencyRetryPolicy does not work with EACH_QUORUM when 1 DC is down.
4141 - [bug] JAVA-1002: Avoid deadlock when re-preparing a statement on other hosts.
4242 - [bug] JAVA-1072: Ensure defunct connections are properly evicted from the pool.
43+- [bug] JAVA-1152: Fix NPE at ControlConnection.refreshNodeListAndTokenMap().
4344
4445
4546 ### 3.0.0
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +2 −0
@@ -582,6 +582,8 @@
582582 continue;
583583
584584 InetSocketAddress rpcAddress = rpcAddressForPeerHost(row, connection.address, cluster);
585+ if (rpcAddress == null)
586+ continue;
585587 foundHosts.add(rpcAddress);
586588 dcs.add(row.getString("data_center"));
587589 racks.add(row.getString("rack"));
modified driver-core/src/test/java/com/datastax/driver/core/CCMCache.java +3 −3
@@ -271,10 +271,10 @@
271271 // CCM nodes are started with -Xms500M -Xmx500M
272272 // and allocate up to 100MB non-heap memory in the general case,
273273 // to be conservative we treat 1 "slot" as 800Mb.
274- // We leave 2 slots out to avoid starving system memory,
274+ // We leave 3 slots out to avoid starving system memory,
275275 // and we pick a value with a minimum of 1 slot and a maximum of 8 slots.
276- // For example, an 8GB VM with ~6.5GB currently available heap will yield 6 slots ((6500/800) - 2 = 6).
277- long slotsAvailable = (freeMemoryMB / ONE_CCM_NODE_MB) - 2;
276+ // For example, an 8GB VM with ~6.5GB currently available heap will yield 5 slots ((6500/800) - 3 = 5).
277+ long slotsAvailable = (freeMemoryMB / ONE_CCM_NODE_MB) - 3;
278278 maximumWeight = Math.min(8, Math.max(1, slotsAvailable));
279279 } else {
280280 maximumWeight = Integer.parseInt(numberOfNodes);
modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +14 −3
@@ -21,9 +21,11 @@
2121 import org.assertj.core.api.AbstractAssert;
2222
2323 import java.net.InetAddress;
24+import java.util.concurrent.Callable;
2425 import java.util.concurrent.CountDownLatch;
2526 import java.util.concurrent.TimeUnit;
2627
28+import static com.datastax.driver.core.ConditionChecker.check;
2729 import static org.assertj.core.api.Assertions.assertThat;
2830 import static org.assertj.core.api.Assertions.fail;
2931
@@ -73,9 +75,18 @@
7375 }
7476
7577 public HostAssert isNotReconnectingFromDown() {
76- assertThat(actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone())
77- .isFalse();
78- return this;
78+ // Ensure that host is not attempting a reconnect. Because of JAVA-970 we cannot
79+ // be sure that there is a race and another pool is created before the host is marked down so we
80+ // check to see it stops after 30 seconds.
81+ // TODO: Change this to check only once if JAVA-970 is fixed.
82+ check().before(30, TimeUnit.SECONDS).that(new Callable<Boolean>() {
83+ @Override
84+ public Boolean call() throws Exception {
85+ // Whether or not host is down and reconnection attempt is in progress.
86+ return actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone();
87+ }
88+ }).becomesFalse();
89+ return this.isDown();
7990 }
8091
8192 public HostAssert comesUpWithin(long duration, TimeUnit unit) {