Elffuss BraidHub

kikocis/java-driver public

Merge remote-tracking branch 'oss/3.0.x' into 3.1.x

Conflicts:
	driver-core/src/main/java/com/datastax/driver/core/utils/UUIDs.java
	driver-examples/pom.xml
	driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationChecks.java
	driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java
Changesetdfb47c04f71cafc661e763a62245e9be159624e1ea20ef9180c6eafead137271
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2017-03-02 11:12 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2017-03-02 11:12 +01:00
Parentse89d80dbfee5, 503af700a078

Browse the files at this changeset

26 files changed

modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +2 −1
@@ -1211,6 +1211,7 @@
12111211
12121212 ChannelFuture future = channel.close();
12131213 future.addListener(new ChannelFutureListener() {
1214+ @Override
12141215 public void operationComplete(ChannelFuture future) {
12151216 factory.allChannels.remove(channel);
12161217 if (future.cause() != null) {
@@ -1421,7 +1422,7 @@
14211422 pipeline.addLast("ssl", sslOptions.newSSLHandler(channel));
14221423 }
14231424
1424- // pipeline.addLast("debug", new LoggingHandler(LogLevel.INFO));
1425+ // pipeline.addLast("debug", new LoggingHandler(LogLevel.INFO));
14251426
14261427 pipeline.addLast("frameDecoder", new Frame.Decoder());
14271428 pipeline.addLast("frameEncoder", frameEncoder);
modified driver-core/src/main/java/com/datastax/driver/core/DataType.java +1 −1
@@ -709,7 +709,7 @@
709709 * The driver provides a minimal support for such types through
710710 * instances of this class.
711711 * <p/>
712- * A codec for custom types can be obtained via {@link TypeCodec#custom(CustomType)}.
712+ * A codec for custom types can be obtained via {@link TypeCodec#custom(DataType.CustomType)}.
713713 */
714714 public static class CustomType extends DataType {
715715
modified driver-core/src/main/java/com/datastax/driver/core/TypeCodec.java +4 −2
@@ -90,8 +90,10 @@
9090 * the wrapper Java class instead, and implement the appropriate interface
9191 * (e.g. {@link com.datastax.driver.core.TypeCodec.PrimitiveBooleanCodec} for primitive {@code boolean} types;
9292 * there is one such interface for each Java primitive type).</li>
93- * <li>TypeCodec implementations should not consume {@link ByteBuffer} instances by performing read operations
94- * that modify their current position; if necessary, codecs should {@link ByteBuffer#duplicate()} duplicate} them.</li>
93+ * <li>When deserializing, TypeCodec implementations should not consume {@link ByteBuffer} instances
94+ * by performing relative read operations that modify their current position;
95+ * codecs should instead prefer absolute read methods, or, if necessary, they should
96+ * {@link ByteBuffer#duplicate() duplicate} their byte buffers prior to reading them.</li>
9597 * </ol>
9698 *
9799 * @param <T> The codec's Java type
modified driver-core/src/main/java/com/datastax/driver/core/policies/FallthroughRetryPolicy.java +1 −1
@@ -24,7 +24,7 @@
2424 /**
2525 * A retry policy that never retries (nor ignores).
2626 * <p/>
27- * All of the methods of this retry policy unconditionally return {@link RetryDecision#rethrow()}.
27+ * All of the methods of this retry policy unconditionally return {@link RetryPolicy.RetryDecision#rethrow()}.
2828 * If this policy is used, retry logic will have to be implemented in business code.
2929 */
3030 public class FallthroughRetryPolicy implements RetryPolicy {
modified driver-core/src/main/java/com/datastax/driver/core/utils/UUIDs.java +1 −0
@@ -68,6 +68,7 @@
6868 private UUIDs() {
6969 }
7070
71+ // http://www.ietf.org/rfc/rfc4122.txt
7172 private static final long START_EPOCH = makeEpoch();
7273 private static final long CLOCK_SEQ_AND_NODE = makeClockSeqAndNode();
7374
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +2 −2
@@ -44,6 +44,7 @@
4444 import static com.datastax.driver.core.TestUtils.ipOfNode;
4545 import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
4646 import static org.mockito.Mockito.*;
47+import static org.scassandra.http.client.PrimingRequest.then;
4748
4849 public class ClusterInitTest {
4950 private static final Logger logger = LoggerFactory.getLogger(ClusterInitTest.class);
@@ -278,8 +279,7 @@
278279 primingClient.prime(
279280 PrimingRequest.queryBuilder()
280281 .withQuery("SELECT * FROM system.peers")
281- .withColumnTypes(ScassandraCluster.SELECT_PEERS)
282- .withRows(rows)
282+ .withThen(then().withRows(rows).withColumnTypes(ScassandraCluster.SELECT_PEERS))
283283 .build());
284284 }
285285 }
modified driver-core/src/test/java/com/datastax/driver/core/ConnectionReleaseTest.java +5 −4
@@ -28,6 +28,7 @@
2828 import java.util.concurrent.TimeoutException;
2929
3030 import static org.assertj.core.api.Assertions.assertThat;
31+import static org.scassandra.http.client.PrimingRequest.then;
3132 import static org.testng.Assert.fail;
3233
3334 public class ConnectionReleaseTest extends ScassandraTestBase {
@@ -66,20 +67,20 @@
6667 primingClient.prime(
6768 PrimingRequest.queryBuilder()
6869 .withQuery("mock query")
69- .withRows(ImmutableMap.of("key", 1))
70- .withFixedDelay(10000)
70+ .withThen(then().withRows(ImmutableMap.of("key", 1))
71+ .withFixedDelay(10000L))
7172 .build()
7273 );
7374 primingClient.prime(
7475 PrimingRequest.queryBuilder()
7576 .withQuery("select c from test1 where k=1")
76- .withRows(ImmutableMap.of("c", "hello"))
77+ .withThen(then().withRows(ImmutableMap.of("c", "hello")))
7778 .build()
7879 );
7980 primingClient.prime(
8081 PrimingRequest.queryBuilder()
8182 .withQuery("select n from test2 where c='hello'")
82- .withRows(ImmutableMap.of("n", "world"))
83+ .withThen(then().withRows(ImmutableMap.of("n", "world")))
8384 .build()
8485 );
8586
modified driver-core/src/test/java/com/datastax/driver/core/ConsistencyTest.java +285 −676
@@ -15,716 +15,325 @@
1515 */
1616 package com.datastax.driver.core;
1717
18-import com.datastax.driver.core.exceptions.InvalidQueryException;
19-import com.datastax.driver.core.exceptions.ReadTimeoutException;
20-import com.datastax.driver.core.exceptions.UnavailableException;
21-import com.datastax.driver.core.exceptions.WriteTimeoutException;
22-import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
23-import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
24-import com.datastax.driver.core.policies.RoundRobinPolicy;
25-import com.datastax.driver.core.policies.TokenAwarePolicy;
26-import com.google.common.util.concurrent.Uninterruptibles;
18+import org.scassandra.Scassandra;
19+import org.scassandra.http.client.BatchExecution;
20+import org.scassandra.http.client.PreparedStatementExecution;
21+import org.scassandra.http.client.Query;
2722 import org.slf4j.Logger;
2823 import org.slf4j.LoggerFactory;
24+import org.testng.annotations.AfterClass;
25+import org.testng.annotations.AfterMethod;
26+import org.testng.annotations.BeforeClass;
2927 import org.testng.annotations.Test;
3028
31-import java.util.Arrays;
32-import java.util.EnumSet;
3329 import java.util.List;
34-import java.util.Set;
35-import java.util.concurrent.TimeUnit;
36-
37-import static com.datastax.driver.core.CreateCCM.TestMode.PER_METHOD;
38-import static com.datastax.driver.core.TestUtils.IP_PREFIX;
39-import static com.datastax.driver.core.TestUtils.ipOfNode;
40-import static java.util.Collections.emptyList;
41-import static java.util.Collections.singletonList;
42-import static org.testng.Assert.assertTrue;
43-import static org.testng.Assert.fail;
44-
45-@SuppressWarnings("unused")
46-@CreateCCM(PER_METHOD)
47-@CCMConfig(
48- dirtiesContext = true,
49- createKeyspace = false,
50- config = {
51- // tests fail often with write or read timeouts
52- "phi_convict_threshold:5",
53- "read_request_timeout_in_ms:200000",
54- "write_request_timeout_in_ms:200000"
55- }
56-)
57-public class ConsistencyTest extends AbstractPoliciesTest {
58-
59- private static final Logger logger = LoggerFactory.getLogger(ConsistencyTest.class);
60-
61- private Cluster.Builder tokenAwareRoundRobin() {
62- return Cluster.builder()
63- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
64- .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()));
65- }
66-
67- private Cluster.Builder tokenAwareRoundRobinNoShuffle() {
68- return Cluster.builder()
69- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
70- .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy(), false));
71- }
7230
73- private Cluster.Builder tokenAwareRoundRobinDowngrading() {
74- return Cluster.builder()
75- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
76- .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()))
77- .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
78- }
31+import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
32+import static org.testng.Assert.*;
7933
80- private Cluster.Builder tokenAwareRoundRobinNoShuffleDowngrading() {
81- return Cluster.builder()
82- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
83- .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy(), false))
84- .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
85- }
34+public class ConsistencyTest {
8635
87- private Cluster.Builder roundRobinDowngrading() {
88- return Cluster.builder()
89- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
90- .withLoadBalancingPolicy(new RoundRobinPolicy())
91- .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
92- }
36+ private static final Logger logger = LoggerFactory.getLogger(ConsistencyTest.class);
37+ private ScassandraCluster sCluster;
9338
94- private Cluster.Builder tokenAwareDCAwareRoundRobinNoShuffleDowngrading() {
95- return Cluster.builder()
96- .withSocketOptions(new SocketOptions().setReadTimeoutMillis(300000))
97- .withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc("dc2").build(), false))
98- .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
39+ @BeforeClass(groups = "short")
40+ public void setUp() {
41+ sCluster = ScassandraCluster.builder().withNodes(1).build();
42+ sCluster.init();
9943 }
10044
101- @Test(groups = "long")
102- @CCMConfig(
103- numberOfNodes = 3,
104- clusterProvider = "tokenAwareRoundRobin")
105- public void testRFOneTokenAware() throws Throwable {
106-
107- createSchema(1);
108- init(12, ConsistencyLevel.ONE);
109- query(12, ConsistencyLevel.ONE);
110-
111- assertQueried(IP_PREFIX + '1', 0);
112- assertQueried(IP_PREFIX + '2', 12);
113- assertQueried(IP_PREFIX + '3', 0);
114-
115- resetCoordinators();
116- stopAndWait(2);
117-
118- List<ConsistencyLevel> acceptedList = singletonList(ConsistencyLevel.ANY);
119-
120- List<ConsistencyLevel> failList = Arrays.asList(
121- ConsistencyLevel.ONE,
122- ConsistencyLevel.TWO,
123- ConsistencyLevel.THREE,
124- ConsistencyLevel.QUORUM,
125- ConsistencyLevel.ALL,
126- ConsistencyLevel.LOCAL_QUORUM,
127- ConsistencyLevel.EACH_QUORUM);
128-
129- // Test successful writes
130- for (ConsistencyLevel cl : acceptedList) {
131- try {
132- init(12, cl);
133- } catch (Exception e) {
134- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
135- }
136- }
137-
138- // Test successful reads
139- for (ConsistencyLevel cl : acceptedList) {
140- try {
141- query(12, cl);
142- } catch (InvalidQueryException e) {
143- List<String> acceptableErrorMessages = singletonList(
144- "ANY ConsistencyLevel is only supported for writes");
145- assertTrue(acceptableErrorMessages.contains(e.getMessage()));
146- }
147- }
148-
149- // Test writes which should fail
150- for (ConsistencyLevel cl : failList) {
151- try {
152- init(12, cl);
153- fail(String.format("Test passed at CL.%s.", cl));
154- } catch (InvalidQueryException e) {
155- List<String> acceptableErrorMessages = Arrays.asList(
156- "consistency level LOCAL_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)",
157- "consistency level EACH_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)");
158- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
159- } catch (UnavailableException e) {
160- // expected to fail when the client has already marked the
161- // node as DOWN
162- } catch (WriteTimeoutException e) {
163- // expected to fail when the client hasn't marked the
164- // node as DOWN yet
165- }
166- }
167-
168- // Test reads which should fail
169- for (ConsistencyLevel cl : failList) {
170- try {
171- query(12, cl);
172- fail(String.format("Test passed at CL.%s.", cl));
173- } catch (InvalidQueryException e) {
174- List<String> acceptableErrorMessages = Arrays.asList(
175- "consistency level LOCAL_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)",
176- "EACH_QUORUM ConsistencyLevel is only supported for writes");
177- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
178- } catch (ReadTimeoutException e) {
179- // expected to fail when the client hasn't marked the
180- // node as DOWN yet
181- } catch (UnavailableException e) {
182- // expected to fail when the client has already marked the
183- // node as DOWN
184- }
185- }
45+ @AfterClass(groups = "short")
46+ public void tearDownClass() {
47+ sCluster.stop();
18648 }
18749
188- @Test(groups = "long")
189- @CCMConfig(numberOfNodes = 3,
190- clusterProvider = "tokenAwareRoundRobinNoShuffle")
191- public void testRFTwoTokenAware() throws Throwable {
192- createSchema(2);
193- init(12, ConsistencyLevel.TWO);
194- query(12, ConsistencyLevel.TWO);
195-
196- assertQueried(IP_PREFIX + '1', 0);
197- assertQueried(IP_PREFIX + '2', 12);
198- assertQueried(IP_PREFIX + '3', 0);
199-
200- resetCoordinators();
201- stopAndWait(2);
202-
203- List<ConsistencyLevel> acceptedList = Arrays.asList(
204- ConsistencyLevel.ANY,
205- ConsistencyLevel.ONE
206- );
207-
208- List<ConsistencyLevel> failList = Arrays.asList(
209- ConsistencyLevel.TWO,
210- ConsistencyLevel.QUORUM,
211- ConsistencyLevel.THREE,
212- ConsistencyLevel.ALL,
213- ConsistencyLevel.LOCAL_QUORUM,
214- ConsistencyLevel.EACH_QUORUM);
215-
216- // Test successful writes
217- for (ConsistencyLevel cl : acceptedList) {
218- try {
219- init(12, cl);
220- } catch (Exception e) {
221- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
222- }
223- }
224-
225- // Test successful reads
226- for (ConsistencyLevel cl : acceptedList) {
227- try {
228- query(12, cl);
229- } catch (InvalidQueryException e) {
230- List<String> acceptableErrorMessages = singletonList(
231- "ANY ConsistencyLevel is only supported for writes");
232- assertTrue(acceptableErrorMessages.contains(e.getMessage()));
233- }
234- }
235-
236- // Test writes which should fail
237- for (ConsistencyLevel cl : failList) {
238- try {
239- init(12, cl);
240- fail(String.format("Test passed at CL.%s.", cl));
241- } catch (InvalidQueryException e) {
242- List<String> acceptableErrorMessages = Arrays.asList(
243- "consistency level LOCAL_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)",
244- "consistency level EACH_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)");
245- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
246- } catch (UnavailableException e) {
247- // expected to fail when the client has already marked the
248- // node as DOWN
249- } catch (WriteTimeoutException e) {
250- // expected to fail when the client hasn't marked the
251- // node as DOWN yet
252- }
253- }
254-
255- // Test reads which should fail
256- for (ConsistencyLevel cl : failList) {
257- try {
258- query(12, cl);
259- fail(String.format("Test passed at CL.%s.", cl));
260- } catch (InvalidQueryException e) {
261- List<String> acceptableErrorMessages = Arrays.asList(
262- "consistency level LOCAL_QUORUM not compatible with replication strategy (org.apache.cassandra.locator.SimpleStrategy)",
263- "EACH_QUORUM ConsistencyLevel is only supported for writes");
264- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
265- } catch (ReadTimeoutException e) {
266- // expected to fail when the client hasn't marked the
267- // node as DOWN yet
268- } catch (UnavailableException e) {
269- // expected to fail when the client has already marked the
270- // node as DOWN
271- }
272- }
50+ @AfterMethod(groups = "short")
51+ public void tearDown() {
52+ clearActivityLog();
27353 }
27454
275- @Test(groups = "long")
276- @CCMConfig(numberOfNodes = 3,
277- clusterProvider = "tokenAwareRoundRobinNoShuffle")
278- public void testRFThreeTokenAware() throws Throwable {
279- createSchema(3);
280- init(12, ConsistencyLevel.TWO);
281- query(12, ConsistencyLevel.TWO);
282-
283- assertQueried(IP_PREFIX + '1', 0);
284- assertQueried(IP_PREFIX + '2', 12);
285- assertQueried(IP_PREFIX + '3', 0);
286-
287- resetCoordinators();
288- stopAndWait(2);
289-
290- Set<ConsistencyLevel> cls = EnumSet.allOf(ConsistencyLevel.class);
291- // Remove serial consistencies as they require conditional read/writes
292- cls.remove(ConsistencyLevel.SERIAL);
293- cls.remove(ConsistencyLevel.LOCAL_SERIAL);
294-
295- List<ConsistencyLevel> acceptedList = Arrays.asList(
296- ConsistencyLevel.ANY,
297- ConsistencyLevel.ONE,
298- ConsistencyLevel.TWO,
299- ConsistencyLevel.QUORUM,
300- ConsistencyLevel.LOCAL_QUORUM,
301- ConsistencyLevel.EACH_QUORUM
302- );
303-
304- List<ConsistencyLevel> failList = Arrays.asList(
305- ConsistencyLevel.THREE,
306- ConsistencyLevel.ALL
307- );
308-
309-
310- // Test successful writes
311- for (ConsistencyLevel cl : acceptedList) {
312- try {
313- init(12, cl);
314- } catch (Exception e) {
315- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
316- }
317- }
318-
319- // Test successful reads
320- for (ConsistencyLevel cl : acceptedList) {
321- try {
322- query(12, cl);
323- } catch (InvalidQueryException e) {
324- List<String> acceptableErrorMessages = Arrays.asList(
325- "ANY ConsistencyLevel is only supported for writes",
326- "EACH_QUORUM ConsistencyLevel is only supported for writes"
327- );
328- assertTrue(acceptableErrorMessages.contains(e.getMessage()), "Got unexpected message " + e.getMessage());
329- }
330- }
331-
332- // Test writes which should fail
333- for (ConsistencyLevel cl : failList) {
334- try {
335- init(12, cl);
336- fail(String.format("Test passed at CL.%s.", cl));
337- } catch (UnavailableException e) {
338- // expected to fail when the client has already marked the
339- // node as DOWN
340- } catch (WriteTimeoutException e) {
341- // expected to fail when the client hasn't marked the
342- // node as DOWN yet
343- }
344- }
345-
346- // Test reads which should fail
347- for (ConsistencyLevel cl : failList) {
348- try {
349- query(12, cl);
350- fail(String.format("Test passed at CL.%s.", cl));
351- } catch (ReadTimeoutException e) {
352- // expected to fail when the client hasn't marked the
353- // node as DOWN yet
354- } catch (UnavailableException e) {
355- // expected to fail when the client has already marked the
356- // node as DOWN
357- }
55+ public void clearActivityLog() {
56+ for (Scassandra node : sCluster.nodes()) {
57+ node.activityClient().clearAllRecordedActivity();
35858 }
35959 }
36060
361-
362- @Test(groups = "long")
363- @CCMConfig(numberOfNodes = 3,
364- clusterProvider = "tokenAwareRoundRobinDowngrading")
365- public void testRFOneDowngradingCL() throws Throwable {
366- createSchema(1);
367- init(12, ConsistencyLevel.ONE);
368- query(12, ConsistencyLevel.ONE);
369-
370- assertQueried(IP_PREFIX + '1', 0);
371- assertQueried(IP_PREFIX + '2', 12);
372- assertQueried(IP_PREFIX + '3', 0);
373-
374- resetCoordinators();
375- stopAndWait(2);
376-
377- List<ConsistencyLevel> acceptedList = singletonList(
378- ConsistencyLevel.ANY
379- );
380-
381- List<ConsistencyLevel> failList = Arrays.asList(
382- ConsistencyLevel.ONE,
383- ConsistencyLevel.TWO,
384- ConsistencyLevel.THREE,
385- ConsistencyLevel.QUORUM,
386- ConsistencyLevel.ALL,
387- ConsistencyLevel.LOCAL_QUORUM,
388- ConsistencyLevel.EACH_QUORUM);
389-
390- // Test successful writes
391- for (ConsistencyLevel cl : acceptedList) {
392- try {
393- init(12, cl);
394- } catch (Exception e) {
395- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
396- }
397- }
398-
399- // Test successful reads
400- for (ConsistencyLevel cl : acceptedList) {
401- try {
402- query(12, cl);
403- } catch (InvalidQueryException e) {
404- List<String> acceptableErrorMessages = singletonList(
405- "ANY ConsistencyLevel is only supported for writes");
406- assertTrue(acceptableErrorMessages.contains(e.getMessage()));
407- }
408- }
409-
410- // Test writes which should fail
411- for (ConsistencyLevel cl : failList) {
412- try {
413- init(12, cl);
414- fail(String.format("Test passed at CL.%s.", cl));
415- } catch (UnavailableException e) {
416- // expected to fail when the client has already marked the
417- // node as DOWN
418- } catch (WriteTimeoutException e) {
419- // expected to fail when the client hasn't marked the
420- // node as DOWN yet
421- }
422- }
423-
424- // Test reads which should fail
425- for (ConsistencyLevel cl : failList) {
426- try {
427- query(12, cl);
428- fail(String.format("Test passed at CL.%s.", cl));
429- } catch (InvalidQueryException e) {
430- List<String> acceptableErrorMessages = singletonList(
431- "EACH_QUORUM ConsistencyLevel is only supported for writes"
432- );
433- assertTrue(acceptableErrorMessages.contains(e.getMessage()), "Got unexpected message " + e.getMessage());
434- } catch (ReadTimeoutException e) {
435- // expected to fail when the client hasn't marked the
436- // node as DOWN yet
437- } catch (UnavailableException e) {
438- // expected to fail when the client has already marked the
439- // node as DOWN
440- }
441- }
61+ public Cluster.Builder builder() {
62+ //Note: nonQuietClusterCloseOptions is used to speed up tests
63+ return Cluster.builder()
64+ .addContactPoints(sCluster.address(1).getAddress())
65+ .withPort(sCluster.getBinaryPort()).withNettyOptions(nonQuietClusterCloseOptions);
44266 }
44367
444- @Test(groups = "long")
445- @CCMConfig(numberOfNodes = 3,
446- clusterProvider = "tokenAwareRoundRobinNoShuffleDowngrading")
447- public void testRFTwoDowngradingCL() throws Throwable {
448- createSchema(2);
449- init(12, ConsistencyLevel.TWO);
450- query(12, ConsistencyLevel.TWO);
451-
452- assertQueried(IP_PREFIX + '1', 0);
453- assertQueried(IP_PREFIX + '2', 12);
454- assertQueried(IP_PREFIX + '3', 0);
455-
456- resetCoordinators();
457- stopAndWait(2);
458-
459- Set<ConsistencyLevel> acceptedList = EnumSet.allOf(ConsistencyLevel.class);
460- // Remove serial consistencies as they require conditional read/writes
461- acceptedList.remove(ConsistencyLevel.SERIAL);
462- acceptedList.remove(ConsistencyLevel.LOCAL_SERIAL);
463-
464- // Test successful writes
465- for (ConsistencyLevel cl : acceptedList) {
466- try {
467- init(12, cl);
468- } catch (Exception e) {
469- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
470- }
68+ /**
69+ * This method checks the expected/sent serial consistency level against that which is received.
70+ * ConsistencyLevel.SERIAL is the default serial consistency level, so even when sent it will return
71+ * as null.
72+ */
73+ public void checkSerialCLMatch(ConsistencyLevel expected, String received) {
74+ if (expected.equals(ConsistencyLevel.SERIAL)) {
75+ assertNull(received);
76+ } else {
77+ assertTrue(received.equals(expected.toString()));
47178 }
472-
473- // Test successful reads
474- for (ConsistencyLevel cl : acceptedList) {
475- try {
476- query(12, cl);
477- } catch (InvalidQueryException e) {
478- List<String> acceptableErrorMessages = Arrays.asList(
479- "ANY ConsistencyLevel is only supported for writes",
480- "EACH_QUORUM ConsistencyLevel is only supported for writes"
481- );
482- assertTrue(acceptableErrorMessages.contains(e.getMessage()), "Got unexpected message " + e.getMessage());
483- }
484- }
485- }
486-
487- @Test(groups = "long")
488- @CCMConfig(numberOfNodes = 3,
489- clusterProvider = "roundRobinDowngrading")
490- public void testRFThreeRoundRobinDowngradingCL() throws Throwable {
491- testRFThreeDowngradingCL();
492- }
493-
494- @Test(groups = "long")
495- @CCMConfig(numberOfNodes = 3,
496- clusterProvider = "tokenAwareRoundRobinNoShuffleDowngrading")
497- public void testRFThreeTokenAwareDowngradingCL() throws Throwable {
498- testRFThreeDowngradingCL();
49979 }
50080
501- private void testRFThreeDowngradingCL() throws Throwable {
502-
503- createSchema(3);
504- init(12, ConsistencyLevel.ALL);
505- query(12, ConsistencyLevel.ALL);
506-
507- try {
508- // This test catches TokenAwarePolicy
509- // However, full tests in LoadBalancingPolicyTest.java
510- assertQueried(IP_PREFIX + '1', 0);
511- assertQueried(IP_PREFIX + '2', 12);
512- assertQueried(IP_PREFIX + '3', 0);
513- } catch (AssertionError e) {
514- // This test catches RoundRobinPolicy
515- assertQueried(IP_PREFIX + '1', 4);
516- assertQueried(IP_PREFIX + '2', 4);
517- assertQueried(IP_PREFIX + '3', 4);
518- }
519-
520- resetCoordinators();
521- stopAndWait(2);
522-
523- Set<ConsistencyLevel> acceptedList = EnumSet.allOf(ConsistencyLevel.class);
524- // Remove serial consistencies as they require conditional read/writes
525- acceptedList.remove(ConsistencyLevel.SERIAL);
526- acceptedList.remove(ConsistencyLevel.LOCAL_SERIAL);
527-
528- // Test successful writes
529- for (ConsistencyLevel cl : acceptedList) {
530- try {
531- init(12, cl);
532- } catch (Exception e) {
533- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
534- }
81+ public PreparedStatementExecution executePrepared(Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) {
82+ PreparedStatement ps = session.prepare(statement);
83+ BoundStatement bound = ps.bind();
84+ if (level != null) {
85+ bound.setConsistencyLevel(level);
53586 }
536-
537- // Test successful reads
538- for (ConsistencyLevel cl : acceptedList) {
539- try {
540- query(12, cl);
541- } catch (InvalidQueryException e) {
542- List<String> acceptableErrorMessages = Arrays.asList(
543- "ANY ConsistencyLevel is only supported for writes",
544- "EACH_QUORUM ConsistencyLevel is only supported for writes"
545- );
546- assertTrue(acceptableErrorMessages.contains(e.getMessage()), "Got unexpected message " + e.getMessage());
547- }
87+ if (serialLevel != null) {
88+ bound.setSerialConsistencyLevel(serialLevel);
54889 }
90+ session.execute(bound);
91+ List<PreparedStatementExecution> pses = sCluster.node(1).activityClient().retrievePreparedStatementExecutions();
92+ PreparedStatementExecution pse = pses.get(0);
93+ assertTrue(pse.getPreparedStatementText().equals(statement));
94+ return pse;
54995 }
55096
551- @Test(groups = "long")
552- @CCMConfig(
553- numberOfNodes = {3, 3},
554- clusterProvider = "tokenAwareRoundRobinNoShuffleDowngrading"
555- )
556- public void testRFThreeDowngradingCLTwoDCs() throws Throwable {
557- createMultiDCSchema(3, 3);
558- init(12, ConsistencyLevel.TWO);
559- query(12, ConsistencyLevel.TWO);
560-
561- assertQueried(IP_PREFIX + '1', 0);
562- assertQueried(IP_PREFIX + '2', 12);
563- assertQueried(IP_PREFIX + '3', 0);
564- assertQueried(IP_PREFIX + '4', 0);
565- assertQueried(IP_PREFIX + '5', 0);
566- assertQueried(IP_PREFIX + '6', 0);
567-
568- resetCoordinators();
569- stopAndWait(3);
570-
571- List<ConsistencyLevel> acceptedList = Arrays.asList(
572- ConsistencyLevel.ANY,
573- ConsistencyLevel.ONE,
574- ConsistencyLevel.TWO,
575- ConsistencyLevel.QUORUM,
576- ConsistencyLevel.THREE,
577- ConsistencyLevel.ALL,
578- ConsistencyLevel.LOCAL_QUORUM,
579- ConsistencyLevel.EACH_QUORUM
580- );
581-
582- List<ConsistencyLevel> failList = emptyList();
583-
584- // Test successful writes
585- for (ConsistencyLevel cl : acceptedList) {
586- logger.debug("Test successful init(): " + cl);
587- try {
588- init(12, cl);
589- } catch (Exception e) {
590- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
591- }
592- }
593-
594- // Test successful reads
595- for (ConsistencyLevel cl : acceptedList) {
596- logger.debug("Test successful query(): " + cl);
597- try {
598- query(12, cl);
599- } catch (InvalidQueryException e) {
600- List<String> acceptableErrorMessages = Arrays.asList(
601- "EACH_QUORUM ConsistencyLevel is only supported for writes",
602- "ANY ConsistencyLevel is only supported for writes");
603- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
604- }
605- }
97+ public BatchExecution executeBatch(Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) {
98+ BatchStatement batch = new BatchStatement();
99+ batch.add(new SimpleStatement(statement));
606100
607- // Test writes which should fail
608- for (ConsistencyLevel cl : failList) {
609- logger.debug("Test failure init(): " + cl);
610- try {
611- init(12, cl);
612- fail(String.format("Test passed at CL.%s.", cl));
613- } catch (UnavailableException e) {
614- // expected to fail when the client has already marked the
615- // node as DOWN
616- } catch (WriteTimeoutException e) {
617- // expected to fail when the client hasn't marked the
618- // node as DOWN yet
619- }
101+ if (level != null) {
102+ batch.setConsistencyLevel(level);
620103 }
621-
622- // Test reads which should fail
623- for (ConsistencyLevel cl : failList) {
624- logger.debug("Test failure query(): " + cl);
625- try {
626- query(12, cl);
627- fail(String.format("Test passed at CL.%s.", cl));
628- } catch (ReadTimeoutException e) {
629- // expected to fail when the client hasn't marked the
630- // node as DOWN yet
631- } catch (UnavailableException e) {
632- // expected to fail when the client has already marked the
633- // node as DOWN
634- }
104+ if (serialLevel != null) {
105+ batch.setSerialConsistencyLevel(serialLevel);
635106 }
107+ session.execute(batch);
108+ List<BatchExecution> batches = sCluster.node(1).activityClient().retrieveBatches();
109+ assertEquals(batches.size(), 1);
110+ return batches.get(0);
636111 }
637112
638- @Test(groups = "long")
639- @CCMConfig(
640- numberOfNodes = {3, 3},
641- clusterProvider = "tokenAwareDCAwareRoundRobinNoShuffleDowngrading"
642- )
643- public void testRFThreeDowngradingCLTwoDCsDCAware() throws Throwable {
644- createMultiDCSchema(3, 3);
645- init(12, ConsistencyLevel.TWO);
646- query(12, ConsistencyLevel.TWO);
647-
648- assertQueried(IP_PREFIX + '1', 0);
649- assertQueried(IP_PREFIX + '2', 0);
650- assertQueried(IP_PREFIX + '3', 0);
651- assertQueried(IP_PREFIX + '4', 0);
652- assertQueried(IP_PREFIX + '5', 12);
653- assertQueried(IP_PREFIX + '6', 0);
654-
655- resetCoordinators();
656- stopAndWait(2);
657-
658- List<ConsistencyLevel> acceptedList = Arrays.asList(
659- ConsistencyLevel.ANY,
660- ConsistencyLevel.ONE,
661- ConsistencyLevel.TWO,
662- ConsistencyLevel.QUORUM,
663- ConsistencyLevel.THREE,
664- ConsistencyLevel.ALL,
665- ConsistencyLevel.LOCAL_QUORUM,
666- ConsistencyLevel.EACH_QUORUM
667- );
668-
669- List<ConsistencyLevel> failList = emptyList();
670-
671- // Test successful writes
672- for (ConsistencyLevel cl : acceptedList) {
673- try {
674- init(12, cl);
675- } catch (Exception e) {
676- fail(String.format("Test failed at CL.%s with message: %s", cl, e.getMessage()));
677- }
678- }
679-
680- // Test successful reads
681- for (ConsistencyLevel cl : acceptedList) {
682- try {
683- query(12, cl);
684- } catch (InvalidQueryException e) {
685- List<String> acceptableErrorMessages = Arrays.asList(
686- "EACH_QUORUM ConsistencyLevel is only supported for writes",
687- "ANY ConsistencyLevel is only supported for writes");
688- assertTrue(acceptableErrorMessages.contains(e.getMessage()), String.format("Received: %s", e.getMessage()));
689- }
690- }
691-
692- // Test writes which should fail
693- for (ConsistencyLevel cl : failList) {
694- try {
695- init(12, cl);
696- fail(String.format("Test passed at CL.%s.", cl));
697- } catch (UnavailableException e) {
698- // expected to fail when the client has already marked the
699- // node as DOWN
700- } catch (WriteTimeoutException e) {
701- // expected to fail when the client hasn't marked the
702- // node as DOWN yet
703- }
113+ public Query executeSimple(Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) {
114+ SimpleStatement simpleStatement = new SimpleStatement(statement);
115+ if (level != null) {
116+ simpleStatement.setConsistencyLevel(level);
704117 }
118+ if (serialLevel != null) {
119+ simpleStatement.setSerialConsistencyLevel(serialLevel);
120+ }
121+ session.execute(simpleStatement);
122+ //Find the unique query in the activity log.
123+ List<Query> queries = sCluster.node(1).activityClient().retrieveQueries();
124+ for (Query query : queries) {
125+ if (query.getQuery().equals(statement))
126+ return query;
127+ }
128+ return null;
129+ }
130+
131+ /**
132+ * When no consistency level is defined the default of LOCAL_ONE should be used.
133+ *
134+ * @test_category consistency
135+ */
136+ @Test(groups = "short")
137+ public void should_use_global_default_cl_when_none_specified() throws Throwable {
138+ //Build a cluster with no CL level set in the query options.
139+ Cluster cluster = builder().build();
140+ try {
141+ Session session = cluster.connect();
142+
143+ //Construct unique simple statement query, with no CL defined.
144+ //Check to ensure
145+ String queryString = "default_cl";
146+ Query clQuery = executeSimple(session, queryString, null, null);
147+ assertTrue(clQuery.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
148+
149+ //Check prepared statement default CL
150+ String prepareString = "prepared_default_cl";
151+ PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
152+ assertTrue(pse.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
153+
154+ //Check batch statement default CL
155+ String batchStateString = "batch_default_cl";
156+ BatchExecution batch = executeBatch(session, batchStateString, null, null);
157+ assertTrue(batch.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
158+ } finally {
159+ cluster.close();
160+ }
161+ }
162+
163+ /**
164+ * Exhaustively tests all consistency levels when they are set via QueryOptions.
165+ *
166+ * @test_category consistency
167+ */
168+ @Test(groups = "short", dataProvider = "consistencyLevels", dataProviderClass = DataProviders.class)
169+ public void should_use_query_option_cl(ConsistencyLevel cl) throws Throwable {
170+ //Build a cluster with a CL level set in the query options.
171+ Cluster cluster = builder().withQueryOptions(new QueryOptions().setConsistencyLevel(cl)).build();
172+ try {
173+ Session session = cluster.connect();
174+ //Construct unique query, with no CL defined.
175+ String queryString = "query_cl";
176+ Query clQuery = executeSimple(session, queryString, null, null);
177+ assertTrue(clQuery.getConsistency().equals(cl.toString()));
178+
179+ //Check prepared statement CL
180+ String prepareString = "preapred_query_cl";
181+ PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
182+ assertTrue(pse.getConsistency().equals(cl.toString()));
183+
184+ //Check batch statement CL
185+ String batchStateString = "batch_query_cl";
186+ BatchExecution batch = executeBatch(session, batchStateString, null, null);
187+ assertTrue(batch.getConsistency().equals(cl.toString()));
188+ } finally {
189+ cluster.close();
190+ }
191+ }
192+
193+ /**
194+ * Exhaustively tests all consistency levels when they are set at the statement level.
195+ *
196+ * @test_category consistency
197+ */
198+ @Test(groups = "short", dataProvider = "consistencyLevels", dataProviderClass = DataProviders.class)
199+ public void should_use_statement_cl(ConsistencyLevel cl) throws Throwable {
200+ //Build a cluster with no CL set in the query options.
201+ //Note: nonQuietClusterCloseOptions is used to speed up tests
202+ Cluster cluster = builder().build();
203+ try {
204+ Session session = cluster.connect();
205+ //Construct unique query statement with a CL defined.
206+ String queryString = "statement_cl";
207+ Query clQuery = executeSimple(session, queryString, cl, null);
208+ assertTrue(clQuery.getConsistency().equals(cl.toString()));
209+
210+ //Check prepared statement CL
211+ String prepareString = "preapred_statement_cl";
212+ PreparedStatementExecution pse = executePrepared(session, prepareString, cl, null);
213+ assertTrue(pse.getConsistency().equals(cl.toString()));
214+
215+ //Check batch statement CL
216+ String batchStateString = "batch_statement_cl";
217+ BatchExecution batch = executeBatch(session, batchStateString, cl, null);
218+ assertTrue(batch.getConsistency().equals(cl.toString()));
219+ } finally {
220+ cluster.close();
221+ }
222+ }
223+
224+ /**
225+ * Tests that order of precedence is followed when defining CLs.
226+ * Statement level CL should be honored above QueryOptions.
227+ * QueryOptions should be honored above default CL.
228+ *
229+ * @test_category consistency
230+ */
231+ @Test(groups = "short")
232+ public void should_use_appropriate_cl_when_multiple_defined() throws Throwable {
233+ ConsistencyLevel cl_one = ConsistencyLevel.ONE;
234+ //Build a cluster with no CL set in the query options.
235+ Cluster cluster = builder().withQueryOptions(new QueryOptions().setConsistencyLevel(cl_one)).build();
236+ try {
705237
706- // Test reads which should fail
707- for (ConsistencyLevel cl : failList) {
708- try {
709- query(12, cl);
710- fail(String.format("Test passed at CL.%s.", cl));
711- } catch (ReadTimeoutException e) {
712- // expected to fail when the client hasn't marked the
713- // node as DOWN yet
714- } catch (UnavailableException e) {
715- // expected to fail when the client has already marked the
716- // node as DOWN
717- }
238+ Session session = cluster.connect();
239+
240+ //Check order of precedence for simple statements
241+ //Construct unique query statement with no CL defined.
242+ String queryString = "opts_cl";
243+ Query clQuery = executeSimple(session, queryString, null, null);
244+ assertTrue(clQuery.getConsistency().equals(cl_one.toString()));
245+
246+ //Construct unique query statement with a CL defined.
247+ ConsistencyLevel cl_all = ConsistencyLevel.ALL;
248+ queryString = "stm_cl";
249+ clQuery = executeSimple(session, queryString, cl_all, null);
250+ assertTrue(clQuery.getConsistency().equals(cl_all.toString()));
251+
252+ //Check order of precedence for prepared statements
253+ //Construct unique prepared statement with no CL defined.
254+ String prepareString = "prep_opts_cl";
255+ PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
256+ assertTrue(pse.getConsistency().equals(cl_one.toString()));
257+ clearActivityLog();
258+
259+ //Construct unique prepared statement with a CL defined.
260+ prepareString = "prep_stm_cl";
261+ pse = executePrepared(session, prepareString, cl_all, null);
262+ assertTrue(pse.getConsistency().equals(cl_all.toString()));
263+
264+ //Check order of precedence for batch statements
265+ //Construct unique batch statement with no CL defined.
266+ String batchString = "batch_opts_cl";
267+ BatchExecution batch = executeBatch(session, batchString, null, null);
268+ assertTrue(batch.getConsistency().equals(cl_one.toString()));
269+ clearActivityLog();
270+
271+ //Construct unique prepared statement with a CL defined.
272+ batchString = "prep_stm_cl";
273+ batch = executeBatch(session, batchString, cl_all, null);
274+ assertTrue(batch.getConsistency().equals(cl_all.toString()));
275+ } finally {
276+ cluster.close();
277+ }
278+ }
279+
280+ /**
281+ * Exhaustively tests all serial consistency levels when they are set via QueryOptions.
282+ *
283+ * @test_category consistency
284+ */
285+ @Test(groups = "short", dataProvider = "serialConsistencyLevels", dataProviderClass = DataProviders.class)
286+ public void should_use_query_option_serial_cl(ConsistencyLevel cl) throws Throwable {
287+ //Build a cluster with a CL level set in the query options.
288+ Cluster cluster = builder().withQueryOptions(new QueryOptions().setSerialConsistencyLevel(cl)).build();
289+ try {
290+ Session session = cluster.connect();
291+ //Construct unique query, with no CL defined.
292+ String queryString = "serial_query_cl";
293+ Query clQuery = executeSimple(session, queryString, null, cl);
294+ checkSerialCLMatch(cl, clQuery.getSerialConsistency());
295+
296+ //Check prepared statement CL
297+ String prepareString = "preapred_statement_serial_cl";
298+ PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
299+ checkSerialCLMatch(cl, pse.getSerialConsistency());
300+
301+ //Check batch statement CL
302+ String batchStateString = "batch_statement_serial_cl";
303+ BatchExecution batch = executeBatch(session, batchStateString, null, null);
304+ checkSerialCLMatch(cl, batch.getSerialConsistency());
305+ } finally {
306+ cluster.close();
307+ }
308+ }
309+
310+ /**
311+ * Exhaustively tests all serial consistency levels when they are set at the statement level.
312+ *
313+ * @test_category consistency
314+ */
315+ @Test(groups = "short", dataProvider = "serialConsistencyLevels", dataProviderClass = DataProviders.class)
316+ public void should_use_statement_serial_cl(ConsistencyLevel cl) throws Throwable {
317+ //Build a cluster with no CL set in the query options.
318+ Cluster cluster = builder().build();
319+ try {
320+ Session session = cluster.connect();
321+ //Construct unique query statement with a CL defined.
322+ String queryString = "statement_serial_cl";
323+ Query clQuery = executeSimple(session, queryString, null, cl);
324+ checkSerialCLMatch(cl, clQuery.getSerialConsistency());
325+
326+ //Check prepared statement CL
327+ String prepareString = "preapred_statement_serial_cl";
328+ PreparedStatementExecution pse = executePrepared(session, prepareString, null, cl);
329+ checkSerialCLMatch(cl, pse.getSerialConsistency());
330+
331+ //Check batch statement CL
332+ String batchStateString = "batch_statement_serial_cl";
333+ BatchExecution batch = executeBatch(session, batchStateString, null, cl);
334+ checkSerialCLMatch(cl, batch.getSerialConsistency());
335+ } finally {
336+ cluster.close();
718337 }
719338 }
720-
721- private void stopAndWait(int node) {
722- logger.debug("Stopping node " + node);
723- ccm().stop(node);
724- ccm().waitForDown(node);// this uses port ping
725- TestUtils.waitForDown(ipOfNode(node), cluster()); // this uses UP/DOWN events
726- logger.debug("Node " + node + " stopped, sleeping one extra minute to allow nodes to gossip");
727- Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MINUTES);
728- }
729-
730339 }
modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +7 −0
@@ -123,6 +123,7 @@
123123 public HostAssert goesDownWithin(long duration, TimeUnit unit) {
124124 final CountDownLatch downSignal = new CountDownLatch(1);
125125 StateListener upListener = new StateListenerBase() {
126+ @Override
126127 public void onDown(Host host) {
127128 downSignal.countDown();
128129 }
@@ -141,31 +142,37 @@
141142 return this;
142143 }
143144
145+ @SuppressWarnings("deprecation")
144146 public HostAssert hasWorkload(String workload) {
145147 assertThat(actual.getDseWorkload()).isNotNull().isEqualTo(workload);
146148 return this;
147149 }
148150
151+ @SuppressWarnings("deprecation")
149152 public HostAssert hasNoWorkload() {
150153 assertThat(actual.getDseWorkload()).isNull();
151154 return this;
152155 }
153156
157+ @SuppressWarnings("deprecation")
154158 public HostAssert hasDseVersion(VersionNumber versionNumber) {
155159 assertThat(actual.getDseVersion()).isNotNull().isEqualTo(versionNumber);
156160 return this;
157161 }
158162
163+ @SuppressWarnings("deprecation")
159164 public HostAssert hasNoDseVersion() {
160165 assertThat(actual.getDseVersion()).isNull();
161166 return this;
162167 }
163168
169+ @SuppressWarnings("deprecation")
164170 public HostAssert hasDseGraph() {
165171 assertThat(actual.isDseGraphEnabled()).isTrue();
166172 return this;
167173 }
168174
175+ @SuppressWarnings("deprecation")
169176 public HostAssert hasNoDseGraph() {
170177 assertThat(actual.isDseGraphEnabled()).isFalse();
171178 return this;
modified driver-core/src/test/java/com/datastax/driver/core/RequestHandlerTest.java +6 −2
@@ -20,10 +20,14 @@
2020 import org.scassandra.http.client.PrimingRequest;
2121 import org.testng.annotations.Test;
2222
23+import java.util.Collections;
24+import java.util.List;
25+import java.util.Map;
2326 import java.util.concurrent.TimeUnit;
2427 import java.util.concurrent.TimeoutException;
2528
2629 import static org.assertj.core.api.Assertions.assertThat;
30+import static org.scassandra.http.client.PrimingRequest.then;
2731
2832 public class RequestHandlerTest {
2933
@@ -35,11 +39,11 @@
3539 try {
3640 // Use a mock server that takes a constant time to reply
3741 scassandra.start();
42+ List<Map<String, ?>> rows = Collections.<Map<String, ?>>singletonList(ImmutableMap.of("key", 1));
3843 scassandra.primingClient().prime(
3944 PrimingRequest.queryBuilder()
4045 .withQuery("mock query")
41- .withRows(ImmutableMap.of("key", 1))
42- .withFixedDelay(10)
46+ .withThen(then().withRows(rows).withFixedDelay(10L))
4347 .build()
4448 );
4549
modified driver-core/src/test/java/com/datastax/driver/core/ScassandraCluster.java +3 −2
@@ -27,6 +27,7 @@
2727
2828 import java.net.InetAddress;
2929 import java.net.InetSocketAddress;
30+import java.util.Collections;
3031 import java.util.List;
3132 import java.util.Map;
3233 import java.util.TreeSet;
@@ -364,7 +365,7 @@
364365 .withQuery(query)
365366 .withThen(then()
366367 .withColumnTypes(metadata)
367- .withRows(row)
368+ .withRows(Collections.<Map<String, ?>>singletonList(row))
368369 .build())
369370 .build());
370371 }
@@ -386,7 +387,7 @@
386387 .withQuery("select cluster_name from system.local")
387388 .withThen(then()
388389 .withColumnTypes(SELECT_CLUSTER_NAME)
389- .withRows(clusterNameRow)
390+ .withRows(Collections.<Map<String, ?>>singletonList(clusterNameRow))
390391 .build())
391392 .build());
392393
modified driver-core/src/test/java/com/datastax/driver/core/SpeculativeExecutionTest.java +10 −14
@@ -35,6 +35,7 @@
3535 import static com.datastax.driver.core.Assertions.assertThat;
3636 import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
3737 import static org.mockito.Mockito.*;
38+import static org.scassandra.http.client.PrimingRequest.then;
3839
3940 public class SpeculativeExecutionTest {
4041 ScassandraCluster scassandras;
@@ -84,7 +85,7 @@
8485 public void should_not_start_speculative_execution_if_first_execution_completes_successfully() {
8586 scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder()
8687 .withQuery("mock query")
87- .withRows(row("result", "result1"))
88+ .withThen(then().withRows(row("result", "result1")))
8889 .build()
8990 );
9091
@@ -104,14 +105,14 @@
104105 scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder()
105106 .withQuery("mock query")
106107 .withConsistency(Consistency.TWO)
107- .withResult(Result.read_request_timeout)
108+ .withThen(then().withResult(Result.read_request_timeout))
108109 .build()
109110 );
110111
111112 scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder()
112113 .withQuery("mock query")
113114 .withConsistency(Consistency.ONE)
114- .withRows(row("result", "result1"))
115+ .withThen(then().withRows(row("result", "result1")))
115116 .build()
116117 );
117118
@@ -134,14 +135,13 @@
134135 public void should_start_speculative_execution_if_first_execution_takes_too_long() {
135136 scassandras.node(1).primingClient().prime(PrimingRequest.queryBuilder()
136137 .withQuery("mock query")
137- .withFixedDelay(400)
138- .withRows(row("result", "result1"))
138+ .withThen(then().withRows(row("result", "result1")).withFixedDelay(400L))
139139 .build()
140140 );
141141
142142 scassandras.node(2).primingClient().prime(PrimingRequest.queryBuilder()
143143 .withQuery("mock query")
144- .withRows(row("result", "result2"))
144+ .withThen(then().withRows(row("result", "result2")))
145145 .build()
146146 );
147147 long execStartCount = errors.getSpeculativeExecutions().getCount();
@@ -163,15 +163,13 @@
163163 // execution1 starts with host1, which will time out at t=1000
164164 .prime(PrimingRequest.queryBuilder()
165165 .withQuery("mock query")
166- .withFixedDelay(2000)
167- .withRows(row("result", "result1"))
166+ .withThen(then().withRows(row("result", "result1")).withFixedDelay(2000L))
168167 .build());
169168 // at t=1000, execution1 moves to host3, which eventually succeeds at t=1500
170169 scassandras.node(3).primingClient()
171170 .prime(PrimingRequest.queryBuilder()
172171 .withQuery("mock query")
173- .withFixedDelay(500)
174- .withRows(row("result", "result3"))
172+ .withThen(then().withRows(row("result", "result3")).withFixedDelay(500L))
175173 .build());
176174 // meanwhile, execution2 starts at t=200, using host2 which times out at t=1200
177175 // at that time, the query plan is empty so execution2 fails
@@ -179,8 +177,7 @@
179177 scassandras.node(2).primingClient()
180178 .prime(PrimingRequest.queryBuilder()
181179 .withQuery("mock query")
182- .withFixedDelay(2000)
183- .withRows(row("result", "result2"))
180+ .withThen(then().withRows(row("result", "result2")).withFixedDelay(2000L))
184181 .build());
185182 long execStartCount = errors.getSpeculativeExecutions().getCount();
186183
@@ -247,8 +244,7 @@
247244 // execution1 starts with host1, which will time out at t=1000
248245 .prime(PrimingRequest.queryBuilder()
249246 .withQuery("mock query")
250- .withFixedDelay(2000)
251- .withRows(row("result", "result1"))
247+ .withThen(then().withRows(row("result", "result1")).withFixedDelay(2000L))
252248 .build());
253249
254250 Session session = cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +3 −3
@@ -129,13 +129,13 @@
129129 data.setUUID(i, (UUID) value);
130130 break;
131131 case LIST:
132- data.setList(i, (List) value);
132+ data.setList(i, (List<?>) value);
133133 break;
134134 case SET:
135- data.setSet(i, (Set) value);
135+ data.setSet(i, (Set<?>) value);
136136 break;
137137 case MAP:
138- data.setMap(i, (Map) value);
138+ data.setMap(i, (Map<?, ?>) value);
139139 break;
140140 default:
141141 throw new RuntimeException("Missing handling of " + type);
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/ExceptionsScassandraTest.java +2 −1
@@ -30,6 +30,7 @@
3030 import static com.datastax.driver.core.ConsistencyLevel.LOCAL_ONE;
3131 import static org.assertj.core.api.Assertions.assertThat;
3232 import static org.assertj.core.api.Assertions.fail;
33+import static org.scassandra.http.client.PrimingRequest.then;
3334 import static org.scassandra.http.client.Result.*;
3435
3536 public class ExceptionsScassandraTest {
@@ -115,7 +116,7 @@
115116 protected void simulateError(int hostNumber, Result result) {
116117 scassandras.node(hostNumber).primingClient().prime(PrimingRequest.queryBuilder()
117118 .withQuery("mock query")
118- .withResult(result)
119+ .withThen(then().withResult(result))
119120 .build());
120121 }
121122
modified driver-core/src/test/java/com/datastax/driver/core/policies/AbstractRetryPolicyIntegrationTest.java +7 −5
@@ -39,6 +39,7 @@
3939 import static org.assertj.core.api.Assertions.assertThat;
4040 import static org.mockito.Matchers.*;
4141 import static org.mockito.Mockito.times;
42+import static org.scassandra.http.client.PrimingRequest.then;
4243 import static org.scassandra.http.client.Result.overloaded;
4344 import static org.scassandra.http.client.Result.server_error;
4445
@@ -111,12 +112,13 @@
111112 }
112113
113114 protected void simulateError(int hostNumber, Result result, Config config) {
114- PrimingRequestBuilder builder = PrimingRequest.queryBuilder()
115- .withQuery("mock query")
116- .withResult(result);
115+ PrimingRequest.Then.ThenBuilder then = then().withResult(result);
116+ PrimingRequestBuilder builder = PrimingRequest.queryBuilder().withQuery("mock query");
117117
118118 if (config != null)
119- builder = builder.withConfig(config);
119+ then = then.withConfig(config);
120+
121+ builder = builder.withThen(then);
120122
121123 scassandras.node(hostNumber).primingClient().prime(builder.build());
122124 }
@@ -124,7 +126,7 @@
124126 protected void simulateNormalResponse(int hostNumber) {
125127 scassandras.node(hostNumber).primingClient().prime(PrimingRequest.queryBuilder()
126128 .withQuery("mock query")
127- .withRows(row("result", "result1"))
129+ .withThen(then().withRows(row("result", "result1")))
128130 .build());
129131 }
130132
modified driver-core/src/test/java/com/datastax/driver/core/policies/LatencyAwarePolicyTest.java +3 −2
@@ -27,6 +27,7 @@
2727 import static org.assertj.core.api.Assertions.assertThat;
2828 import static org.assertj.core.api.Assertions.fail;
2929 import static org.scassandra.http.client.PrimingRequest.queryBuilder;
30+import static org.scassandra.http.client.PrimingRequest.then;
3031 import static org.scassandra.http.client.Result.read_request_timeout;
3132 import static org.scassandra.http.client.Result.unavailable;
3233
@@ -106,7 +107,7 @@
106107 primingClient.prime(
107108 queryBuilder()
108109 .withQuery(query)
109- .withResult(unavailable)
110+ .withThen(then().withResult(unavailable))
110111 .build()
111112 );
112113 LatencyAwarePolicy latencyAwarePolicy = LatencyAwarePolicy.builder(new RoundRobinPolicy())
@@ -150,7 +151,7 @@
150151 primingClient.prime(
151152 queryBuilder()
152153 .withQuery(query)
153- .withResult(read_request_timeout)
154+ .withThen(then().withResult(read_request_timeout))
154155 .build()
155156 );
156157
modified driver-dist/pom.xml +12 −39
@@ -70,51 +70,13 @@
7070 </goals>
7171 <configuration>
7272 <includeDependencySources>true</includeDependencySources>
73- <!-- optional dependencies from other modules (must be explicitly declared here in order to be correctly resolved) -->
74- <additionalDependencies>
75- <additionalDependency>
76- <groupId>org.xerial.snappy</groupId>
77- <artifactId>snappy-java</artifactId>
78- <version>${snappy.version}</version>
79- </additionalDependency>
80- <additionalDependency>
81- <groupId>net.jpountz.lz4</groupId>
82- <artifactId>lz4</artifactId>
83- <version>${lz4.version}</version>
84- </additionalDependency>
85- <additionalDependency>
86- <groupId>org.hdrhistogram</groupId>
87- <artifactId>HdrHistogram</artifactId>
88- <version>${hdr.version}</version>
89- </additionalDependency>
90- <additionalDependency>
91- <groupId>com.fasterxml.jackson.core</groupId>
92- <artifactId>jackson-core</artifactId>
93- <version>${jackson.version}</version>
94- </additionalDependency>
95- <additionalDependency>
96- <groupId>com.fasterxml.jackson.core</groupId>
97- <artifactId>jackson-databind</artifactId>
98- <version>${jackson.version}</version>
99- </additionalDependency>
100- <additionalDependency>
101- <groupId>joda-time</groupId>
102- <artifactId>joda-time</artifactId>
103- <version>${joda.version}</version>
104- </additionalDependency>
105- <additionalDependency>
106- <groupId>javax.json</groupId>
107- <artifactId>javax.json-api</artifactId>
108- <version>${jsr353-api.version}</version>
109- </additionalDependency>
110- </additionalDependencies>
11173 </configuration>
11274 </execution>
11375 </executions>
11476 </plugin>
11577 <plugin>
11678 <artifactId>maven-assembly-plugin</artifactId>
117- <version>2.6</version>
79+ <version>3.0.0</version>
11880 <executions>
11981 <execution>
12082 <id>assemble-binary-tarball</id>
@@ -132,6 +94,17 @@
13294 <tarLongFileMode>posix</tarLongFileMode>
13395 </configuration>
13496 </plugin>
97+ <plugin>
98+ <artifactId>maven-jar-plugin</artifactId>
99+ <version>3.0.2</version>
100+ <!-- http://stackoverflow.com/questions/13218313/unable-to-disable-generation-of-empty-jar-maven-jar-plugin -->
101+ <executions>
102+ <execution>
103+ <id>default-jar</id>
104+ <phase>none</phase>
105+ </execution>
106+ </executions>
107+ </plugin>
135108 <plugin>
136109 <groupId>org.apache.maven.plugins</groupId>
137110 <artifactId>maven-install-plugin</artifactId>
modified driver-dist/src/assembly/binary-tarball.xml +85 −5
@@ -23,13 +23,14 @@
2323 <format>tar.gz</format>
2424 </formats>
2525 <includeBaseDirectory>true</includeBaseDirectory>
26+
2627 <moduleSets>
28+
29+ <!-- dependencies of module cassandra-driver-core -->
2730 <moduleSet>
2831 <useAllReactorProjects>true</useAllReactorProjects>
2932 <includes>
3033 <include>com.datastax.cassandra:cassandra-driver-core</include>
31- <include>com.datastax.cassandra:cassandra-driver-mapping</include>
32- <include>com.datastax.cassandra:cassandra-driver-extras</include>
3334 </includes>
3435 <binaries>
3536 <unpack>false</unpack>
@@ -37,19 +38,75 @@
3738 <dependencySet>
3839 <outputDirectory>lib</outputDirectory>
3940 <excludes>
40- <exclude>com.datastax.cassandra:*</exclude>
41+ <!-- reactor projects -->
42+ <exclude>com.datastax.cassandra:cassandra-driver-core</exclude>
43+ <exclude>com.datastax.cassandra:cassandra-driver-mapping</exclude>
44+ <exclude>com.datastax.cassandra:cassandra-driver-extras</exclude>
45+ <!-- platform-dependent -->
4146 <exclude>io.netty:netty-transport-native-epoll:*</exclude>
4247 </excludes>
48+ <useTransitiveFiltering>true</useTransitiveFiltering>
49+ </dependencySet>
50+ </dependencySets>
51+ </binaries>
52+ </moduleSet>
53+
54+ <!-- dependencies of module cassandra-driver-mapping -->
55+ <moduleSet>
56+ <useAllReactorProjects>true</useAllReactorProjects>
57+ <includes>
58+ <include>com.datastax.cassandra:cassandra-driver-mapping</include>
59+ </includes>
60+ <binaries>
61+ <unpack>false</unpack>
62+ <dependencySets>
63+ <dependencySet>
64+ <outputDirectory>lib/mapping</outputDirectory>
65+ <excludes>
66+ <!-- reactor projects -->
67+ <exclude>com.datastax.cassandra:cassandra-driver-core</exclude>
68+ <exclude>com.datastax.cassandra:cassandra-driver-mapping</exclude>
69+ <exclude>com.datastax.cassandra:cassandra-driver-extras</exclude>
70+ </excludes>
71+ <useTransitiveFiltering>true</useTransitiveFiltering>
72+ </dependencySet>
73+ </dependencySets>
74+ </binaries>
75+ </moduleSet>
76+
77+ <!-- dependencies of module cassandra:cassandra-driver-extras -->
78+ <moduleSet>
79+ <useAllReactorProjects>true</useAllReactorProjects>
80+ <includes>
81+ <include>com.datastax.cassandra:cassandra-driver-extras</include>
82+ </includes>
83+ <binaries>
84+ <unpack>false</unpack>
85+ <dependencySets>
86+ <dependencySet>
87+ <outputDirectory>lib/extras</outputDirectory>
88+ <excludes>
89+ <!-- reactor projects -->
90+ <exclude>com.datastax.cassandra:cassandra-driver-core</exclude>
91+ <exclude>com.datastax.cassandra:cassandra-driver-mapping</exclude>
92+ <exclude>com.datastax.cassandra:cassandra-driver-extras</exclude>
93+ <!-- already included in lib/core -->
94+ <exclude>com.google.guava:guava</exclude>
95+ </excludes>
96+ <useTransitiveFiltering>true</useTransitiveFiltering>
4397 </dependencySet>
4498 </dependencySets>
4599 </binaries>
46100 </moduleSet>
101+
102+ <!-- sources for all modules -->
47103 <moduleSet>
48104 <useAllReactorProjects>true</useAllReactorProjects>
49105 <includes>
50106 <include>com.datastax.cassandra:cassandra-driver-core</include>
51107 <include>com.datastax.cassandra:cassandra-driver-mapping</include>
52108 <include>com.datastax.cassandra:cassandra-driver-extras</include>
109+ <include>com.datastax.cassandra:cassandra-driver-examples</include>
53110 </includes>
54111 <binaries>
55112 <unpack>false</unpack>
@@ -61,18 +118,41 @@
61118 </excludes>
62119 </binaries>
63120 </moduleSet>
121+
64122 </moduleSets>
123+
65124 <fileSets>
125+
66126 <fileSet>
67127 <directory>target/apidocs</directory>
68128 <outputDirectory>apidocs</outputDirectory>
69129 </fileSet>
130+
70131 <fileSet>
71132 <directory>..</directory>
133+ <outputDirectory>.</outputDirectory>
72134 <includes>
73- <include>changelog/README.md</include>
74- <include>upgrade_guide/README.md</include>
135+ <include>README*</include>
136+ <include>LICENSE*</include>
75137 </includes>
76138 </fileSet>
139+
140+ <fileSet>
141+ <directory>../changelog</directory>
142+ </fileSet>
143+
144+ <fileSet>
145+ <directory>../faq</directory>
146+ </fileSet>
147+
148+ <fileSet>
149+ <directory>../manual</directory>
150+ </fileSet>
151+
152+ <fileSet>
153+ <directory>../upgrade_guide</directory>
154+ </fileSet>
155+
77156 </fileSets>
157+
78158 </assembly>
modified driver-examples/pom.xml +9 −0
@@ -152,6 +152,15 @@
152152 </configuration>
153153 </plugin>
154154
155+ <plugin>
156+ <groupId>org.codehaus.mojo</groupId>
157+ <artifactId>clirr-maven-plugin</artifactId>
158+ <version>2.7</version>
159+ <configuration>
160+ <skip>true</skip>
161+ </configuration>
162+ </plugin>
163+
155164 <plugin>
156165 <groupId>org.apache.maven.plugins</groupId>
157166 <artifactId>maven-install-plugin</artifactId>
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationChecks.java +0 −2
@@ -49,9 +49,7 @@
4949 return instance;
5050 }
5151
52- @SuppressWarnings("unchecked")
5352 private static void validateAnnotations(Class<?> clazz, Class<? extends Annotation> allowed) {
54- @SuppressWarnings("unchecked")
5553 Collection<Annotation> classAnnotations = new HashSet<Annotation>();
5654 Collections.addAll(classAnnotations, clazz.getAnnotations());
5755 Class<? extends Annotation> invalid = validateAnnotations(classAnnotations, Collections.singleton(allowed));
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationParser.java +1 −1
@@ -36,12 +36,12 @@
3636 * - {@link #parseUDT(Class, MappingManager)}: UDT classes into {@link MappedUDTCodec} instances.
3737 * - {@link #parseAccessor(Class, MappingManager)}: Accessor interfaces into {@link AccessorMapper} instances.
3838 */
39-@SuppressWarnings({"unchecked", "WeakerAccess"})
4039 class AnnotationParser {
4140
4241 /**
4342 * Annotations allowed on a property that maps to a table column.
4443 */
44+ @SuppressWarnings("unchecked")
4545 private static final Set<Class<? extends Annotation>> VALID_COLUMN_ANNOTATIONS = ImmutableSet.of(
4646 Column.class,
4747 Computed.class,
modified driver-tests/osgi/pom.xml +14 −15
@@ -24,7 +24,7 @@
2424 </parent>
2525
2626 <artifactId>cassandra-driver-tests-osgi</artifactId>
27- <packaging>bundle</packaging>
27+ <packaging>jar</packaging>
2828 <name>DataStax Java Driver for Apache Cassandra Tests - OSGi</name>
2929 <description>A test for the DataStax Java Driver in an OSGi container.</description>
3030 <url>https://github.com/datastax/java-driver</url>
@@ -36,6 +36,7 @@
3636 <pax-exam.version>3.6.0</pax-exam.version>
3737 <url.version>2.4.0</url.version>
3838 <logback.version>1.1.3</logback.version>
39+ <slf4j.version>1.7.5</slf4j.version>
3940 <test.groups>none</test.groups>
4041 <!--
4142 Skip tests by default, short or long profile is required to run tests in this module
@@ -75,7 +76,7 @@
7576 <dependency>
7677 <groupId>org.slf4j</groupId>
7778 <artifactId>slf4j-api</artifactId>
78- <version>1.7.5</version>
79+ <version>${slf4j.version}</version>
7980 </dependency>
8081
8182 <dependency>
@@ -128,13 +129,6 @@
128129 <scope>test</scope>
129130 </dependency>
130131
131- <dependency>
132- <groupId>com.jcabi</groupId>
133- <artifactId>jcabi-manifests</artifactId>
134- <version>1.1</version>
135- <scope>test</scope>
136- </dependency>
137-
138132 <dependency>
139133 <groupId>javax.servlet</groupId>
140134 <artifactId>javax.servlet-api</artifactId>
@@ -203,6 +197,16 @@
203197 <groups>${test.groups}</groups>
204198 <systemPropertyVariables>
205199 <cassandra.version>${cassandra.version}</cassandra.version>
200+ <!-- pull in declared version properties, this ensures we test with the same versions used by the driver -->
201+ <guava.version>${guava.version}</guava.version>
202+ <lz4.version>${lz4.version}</lz4.version>
203+ <snappy.version>${snappy.version}</snappy.version>
204+ <hdr.version>${hdr.version}</hdr.version>
205+ <netty.version>${netty.version}</netty.version>
206+ <slf4j.version>${slf4j.version}</slf4j.version>
207+ <logback.version>${logback.version}</logback.version>
208+ <metrics.version>${metrics.version}</metrics.version>
209+ <testng.version>${testng.version}</testng.version>
206210 <ipprefix>${ipprefix}</ipprefix>
207211 </systemPropertyVariables>
208212 </configuration>
@@ -229,13 +233,8 @@
229233 <Export-Package>com.datastax.driver.osgi.api,!com.datastax.driver.osgi.impl</Export-Package>
230234 <Bundle-Activator>com.datastax.driver.osgi.impl.Activator</Bundle-Activator>
231235 <_include>-osgi.bnd</_include>
232- <Import-Package><![CDATA[com.google.common*;version="[16.0.1,20)",*]]></Import-Package>
236+ <Import-Package><![CDATA[com.google.common.*;version="[16.0.1,20)",*]]></Import-Package>
233237 </instructions>
234- <supportedProjectTypes>
235- <supportedProjectType>jar</supportedProjectType>
236- <supportedProjectType>bundle</supportedProjectType>
237- <supportedProjectType>pom</supportedProjectType>
238- </supportedProjectTypes>
239238 </configuration>
240239 <executions>
241240 <execution>
modified driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java +22 −14
@@ -16,6 +16,7 @@
1616 package com.datastax.driver.osgi;
1717
1818 import com.datastax.driver.core.CCMBridge;
19+import com.datastax.driver.core.Cluster;
1920 import com.datastax.driver.core.ProtocolOptions;
2021 import com.datastax.driver.core.TestUtils;
2122 import com.google.common.collect.Lists;
@@ -27,7 +28,6 @@
2728
2829 import java.util.List;
2930
30-import static com.datastax.driver.osgi.VersionProvider.projectVersion;
3131 import static org.ops4j.pax.exam.CoreOptions.*;
3232
3333 public class BundleOptions {
@@ -38,19 +38,19 @@
3838
3939 public static UrlProvisionOption driverBundle(boolean useShaded) {
4040 String classifier = useShaded ? "-shaded" : "";
41- return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-core/target/cassandra-driver-core-" + projectVersion() + classifier + ".jar");
41+ return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-core/target/cassandra-driver-core-" + Cluster.getDriverVersion() + classifier + ".jar");
4242 }
4343
4444 public static UrlProvisionOption mappingBundle() {
45- return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-mapping/target/cassandra-driver-mapping-" + projectVersion() + ".jar");
45+ return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-mapping/target/cassandra-driver-mapping-" + Cluster.getDriverVersion() + ".jar");
4646 }
4747
4848 public static UrlProvisionOption extrasBundle() {
49- return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-extras/target/cassandra-driver-extras-" + projectVersion() + ".jar");
49+ return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-extras/target/cassandra-driver-extras-" + Cluster.getDriverVersion() + ".jar");
5050 }
5151
5252 public static MavenArtifactProvisionOption guavaBundle() {
53- return mavenBundle("com.google.guava", "guava", "16.0.1");
53+ return mavenBundle("com.google.guava", "guava", getVersion("guava.version"));
5454 }
5555
5656 public static CompositeOption lz4Bundle() {
@@ -60,7 +60,7 @@
6060 public Option[] getOptions() {
6161 return options(
6262 systemProperty("cassandra.compression").value(ProtocolOptions.Compression.LZ4.name()),
63- mavenBundle("net.jpountz.lz4", "lz4", "1.3.0")
63+ mavenBundle("net.jpountz.lz4", "lz4", getVersion("lz4.version"))
6464 );
6565 }
6666 };
@@ -73,7 +73,7 @@
7373 public Option[] getOptions() {
7474 return options(
7575 systemProperty("cassandra.compression").value(ProtocolOptions.Compression.SNAPPY.name()),
76- mavenBundle("org.xerial.snappy", "snappy-java", "1.1.2.6")
76+ mavenBundle("org.xerial.snappy", "snappy-java", getVersion("snappy.version"))
7777 );
7878 }
7979 };
@@ -86,14 +86,14 @@
8686 public Option[] getOptions() {
8787 return options(
8888 systemProperty("cassandra.usePercentileSpeculativeExecutionPolicy").value("true"),
89- mavenBundle("org.hdrhistogram", "HdrHistogram", "2.1.9")
89+ mavenBundle("org.hdrhistogram", "HdrHistogram", getVersion("hdr.version"))
9090 );
9191 }
9292 };
9393 }
9494
9595 public static CompositeOption nettyBundles() {
96- final String nettyVersion = "4.0.33.Final";
96+ final String nettyVersion = getVersion("netty.version");
9797 return new CompositeOption() {
9898
9999 @Override
@@ -125,11 +125,11 @@
125125 systemProperty("cassandra.version").value(CCMBridge.getGlobalCassandraVersion().toString()),
126126 systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1),
127127 systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"),
128- mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
129- mavenBundle("ch.qos.logback", "logback-classic", "1.1.3"),
130- mavenBundle("ch.qos.logback", "logback-core", "1.1.3"),
131- mavenBundle("io.dropwizard.metrics", "metrics-core", "3.1.2"),
132- mavenBundle("org.testng", "testng", "6.8.8"),
128+ mavenBundle("org.slf4j", "slf4j-api", getVersion("slf4j.version")),
129+ mavenBundle("ch.qos.logback", "logback-classic", getVersion("logback.version")),
130+ mavenBundle("ch.qos.logback", "logback-core", getVersion("logback.version")),
131+ mavenBundle("io.dropwizard.metrics", "metrics-core", getVersion("metrics.version")),
132+ mavenBundle("org.testng", "testng", getVersion("testng.version")),
133133 systemPackages("org.testng", "org.junit", "org.junit.runner", "org.junit.runner.manipulation",
134134 "org.junit.runner.notification", "com.jcabi.manifests")
135135 );
@@ -145,4 +145,12 @@
145145 }
146146 };
147147 }
148+
149+ private static String getVersion(String propertyName) {
150+ String value = System.getProperty(propertyName);
151+ if (value == null) {
152+ throw new IllegalArgumentException(propertyName + " system property is not set.");
153+ }
154+ return value;
155+ }
148156 }
deleted driver-tests/osgi/src/test/java/com/datastax/driver/osgi/VersionProvider.java +0 −59
@@ -1,59 +0,0 @@
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.osgi;
17-
18-import com.jcabi.manifests.Manifests;
19-
20-import java.util.regex.Matcher;
21-import java.util.regex.Pattern;
22-
23-/**
24- * Attempts to resolve the project version from the Bundle manifest. If not present, will throw RuntimeException
25- * on initialization. If this happens, try building with 'mvn compile' to generate the Bundle manifest.
26- * <p/>
27- * In IntelliJ you can have compile run after make by right clicking on 'compile' in the 'Maven Projects' tool window.
28- */
29-public class VersionProvider {
30-
31- private static final Pattern versionPattern = Pattern.compile(("(\\d+.\\d+\\.\\d+)(.*)"));
32-
33- private static final String PROJECT_VERSION;
34-
35- static {
36- String bundleName = Manifests.read("Bundle-SymbolicName");
37- if (bundleName.equals("com.datastax.driver.osgi")) {
38- String bundleVersion = Manifests.read("Bundle-Version");
39- Matcher matcher = versionPattern.matcher(bundleVersion);
40- if (matcher.matches()) {
41- String majorVersion = matcher.group(1);
42- // Replace all instances of '.' after the main version with '-' to properly
43- // resolve the correct version.
44- String rest = matcher.group(2).replaceAll("\\.", "-");
45- PROJECT_VERSION = majorVersion + rest;
46- } else {
47- // This should never happen, but if we are using a non X.Y.Z version number
48- // we'll just back off to the bundle version.
49- PROJECT_VERSION = bundleVersion;
50- }
51- } else {
52- throw new RuntimeException("Couldn't resolve bundle manifest (try building with mvn compile)");
53- }
54- }
55-
56- public static String projectVersion() {
57- return PROJECT_VERSION;
58- }
59-}
modified driver-tests/pom.xml +15 −0
@@ -61,7 +61,18 @@
6161 </developers>
6262
6363 <build>
64+
6465 <plugins>
66+
67+ <plugin>
68+ <groupId>org.codehaus.mojo</groupId>
69+ <artifactId>clirr-maven-plugin</artifactId>
70+ <version>2.7</version>
71+ <configuration>
72+ <skip>true</skip>
73+ </configuration>
74+ </plugin>
75+
6576 <plugin>
6677 <groupId>org.apache.maven.plugins</groupId>
6778 <artifactId>maven-install-plugin</artifactId>
@@ -70,6 +81,7 @@
7081 <skip>true</skip>
7182 </configuration>
7283 </plugin>
84+
7385 <plugin>
7486 <groupId>org.apache.maven.plugins</groupId>
7587 <artifactId>maven-deploy-plugin</artifactId>
@@ -78,6 +90,9 @@
7890 <skip>true</skip>
7991 </configuration>
8092 </plugin>
93+
8194 </plugins>
95+
8296 </build>
97+
8398 </project>
modified pom.xml +45 −1
@@ -68,7 +68,7 @@
6868 <assertj.version>1.7.0</assertj.version>
6969 <mockito.version>1.10.8</mockito.version>
7070 <commons-exec.version>1.3</commons-exec.version>
71- <scassandra.version>1.1.1</scassandra.version>
71+ <scassandra.version>1.1.2</scassandra.version>
7272 <main.basedir>${project.basedir}</main.basedir>
7373 <ipprefix>127.0.1.</ipprefix>
7474 <test.groups>unit</test.groups>
@@ -228,6 +228,7 @@
228228 <version>2.9.1</version>
229229 <inherited>true</inherited>
230230 <configuration>
231+ <quiet>true</quiet>
231232 <verbose>false</verbose>
232233 <additionalparam>${javadoc.opts}</additionalparam>
233234 <links>
@@ -240,6 +241,49 @@
240241 <link>http://fasterxml.github.io/jackson-databind/javadoc/2.6/</link>
241242 <link>https://javaee-spec.java.net/nonav/javadocs/</link>
242243 </links>
244+ <!-- optional dependencies from other modules (must be explicitly declared here in order to be correctly resolved) -->
245+ <additionalDependencies>
246+ <additionalDependency>
247+ <groupId>org.xerial.snappy</groupId>
248+ <artifactId>snappy-java</artifactId>
249+ <version>${snappy.version}</version>
250+ </additionalDependency>
251+ <additionalDependency>
252+ <groupId>net.jpountz.lz4</groupId>
253+ <artifactId>lz4</artifactId>
254+ <version>${lz4.version}</version>
255+ </additionalDependency>
256+ <additionalDependency>
257+ <groupId>org.hdrhistogram</groupId>
258+ <artifactId>HdrHistogram</artifactId>
259+ <version>${hdr.version}</version>
260+ </additionalDependency>
261+ <additionalDependency>
262+ <groupId>com.fasterxml.jackson.core</groupId>
263+ <artifactId>jackson-core</artifactId>
264+ <version>${jackson.version}</version>
265+ </additionalDependency>
266+ <additionalDependency>
267+ <groupId>com.fasterxml.jackson.core</groupId>
268+ <artifactId>jackson-annotations</artifactId>
269+ <version>${jackson.version}</version>
270+ </additionalDependency>
271+ <additionalDependency>
272+ <groupId>com.fasterxml.jackson.core</groupId>
273+ <artifactId>jackson-databind</artifactId>
274+ <version>${jackson.version}</version>
275+ </additionalDependency>
276+ <additionalDependency>
277+ <groupId>joda-time</groupId>
278+ <artifactId>joda-time</artifactId>
279+ <version>${joda.version}</version>
280+ </additionalDependency>
281+ <additionalDependency>
282+ <groupId>javax.json</groupId>
283+ <artifactId>javax.json-api</artifactId>
284+ <version>${jsr353-api.version}</version>
285+ </additionalDependency>
286+ </additionalDependencies>
243287 </configuration>
244288 <executions>
245289 <execution>