Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.1' into 3.0

Conflicts:
	driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java
	driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java
	driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java
	driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java
	driver-core/src/test/java/com/datastax/driver/core/EventDebouncerIntegrationTest.java
	driver-core/src/test/java/com/datastax/driver/core/HeartbeatTest.java
	driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolMultiTest.java
	driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java
	driver-core/src/test/java/com/datastax/driver/core/MetadataTest.java
	driver-core/src/test/java/com/datastax/driver/core/MissingRpcAddressTest.java
	driver-core/src/test/java/com/datastax/driver/core/NettyOptionsTest.java
	driver-core/src/test/java/com/datastax/driver/core/NodeRefreshDebouncerTest.java
	driver-core/src/test/java/com/datastax/driver/core/QueryOptionsTest.java
	driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java
	driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java
	driver-core/src/test/java/com/datastax/driver/core/RefreshConnectedHostTest.java
	driver-core/src/test/java/com/datastax/driver/core/SSLEncryptionTest.java
	driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java
	driver-core/src/test/java/com/datastax/driver/core/ScassandraCluster.java
	driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java
	driver-core/src/test/java/com/datastax/driver/core/SessionLeakTest.java
	driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java
	driver-core/src/test/java/com/datastax/driver/core/TestUtils.java
	driver-core/src/test/java/com/datastax/driver/core/exceptions/ExceptionsScassandraTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/AbstractRetryPolicyIntegrationTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/DCAwareRoundRobinPolicyTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/DefaultRetryPolicyIntegrationTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/DowngradingConsistencyRetryPolicyIntegrationTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/RoundRobinPolicyTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/TokenAwarePolicyTest.java
	driver-core/src/test/java/com/datastax/driver/core/policies/WhiteListPolicyTest.java
	driver-mapping/src/test/java/com/datastax/driver/mapping/UDTFieldMapperTest.java
Changeseta09129ebe89a3d35cfbd0346ea1579cd919ddbadc6d42b0d76719d37261055a2
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 18:47 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 18:47 +01:00
Parents542f59d6e0ec, 446aa287b841

Browse the files at this changeset

47 files changed

modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java +19 −1
@@ -50,7 +50,21 @@
5050 */
5151 public class PoolingOptions {
5252
53- static final int UNSET = Integer.MIN_VALUE;
53+ /**
54+ * The value returned for connection options when they have not been set by the client, and the protocol version
55+ * is not known yet.
56+ * <p/>
57+ * Once a {@code PoolingOptions} object is associated to a {@link Cluster} and that cluster initializes, the
58+ * protocol version will be detected, and connection options will take their default values for that protocol
59+ * version.
60+ * <p/>
61+ * The methods that may return this value are:
62+ * {@link #getCoreConnectionsPerHost(HostDistance)},
63+ * {@link #getMaxConnectionsPerHost(HostDistance)},
64+ * {@link #getNewConnectionThreshold(HostDistance)},
65+ * {@link #getMaxRequestsPerConnection(HostDistance)}.
66+ */
67+ public static final int UNSET = Integer.MIN_VALUE;
5468
5569 private static final Map<ProtocolVersion, Map<String, Integer>> DEFAULTS = ImmutableMap.<ProtocolVersion, Map<String, Integer>>of(
5670 ProtocolVersion.V2, ImmutableMap.<String, Integer>builder()
@@ -139,6 +153,7 @@
139153 public synchronized PoolingOptions setCoreConnectionsPerHost(HostDistance distance, int newCoreConnections) {
140154 if (distance == HostDistance.IGNORED)
141155 throw new IllegalArgumentException("Cannot set core connections per host for " + distance + " hosts");
156+ Preconditions.checkArgument(newCoreConnections >= 0, "core number of connections must be positive");
142157
143158 if (maxConnections[distance.ordinal()] != UNSET)
144159 checkConnectionsPerHostOrder(newCoreConnections, maxConnections[distance.ordinal()], distance);
@@ -182,6 +197,7 @@
182197 public synchronized PoolingOptions setMaxConnectionsPerHost(HostDistance distance, int newMaxConnections) {
183198 if (distance == HostDistance.IGNORED)
184199 throw new IllegalArgumentException("Cannot set max connections per host for " + distance + " hosts");
200+ Preconditions.checkArgument(newMaxConnections >= 0, "max number of connections must be positive");
185201
186202 if (coreConnections[distance.ordinal()] != UNSET)
187203 checkConnectionsPerHostOrder(coreConnections[distance.ordinal()], newMaxConnections, distance);
@@ -206,6 +222,8 @@
206222 public synchronized PoolingOptions setConnectionsPerHost(HostDistance distance, int core, int max) {
207223 if (distance == HostDistance.IGNORED)
208224 throw new IllegalArgumentException("Cannot set connections per host for " + distance + " hosts");
225+ Preconditions.checkArgument(core >= 0, "core number of connections must be positive");
226+ Preconditions.checkArgument(max >= 0, "max number of connections must be positive");
209227
210228 checkConnectionsPerHostOrder(core, max, distance);
211229 coreConnections[distance.ordinal()] = core;
modified driver-core/src/test/java/com/datastax/driver/core/AuthenticationTest.java +3 −3
@@ -50,7 +50,7 @@
5050 PlainTextAuthProvider authProvider = spy(new PlainTextAuthProvider("cassandra", "cassandra"));
5151 Cluster cluster = Cluster.builder()
5252 .addContactPointsWithPorts(getInitialContactPoints())
53- .withAddressTranslator(getAddressTranslator())
53+ .withPort(ccm.getBinaryPort())
5454 .withAuthProvider(authProvider)
5555 .build();
5656 cluster.connect();
@@ -61,7 +61,7 @@
6161 public void should_fail_to_connect_with_wrong_credentials() throws InterruptedException {
6262 Cluster cluster = register(Cluster.builder()
6363 .addContactPointsWithPorts(getInitialContactPoints())
64- .withAddressTranslator(getAddressTranslator())
64+ .withPort(ccm.getBinaryPort())
6565 .withCredentials("bogus", "bogus")
6666 .build());
6767 cluster.connect();
@@ -71,7 +71,7 @@
7171 public void should_fail_to_connect_without_credentials() throws InterruptedException {
7272 Cluster cluster = register(Cluster.builder()
7373 .addContactPointsWithPorts(getInitialContactPoints())
74- .withAddressTranslator(getAddressTranslator())
74+ .withPort(ccm.getBinaryPort())
7575 .build());
7676 cluster.connect();
7777 }
added driver-core/src/test/java/com/datastax/driver/core/CCMAccess.java +219 −0
@@ -0,0 +1,219 @@
1+/*
2+ * Copyright (C) 2012-2015 DataStax Inc.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package com.datastax.driver.core;
17+
18+import java.io.Closeable;
19+import java.io.File;
20+import java.net.InetSocketAddress;
21+import java.util.Map;
22+
23+public interface CCMAccess extends Closeable {
24+
25+ // Inspection methods
26+
27+ /**
28+ * @return The CCM cluster name.
29+ */
30+ String getClusterName();
31+
32+ /**
33+ * Returns the Cassandra version of this CCM cluster.
34+ * <p/>
35+ * By default the version is equal to {@link CCMBridge#getCassandraVersion()}.
36+ *
37+ * @return The version of this CCM cluster.
38+ */
39+ VersionNumber getVersion();
40+
41+ /**
42+ * @return The config directory for this CCM cluster.
43+ */
44+ File getCcmDir();
45+
46+ /**
47+ * @return The cluster directory for this CCM cluster.
48+ */
49+ File getClusterDir();
50+
51+ /**
52+ * @param n the node number, starting with 1.
53+ * @return The node directory for this CCM cluster.
54+ */
55+ File getNodeDir(int n);
56+
57+ /**
58+ * @param n the node number, starting with 1.
59+ * @return The node config directory for this CCM cluster.
60+ */
61+ File getNodeConfDir(int n);
62+
63+ /**
64+ * @return The storage port for this CCM cluster.
65+ */
66+ int getStoragePort();
67+
68+ /**
69+ * @return The thrift port for this CCM cluster.
70+ */
71+ int getThriftPort();
72+
73+ /**
74+ * @return The binary port for this CCM cluster.
75+ */
76+ int getBinaryPort();
77+
78+ /**
79+ * Signals that logs for this CCM cluster should be kept after the cluster is stopped.
80+ */
81+ void setKeepLogs(boolean keepLogs);
82+
83+ /**
84+ * Returns the address of the {@code nth} host in the CCM cluster (counting from 1, i.e.,
85+ * {@code addressOfNode(1)} returns the address of the first node.
86+ * <p/>
87+ * In multi-DC setups, nodes are numbered in ascending order of their datacenter number.
88+ * E.g. with 2 DCs and 3 nodes in each DC, the first node in DC 2 is number 4.
89+ *
90+ * @return the address of the {@code nth} host in the cluster.
91+ */
92+ InetSocketAddress addressOfNode(int n);
93+
94+
95+ // Methods altering the whole cluster
96+
97+ /**
98+ * Starts the cluster.
99+ */
100+ void start();
101+
102+ /**
103+ * Stops the cluster.
104+ */
105+ void stop();
106+
107+ /**
108+ * Aggressively stops the cluster.
109+ */
110+ void forceStop();
111+
112+ /**
113+ * Alias for {@link #stop()}.
114+ */
115+ @Override
116+ void close();
117+
118+ /**
119+ * Removes this CCM cluster and deletes all of its files.
120+ */
121+ void remove();
122+
123+ /**
124+ * Updates the config files for all nodes in the CCM cluster.
125+ */
126+ void updateConfig(Map<String, Object> configs);
127+
128+ /**
129+ * Updates the DSE config files for all nodes in the CCM cluster.
130+ */
131+ void updateDSEConfig(Map<String, Object> configs);
132+
133+
134+ // Methods altering nodes
135+
136+ /**
137+ * Starts the {@code nth} host in the CCM cluster.
138+ *
139+ * @param n the node number (starting from 1).
140+ */
141+ void start(int n);
142+
143+ /**
144+ * Stops the {@code nth} host in the CCM cluster.
145+ *
146+ * @param n the node number (starting from 1).
147+ */
148+ void stop(int n);
149+
150+ /**
151+ * Aggressively stops the {@code nth} host in the CCM cluster.
152+ *
153+ * @param n the node number (starting from 1).
154+ */
155+ void forceStop(int n);
156+
157+ /**
158+ * Removes the {@code nth} host in the CCM cluster.
159+ *
160+ * @param n the node number (starting from 1).
161+ */
162+ void remove(int n);
163+
164+ /**
165+ * Adds the {@code nth} host in the CCM cluster.
166+ *
167+ * @param n the node number (starting from 1).
168+ */
169+ void add(int n);
170+
171+ /**
172+ * Adds the {@code nth} host in the CCM cluster.
173+ *
174+ * @param n the node number (starting from 1).
175+ */
176+ void add(int dc, int n);
177+
178+ /**
179+ * Decommissions the {@code nth} host in the CCM cluster.
180+ *
181+ * @param n the node number (starting from 1).
182+ */
183+ void decommision(int n);
184+
185+ /**
186+ * Updates the {@code nth} host's config file in the CCM cluster.
187+ *
188+ * @param n the node number (starting from 1).
189+ */
190+ void updateNodeConfig(int n, String key, Object value);
191+
192+ /**
193+ * Updates the {@code nth} host's config file in the CCM cluster.
194+ *
195+ * @param n the node number (starting from 1).
196+ */
197+ void updateNodeConfig(int n, Map<String, Object> configs);
198+
199+ /**
200+ * Sets the workload for the {@code nth} host in the CCM cluster.
201+ *
202+ * @param n the node number (starting from 1).
203+ */
204+ void setWorkload(int n, String workload);
205+
206+
207+ // Methods blocking until nodes are up or down
208+
209+ /**
210+ * Waits for a host to be up by pinging the TCP socket directly, without using the Java driver's API.
211+ */
212+ void waitForUp(int node);
213+
214+ /**
215+ * Waits for a host to be down by pinging the TCP socket directly, without using the Java driver's API.
216+ */
217+ void waitForDown(int node);
218+
219+}
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +70 −93
@@ -15,10 +15,10 @@
1515 */
1616 package com.datastax.driver.core;
1717
18-import com.datastax.driver.core.policies.AddressTranslator;
1918 import com.google.common.base.Joiner;
2019 import com.google.common.base.Throwables;
2120 import com.google.common.collect.ImmutableMap;
21+import com.google.common.collect.ImmutableSet;
2222 import com.google.common.collect.Maps;
2323 import com.google.common.io.ByteStreams;
2424 import com.google.common.io.Closer;
@@ -35,13 +35,13 @@
3535 import static com.datastax.driver.core.TestUtils.executeNoFail;
3636 import static com.datastax.driver.core.TestUtils.findAvailablePort;
3737
38-public class CCMBridge implements Closeable {
38+public class CCMBridge implements CCMAccess {
3939
4040 private static final Logger logger = LoggerFactory.getLogger(CCMBridge.class);
4141
4242 private static final String CASSANDRA_VERSION;
4343
44- private static final String CASSANDRA_INSTALL_ARGS;
44+ private static final Set<String> CASSANDRA_INSTALL_ARGS;
4545
4646 private static final boolean IS_DSE;
4747
@@ -137,23 +137,20 @@
137137 // otherwise if there is a value, parse as boolean.
138138 IS_DSE = dseProperty != null && (dseProperty.isEmpty() || Boolean.parseBoolean(dseProperty));
139139
140- StringBuilder installArgs = new StringBuilder();
140+ ImmutableSet.Builder<String> installArgs = ImmutableSet.builder();
141141 if (installDirectory != null && !installDirectory.trim().isEmpty()) {
142- installArgs.append("--install-dir=");
143- installArgs.append(new File(installDirectory).getAbsolutePath());
142+ installArgs.add("--install-dir=" + new File(installDirectory).getAbsolutePath());
144143 } else if (branch != null && !branch.trim().isEmpty()) {
145- installArgs.append("-v git:");
146- installArgs.append(branch.trim().replaceAll("\"", ""));
144+ installArgs.add("-v git:" + branch.trim().replaceAll("\"", ""));
147145 } else {
148- installArgs.append("-v ");
149- installArgs.append(CASSANDRA_VERSION);
146+ installArgs.add("-v " + CASSANDRA_VERSION);
150147 }
151148
152149 if (IS_DSE) {
153- installArgs.append(" --dse");
150+ installArgs.add("--dse");
154151 }
155152
156- CASSANDRA_INSTALL_ARGS = installArgs.toString();
153+ CASSANDRA_INSTALL_ARGS = installArgs.build();
157154
158155 // Inherit the current environment.
159156 Map<String, String> envMap = Maps.newHashMap(new ProcessBuilder().environment());
@@ -181,10 +178,10 @@
181178 ENVIRONMENT_MAP = ImmutableMap.copyOf(envMap);
182179
183180 if (CCMBridge.isDSE()) {
184- logger.info("Tests requiring CCM will use DSE version {} (C* {}, install arguments: {})",
181+ logger.info("Tests requiring CCM will by default use DSE version {} (C* {}, install arguments: {})",
185182 CCMBridge.getDSEVersion(), CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
186183 } else {
187- logger.info("Tests requiring CCM will use Cassandra version {} (install arguments: {})",
184+ logger.info("Tests requiring CCM will by default use Cassandra version {} (install arguments: {})",
188185 CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
189186 }
190187 }
@@ -216,13 +213,11 @@
216213
217214 private final String jvmArgs;
218215
219- private final int initialNumberOfNodes;
220-
221216 private boolean keepLogs = false;
222217
223218 private boolean closed = false;
224219
225- private CCMBridge(String clusterName, boolean isDSE, VersionNumber version, int storagePort, int thriftPort, int binaryPort, String jvmArgs, int initialNumberOfNodes) {
220+ private CCMBridge(String clusterName, boolean isDSE, VersionNumber version, int storagePort, int thriftPort, int binaryPort, String jvmArgs) {
226221 this.clusterName = clusterName;
227222 this.version = version;
228223 this.storagePort = storagePort;
@@ -230,7 +225,6 @@
230225 this.binaryPort = binaryPort;
231226 this.isDSE = isDSE;
232227 this.jvmArgs = jvmArgs;
233- this.initialNumberOfNodes = initialNumberOfNodes;
234228 this.ccmDir = Files.createTempDir();
235229 }
236230
@@ -287,7 +281,7 @@
287281 /**
288282 * @return The install arguments to pass to CCM when creating the cluster.
289283 */
290- public static String getInstallArguments() {
284+ public static Set<String> getInstallArguments() {
291285 return CASSANDRA_INSTALL_ARGS;
292286 }
293287
@@ -295,97 +289,57 @@
295289 return new Builder();
296290 }
297291
298- /**
299- * Returns the address of the {@code nth} host in the CCM cluster (counting from 1, i.e.,
300- * {@code getHostAddress(1)} returns the address of the first node.
301- * <p/>
302- * In multi-DC setups, nodes are numbered in ascending order of their datacenter number.
303- * E.g. with 2 DCs and 3 nodes in each DC, the first node in DC 2 is number 4.
304- *
305- * @return the address of the {@code nth} host in the cluster.
306- */
307- public InetSocketAddress addressOfNode(int n) {
308- return new InetSocketAddress(TestUtils.ipOfNode(n), binaryPort);
292+ @Override
293+ public String getClusterName() {
294+ return clusterName;
309295 }
310296
311- /**
312- * Returns an {@link AddressTranslator} to use when tests must manually create
313- * {@link Cluster} instances.
314- * <p/>
315- * This translator is necessary because hosts in this cluster do not necessarily use standard ports.
316- *
317- * @return an {@link AddressTranslator} to use when tests must manually create
318- * {@link Cluster} instances.
319- */
320- public AddressTranslator addressTranslator() {
321- return new AddressTranslator() {
322- @Override
323- public InetSocketAddress translate(InetSocketAddress address) {
324- return new InetSocketAddress(address.getAddress(), getBinaryPort());
325- }
326-
327- @Override
328- public void init(Cluster cluster) {
329-
330- }
331-
332- @Override
333- public void close() {
334-
335- }
336- };
297+ @Override
298+ public InetSocketAddress addressOfNode(int n) {
299+ return new InetSocketAddress(TestUtils.ipOfNode(n), binaryPort);
337300 }
338301
339- /**
340- * Returns the Cassandra version of this CCM cluster.
341- * <p/>
342- * By default the version is equal to {@link #getCassandraVersion()}.
343- *
344- * @return The version of this CCM cluster.
345- */
302+ @Override
346303 public VersionNumber getVersion() {
347304 return version;
348305 }
349306
350- /**
351- * The number of nodes that were initially created with this CCM instance.
352- * <p/>
353- * This does not account for nodes created or removed during the cluster's lifecycle.
354- *
355- * @return The number of nodes that were initially created with this CCM instance.
356- */
357- public int getInitialNumberOfNodes() {
358- return initialNumberOfNodes;
359- }
360-
307+ @Override
361308 public File getCcmDir() {
362309 return ccmDir;
363310 }
364311
312+ @Override
365313 public File getClusterDir() {
366314 return new File(ccmDir, clusterName);
367315 }
368316
317+ @Override
369318 public File getNodeDir(int n) {
370319 return new File(getClusterDir(), "node" + n);
371320 }
372321
322+ @Override
373323 public File getNodeConfDir(int n) {
374324 return new File(getNodeDir(n), "conf");
375325 }
376326
327+ @Override
377328 public int getStoragePort() {
378329 return storagePort;
379330 }
380331
332+ @Override
381333 public int getThriftPort() {
382334 return thriftPort;
383335 }
384336
337+ @Override
385338 public int getBinaryPort() {
386339 return binaryPort;
387340 }
388341
342+ @Override
389343 public void setKeepLogs(boolean keepLogs) {
390344 this.keepLogs = keepLogs;
391345 }
@@ -421,11 +375,13 @@
421375 logger.debug("Closed: " + this);
422376 }
423377
378+ @Override
424379 public void start() {
425380 logger.debug("Starting: " + this);
426381 execute(CCM_COMMAND + " start --wait-other-notice --wait-for-binary-proto" + jvmArgs);
427382 }
428383
384+ @Override
429385 public synchronized void stop() {
430386 if (closed)
431387 return;
@@ -434,6 +390,7 @@
434390 closed = true;
435391 }
436392
393+ @Override
437394 public synchronized void forceStop() {
438395 if (closed)
439396 return;
@@ -442,36 +399,43 @@
442399 closed = true;
443400 }
444401
402+ @Override
445403 public void start(int n) {
446404 logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
447405 execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto" + jvmArgs, n);
448406 }
449407
408+ @Override
450409 public void stop(int n) {
451410 logger.debug(String.format("Stopping: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
452411 execute(CCM_COMMAND + " node%d stop", n);
453412 }
454413
414+ @Override
455415 public void forceStop(int n) {
456416 logger.debug(String.format("Force stopping: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
457417 execute(CCM_COMMAND + " node%d stop --not-gently", n);
458418 }
459419
420+ @Override
460421 public synchronized void remove() {
461422 stop();
462423 logger.debug("Removing: " + this);
463424 execute(CCM_COMMAND + " remove");
464425 }
465426
427+ @Override
466428 public void remove(int n) {
467429 logger.debug(String.format("Removing: node %s (%s%s:%s) from %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
468430 execute(CCM_COMMAND + " node%d remove", n);
469431 }
470432
433+ @Override
471434 public void add(int n) {
472435 add(1, n);
473436 }
474437
438+ @Override
475439 public void add(int dc, int n) {
476440 logger.debug(String.format("Adding: node %s (%s%s:%s) to %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
477441 String thriftItf = TestUtils.ipOfNode(n) + ":" + thriftPort;
@@ -482,11 +446,13 @@
482446 n, dc, TestUtils.IP_PREFIX, n, thriftItf, storageItf, binaryItf, TestUtils.findAvailablePort(), remoteLogItf);
483447 }
484448
485- public void decommissionNode(int n) {
449+ @Override
450+ public void decommision(int n) {
486451 logger.debug(String.format("Decommissioning: node %s (%s%s:%s) from %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
487452 execute(CCM_COMMAND + " node%d decommission", n);
488453 }
489454
455+ @Override
490456 public void updateConfig(Map<String, Object> configs) {
491457 StringBuilder confStr = new StringBuilder();
492458 for (Map.Entry<String, Object> entry : configs.entrySet()) {
@@ -499,6 +465,7 @@
499465 execute(CCM_COMMAND + " updateconf " + confStr);
500466 }
501467
468+ @Override
502469 public void updateDSEConfig(Map<String, Object> configs) {
503470 StringBuilder confStr = new StringBuilder();
504471 for (Map.Entry<String, Object> entry : configs.entrySet()) {
@@ -511,10 +478,12 @@
511478 execute(CCM_COMMAND + " updatedseconf " + confStr);
512479 }
513480
481+ @Override
514482 public void updateNodeConfig(int n, String key, Object value) {
515483 updateNodeConfig(n, ImmutableMap.<String, Object>builder().put(key, value).build());
516484 }
517485
486+ @Override
518487 public void updateNodeConfig(int n, Map<String, Object> configs) {
519488 StringBuilder confStr = new StringBuilder();
520489 for (Map.Entry<String, Object> entry : configs.entrySet()) {
@@ -527,6 +496,7 @@
527496 execute(CCM_COMMAND + " node%s updateconf %s", n, confStr);
528497 }
529498
499+ @Override
530500 public void setWorkload(int node, String workload) {
531501 execute(CCM_COMMAND + " node%d setworkload %s", node, workload);
532502 }
@@ -633,6 +603,12 @@
633603 return "CCM cluster " + clusterName;
634604 }
635605
606+ @Override
607+ protected void finalize() throws Throwable {
608+ close();
609+ super.finalize();
610+ }
611+
636612 /**
637613 * use {@link #builder()} to get an instance
638614 */
@@ -642,8 +618,8 @@
642618 int[] nodes = {1};
643619 private boolean start = true;
644620 private boolean isDSE = isDSE();
645- private String cassandraVersion = getCassandraVersion();
646- private Set<String> createOptions = new LinkedHashSet<String>();
621+ private String version = getCassandraVersion();
622+ private Set<String> createOptions = new HashSet<String>(getInstallArguments());
647623 private Set<String> jvmArgs = new LinkedHashSet<String>();
648624 private final Map<String, Object> cassandraConfiguration = Maps.newHashMap();
649625 private final Map<String, Object> dseConfiguration = Maps.newHashMap();
@@ -701,6 +677,7 @@
701677 * Sets this cluster to be a DSE cluster (defaults to {@link #isDSE()} if this is never called).
702678 */
703679 public Builder withDSE() {
680+ this.createOptions.add("--dse");
704681 this.isDSE = true;
705682 return this;
706683 }
@@ -710,8 +687,17 @@
710687 * <p/>
711688 * Defaults to {@link #getCassandraVersion()}.
712689 */
713- public Builder withVersion(String cassandraVersion) {
714- this.cassandraVersion = cassandraVersion;
690+ public Builder withVersion(String version) {
691+ Iterator<String> it = createOptions.iterator();
692+ while (it.hasNext()) {
693+ String option = it.next();
694+ // remove any version previously set and
695+ // install-dir, which is incompatible
696+ if (option.startsWith("-v ") || option.startsWith("--install-dir"))
697+ it.remove();
698+ }
699+ this.createOptions.add("-v " + version);
700+ this.version = version;
715701 return this;
716702 }
717703
@@ -766,15 +752,11 @@
766752
767753 public CCMBridge build() {
768754 // be careful NOT to alter internal state (hashCode/equals) during build!
769- int initialNumberOfNodes = 0;
770- for (int nodesPerDc : nodes) {
771- initialNumberOfNodes += nodesPerDc;
772- }
773755 int storagePort = this.storagePort == -1 ? findAvailablePort() : this.storagePort;
774756 int thriftPort = this.thriftPort == -1 ? findAvailablePort() : this.thriftPort;
775757 int binaryPort = this.binaryPort == -1 ? findAvailablePort() : this.binaryPort;
776- VersionNumber version = VersionNumber.parse(cassandraVersion);
777- final CCMBridge ccm = new CCMBridge(clusterName, isDSE, version, storagePort, thriftPort, binaryPort, joinJvmArgs(), initialNumberOfNodes);
758+ VersionNumber version = VersionNumber.parse(this.version);
759+ final CCMBridge ccm = new CCMBridge(clusterName, isDSE, version, storagePort, thriftPort, binaryPort, joinJvmArgs());
778760 Runtime.getRuntime().addShutdownHook(new Thread() {
779761 @Override
780762 public void run() {
@@ -809,10 +791,6 @@
809791 result.append(" ").append(clusterName);
810792 result.append(" -i ").append(TestUtils.IP_PREFIX);
811793 result.append(" ");
812- if (cassandraVersion != null)
813- result.append("-v ").append(cassandraVersion);
814- else
815- result.append(CASSANDRA_INSTALL_ARGS);
816794 if (nodes.length > 0) {
817795 result.append(" -n ");
818796 for (int i = 0; i < nodes.length; i++) {
@@ -822,8 +800,7 @@
822800 result.append(node);
823801 }
824802 }
825- if (!createOptions.isEmpty())
826- result.append(" ").append(Joiner.on(" ").join(createOptions));
803+ result.append(" ").append(Joiner.on(" ").join(createOptions));
827804 return result.toString();
828805 }
829806
@@ -893,7 +870,7 @@
893870 if (!jvmArgs.equals(builder.jvmArgs)) return false;
894871 if (!dseConfiguration.equals(builder.dseConfiguration)) return false;
895872 if (!cassandraConfiguration.equals(builder.cassandraConfiguration)) return false;
896- return cassandraVersion.equals(builder.cassandraVersion);
873+ return version.equals(builder.version);
897874 }
898875
899876 @Override
@@ -909,7 +886,7 @@
909886 result = 31 * result + thriftPort;
910887 result = 31 * result + binaryPort;
911888 result = 31 * result + storagePort;
912- result = 31 * result + cassandraVersion.hashCode();
889+ result = 31 * result + version.hashCode();
913890 return result;
914891 }
915892 }
modified driver-core/src/test/java/com/datastax/driver/core/CCMConfig.java +7 −0
@@ -43,6 +43,10 @@
4343 /**
4444 * The C* or DSE version to use; defaults to the version defined by
4545 * the System property {@code cassandra.version}.
46+ * <p/>
47+ * Note that setting this property completely
48+ * overrides the System properties {@code cassandra.version}
49+ * and {@code cassandra.directory}.
4650 *
4751 * @return The C* or DSE version to use
4852 * @see CCMBridge#getCassandraVersion()
@@ -51,6 +55,9 @@
5155
5256 /**
5357 * Whether to launch a DSE instance rather than an OSS C*.
58+ * <p/>
59+ * Note that setting this property completely
60+ * overrides the System property {@code dse}.
5461 *
5562 * @return {@code true} to launch a DSE instance, {@code false} to launch an OSS C* instance (default).
5663 */
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +294 −59
@@ -16,17 +16,19 @@
1616 package com.datastax.driver.core;
1717
1818 import com.datastax.driver.core.CreateCCM.TestMode;
19-import com.datastax.driver.core.policies.AddressTranslator;
2019 import com.google.common.base.Throwables;
2120 import com.google.common.cache.*;
2221 import com.google.common.collect.Lists;
2322 import com.google.common.io.Closer;
23+import com.google.common.util.concurrent.MoreExecutors;
24+import com.google.common.util.concurrent.ThreadFactoryBuilder;
2425 import org.slf4j.Logger;
2526 import org.slf4j.LoggerFactory;
2627 import org.testng.ITestResult;
2728 import org.testng.annotations.*;
2829
2930 import java.io.Closeable;
31+import java.io.File;
3032 import java.io.IOException;
3133 import java.lang.annotation.Annotation;
3234 import java.lang.reflect.Constructor;
@@ -35,8 +37,7 @@
3537 import java.lang.reflect.ParameterizedType;
3638 import java.net.InetSocketAddress;
3739 import java.util.*;
38-import java.util.concurrent.Callable;
39-import java.util.concurrent.ExecutionException;
40+import java.util.concurrent.*;
4041 import java.util.concurrent.atomic.AtomicInteger;
4142
4243 import static com.datastax.driver.core.CreateCCM.TestMode.PER_CLASS;
@@ -53,6 +54,166 @@
5354
5455 private static final List<String> TEST_GROUPS = Lists.newArrayList("isolated", "short", "long", "stress", "duration");
5556
57+
58+ private static class ReadOnlyCCMBridge implements CCMAccess {
59+
60+ private final CCMAccess delegate;
61+
62+ private ReadOnlyCCMBridge(CCMAccess delegate) {
63+ this.delegate = delegate;
64+ }
65+
66+ @Override
67+ public String getClusterName() {
68+ return delegate.getClusterName();
69+ }
70+
71+ @Override
72+ public InetSocketAddress addressOfNode(int n) {
73+ return delegate.addressOfNode(n);
74+ }
75+
76+ @Override
77+ public VersionNumber getVersion() {
78+ return delegate.getVersion();
79+ }
80+
81+ @Override
82+ public File getCcmDir() {
83+ return delegate.getCcmDir();
84+ }
85+
86+ @Override
87+ public File getClusterDir() {
88+ return delegate.getClusterDir();
89+ }
90+
91+ @Override
92+ public File getNodeDir(int n) {
93+ return delegate.getNodeDir(n);
94+ }
95+
96+ @Override
97+ public File getNodeConfDir(int n) {
98+ return delegate.getNodeConfDir(n);
99+ }
100+
101+ @Override
102+ public int getStoragePort() {
103+ return delegate.getStoragePort();
104+ }
105+
106+ @Override
107+ public int getThriftPort() {
108+ return delegate.getThriftPort();
109+ }
110+
111+ @Override
112+ public int getBinaryPort() {
113+ return delegate.getBinaryPort();
114+ }
115+
116+ @Override
117+ public void setKeepLogs(boolean keepLogs) {
118+ delegate.setKeepLogs(keepLogs);
119+ }
120+
121+ @Override
122+ public void close() {
123+ throw new UnsupportedOperationException("This CCM cluster is read-only");
124+ }
125+
126+ @Override
127+ public void start() {
128+ throw new UnsupportedOperationException("This CCM cluster is read-only");
129+ }
130+
131+ @Override
132+ public void stop() {
133+ throw new UnsupportedOperationException("This CCM cluster is read-only");
134+ }
135+
136+ @Override
137+ public void forceStop() {
138+ throw new UnsupportedOperationException("This CCM cluster is read-only");
139+ }
140+
141+ @Override
142+ public void remove() {
143+ throw new UnsupportedOperationException("This CCM cluster is read-only");
144+ }
145+
146+ @Override
147+ public void start(int n) {
148+ throw new UnsupportedOperationException("This CCM cluster is read-only");
149+ }
150+
151+ @Override
152+ public void stop(int n) {
153+ throw new UnsupportedOperationException("This CCM cluster is read-only");
154+ }
155+
156+ @Override
157+ public void forceStop(int n) {
158+ throw new UnsupportedOperationException("This CCM cluster is read-only");
159+ }
160+
161+ @Override
162+ public void remove(int n) {
163+ throw new UnsupportedOperationException("This CCM cluster is read-only");
164+ }
165+
166+ @Override
167+ public void add(int n) {
168+ throw new UnsupportedOperationException("This CCM cluster is read-only");
169+ }
170+
171+ @Override
172+ public void add(int dc, int n) {
173+ throw new UnsupportedOperationException("This CCM cluster is read-only");
174+ }
175+
176+ @Override
177+ public void decommision(int n) {
178+ throw new UnsupportedOperationException("This CCM cluster is read-only");
179+ }
180+
181+ @Override
182+ public void updateConfig(Map<String, Object> configs) {
183+ throw new UnsupportedOperationException("This CCM cluster is read-only");
184+ }
185+
186+ @Override
187+ public void updateDSEConfig(Map<String, Object> configs) {
188+ throw new UnsupportedOperationException("This CCM cluster is read-only");
189+ }
190+
191+ @Override
192+ public void updateNodeConfig(int n, String key, Object value) {
193+ throw new UnsupportedOperationException("This CCM cluster is read-only");
194+ }
195+
196+ @Override
197+ public void updateNodeConfig(int n, Map<String, Object> configs) {
198+ throw new UnsupportedOperationException("This CCM cluster is read-only");
199+ }
200+
201+ @Override
202+ public void setWorkload(int node, String workload) {
203+ throw new UnsupportedOperationException("This CCM cluster is read-only");
204+ }
205+
206+ @Override
207+ public void waitForUp(int node) {
208+ throw new UnsupportedOperationException("This CCM cluster is read-only");
209+ }
210+
211+ @Override
212+ public void waitForDown(int node) {
213+ throw new UnsupportedOperationException("This CCM cluster is read-only");
214+ }
215+ }
216+
56217 private static class CCMTestConfig {
57218
58219 private final List<CCMConfig> annotations;
@@ -110,6 +271,7 @@
110271 @SuppressWarnings("SimplifiableIfStatement")
111272 private Map<String, Object> config() {
112273 Map<String, Object> config = new HashMap<String, Object>();
274+ config.put("start_rpc", false);
113275 for (int i = annotations.size() - 1; i == 0; i--) {
114276 CCMConfig ann = annotations.get(i);
115277 addConfigOptions(ann.config(), config);
@@ -205,8 +367,7 @@
205367
206368 private CCMBridge.Builder ccmBuilder() {
207369 if (ccmBuilder == null) {
208- ccmBuilder = CCMBridge.builder()
209- .withNodes(numberOfNodes());
370+ ccmBuilder = CCMBridge.builder().withNodes(numberOfNodes());
210371 if (version() != null)
211372 ccmBuilder.withVersion(version());
212373 if (dse())
@@ -286,31 +447,115 @@
286447 }
287448 }
288449
450+ private int weight() {
451+ int weight = 0;
452+ weight += totalNodes() - 1;
453+ weight += config().size() - 1;
454+ weight += dseConfig().size();
455+ weight += dse() ? 1 : 0;
456+ weight += jvmArgs().size();
457+ weight += startOptions().size();
458+ weight += ssl() ? 1 : 0;
459+ weight += auth() ? 1 : 0;
460+ weight += version() != null ? 1 : 0;
461+ return weight;
462+ }
463+
464+ private int totalNodes() {
465+ int nodes = 0;
466+ for (int nodesPerDc : numberOfNodes()) {
467+ nodes += nodesPerDc;
468+ }
469+ return nodes;
470+ }
471+ }
472+
473+ private static class CCMTestContextKey {
474+
475+ private final CCMBridge.Builder builder;
476+
477+ private final int weight;
478+
479+ private CCMTestContextKey(CCMBridge.Builder builder, int weight) {
480+ this.builder = builder;
481+ this.weight = weight;
482+ }
483+
484+ @Override
485+ public boolean equals(Object o) {
486+ if (this == o) return true;
487+ if (o == null || getClass() != o.getClass()) return false;
488+ CCMTestContextKey that = (CCMTestContextKey) o;
489+ return builder.equals(that.builder);
490+ }
491+
492+ @Override
493+ public int hashCode() {
494+ return builder.hashCode();
495+ }
496+ }
497+
498+ private static class CCMTestContext implements Runnable {
499+
500+ private CCMAccess ccm;
501+
502+ private final AtomicInteger refCount = new AtomicInteger(1);
503+
504+ private volatile boolean evicted = false;
505+
506+ private CCMTestContext(CCMAccess ccm) {
507+ this(ccm, false);
508+ }
509+
510+ public CCMTestContext(CCMAccess ccm, boolean evicted) {
511+ this.ccm = ccm;
512+ this.evicted = evicted;
513+ }
514+
515+ @Override
516+ public void run() {
517+ if (ccm != null)
518+ ccm.close();
519+ ccm = null;
520+ }
521+
522+ private void markEvicted() {
523+ evicted = true;
524+ }
525+
526+ private void maybeClose() {
527+ if (refCount.get() <= 0 && evicted)
528+ POOL.execute(this);
529+ }
289530 }
290531
291- private static class CCMTestContextLoader extends CacheLoader<CCMBridge.Builder, CCMBridge> {
532+ private static class CCMTestContextLoader extends CacheLoader<CCMTestContextKey, CCMTestContext> {
292533
293534 @Override
294- public CCMBridge load(CCMBridge.Builder builder) {
295- return builder.build();
535+ public CCMTestContext load(CCMTestContextKey key) {
536+ return new CCMTestContext(key.builder.build());
296537 }
297538
298539 }
299540
300- private static class CCMTestContextWeigher implements Weigher<CCMBridge.Builder, CCMBridge> {
541+ private static class CCMTestContextWeigher implements Weigher<CCMTestContextKey, CCMTestContext> {
542+
301543 @Override
302- public int weigh(CCMBridge.Builder key, CCMBridge value) {
303- return value.getInitialNumberOfNodes();
544+ public int weigh(CCMTestContextKey key, CCMTestContext value) {
545+ return key.weight;
304546 }
547+
305548 }
306549
307- private static class CCMTestContextRemovalListener implements RemovalListener<CCMBridge.Builder, CCMBridge> {
550+ private static class CCMTestContextRemovalListener implements RemovalListener<CCMTestContextKey, CCMTestContext> {
308551
309552 @Override
310- public void onRemoval(RemovalNotification<CCMBridge.Builder, CCMBridge> notification) {
311- if (notification.getValue() != null) {
312- LOGGER.debug("Evicting: " + notification.getValue());
313- notification.getValue().close();
553+ public void onRemoval(RemovalNotification<CCMTestContextKey, CCMTestContext> notification) {
554+ CCMTestContext context = notification.getValue();
555+ if (context != null && context.ccm != null) {
556+ LOGGER.debug("Evicting: {} because of {}", context.ccm, notification.getCause());
557+ context.markEvicted();
558+ context.maybeClose();
314559 }
315560 }
316561
@@ -319,7 +564,11 @@
319564 /**
320565 * A LoadingCache that stores running CCM clusters.
321566 */
322- private static final LoadingCache<CCMBridge.Builder, CCMBridge> CACHE;
567+ private static final LoadingCache<CCMTestContextKey, CCMTestContext> CACHE;
568+
569+ private static final ExecutorService POOL = MoreExecutors.getExitingExecutorService(
570+ (ThreadPoolExecutor) Executors.newFixedThreadPool(2,
571+ new ThreadFactoryBuilder().setNameFormat("ccm-removal-%d").build()));
323572
324573 static {
325574 long maximumWeight;
@@ -329,14 +578,16 @@
329578 if (freeMemoryMB < 1000)
330579 LOGGER.warn("Available memory below 1GB: {}MB, CCM clusters might fail to start", freeMemoryMB);
331580 // CCM nodes are started with -Xms500M -Xmx500M
332- // leave at least 500 MB out, with a minimum of 1 node and a maximum of 10 nodes
333- maximumWeight = Math.min(10, Math.max(1, (freeMemoryMB / 500) - 1));
581+ // so 1 "slot" is roughly 500MB
582+ // leave at least 2 slots out, with a minimum of 1 slot and a maximum of 6 slots
583+ long slotsAvailable = (freeMemoryMB / 500) - 2;
584+ maximumWeight = Math.min(6, Math.max(1, slotsAvailable));
334585 } else {
335586 maximumWeight = Integer.parseInt(numberOfNodes);
336587 }
337588 LOGGER.info("Maximum number of running CCM nodes: {}", maximumWeight);
338589 CACHE = CacheBuilder.newBuilder()
339- .initialCapacity(1)
590+ .initialCapacity(3)
340591 .maximumWeight(maximumWeight)
341592 .weigher(new CCMTestContextWeigher())
342593 .removalListener(new CCMTestContextRemovalListener())
@@ -347,7 +598,9 @@
347598
348599 private CCMTestConfig ccmTestConfig;
349600
350- protected CCMBridge ccm;
601+ private CCMTestContext ccmTestContext;
602+
603+ protected CCMAccess ccm;
351604
352605 protected Cluster cluster;
353606
@@ -540,36 +793,6 @@
540793 return contactPoints;
541794 }
542795
543- /**
544- * Returns the address of the {@code nth} host in the CCM cluster (counting from 1, i.e.,
545- * {@code getHostAddress(1)} returns the address of the first node.
546- * <p/>
547- * In multi-DC setups, nodes are numbered in ascending order of their datacenter number.
548- * E.g. with 2 DCs and 3 nodes in each DC, the first node in DC 2 is number 4.
549- * <p/>
550- * This method should not be called before the test has started, nor after the test is finished.
551- *
552- * @return the address of the {@code nth} host in the cluster.
553- */
554- public InetSocketAddress getHostAddress(int n) {
555- return ccm.addressOfNode(n);
556- }
557-
558- /**
559- * Returns an {@link AddressTranslator} to use when tests must manually create
560- * {@link Cluster} instances.
561- * <p/>
562- * This translator is necessary because hosts create with this class do not use standard ports.
563- * <p/>
564- * This method should not be called before the test has started, nor after the test is finished.
565- *
566- * @return an {@link AddressTranslator} to use when tests must manually create
567- * {@link Cluster} instances.
568- */
569- public AddressTranslator getAddressTranslator() {
570- return ccm.addressTranslator();
571- }
572-
573796 /**
574797 * Registers the given {@link Closeable} to be closed at the end of the current test method.
575798 * <p/>
@@ -590,22 +813,32 @@
590813 if (ccmTestConfig.createCcm()) {
591814 if (ccmTestConfig.dirtiesContext()) {
592815 ccm = ccmTestConfig.ccmBuilder().build();
816+ ccmTestContext = new CCMTestContext(ccm, true);
593817 LOGGER.debug("Using dedicated {}", ccm);
594818 } else {
595- CCMBridge.Builder key = ccmTestConfig.ccmBuilder();
596- ccm = CACHE.getIfPresent(key);
597- if (ccm != null) {
819+ CCMBridge.Builder builder = ccmTestConfig.ccmBuilder();
820+ int weight = ccmTestConfig.weight();
821+ CCMTestContextKey key = new CCMTestContextKey(builder, weight);
822+ CCMAccess ccm;
823+ ccmTestContext = CACHE.getIfPresent(key);
824+ if (ccmTestContext != null) {
825+ ccmTestContext.refCount.incrementAndGet();
826+ ccm = ccmTestContext.ccm;
598827 LOGGER.debug("Reusing {}", ccm);
599828 } else {
600829 try {
601- ccm = CACHE.get(ccmTestConfig.ccmBuilder());
830+ ccmTestContext = CACHE.get(key);
831+ ccm = ccmTestContext.ccm;
602832 LOGGER.debug("Using newly-created {}", ccm);
603833 } catch (ExecutionException e) {
604- Throwables.propagate(e);
834+ throw Throwables.propagate(e);
605835 }
606836 }
837+ this.ccm = new ReadOnlyCCMBridge(ccm);
607838 }
839+ assert ccmTestContext != null;
608840 assert ccm != null;
841+
609842 }
610843 }
611844
@@ -615,7 +848,7 @@
615848 // add contact points only if the provided builder didn't do so
616849 if (builder.getContactPoints().isEmpty())
617850 builder.addContactPointsWithPorts(getInitialContactPoints());
618- builder.withAddressTranslator(ccm.addressTranslator());
851+ builder.withPort(ccm.getBinaryPort());
619852 cluster = register(builder.build());
620853 cluster.init();
621854 }
@@ -656,10 +889,12 @@
656889 }
657890
658891 private void closeTestContext() {
659- if (ccmTestConfig != null && ccm != null && ccmTestConfig.dirtiesContext()) {
660- ccm.close();
892+ if (ccmTestContext != null) {
893+ ccmTestContext.refCount.decrementAndGet();
894+ ccmTestContext.maybeClose();
661895 }
662896 ccmTestConfig = null;
897+ ccmTestContext = null;
663898 ccm = null;
664899 }
665900
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +2 −2
@@ -231,8 +231,8 @@
231231 .forcePeerInfo(1, 2, "release_version", "1.2.19")
232232 .build();
233233 Cluster cluster = Cluster.builder()
234- .addContactPointsWithPorts(scassandraCluster.address(1))
235- .withAddressTranslator(scassandraCluster.addressTranslator())
234+ .addContactPoints(scassandraCluster.address(1).getAddress())
235+ .withPort(scassandraCluster.getBinaryPort())
236236 .withNettyOptions(nonQuietClusterCloseOptions)
237237 .build();
238238
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +11 −11
@@ -61,8 +61,8 @@
6161
6262 // We pass only the first host as contact point, so we know the control connection will be on this host
6363 cluster = register(Cluster.builder()
64- .addContactPointsWithPorts(getHostAddress(1))
65- .withAddressTranslator(getAddressTranslator())
64+ .addContactPoints(ccm.addressOfNode(1).getAddress())
65+ .withPort(ccm.getBinaryPort())
6666 .withReconnectionPolicy(reconnectionPolicy)
6767 .withLoadBalancingPolicy(loadBalancingPolicy)
6868 .build());
@@ -88,11 +88,11 @@
8888 @CassandraVersion(major = 2.1)
8989 public void should_parse_UDT_definitions_when_using_default_protocol_version() {
9090 Cluster cluster;
91- InetSocketAddress firstHost = getHostAddress(1);
91+ InetSocketAddress firstHost = ccm.addressOfNode(1);
9292 // First driver instance: create UDT
9393 cluster = register(Cluster.builder()
9494 .addContactPointsWithPorts(firstHost)
95- .withAddressTranslator(getAddressTranslator())
95+ .withPort(ccm.getBinaryPort())
9696 .build());
9797 Session session = cluster.connect();
9898 session.execute("create keyspace ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}");
@@ -118,10 +118,10 @@
118118 @Test(groups = "long")
119119 @CCMConfig(numberOfNodes = 3)
120120 public void should_reestablish_if_control_node_decommissioned() throws InterruptedException {
121- InetSocketAddress firstHost = getHostAddress(1);
121+ InetSocketAddress firstHost = ccm.addressOfNode(1);
122122 Cluster cluster = register(Cluster.builder()
123123 .addContactPointsWithPorts(firstHost)
124- .withAddressTranslator(getAddressTranslator())
124+ .withPort(ccm.getBinaryPort())
125125 .withQueryOptions(nonDebouncingQueryOptions())
126126 .build());
127127 cluster.init();
@@ -131,7 +131,7 @@
131131 assertThat(controlHost).isEqualTo(firstHost.getAddress());
132132
133133 // Decommission the node.
134- ccm.decommissionNode(1);
134+ ccm.decommision(1);
135135
136136 // Ensure that the new control connection is not null and it's host is not equal to the decommissioned node.
137137 Host newHost = cluster.manager.controlConnection.connectedHost();
@@ -161,15 +161,15 @@
161161 scassandras.init();
162162
163163 try {
164- Collection<InetSocketAddress> contactPoints = newArrayList();
164+ Collection<InetAddress> contactPoints = newArrayList();
165165 for (int i = 1; i <= hostCount; i++) {
166- contactPoints.add(scassandras.address(i));
166+ contactPoints.add(scassandras.address(i).getAddress());
167167 }
168168 final HashMultiset<InetAddress> occurrencesByHost = HashMultiset.create(hostCount);
169169 for (int i = 0; i < iterations; i++) {
170170 Cluster cluster = Cluster.builder()
171- .addContactPointsWithPorts(contactPoints)
172- .withAddressTranslator(scassandras.addressTranslator())
171+ .addContactPoints(contactPoints)
172+ .withPort(scassandras.getBinaryPort())
173173 .withNettyOptions(nonQuietClusterCloseOptions)
174174 .build();
175175
modified driver-core/src/test/java/com/datastax/driver/core/CustomPayloadTest.java +1 −1
@@ -241,7 +241,7 @@
241241 try {
242242 v3cluster = Cluster.builder()
243243 .addContactPointsWithPorts(getInitialContactPoints())
244- .withAddressTranslator(getAddressTranslator())
244+ .withPort(ccm.getBinaryPort())
245245 .withProtocolVersion(V3)
246246 .build()
247247 .init();
added driver-core/src/test/java/com/datastax/driver/core/DseCCMClusterTest.java +71 −0
@@ -0,0 +1,71 @@
1+/*
2+ * Copyright (C) 2012-2015 DataStax Inc.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package com.datastax.driver.core;
17+
18+import org.testng.annotations.Test;
19+
20+/**
21+ * A simple test to validate DSE setups.
22+ * <p/>
23+ * <h3>Running all tests against DSE</h3>
24+ * <p/>
25+ * To run tests globally against DSE, set the system property {@code dse}
26+ * to {@code true}.
27+ * <p/>
28+ * When this flag is provided, it is assumed a DSE version is passed under
29+ * the system property {@code cassandra.version}.
30+ * A mapping for determining C* version from DSE version is described in {@link CCMBridge}.
31+ * <p/>
32+ * Example usages:
33+ * <p/>
34+ * DSE 4.8.3:
35+ * <pre>
36+ * -Ddse -Dcassandra.version=4.8.3
37+ * -Ddse=true -Dcassandra.version=4.8.3
38+ * </pre>
39+ * <p/>
40+ * Custom local install of DSE 5.0 (using {@code cassandra.directory} instead of {@code cassandra.version}):
41+ * <pre>
42+ * -Dcassandra.version=5.0 -Ddse -Dcassandra.directory=/path/to/dse
43+ * </pre>
44+ * <p/>
45+ * <h3>Running a specific test against DSE</h3>
46+ * <p/>
47+ * Set the following properties on the test:
48+ * <pre>{@code @CCMConfig(dse = true, version = "4.8.3")}</pre>
49+ *
50+ * <h3>Supplying DSE credentials</h3>
51+ *
52+ * Rather than adding system properties for DSE credentials,
53+ * DSE tests rely on a recent change in CCM to support providing
54+ * credentials via {@code $HOME/.ccm/.dse.ini}.
55+ *
56+ * The contents of this file need to be formed in this way:
57+ * <pre>
58+ * [dse_credentials]
59+ * dse_username = myusername
60+ * dse_password = mypassword
61+ * </pre>
62+ */
63+@Test(enabled = false)
64+@CCMConfig(dse = true, version = "4.8.3")
65+public class DseCCMClusterTest extends CCMTestsSupport {
66+
67+ @Test(groups = "short")
68+ public void should_conenct_to_dse() throws InterruptedException {
69+ }
70+
71+}
modified driver-core/src/test/java/com/datastax/driver/core/EventDebouncerIntegrationTest.java +2 −2
@@ -44,8 +44,8 @@
4444 public void should_wait_until_load_balancing_policy_is_fully_initialized() throws InterruptedException {
4545 TestLoadBalancingPolicy policy = new TestLoadBalancingPolicy();
4646 final Cluster cluster = register(createClusterBuilderNoDebouncing()
47- .addContactPointsWithPorts(getHostAddress(1))
48- .withAddressTranslator(getAddressTranslator())
47+ .addContactPoints(ccm.addressOfNode(1).getAddress())
48+ .withPort(ccm.getBinaryPort())
4949 .withLoadBalancingPolicy(policy).build());
5050 new Thread() {
5151 @Override
modified driver-core/src/test/java/com/datastax/driver/core/HeartbeatTest.java +4 −4
@@ -57,8 +57,8 @@
5757 @Test(groups = "long")
5858 public void should_send_heartbeat_when_connection_is_inactive() throws InterruptedException {
5959 Cluster cluster = register(Cluster.builder()
60- .addContactPointsWithPorts(getHostAddress(1))
61- .withAddressTranslator(getAddressTranslator())
60+ .addContactPoints(ccm.addressOfNode(1).getAddress())
61+ .withPort(ccm.getBinaryPort())
6262 .withPoolingOptions(new PoolingOptions()
6363 .setHeartbeatIntervalSeconds(3))
6464 .build());
@@ -113,8 +113,8 @@
113113 @Test(groups = "long")
114114 public void should_not_send_heartbeat_when_disabled() throws InterruptedException {
115115 Cluster cluster = register(Cluster.builder()
116- .addContactPointsWithPorts(getHostAddress(1))
117- .withAddressTranslator(getAddressTranslator())
116+ .addContactPoints(ccm.addressOfNode(1).getAddress())
117+ .withPort(ccm.getBinaryPort())
118118 .withPoolingOptions(new PoolingOptions()
119119 .setHeartbeatIntervalSeconds(0))
120120 .build());
modified driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolMultiTest.java +2 −2
@@ -53,8 +53,8 @@
5353 PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(LOCAL, core, max);
5454 SocketOptions socketOptions = new SocketOptions().setReadTimeoutMillis(1000);
5555 cluster = Cluster.builder()
56- .addContactPointsWithPorts(scassandra.address(1))
57- .withAddressTranslator(scassandra.addressTranslator())
56+ .addContactPoints(scassandra.address(1).getAddress())
57+ .withPort(scassandra.getBinaryPort())
5858 .withQueryOptions(nonDebouncingQueryOptions())
5959 .withPoolingOptions(poolingOptions)
6060 .withSocketOptions(socketOptions)
modified driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java +2 −2
@@ -49,7 +49,7 @@
4949
5050 Cluster cluster = register(Cluster.builder()
5151 .addContactPointsWithPorts(getInitialContactPoints())
52- .withAddressTranslator(ccm.addressTranslator())
52+ .withPort(ccm.getBinaryPort())
5353 .withLoadBalancingPolicy(policy)
5454 .build());
5555
@@ -91,7 +91,7 @@
9191 HistoryPolicy policy = new HistoryPolicy(new RoundRobinPolicy());
9292 Cluster cluster = register(Cluster.builder()
9393 .addContactPointsWithPorts(getInitialContactPoints())
94- .withAddressTranslator(ccm.addressTranslator())
94+ .withPort(ccm.getBinaryPort())
9595 .withLoadBalancingPolicy(policy)
9696 .build());
9797
modified driver-core/src/test/java/com/datastax/driver/core/MetadataTest.java +3 −3
@@ -55,8 +55,8 @@
5555 @CCMConfig(numberOfNodes = 3, dirtiesContext = true, createCluster = false)
5656 public void should_update_metadata_on_topology_change() {
5757 Cluster cluster = register(Cluster.builder()
58- .addContactPointsWithPorts(getHostAddress(1))
59- .withAddressTranslator(getAddressTranslator())
58+ .addContactPoints(ccm.addressOfNode(1).getAddress())
59+ .withPort(ccm.getBinaryPort())
6060 .withQueryOptions(nonDebouncingQueryOptions())
6161 .build());
6262 Session session = cluster.connect();
@@ -73,7 +73,7 @@
7373 Host host3 = TestUtils.findHost(cluster, 3);
7474 Token host3Token = tokensForHost.get(host3);
7575
76- ccm.decommissionNode(3);
76+ ccm.decommision(3);
7777 ccm.remove(3);
7878
7979 // Ensure that the token ranges were updated, there should only be 2 ranges now.
modified driver-core/src/test/java/com/datastax/driver/core/MetricsTest.java +2 −2
@@ -126,7 +126,7 @@
126126 public void metrics_should_be_null_when_metrics_disabled() throws Exception {
127127 Cluster cluster = register(Cluster.builder()
128128 .addContactPointsWithPorts(getInitialContactPoints())
129- .withAddressTranslator(getAddressTranslator())
129+ .withPort(ccm.getBinaryPort())
130130 .withoutMetrics()
131131 .build());
132132 try {
@@ -151,7 +151,7 @@
151151 public void should_be_no_jmx_mbean_when_jmx_is_disabled() throws Exception {
152152 Cluster cluster = register(Cluster.builder()
153153 .addContactPointsWithPorts(getInitialContactPoints())
154- .withAddressTranslator(getAddressTranslator())
154+ .withPort(ccm.getBinaryPort())
155155 .withoutJMXReporting()
156156 .build());
157157 try {
modified driver-core/src/test/java/com/datastax/driver/core/MissingRpcAddressTest.java +4 −4
@@ -42,8 +42,8 @@
4242 deleteNode2RpcAddressFromNode1();
4343 // Use only one contact point to make sure that the control connection is on node1
4444 Cluster cluster = register(Cluster.builder()
45- .addContactPointsWithPorts(getHostAddress(1))
46- .withAddressTranslator(getAddressTranslator())
45+ .addContactPoints(ccm.addressOfNode(1).getAddress())
46+ .withPort(ccm.getBinaryPort())
4747 .build());
4848 cluster.connect();
4949
@@ -54,10 +54,10 @@
5454
5555 // Artificially modify the system tables to simulate the missing rpc_address.
5656 private void deleteNode2RpcAddressFromNode1() throws Exception {
57- InetSocketAddress firstHost = getHostAddress(1);
57+ InetSocketAddress firstHost = ccm.addressOfNode(1);
5858 Cluster cluster = register(Cluster.builder()
5959 .addContactPointsWithPorts(singleton(firstHost))
60- .withAddressTranslator(getAddressTranslator())
60+ .withPort(ccm.getBinaryPort())
6161 // ensure we will only connect to node1
6262 .withLoadBalancingPolicy(new WhiteListPolicy(Policies.defaultLoadBalancingPolicy(),
6363 Lists.newArrayList(firstHost)))
modified driver-core/src/test/java/com/datastax/driver/core/NettyOptionsTest.java +1 −1
@@ -64,7 +64,7 @@
6464 }).when(nettyOptions).afterChannelInitialized(any(SocketChannel.class));
6565 cluster = Cluster.builder()
6666 .addContactPointsWithPorts(ccm.addressOfNode(1))
67- .withAddressTranslator(ccm.addressTranslator())
67+ .withPort(ccm.getBinaryPort())
6868 .withPoolingOptions(new PoolingOptions()
6969 .setConnectionsPerHost(HostDistance.LOCAL, coreConnections, coreConnections)
7070 )
modified driver-core/src/test/java/com/datastax/driver/core/NodeRefreshDebouncerTest.java +2 −2
@@ -43,8 +43,8 @@
4343 int refreshNodeInterval = 30000;
4444 QueryOptions queryOptions = new QueryOptions().setRefreshNodeIntervalMillis(refreshNodeInterval);
4545 Cluster cluster = register(Cluster.builder()
46- .addContactPointsWithPorts(getHostAddress(1))
47- .withAddressTranslator(getAddressTranslator())
46+ .addContactPoints(ccm.addressOfNode(1).getAddress())
47+ .withPort(ccm.getBinaryPort())
4848 .withQueryOptions(queryOptions)
4949 .build());
5050 cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/PoolingOptionsTest.java +44 −0
@@ -93,5 +93,49 @@
9393 assertThat(options.getCoreConnectionsPerHost(LOCAL)).isEqualTo(10);
9494 assertThat(options.getMaxConnectionsPerHost(LOCAL)).isEqualTo(15);
9595 }
96+
97+ @Test(groups = "unit")
98+ public void should_leave_connection_options_unset_until_protocol_version_known() {
99+ PoolingOptions options = new PoolingOptions();
100+
101+ assertThat(options.getCoreConnectionsPerHost(LOCAL)).isEqualTo(PoolingOptions.UNSET);
102+ assertThat(options.getCoreConnectionsPerHost(REMOTE)).isEqualTo(PoolingOptions.UNSET);
103+ assertThat(options.getMaxConnectionsPerHost(LOCAL)).isEqualTo(PoolingOptions.UNSET);
104+ assertThat(options.getMaxConnectionsPerHost(REMOTE)).isEqualTo(PoolingOptions.UNSET);
105+ assertThat(options.getNewConnectionThreshold(LOCAL)).isEqualTo(PoolingOptions.UNSET);
106+ assertThat(options.getNewConnectionThreshold(REMOTE)).isEqualTo(PoolingOptions.UNSET);
107+ assertThat(options.getMaxRequestsPerConnection(LOCAL)).isEqualTo(PoolingOptions.UNSET);
108+ assertThat(options.getMaxRequestsPerConnection(REMOTE)).isEqualTo(PoolingOptions.UNSET);
109+ }
110+
111+ @Test(groups = "unit")
112+ public void should_reject_negative_connection_options_even_when_protocol_version_unknown() {
113+ PoolingOptions options = new PoolingOptions();
114+
115+ try {
116+ options.setCoreConnectionsPerHost(LOCAL, -1);
117+ fail("expected an IllegalArgumentException");
118+ } catch (IllegalArgumentException e) { /*expected*/ }
119+ try {
120+ options.setMaxConnectionsPerHost(LOCAL, -1);
121+ fail("expected an IllegalArgumentException");
122+ } catch (IllegalArgumentException e) { /*expected*/ }
123+ try {
124+ options.setConnectionsPerHost(LOCAL, -1, 1);
125+ fail("expected an IllegalArgumentException");
126+ } catch (IllegalArgumentException e) { /*expected*/ }
127+ try {
128+ options.setConnectionsPerHost(LOCAL, -2, -1);
129+ fail("expected an IllegalArgumentException");
130+ } catch (IllegalArgumentException e) { /*expected*/ }
131+ try {
132+ options.setNewConnectionThreshold(LOCAL, -1);
133+ fail("expected an IllegalArgumentException");
134+ } catch (IllegalArgumentException e) { /*expected*/ }
135+ try {
136+ options.setMaxRequestsPerConnection(LOCAL, -1);
137+ fail("expected an IllegalArgumentException");
138+ } catch (IllegalArgumentException e) { /*expected*/ }
139+ }
96140 }
97141
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +3 −3
@@ -407,7 +407,7 @@
407407 public void should_fail_when_prepared_on_another_cluster() throws Exception {
408408 Cluster otherCluster = Cluster.builder()
409409 .addContactPointsWithPorts(getInitialContactPoints())
410- .withAddressTranslator(getAddressTranslator())
410+ .withPort(ccm.getBinaryPort())
411411 .build();
412412 try {
413413 PreparedStatement pst = otherCluster.connect().prepare("select * from system.peers where inet = ?");
@@ -434,7 +434,7 @@
434434 public void should_not_allow_unbound_value_on_bound_statement_when_protocol_lesser_than_v4() {
435435 Cluster cluster = Cluster.builder()
436436 .addContactPointsWithPorts(getInitialContactPoints())
437- .withAddressTranslator(getAddressTranslator())
437+ .withPort(ccm.getBinaryPort())
438438 .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3))
439439 .build();
440440 Session session = cluster.connect();
@@ -467,7 +467,7 @@
467467 public void should_not_allow_unbound_value_on_batch_statement_when_protocol_lesser_than_v4() {
468468 Cluster cluster = Cluster.builder()
469469 .addContactPointsWithPorts(getInitialContactPoints())
470- .withAddressTranslator(getAddressTranslator())
470+ .withPort(ccm.getBinaryPort())
471471 .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3))
472472 .build();
473473 Session session = cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/QueryOptionsTest.java +2 −2
@@ -49,8 +49,8 @@
4949 queryOptions = new QueryOptions();
5050 loadBalancingPolicy = new SortingLoadBalancingPolicy();
5151 cluster = Cluster.builder()
52- .addContactPointsWithPorts(scassandra.address(2))
53- .withAddressTranslator(scassandra.addressTranslator())
52+ .addContactPoints(scassandra.address(2).getAddress())
53+ .withPort(scassandra.getBinaryPort())
5454 .withLoadBalancingPolicy(loadBalancingPolicy)
5555 .withQueryOptions(queryOptions)
5656 .withNettyOptions(nonQuietClusterCloseOptions)
modified driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java +8 −8
@@ -51,8 +51,8 @@
5151
5252 // Now start the driver that will connect to node2 and node3, and consider node1 down
5353 mainCluster = Cluster.builder()
54- .addContactPointsWithPorts(mainCcm.addressOfNode(2))
55- .withAddressTranslator(mainCcm.addressTranslator())
54+ .addContactPoints(mainCcm.addressOfNode(2).getAddress())
55+ .withPort(mainCcm.getBinaryPort())
5656 .withQueryOptions(nonDebouncingQueryOptions()).build();
5757 mainCluster.connect();
5858 waitForCountUpHosts(mainCluster, 2);
@@ -80,8 +80,8 @@
8080
8181 // Start the driver, the control connection will be on node2
8282 mainCluster = Cluster.builder()
83- .addContactPointsWithPorts(mainCcm.addressOfNode(2))
84- .withAddressTranslator(mainCcm.addressTranslator())
83+ .addContactPoints(mainCcm.addressOfNode(2).getAddress())
84+ .withPort(mainCcm.getBinaryPort())
8585 .withQueryOptions(nonDebouncingQueryOptions()).build();
8686 mainCluster.connect();
8787 waitForCountUpHosts(mainCluster, 1);
@@ -118,8 +118,8 @@
118118
119119 // Start the driver, it should only connect to node 2
120120 mainCluster = Cluster.builder()
121- .addContactPointsWithPorts(mainCcm.addressOfNode(2))
122- .withAddressTranslator(mainCcm.addressTranslator())
121+ .addContactPoints(mainCcm.addressOfNode(2).getAddress())
122+ .withPort(mainCcm.getBinaryPort())
123123 .withQueryOptions(nonDebouncingQueryOptions()).build();
124124
125125 // When we first initialize the Cluster, all hosts are marked UP
@@ -154,8 +154,8 @@
154154
155155 // Start the driver, it should only connect to node 2
156156 mainCluster = Cluster.builder()
157- .addContactPointsWithPorts(mainCcm.addressOfNode(2))
158- .withAddressTranslator(mainCcm.addressTranslator())
157+ .addContactPoints(mainCcm.addressOfNode(2).getAddress())
158+ .withPort(mainCcm.getBinaryPort())
159159 .withQueryOptions(nonDebouncingQueryOptions()).build();
160160
161161 // Create a session. This will try to open a pool to node 1 and find that it doesn't support protocol version.
modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +5 −5
@@ -51,7 +51,7 @@
5151 public void should_reconnect_after_full_connectivity_loss() throws InterruptedException {
5252 Cluster cluster = register(Cluster.builder()
5353 .addContactPointsWithPorts(ccm.addressOfNode(1))
54- .withAddressTranslator(ccm.addressTranslator())
54+ .withPort(ccm.getBinaryPort())
5555 .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis))
5656 .build());
5757 cluster.connect();
@@ -90,7 +90,7 @@
9090 CountingAuthProvider authProvider = new CountingAuthProvider("cassandra", "cassandra");
9191 Cluster cluster = register(Cluster.builder()
9292 .addContactPointsWithPorts(ccm.addressOfNode(1))
93- .withAddressTranslator(ccm.addressTranslator())
93+ .withPort(ccm.getBinaryPort())
9494 // Start with the correct auth so that we can initialize the server
9595 .withAuthProvider(authProvider)
9696 .withReconnectionPolicy(reconnectionPolicy)
@@ -131,7 +131,7 @@
131131
132132 Cluster cluster = register(Cluster.builder()
133133 .addContactPointsWithPorts(ccm.addressOfNode(1))
134- .withAddressTranslator(ccm.addressTranslator())
134+ .withPort(ccm.getBinaryPort())
135135 .withReconnectionPolicy(reconnectionPolicy).build());
136136 cluster.connect();
137137
@@ -159,7 +159,7 @@
159159 TogglabePolicy loadBalancingPolicy = new TogglabePolicy(new RoundRobinPolicy());
160160 Cluster cluster = register(Cluster.builder()
161161 .addContactPointsWithPorts(ccm.addressOfNode(1))
162- .withAddressTranslator(ccm.addressTranslator())
162+ .withPort(ccm.getBinaryPort())
163163 .withLoadBalancingPolicy(loadBalancingPolicy)
164164 .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis))
165165 .build());
@@ -215,7 +215,7 @@
215215 SocketOptions socketOptions = spy(new SocketOptions());
216216 Cluster cluster = register(Cluster.builder()
217217 .addContactPointsWithPorts(ccm.addressOfNode(1))
218- .withAddressTranslator(ccm.addressTranslator())
218+ .withPort(ccm.getBinaryPort())
219219 .withReconnectionPolicy(new ConstantReconnectionPolicy(5000))
220220 .withLoadBalancingPolicy(loadBalancingPolicy)
221221 .withSocketOptions(socketOptions)
modified driver-core/src/test/java/com/datastax/driver/core/RefreshConnectedHostTest.java +1 −1
@@ -43,7 +43,7 @@
4343 PoolingOptions poolingOptions = Mockito.spy(new PoolingOptions());
4444 cluster = register(Cluster.builder()
4545 .addContactPointsWithPorts(ccm.addressOfNode(1))
46- .withAddressTranslator(ccm.addressTranslator())
46+ .withPort(ccm.getBinaryPort())
4747 .withPoolingOptions(poolingOptions)
4848 .withLoadBalancingPolicy(loadBalancingPolicy)
4949 .withReconnectionPolicy(new ConstantReconnectionPolicy(1000))
modified driver-core/src/test/java/com/datastax/driver/core/SSLEncryptionTest.java +4 −2
@@ -23,7 +23,9 @@
2323 import static com.datastax.driver.core.Assertions.assertThat;
2424 import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_TRUSTSTORE_FILE;
2525 import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_TRUSTSTORE_PASSWORD;
26+import static com.datastax.driver.core.CreateCCM.TestMode.PER_METHOD;
2627
28+@CreateCCM(PER_METHOD)
2729 @CCMConfig(auth = false)
2830 public class SSLEncryptionTest extends SSLTestBase {
2931
@@ -73,7 +75,7 @@
7375 public void should_not_connect_without_ssl_but_node_uses_ssl() throws Exception {
7476 Cluster cluster = register(Cluster.builder()
7577 .addContactPointsWithPorts(this.getInitialContactPoints())
76- .withAddressTranslator(ccm.addressTranslator())
78+ .withPort(ccm.getBinaryPort())
7779 .build());
7880 cluster.connect();
7981 }
@@ -92,7 +94,7 @@
9294 public void should_reconnect_with_ssl_on_node_up(SslImplementation sslImplementation) throws Exception {
9395 Cluster cluster = register(Cluster.builder()
9496 .addContactPointsWithPorts(this.getInitialContactPoints())
95- .withAddressTranslator(ccm.addressTranslator())
97+ .withPort(ccm.getBinaryPort())
9698 .withSSL(getSSLOptions(sslImplementation, true, true))
9799 .build());
98100
modified driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java +2 −2
@@ -56,7 +56,7 @@
5656 protected void connectWithSSLOptions(SSLOptions sslOptions) throws Exception {
5757 Cluster cluster = register(Cluster.builder()
5858 .addContactPointsWithPorts(this.getInitialContactPoints())
59- .withAddressTranslator(ccm.addressTranslator())
59+ .withPort(ccm.getBinaryPort())
6060 .withSSL(sslOptions)
6161 .build());
6262 cluster.connect();
@@ -74,7 +74,7 @@
7474 protected void connectWithSSL() throws Exception {
7575 Cluster cluster = register(Cluster.builder()
7676 .addContactPointsWithPorts(this.getInitialContactPoints())
77- .withAddressTranslator(ccm.addressTranslator())
77+ .withPort(ccm.getBinaryPort())
7878 .withSSL()
7979 .build());
8080 cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/ScassandraCluster.java +4 −32
@@ -17,7 +17,6 @@
1717
1818 import com.beust.jcommander.internal.Lists;
1919 import com.beust.jcommander.internal.Maps;
20-import com.datastax.driver.core.policies.AddressTranslator;
2120 import com.google.common.collect.ImmutableList;
2221 import com.google.common.collect.ImmutableMap;
2322 import com.google.common.collect.ImmutableSet;
@@ -115,6 +114,10 @@
115114 return -1;
116115 }
117116
117+ public int getBinaryPort() {
118+ return binaryPort;
119+ }
120+
118121 public InetSocketAddress address(int node) {
119122 return new InetSocketAddress(ipPrefix + node, binaryPort);
120123 }
@@ -127,37 +130,6 @@
127130 return new InetSocketAddress(ipPrefix + ipSuffix, binaryPort);
128131 }
129132
130- /**
131- * Returns an {@link AddressTranslator} to use when tests must manually create
132- * {@link Cluster} instances.
133- * <p/>
134- * This translator is necessary because hosts create with this class do not use standard ports.
135- * <p/>
136- * This method should not be called before the test has started, nor after the test is finished.
137- *
138- * @return an {@link AddressTranslator} to use when tests must manually create
139- * {@link Cluster} instances.
140- */
141- public AddressTranslator addressTranslator() {
142- return new AddressTranslator() {
143- @Override
144- public InetSocketAddress translate(InetSocketAddress address) {
145- return new InetSocketAddress(address.getAddress(), binaryPort);
146- }
147-
148- @Override
149- public void init(Cluster cluster) {
150-
151- }
152-
153- @Override
154- public void close() {
155-
156- }
157- };
158- }
159-
160-
161133 public Host host(Cluster cluster, int dc, int node) {
162134 InetAddress address = address(dc, node).getAddress();
163135 for (Host host : cluster.getMetadata().getAllHosts()) {
modified driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java +2 −2
@@ -57,14 +57,14 @@
5757 Cluster.builder()
5858 .withLoadBalancingPolicy(lbPolicy)
5959 .addContactPointsWithPorts(ccm.addressOfNode(1))
60- .withAddressTranslator(ccm.addressTranslator())
60+ .withPort(ccm.getBinaryPort())
6161 .build());
6262 // Put cluster2 control connection on node 2 so it doesn't go down (to prevent noise for debugging).
6363 Cluster cluster2 = register(
6464 Cluster.builder()
6565 .withLoadBalancingPolicy(lbPolicy)
6666 .addContactPointsWithPorts(ccm.addressOfNode(2))
67- .withAddressTranslator(ccm.addressTranslator())
67+ .withPort(ccm.getBinaryPort())
6868 .build());
6969 SchemaChangeListener listener = mock(SchemaChangeListener.class);
7070
modified driver-core/src/test/java/com/datastax/driver/core/SessionLeakTest.java +4 −4
@@ -40,8 +40,8 @@
4040 channelMonitor = new SocketChannelMonitor();
4141 channelMonitor.reportAtFixedInterval(1, TimeUnit.SECONDS);
4242 cluster = register(Cluster.builder()
43- .addContactPointsWithPorts(getHostAddress(1))
44- .withAddressTranslator(getAddressTranslator())
43+ .addContactPoints(ccm.addressOfNode(1).getAddress())
44+ .withPort(ccm.getBinaryPort())
4545 .withNettyOptions(channelMonitor.nettyOptions())
4646 .withQueryOptions(nonDebouncingQueryOptions())
4747 .build());
@@ -97,8 +97,8 @@
9797 channelMonitor = new SocketChannelMonitor();
9898 channelMonitor.reportAtFixedInterval(1, TimeUnit.SECONDS);
9999 cluster = register(Cluster.builder()
100- .addContactPointsWithPorts(getHostAddress(1))
101- .withAddressTranslator(getAddressTranslator())
100+ .addContactPoints(ccm.addressOfNode(1).getAddress())
101+ .withPort(ccm.getBinaryPort())
102102 .withNettyOptions(channelMonitor.nettyOptions())
103103 .build());
104104 cluster.init();
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +4 −4
@@ -51,8 +51,8 @@
5151
5252 loadBalancingPolicy = new SortingLoadBalancingPolicy();
5353 cluster = Cluster.builder()
54- .addContactPointsWithPorts(scassandras.address(2))
55- .withAddressTranslator(scassandras.addressTranslator())
54+ .addContactPoints(scassandras.address(2).getAddress())
55+ .withPort(scassandras.getBinaryPort())
5656 .withProtocolVersion(ProtocolVersion.V2) // Scassandra does not support V3 nor V4 yet
5757 .withLoadBalancingPolicy(loadBalancingPolicy)
5858 .withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(speculativeExecutionDelay, 1))
@@ -203,8 +203,8 @@
203203 SpeculativeExecutionPolicy mockPolicy = mock(SpeculativeExecutionPolicy.class);
204204
205205 Cluster cluster = Cluster.builder()
206- .addContactPointsWithPorts(scassandras.address(2))
207- .withAddressTranslator(scassandras.addressTranslator())
206+ .addContactPoints(scassandras.address(2).getAddress())
207+ .withPort(scassandras.getBinaryPort())
208208 // Scassandra does not support V3 nor V4 yet, and V4 may cause the server to crash
209209 .withProtocolVersion(ProtocolVersion.V2)
210210 .withSpeculativeExecutionPolicy(mockPolicy)
modified driver-core/src/test/java/com/datastax/driver/core/StateListenerTest.java +1 −1
@@ -51,7 +51,7 @@
5151 listener.waitForEvent();
5252
5353 listener.setExpectedEvent(REMOVE);
54- ccm.decommissionNode(2);
54+ ccm.decommision(2);
5555 listener.waitForEvent();
5656 }
5757
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +2 −2
@@ -776,12 +776,12 @@
776776 /**
777777 * @return a {@link Cluster} instance that connects only to the control host of the given cluster.
778778 */
779- public static Cluster buildControlCluster(Cluster cluster, CCMBridge ccm) {
779+ public static Cluster buildControlCluster(Cluster cluster, CCMAccess ccm) {
780780 Host controlHost = cluster.manager.controlConnection.connectedHost();
781781 List<InetSocketAddress> singleAddress = Collections.singletonList(controlHost.getSocketAddress());
782782 return Cluster.builder()
783783 .addContactPointsWithPorts(singleAddress)
784- .withAddressTranslator(ccm.addressTranslator())
784+ .withPort(ccm.getBinaryPort())
785785 .withLoadBalancingPolicy(new WhiteListPolicy(new RoundRobinPolicy(), singleAddress))
786786 .build();
787787 }
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecTupleIntegrationTest.java +2 −2
@@ -94,7 +94,7 @@
9494 CodecRegistry codecRegistry = new CodecRegistry();
9595 Cluster cluster = register(Cluster.builder()
9696 .addContactPointsWithPorts(getInitialContactPoints())
97- .withAddressTranslator(getAddressTranslator())
97+ .withPort(ccm.getBinaryPort())
9898 .withCodecRegistry(codecRegistry)
9999 .build());
100100 Session session = cluster.connect(keyspace);
@@ -124,7 +124,7 @@
124124 CodecRegistry codecRegistry = new CodecRegistry();
125125 Cluster cluster = register(Cluster.builder()
126126 .addContactPointsWithPorts(getInitialContactPoints())
127- .withAddressTranslator(getAddressTranslator())
127+ .withPort(ccm.getBinaryPort())
128128 .withCodecRegistry(codecRegistry)
129129 .build());
130130 Session session = cluster.connect(keyspace);
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecUDTIntegrationTest.java +1 −1
@@ -79,7 +79,7 @@
7979 CodecRegistry codecRegistry = new CodecRegistry();
8080 Cluster cluster = register(Cluster.builder()
8181 .addContactPointsWithPorts(getInitialContactPoints())
82- .withAddressTranslator(getAddressTranslator())
82+ .withPort(ccm.getBinaryPort())
8383 .withCodecRegistry(codecRegistry)
8484 .build());
8585 Session session = cluster.connect(keyspace);
modified driver-core/src/test/java/com/datastax/driver/core/UnresolvedUserTypeTest.java +1 −1
@@ -69,7 +69,7 @@
6969 // The parsing logic should sort them to make sure they are loaded in the right order.
7070 Cluster newCluster = register(Cluster.builder()
7171 .addContactPointsWithPorts(getInitialContactPoints())
72- .withAddressTranslator(getAddressTranslator())
72+ .withPort(ccm.getBinaryPort())
7373 .build());
7474 checkUserTypes(newCluster.getMetadata());
7575 }
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/ExceptionsScassandraTest.java +2 −2
@@ -48,8 +48,8 @@
4848 @BeforeMethod(groups = "short")
4949 public void beforeMethod() {
5050 cluster = Cluster.builder()
51- .addContactPointsWithPorts(scassandras.address(1))
52- .withAddressTranslator(scassandras.addressTranslator())
51+ .addContactPoints(scassandras.address(1).getAddress())
52+ .withPort(scassandras.getBinaryPort())
5353 .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
5454 .build();
5555 session = cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/ExceptionsTest.java +4 −4
@@ -66,8 +66,8 @@
6666 assertEquals(e.getKeyspace(), keyspace.toLowerCase());
6767 assertEquals(e.getTable(), null);
6868 assertEquals(e.wasTableCreation(), false);
69- assertEquals(e.getHost(), getHostAddress(1).getAddress());
70- assertEquals(e.getAddress(), getHostAddress(1));
69+ assertEquals(e.getHost(), ccm.addressOfNode(1).getAddress());
70+ assertEquals(e.getAddress(), ccm.addressOfNode(1));
7171 }
7272
7373 session.execute(cqlCommands[1]);
@@ -80,8 +80,8 @@
8080 assertEquals(e.getKeyspace(), keyspace.toLowerCase());
8181 assertEquals(e.getTable(), table.toLowerCase());
8282 assertEquals(e.wasTableCreation(), true);
83- assertEquals(e.getHost(), getHostAddress(1).getAddress());
84- assertEquals(e.getAddress(), getHostAddress(1));
83+ assertEquals(e.getHost(), ccm.addressOfNode(1).getAddress());
84+ assertEquals(e.getAddress(), ccm.addressOfNode(1));
8585 }
8686 }
8787
modified driver-core/src/test/java/com/datastax/driver/core/policies/AbstractRetryPolicyIntegrationTest.java +2 −2
@@ -77,8 +77,8 @@
7777 scassandras.init();
7878
7979 cluster = Cluster.builder()
80- .addContactPointsWithPorts(scassandras.address(1))
81- .withAddressTranslator(scassandras.addressTranslator())
80+ .addContactPoints(scassandras.address(1).getAddress())
81+ .withPort(scassandras.getBinaryPort())
8282 .withRetryPolicy(retryPolicy)
8383 .withLoadBalancingPolicy(new SortingLoadBalancingPolicy())
8484 // Scassandra does not support V3 nor V4 yet, and V4 may cause the server to crash
modified driver-core/src/test/java/com/datastax/driver/core/policies/CloseableLoadBalancingPolicyTest.java +1 −1
@@ -41,7 +41,7 @@
4141 public Cluster.Builder createClusterBuilder() {
4242 policy = new CloseMonitoringPolicy(Policies.defaultLoadBalancingPolicy());
4343 return Cluster.builder()
44- .addContactPointsWithPorts(getHostAddress(1))
44+ .addContactPoints(ccm.addressOfNode(1).getAddress())
4545 .withLoadBalancingPolicy(policy);
4646 }
4747
modified driver-core/src/test/java/com/datastax/driver/core/policies/DCAwareRoundRobinPolicyTest.java +22 −22
@@ -81,8 +81,8 @@
8181 // given: a 10 node 2 DC cluster.
8282 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(5, 5).build();
8383 Cluster cluster = builder()
84- .addContactPointsWithPorts(sCluster.address(1, 1))
85- .withAddressTranslator(sCluster.addressTranslator())
84+ .addContactPoints(sCluster.address(1, 1).getAddress())
85+ .withPort(sCluster.getBinaryPort())
8686 .withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).build())
8787 .build();
8888 try {
@@ -114,8 +114,8 @@
114114 // given: a 10 node 2 DC cluster with DC policy with 2 remote hosts.
115115 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(5, 5).build();
116116 Cluster cluster = builder()
117- .addContactPointsWithPorts(sCluster.address(1, 1))
118- .withAddressTranslator(sCluster.addressTranslator())
117+ .addContactPoints(sCluster.address(1, 1).getAddress())
118+ .withPort(sCluster.getBinaryPort())
119119 .withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).withUsedHostsPerRemoteDc(2).build())
120120 .build();
121121
@@ -157,8 +157,8 @@
157157 // given: a 10 node 2 DC cluster with DC policy with 2 remote hosts.
158158 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(5, 5).build();
159159 Cluster cluster = builder()
160- .addContactPointsWithPorts(sCluster.address(1, 1))
161- .withAddressTranslator(sCluster.addressTranslator())
160+ .addContactPoints(sCluster.address(1, 1).getAddress())
161+ .withPort(sCluster.getBinaryPort())
162162 .withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build())
163163 .build();
164164
@@ -201,8 +201,8 @@
201201 // a local consistency level.
202202 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
203203 Cluster cluster = builder()
204- .addContactPointsWithPorts(sCluster.address(1, 1))
205- .withAddressTranslator(sCluster.addressTranslator())
204+ .addContactPoints(sCluster.address(1, 1).getAddress())
205+ .withPort(sCluster.getBinaryPort())
206206 .withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build())
207207 .build();
208208
@@ -247,8 +247,8 @@
247247 // a local consistency level.
248248 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
249249 Cluster cluster = builder()
250- .addContactPointsWithPorts(sCluster.address(1, 1))
251- .withAddressTranslator(sCluster.addressTranslator())
250+ .addContactPoints(sCluster.address(1, 1).getAddress())
251+ .withPort(sCluster.getBinaryPort())
252252 .withLoadBalancingPolicy(DCAwareRoundRobinPolicy.builder()
253253 .allowRemoteDCsForLocalConsistencyLevel()
254254 .withUsedHostsPerRemoteDc(2).build())
@@ -293,8 +293,8 @@
293293 DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build(),
294294 Lists.newArrayList(datacenter(2)));
295295 Cluster cluster = builder()
296- .addContactPointsWithPorts(sCluster.address(1, 1))
297- .withAddressTranslator(sCluster.addressTranslator())
296+ .addContactPoints(sCluster.address(1, 1).getAddress())
297+ .withPort(sCluster.getBinaryPort())
298298 .withLoadBalancingPolicy(loadBalancingPolicy)
299299 .build();
300300
@@ -347,8 +347,8 @@
347347 DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build(),
348348 Lists.newArrayList(datacenter(1), datacenter(2)));
349349 Cluster cluster = builder()
350- .addContactPointsWithPorts(sCluster.address(1, 1))
351- .withAddressTranslator(sCluster.addressTranslator())
350+ .addContactPoints(sCluster.address(1, 1).getAddress())
351+ .withPort(sCluster.getBinaryPort())
352352 .withLoadBalancingPolicy(loadBalancingPolicy)
353353 .build();
354354
@@ -399,8 +399,8 @@
399399 DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().build());
400400 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
401401 Cluster cluster = builder()
402- .addContactPointsWithPorts(sCluster.address(1, 1))
403- .withAddressTranslator(sCluster.addressTranslator())
402+ .addContactPoints(sCluster.address(1, 1).getAddress())
403+ .withPort(sCluster.getBinaryPort())
404404 .withLoadBalancingPolicy(policy)
405405 .build();
406406
@@ -439,8 +439,8 @@
439439 DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().build());
440440 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
441441 Cluster cluster = builder()
442- .addContactPointsWithPorts(sCluster.address(1, 1), sCluster.address(2, 1))
443- .withAddressTranslator(sCluster.addressTranslator())
442+ .addContactPoints(sCluster.address(1, 1).getAddress(), sCluster.address(2, 1).getAddress())
443+ .withPort(sCluster.getBinaryPort())
444444 .withLoadBalancingPolicy(policy)
445445 .build();
446446
@@ -478,8 +478,8 @@
478478 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
479479 DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).build());
480480 Cluster cluster = builder()
481- .addContactPointsWithPorts(sCluster.address(1, 1))
482- .withAddressTranslator(sCluster.addressTranslator())
481+ .addContactPoints(sCluster.address(1, 1).getAddress())
482+ .withPort(sCluster.getBinaryPort())
483483 .withLoadBalancingPolicy(policy)
484484 .build();
485485
@@ -518,8 +518,8 @@
518518 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build();
519519 DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(3)).build());
520520 Cluster cluster = builder()
521- .addContactPointsWithPorts(sCluster.address(1, 1), sCluster.address(2, 1))
522- .withAddressTranslator(sCluster.addressTranslator())
521+ .addContactPoints(sCluster.address(1, 1).getAddress(), sCluster.address(2, 1).getAddress())
522+ .withPort(sCluster.getBinaryPort())
523523 .withLoadBalancingPolicy(policy)
524524 .build();
525525
modified driver-core/src/test/java/com/datastax/driver/core/policies/DefaultRetryPolicyIntegrationTest.java +2 −2
@@ -113,8 +113,8 @@
113113 Collections.singletonList(host1.getSocketAddress()));
114114
115115 Cluster whiteListedCluster = Cluster.builder()
116- .addContactPointsWithPorts(scassandras.address(1))
117- .withAddressTranslator(scassandras.addressTranslator())
116+ .addContactPoints(scassandras.address(1).getAddress())
117+ .withPort(scassandras.getBinaryPort())
118118 // Scassandra does not support V3 nor V4 yet, and V4 may cause the server to crash
119119 .withProtocolVersion(ProtocolVersion.V2)
120120 .withRetryPolicy(retryPolicy)
modified driver-core/src/test/java/com/datastax/driver/core/policies/RoundRobinPolicyTest.java +6 −6
@@ -59,8 +59,8 @@
5959 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(5).build();
6060
6161 Cluster cluster = Cluster.builder()
62- .addContactPointsWithPorts(sCluster.address(1))
63- .withAddressTranslator(sCluster.addressTranslator())
62+ .addContactPoints(sCluster.address(1).getAddress())
63+ .withPort(sCluster.getBinaryPort())
6464 .withLoadBalancingPolicy(new RoundRobinPolicy())
6565 .withNettyOptions(nonQuietClusterCloseOptions)
6666 .build();
@@ -95,8 +95,8 @@
9595 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2, 2, 2, 2).build();
9696
9797 Cluster cluster = Cluster.builder()
98- .addContactPointsWithPorts(sCluster.address(1))
99- .withAddressTranslator(sCluster.addressTranslator())
98+ .addContactPoints(sCluster.address(1).getAddress())
99+ .withPort(sCluster.getBinaryPort())
100100 .withLoadBalancingPolicy(new RoundRobinPolicy())
101101 .withNettyOptions(nonQuietClusterCloseOptions)
102102 .build();
@@ -134,8 +134,8 @@
134134 ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(1, 1).build();
135135
136136 Cluster cluster = Cluster.builder()
137- .addContactPointsWithPorts(sCluster.address(1))
138- .withAddressTranslator(sCluster.addressTranslator())
137+ .addContactPoints(sCluster.address(1).getAddress())
138+ .withPort(sCluster.getBinaryPort())
139139 .withLoadBalancingPolicy(new RoundRobinPolicy())
140140 .withNettyOptions(nonQuietClusterCloseOptions)
141141 .build();
modified driver-core/src/test/java/com/datastax/driver/core/policies/TokenAwarePolicyTest.java +10 −10
@@ -70,8 +70,8 @@
7070 }
7171
7272 Cluster cluster = Cluster.builder()
73- .addContactPointsWithPorts(sCluster.address(1))
74- .withAddressTranslator(sCluster.addressTranslator())
73+ .addContactPoints(sCluster.address(1).getAddress())
74+ .withPort(sCluster.getBinaryPort())
7575 .withNettyOptions(nonQuietClusterCloseOptions)
7676 .withLoadBalancingPolicy(loadBalancingPolicy)
7777 .build();
@@ -140,8 +140,8 @@
140140 .withSimpleKeyspace("keyspace", 1)
141141 .build();
142142 Cluster cluster = Cluster.builder()
143- .addContactPointsWithPorts(sCluster.address(1))
144- .withAddressTranslator(sCluster.addressTranslator())
143+ .addContactPoints(sCluster.address(1).getAddress())
144+ .withPort(sCluster.getBinaryPort())
145145 .withNettyOptions(nonQuietClusterCloseOptions)
146146 .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()))
147147 .build();
@@ -185,8 +185,8 @@
185185 .withNetworkTopologyKeyspace("keyspace", ImmutableMap.of(1, 1, 2, 1))
186186 .build();
187187 Cluster cluster = Cluster.builder()
188- .addContactPointsWithPorts(sCluster.address(1))
189- .withAddressTranslator(sCluster.addressTranslator())
188+ .addContactPoints(sCluster.address(1).getAddress())
189+ .withPort(sCluster.getBinaryPort())
190190 .withNettyOptions(nonQuietClusterCloseOptions)
191191 .withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder()
192192 .withLocalDc(ScassandraCluster.datacenter(2))
@@ -232,10 +232,10 @@
232232 .withSimpleKeyspace("keyspace", 2)
233233 .build();
234234 Cluster cluster = Cluster.builder()
235- .addContactPointsWithPorts(sCluster.address(2))
236- .withAddressTranslator(sCluster.addressTranslator())
235+ .addContactPoints(sCluster.address(2).getAddress())
236+ .withPort(sCluster.getBinaryPort())
237237 .withNettyOptions(nonQuietClusterCloseOptions)
238- // Don't shuffle replicas just to keep test deterministic.
238+ // Don't shuffle replicas just to keep test deterministic.
239239 .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy(), false))
240240 .build();
241241
@@ -324,7 +324,7 @@
324324 Cluster cluster = Cluster.builder()
325325 .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()))
326326 .addContactPointsWithPorts(ccm.addressOfNode(1))
327- .withAddressTranslator(ccm.addressTranslator())
327+ .withPort(ccm.getBinaryPort())
328328 .build();
329329
330330 try {
modified driver-core/src/test/java/com/datastax/driver/core/policies/WhiteListPolicyTest.java +2 −2
@@ -53,8 +53,8 @@
5353 List<InetSocketAddress> whiteList = Lists.newArrayList(sCluster.address(3), sCluster.address(5));
5454
5555 Cluster cluster = Cluster.builder()
56- .addContactPointsWithPorts(sCluster.address(5))
57- .withAddressTranslator(sCluster.addressTranslator())
56+ .addContactPoints(sCluster.address(5).getAddress())
57+ .withPort(sCluster.getBinaryPort())
5858 .withLoadBalancingPolicy(new WhiteListPolicy(new RoundRobinPolicy(), whiteList))
5959 .withNettyOptions(nonQuietClusterCloseOptions)
6060 .build();
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperUDTTest.java +1 −1
@@ -310,7 +310,7 @@
310310 // Create a separate Cluster/Session to start with a CodecRegistry from scratch (so not already registered).
311311 Cluster cluster = register(Cluster.builder()
312312 .addContactPointsWithPorts(getInitialContactPoints())
313- .withAddressTranslator(getAddressTranslator())
313+ .withPort(ccm.getBinaryPort())
314314 .build());
315315 CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();
316316 Session session = cluster.connect(keyspace);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/UDTFieldMapperTest.java +4 −4
@@ -40,7 +40,7 @@
4040 ccm = CCMBridge.builder().build();
4141 cluster = Cluster.builder()
4242 .addContactPointsWithPorts(ccm.addressOfNode(1))
43- .withAddressTranslator(ccm.addressTranslator())
43+ .withPort(ccm.getBinaryPort())
4444 .build();
4545 Session session1 = cluster.connect();
4646 session1.execute("create schema if not exists java_509 " +
@@ -56,7 +56,7 @@
5656 // Create entities with another connection
5757 cluster = Cluster.builder()
5858 .addContactPointsWithPorts(ccm.addressOfNode(1))
59- .withAddressTranslator(ccm.addressTranslator())
59+ .withPort(ccm.getBinaryPort())
6060 .build();
6161 Session session2 = cluster.newSession();
6262 Mapper<MyHashWithKeyspace> hashMapper = new MappingManager(session2).mapper(MyHashWithKeyspace.class);
@@ -93,7 +93,7 @@
9393 ccm = CCMBridge.builder().build();
9494 cluster = Cluster.builder()
9595 .addContactPointsWithPorts(ccm.addressOfNode(1))
96- .withAddressTranslator(ccm.addressTranslator())
96+ .withPort(ccm.getBinaryPort())
9797 .build();
9898 Session session1 = cluster.connect();
9999 session1.execute("create schema if not exists java_509 " +
@@ -110,7 +110,7 @@
110110 // Create entities with another connection
111111 cluster = Cluster.builder()
112112 .addContactPointsWithPorts(ccm.addressOfNode(1))
113- .withAddressTranslator(ccm.addressTranslator())
113+ .withPort(ccm.getBinaryPort())
114114 .build();
115115 Session session2 = cluster.newSession();
116116