Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.1' into 3.0
Changeset7ffdb0fa8a5f6dfec035b18d2f1d55be93b89486ff167de64ebe30473f8d2878
Authorolim7t <omichallat+github@gmail.com> · 2016-01-05 18:50 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2016-01-05 18:52 +01:00
Parents59d946262597, 23b289c30570

Browse the files at this changeset

39 files changed

modified changelog/README.md +2 −0
@@ -256,6 +256,7 @@
256256 Merged from 2.0 branch:
257257
258258 - [bug] JAVA-994: Don't call on(Up|Down|Add|Remove) methods if Cluster is closed/closing.
259+- [improvement] JAVA-805: Document that metrics are null until Cluster is initialized.
259260
260261
261262 ### 2.1.9
@@ -580,6 +581,7 @@
580581 ### 2.0.13 (in progress)
581582
582583 - [bug] JAVA-994: Don't call on(Up|Down|Add|Remove) methods if Cluster is closed/closing.
584+- [improvement] JAVA-805: Document that metrics are null until Cluster is initialized.
583585
584586 ### 2.0.12
585587
modified driver-core/src/main/java/com/datastax/driver/core/AbstractAddressableByIndexData.java +24 −0
@@ -39,10 +39,12 @@
3939 return (T) this;
4040 }
4141
42+ @Override
4243 protected ByteBuffer getValue(int i) {
4344 return values[i];
4445 }
4546
47+ @Override
4648 public T setBool(int i, boolean v) {
4749 TypeCodec<Boolean> codec = codecFor(i, Boolean.class);
4850 ByteBuffer bb;
@@ -53,6 +55,7 @@
5355 return setValue(i, bb);
5456 }
5557
58+ @Override
5659 public T setByte(int i, byte v) {
5760 TypeCodec<Byte> codec = codecFor(i, Byte.class);
5861 ByteBuffer bb;
@@ -63,6 +66,7 @@
6366 return setValue(i, bb);
6467 }
6568
69+ @Override
6670 public T setShort(int i, short v) {
6771 TypeCodec<Short> codec = codecFor(i, Short.class);
6872 ByteBuffer bb;
@@ -73,6 +77,7 @@
7377 return setValue(i, bb);
7478 }
7579
80+ @Override
7681 public T setInt(int i, int v) {
7782 TypeCodec<Integer> codec = codecFor(i, Integer.class);
7883 ByteBuffer bb;
@@ -83,6 +88,7 @@
8388 return setValue(i, bb);
8489 }
8590
91+ @Override
8692 public T setLong(int i, long v) {
8793 TypeCodec<Long> codec = codecFor(i, Long.class);
8894 ByteBuffer bb;
@@ -93,14 +99,17 @@
9399 return setValue(i, bb);
94100 }
95101
102+ @Override
96103 public T setTimestamp(int i, Date v) {
97104 return setValue(i, codecFor(i, Date.class).serialize(v, protocolVersion));
98105 }
99106
107+ @Override
100108 public T setDate(int i, LocalDate v) {
101109 return setValue(i, codecFor(i, LocalDate.class).serialize(v, protocolVersion));
102110 }
103111
112+ @Override
104113 public T setTime(int i, long v) {
105114 TypeCodec<Long> codec = codecFor(i, Long.class);
106115 ByteBuffer bb;
@@ -111,6 +120,7 @@
111120 return setValue(i, bb);
112121 }
113122
123+ @Override
114124 public T setFloat(int i, float v) {
115125 TypeCodec<Float> codec = codecFor(i, Float.class);
116126 ByteBuffer bb;
@@ -121,6 +131,7 @@
121131 return setValue(i, bb);
122132 }
123133
134+ @Override
124135 public T setDouble(int i, double v) {
125136 TypeCodec<Double> codec = codecFor(i, Double.class);
126137 ByteBuffer bb;
@@ -131,34 +142,42 @@
131142 return setValue(i, bb);
132143 }
133144
145+ @Override
134146 public T setString(int i, String v) {
135147 return setValue(i, codecFor(i, String.class).serialize(v, protocolVersion));
136148 }
137149
150+ @Override
138151 public T setBytes(int i, ByteBuffer v) {
139152 return setValue(i, codecFor(i, ByteBuffer.class).serialize(v, protocolVersion));
140153 }
141154
155+ @Override
142156 public T setBytesUnsafe(int i, ByteBuffer v) {
143157 return setValue(i, v == null ? null : v.duplicate());
144158 }
145159
160+ @Override
146161 public T setVarint(int i, BigInteger v) {
147162 return setValue(i, codecFor(i, BigInteger.class).serialize(v, protocolVersion));
148163 }
149164
165+ @Override
150166 public T setDecimal(int i, BigDecimal v) {
151167 return setValue(i, codecFor(i, BigDecimal.class).serialize(v, protocolVersion));
152168 }
153169
170+ @Override
154171 public T setUUID(int i, UUID v) {
155172 return setValue(i, codecFor(i, UUID.class).serialize(v, protocolVersion));
156173 }
157174
175+ @Override
158176 public T setInet(int i, InetAddress v) {
159177 return setValue(i, codecFor(i, InetAddress.class).serialize(v, protocolVersion));
160178 }
161179
180+ @Override
162181 @SuppressWarnings("unchecked")
163182 public <E> T setList(int i, List<E> v) {
164183 return setValue(i, codecFor(i).serialize(v, protocolVersion));
@@ -174,6 +193,7 @@
174193 return setValue(i, codecFor(i, TypeTokens.listOf(elementsType)).serialize(v, protocolVersion));
175194 }
176195
196+ @Override
177197 @SuppressWarnings("unchecked")
178198 public <K, V> T setMap(int i, Map<K, V> v) {
179199 return setValue(i, codecFor(i).serialize(v, protocolVersion));
@@ -189,6 +209,7 @@
189209 return setValue(i, codecFor(i, TypeTokens.mapOf(keysType, valuesType)).serialize(v, protocolVersion));
190210 }
191211
212+ @Override
192213 @SuppressWarnings("unchecked")
193214 public <E> T setSet(int i, Set<E> v) {
194215 return setValue(i, codecFor(i).serialize(v, protocolVersion));
@@ -204,10 +225,12 @@
204225 return setValue(i, codecFor(i, TypeTokens.setOf(elementsType)).serialize(v, protocolVersion));
205226 }
206227
228+ @Override
207229 public T setUDTValue(int i, UDTValue v) {
208230 return setValue(i, codecFor(i, UDTValue.class).serialize(v, protocolVersion));
209231 }
210232
233+ @Override
211234 public T setTupleValue(int i, TupleValue v) {
212235 return setValue(i, codecFor(i, TupleValue.class).serialize(v, protocolVersion));
213236 }
@@ -228,6 +251,7 @@
228251 return setValue(i, codec.serialize(v, protocolVersion));
229252 }
230253
254+ @Override
231255 public T setToNull(int i) {
232256 return setValue(i, null);
233257 }
modified driver-core/src/main/java/com/datastax/driver/core/ArrayBackedResultSet.java +16 −0
@@ -109,10 +109,12 @@
109109 return new SinglePage(ColumnDefinitions.EMPTY, null, null, null, EMPTY_QUEUE, info);
110110 }
111111
112+ @Override
112113 public ColumnDefinitions getColumnDefinitions() {
113114 return metadata;
114115 }
115116
117+ @Override
116118 public List<Row> all() {
117119 if (isExhausted())
118120 return Collections.emptyList();
@@ -175,30 +177,37 @@
175177 this.rows = rows;
176178 }
177179
180+ @Override
178181 public boolean isExhausted() {
179182 return rows.isEmpty();
180183 }
181184
185+ @Override
182186 public Row one() {
183187 return ArrayBackedRow.fromData(metadata, tokenFactory, protocolVersion, rows.poll());
184188 }
185189
190+ @Override
186191 public int getAvailableWithoutFetching() {
187192 return rows.size();
188193 }
189194
195+ @Override
190196 public boolean isFullyFetched() {
191197 return true;
192198 }
193199
200+ @Override
194201 public ListenableFuture<ResultSet> fetchMoreResults() {
195202 return Futures.<ResultSet>immediateFuture(this);
196203 }
197204
205+ @Override
198206 public ExecutionInfo getExecutionInfo() {
199207 return info;
200208 }
201209
210+ @Override
202211 public List<ExecutionInfo> getAllExecutionInfo() {
203212 return Collections.singletonList(info);
204213 }
@@ -251,16 +260,19 @@
251260 this.statement = statement;
252261 }
253262
263+ @Override
254264 public boolean isExhausted() {
255265 prepareNextRow();
256266 return currentPage.isEmpty();
257267 }
258268
269+ @Override
259270 public Row one() {
260271 prepareNextRow();
261272 return ArrayBackedRow.fromData(metadata, tokenFactory, protocolVersion, currentPage.poll());
262273 }
263274
275+ @Override
264276 public int getAvailableWithoutFetching() {
265277 int available = currentPage.size();
266278 for (Queue<List<ByteBuffer>> page : nextPages)
@@ -268,6 +280,7 @@
268280 return available;
269281 }
270282
283+ @Override
271284 public boolean isFullyFetched() {
272285 return fetchState == null;
273286 }
@@ -297,6 +310,7 @@
297310 }
298311 }
299312
313+ @Override
300314 public ListenableFuture<ResultSet> fetchMoreResults() {
301315 return fetchMoreResults(this.fetchState);
302316 }
@@ -401,10 +415,12 @@
401415 return future;
402416 }
403417
418+ @Override
404419 public ExecutionInfo getExecutionInfo() {
405420 return infos.getLast();
406421 }
407422
423+ @Override
408424 public List<ExecutionInfo> getAllExecutionInfo() {
409425 return new ArrayList<ExecutionInfo>(infos);
410426 }
modified driver-core/src/main/java/com/datastax/driver/core/AuthProvider.java +1 −0
@@ -34,6 +34,7 @@
3434 * This is only useful as a placeholder when no authentication is to be used.
3535 */
3636 public static final AuthProvider NONE = new AuthProvider() {
37+ @Override
3738 public Authenticator newAuthenticator(InetSocketAddress host, String authenticator) {
3839 throw new AuthenticationException(host,
3940 String.format("Host %s requires authentication, but no authenticator found in Cluster configuration", host));
modified driver-core/src/main/java/com/datastax/driver/core/BoundStatement.java +0 −17
@@ -994,23 +994,6 @@
994994 /**
995995 * {@inheritDoc}
996996 */
997- @Override
998- public long getTime(int i) {
999- return wrapper.getTime(i);
1000- }
1001-
1002- /**
1003- * {@inheritDoc}
1004- */
1005- @Override
1006- public long getTime(String name) {
1007- return wrapper.getTime(name);
1008- }
1009-
1010- /**
1011- * {@inheritDoc}
1012- */
1013- @Override
1014997 public float getFloat(int i) {
1015998 return wrapper.getFloat(i);
1016999 }
modified driver-core/src/main/java/com/datastax/driver/core/CloseFuture.java +2 −0
@@ -72,10 +72,12 @@
7272 this.futures = futures;
7373
7474 Futures.addCallback(Futures.allAsList(futures), new FutureCallback<List<Void>>() {
75+ @Override
7576 public void onFailure(Throwable t) {
7677 Forwarding.this.setException(t);
7778 }
7879
80+ @Override
7981 public void onSuccess(List<Void> v) {
8082 Forwarding.this.onFuturesDone();
8183 }
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +15 −3
@@ -406,9 +406,8 @@
406406 /**
407407 * The cluster metrics.
408408 *
409- * @return the cluster metrics, or {@code null} if metrics collection has
410- * been disabled (that is if {@link Configuration#getMetricsOptions}
411- * returns {@code null}).
409+ * @return the cluster metrics, or {@code null} if this cluster has not yet been {@link #init() initialized}, or if
410+ * metrics collection has been disabled (that is if {@link Configuration#getMetricsOptions} returns {@code null}).
412411 */
413412 public Metrics getMetrics() {
414413 checkNotClosed(manager);
@@ -561,6 +560,7 @@
561560 * <p/>
562561 * This method is a shortcut for {@code closeAsync().get()}.
563562 */
563+ @Override
564564 public void close() {
565565 try {
566566 closeAsync().get();
@@ -1797,10 +1797,12 @@
17971797 void startPeriodicReconnectionAttempt(final Host host, final boolean isHostAddition) {
17981798 new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt) {
17991799
1800+ @Override
18001801 protected Connection tryReconnect() throws ConnectionException, InterruptedException, UnsupportedProtocolVersionException, ClusterNameMismatchException {
18011802 return connectionFactory.open(host);
18021803 }
18031804
1805+ @Override
18041806 protected void onReconnection(Connection connection) {
18051807 // Make sure we have up-to-date infos on that host before adding it (so we typically
18061808 // catch that an upgraded node uses a new cassandra version).
@@ -1822,17 +1824,20 @@
18221824 }
18231825 }
18241826
1827+ @Override
18251828 protected boolean onConnectionException(ConnectionException e, long nextDelayMs) {
18261829 if (logger.isDebugEnabled())
18271830 logger.debug("Failed reconnection to {} ({}), scheduling retry in {} milliseconds", host, e.getMessage(), nextDelayMs);
18281831 return true;
18291832 }
18301833
1834+ @Override
18311835 protected boolean onUnknownException(Exception e, long nextDelayMs) {
18321836 logger.error(String.format("Unknown error during reconnection to %s, scheduling retry in %d milliseconds", host, nextDelayMs), e);
18331837 return true;
18341838 }
18351839
1840+ @Override
18361841 protected boolean onAuthenticationException(AuthenticationException e, long nextDelayMs) {
18371842 logger.error(String.format("Authentication error during reconnection to %s, scheduling retry in %d milliseconds", host, nextDelayMs), e);
18381843 return true;
@@ -1850,10 +1855,12 @@
18501855 // Setting an initial delay of 0 to start immediately, and all the exception handlers return false to prevent further attempts
18511856 new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt, 0) {
18521857
1858+ @Override
18531859 protected Connection tryReconnect() throws ConnectionException, InterruptedException, UnsupportedProtocolVersionException, ClusterNameMismatchException {
18541860 return connectionFactory.open(host);
18551861 }
18561862
1863+ @Override
18571864 protected void onReconnection(Connection connection) {
18581865 // Make sure we have up-to-date infos on that host before adding it (so we typically
18591866 // catch that an upgraded node uses a new cassandra version).
@@ -1872,17 +1879,20 @@
18721879 }
18731880 }
18741881
1882+ @Override
18751883 protected boolean onConnectionException(ConnectionException e, long nextDelayMs) {
18761884 if (logger.isDebugEnabled())
18771885 logger.debug("Failed one-time reconnection to {} ({})", host, e.getMessage());
18781886 return false;
18791887 }
18801888
1889+ @Override
18811890 protected boolean onUnknownException(Exception e, long nextDelayMs) {
18821891 logger.error(String.format("Unknown error during one-time reconnection to %s", host), e);
18831892 return false;
18841893 }
18851894
1895+ @Override
18861896 protected boolean onAuthenticationException(AuthenticationException e, long nextDelayMs) {
18871897 logger.error(String.format("Authentication error during one-time reconnection to %s", host), e);
18881898 return false;
@@ -2426,6 +2436,7 @@
24262436 * a netty worker, which we're going to shutdown. So creates some thread for that.
24272437 */
24282438 (new Thread("Shutdown-checker") {
2439+ @Override
24292440 public void run() {
24302441 // Just wait indefinitely on the the completion of the thread pools. Provided the user
24312442 // call force(), we'll never really block forever.
@@ -2621,6 +2632,7 @@
26212632 if (protocolVersion().compareTo(ProtocolVersion.V4) < 0) {
26222633 final SettableFuture<?> future = SettableFuture.create();
26232634 scheduledTasksExecutor.schedule(new ExceptionCatchingRunnable() {
2635+ @Override
26242636 public void runMayThrow() throws Exception {
26252637 ListenableFuture<?> f = execute(task);
26262638 Futures.addCallback(f, new FutureCallback<Object>() {
modified driver-core/src/main/java/com/datastax/driver/core/DefaultPreparedStatement.java +18 −0
@@ -115,42 +115,51 @@
115115 return true;
116116 }
117117
118+ @Override
118119 public ColumnDefinitions getVariables() {
119120 return preparedId.metadata;
120121 }
121122
123+ @Override
122124 public BoundStatement bind(Object... values) {
123125 BoundStatement bs = new BoundStatement(this);
124126 return bs.bind(values);
125127 }
126128
129+ @Override
127130 public BoundStatement bind() {
128131 return new BoundStatement(this);
129132 }
130133
134+ @Override
131135 public PreparedStatement setRoutingKey(ByteBuffer routingKey) {
132136 this.routingKey = routingKey;
133137 return this;
134138 }
135139
140+ @Override
136141 public PreparedStatement setRoutingKey(ByteBuffer... routingKeyComponents) {
137142 this.routingKey = SimpleStatement.compose(routingKeyComponents);
138143 return this;
139144 }
140145
146+ @Override
141147 public ByteBuffer getRoutingKey() {
142148 return routingKey;
143149 }
144150
151+ @Override
145152 public PreparedStatement setConsistencyLevel(ConsistencyLevel consistency) {
146153 this.consistency = consistency;
147154 return this;
148155 }
149156
157+ @Override
150158 public ConsistencyLevel getConsistencyLevel() {
151159 return consistency;
152160 }
153161
162+ @Override
154163 public PreparedStatement setSerialConsistencyLevel(ConsistencyLevel serialConsistency) {
155164 if (serialConsistency != ConsistencyLevel.SERIAL && serialConsistency != ConsistencyLevel.LOCAL_SERIAL)
156165 throw new IllegalArgumentException();
@@ -158,41 +167,50 @@
158167 return this;
159168 }
160169
170+ @Override
161171 public ConsistencyLevel getSerialConsistencyLevel() {
162172 return serialConsistency;
163173 }
164174
175+ @Override
165176 public String getQueryString() {
166177 return query;
167178 }
168179
180+ @Override
169181 public String getQueryKeyspace() {
170182 return queryKeyspace;
171183 }
172184
185+ @Override
173186 public PreparedStatement enableTracing() {
174187 this.traceQuery = true;
175188 return this;
176189 }
177190
191+ @Override
178192 public PreparedStatement disableTracing() {
179193 this.traceQuery = false;
180194 return this;
181195 }
182196
197+ @Override
183198 public boolean isTracing() {
184199 return traceQuery;
185200 }
186201
202+ @Override
187203 public PreparedStatement setRetryPolicy(RetryPolicy policy) {
188204 this.retryPolicy = policy;
189205 return this;
190206 }
191207
208+ @Override
192209 public RetryPolicy getRetryPolicy() {
193210 return retryPolicy;
194211 }
195212
213+ @Override
196214 public PreparedId getPreparedId() {
197215 return preparedId;
198216 }
modified driver-core/src/main/java/com/datastax/driver/core/DefaultResultSetFuture.java +2 −0
@@ -237,6 +237,7 @@
237237 * @throws QueryValidationException if the query is invalid (syntax error,
238238 * unauthorized or any other validation problem).
239239 */
240+ @Override
240241 public ResultSet getUninterruptibly() {
241242 try {
242243 return Uninterruptibles.getUninterruptibly(this);
@@ -269,6 +270,7 @@
269270 * different from a Cassandra timeout, which is a {@code
270271 * QueryExecutionException}).
271272 */
273+ @Override
272274 public ResultSet getUninterruptibly(long timeout, TimeUnit unit) throws TimeoutException {
273275 try {
274276 return Uninterruptibles.getUninterruptibly(this, timeout, unit);
modified driver-core/src/main/java/com/datastax/driver/core/FrameCompressor.java +4 −0
@@ -56,6 +56,7 @@
5656 Snappy.getNativeLibraryVersion();
5757 }
5858
59+ @Override
5960 public Frame compress(Frame frame) throws IOException {
6061 byte[] input = CBUtil.readRawBytes(frame.body);
6162 byte[] output = new byte[Snappy.maxCompressedLength(input.length)];
@@ -64,6 +65,7 @@
6465 return frame.with(Unpooled.wrappedBuffer(output, 0, written));
6566 }
6667
68+ @Override
6769 public Frame decompress(Frame frame) throws IOException {
6870 byte[] input = CBUtil.readRawBytes(frame.body);
6971
@@ -105,6 +107,7 @@
105107 decompressor = lz4Factory.fastDecompressor();
106108 }
107109
110+ @Override
108111 public Frame compress(Frame frame) throws IOException {
109112 byte[] input = CBUtil.readRawBytes(frame.body);
110113
@@ -124,6 +127,7 @@
124127 }
125128 }
126129
130+ @Override
127131 public Frame decompress(Frame frame) throws IOException {
128132 byte[] input = CBUtil.readRawBytes(frame.body);
129133
modified driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java +1 −0
@@ -639,6 +639,7 @@
639639 for (final Connection connection : connections) {
640640 CloseFuture future = connection.closeAsync();
641641 future.addListener(new Runnable() {
642+ @Override
642643 public void run() {
643644 if (connection.state.compareAndSet(OPEN, GONE))
644645 open.decrementAndGet();
modified driver-core/src/main/java/com/datastax/driver/core/PlainTextAuthProvider.java +2 −0
@@ -78,6 +78,7 @@
7878 * @return an Authenticator instance which can be used to perform
7979 * authentication negotiations on behalf of the client
8080 */
81+ @Override
8182 public Authenticator newAuthenticator(InetSocketAddress host, String authenticator) {
8283 return new PlainTextAuthenticator(username, password);
8384 }
@@ -117,6 +118,7 @@
117118 // no-op, the server should send nothing anyway
118119 }
119120
121+ @Override
120122 Map<String, String> getCredentials() {
121123 return ImmutableMap.of("username", new String(username, Charsets.UTF_8),
122124 "password", new String(password, Charsets.UTF_8));
modified driver-core/src/main/java/com/datastax/driver/core/ReplicationStategy.java +3 −1
@@ -73,6 +73,7 @@
7373 this.replicationFactor = replicationFactor;
7474 }
7575
76+ @Override
7677 Map<Token, Set<Host>> computeTokenToReplicaMap(String keyspaceName, Map<Token, Host> tokenToPrimary, List<Token> ring) {
7778
7879 int rf = Math.min(replicationFactor, ring.size());
@@ -116,7 +117,8 @@
116117 this.replicationFactors = replicationFactors;
117118 }
118119
119- Map<Token, Set<Host>> computeTokenToReplicaMap(String keyspaceName, Map<Token, Host> tokenToPrimary, List<Token> ring) {
120+ @Override
121+ Map<Token, Set<Host>> computeTokenToReplicaMap(String keyspaceName, Map<Token, Host> tokenToPrimary, List<Token> ring) {
120122
121123 // This is essentially a copy of org.apache.cassandra.locator.NetworkTopologyStrategy
122124 Map<String, Set<String>> racks = getRacksInDcs(tokenToPrimary.values());
modified driver-core/src/main/java/com/datastax/driver/core/Requests.java +18 −0
@@ -36,10 +36,12 @@
3636 static final String COMPRESSION_OPTION = "COMPRESSION";
3737
3838 static final Message.Coder<Startup> coder = new Message.Coder<Startup>() {
39+ @Override
3940 public void encode(Startup msg, ByteBuf dest, ProtocolVersion version) {
4041 CBUtil.writeStringMap(msg.options, dest);
4142 }
4243
44+ @Override
4345 public int encodedSize(Startup msg, ProtocolVersion version) {
4446 return CBUtil.sizeOfStringMap(msg.options);
4547 }
@@ -68,11 +70,13 @@
6870
6971 static final Message.Coder<Credentials> coder = new Message.Coder<Credentials>() {
7072
73+ @Override
7174 public void encode(Credentials msg, ByteBuf dest, ProtocolVersion version) {
7275 assert version == ProtocolVersion.V1;
7376 CBUtil.writeStringMap(msg.credentials, dest);
7477 }
7578
79+ @Override
7680 public int encodedSize(Credentials msg, ProtocolVersion version) {
7781 assert version == ProtocolVersion.V1;
7882 return CBUtil.sizeOfStringMap(msg.credentials);
@@ -90,9 +94,11 @@
9094 static class Options extends Message.Request {
9195
9296 static final Message.Coder<Options> coder = new Message.Coder<Options>() {
97+ @Override
9398 public void encode(Options msg, ByteBuf dest, ProtocolVersion version) {
9499 }
95100
101+ @Override
96102 public int encodedSize(Options msg, ProtocolVersion version) {
97103 return 0;
98104 }
@@ -111,11 +117,13 @@
111117 static class Query extends Message.Request {
112118
113119 static final Message.Coder<Query> coder = new Message.Coder<Query>() {
120+ @Override
114121 public void encode(Query msg, ByteBuf dest, ProtocolVersion version) {
115122 CBUtil.writeLongString(msg.query, dest);
116123 msg.options.encode(dest, version);
117124 }
118125
126+ @Override
119127 public int encodedSize(Query msg, ProtocolVersion version) {
120128 return CBUtil.sizeOfLongString(msg.query)
121129 + msg.options.encodedSize(version);
@@ -154,11 +162,13 @@
154162 static class Execute extends Message.Request {
155163
156164 static final Message.Coder<Execute> coder = new Message.Coder<Execute>() {
165+ @Override
157166 public void encode(Execute msg, ByteBuf dest, ProtocolVersion version) {
158167 CBUtil.writeBytes(msg.statementId.bytes, dest);
159168 msg.options.encode(dest, version);
160169 }
161170
171+ @Override
162172 public int encodedSize(Execute msg, ProtocolVersion version) {
163173 return CBUtil.sizeOfBytes(msg.statementId.bytes)
164174 + msg.options.encodedSize(version);
@@ -336,6 +346,7 @@
336346 static class Batch extends Message.Request {
337347
338348 static final Message.Coder<Batch> coder = new Message.Coder<Batch>() {
349+ @Override
339350 public void encode(Batch msg, ByteBuf dest, ProtocolVersion version) {
340351 int queries = msg.queryOrIdList.size();
341352 assert queries <= 0xFFFF;
@@ -357,6 +368,7 @@
357368 msg.options.encode(dest, version);
358369 }
359370
371+ @Override
360372 public int encodedSize(Batch msg, ProtocolVersion version) {
361373 int size = 3; // type + nb queries
362374 for (int i = 0; i < msg.queryOrIdList.size(); i++) {
@@ -491,10 +503,12 @@
491503
492504 static final Message.Coder<Prepare> coder = new Message.Coder<Prepare>() {
493505
506+ @Override
494507 public void encode(Prepare msg, ByteBuf dest, ProtocolVersion version) {
495508 CBUtil.writeLongString(msg.query, dest);
496509 }
497510
511+ @Override
498512 public int encodedSize(Prepare msg, ProtocolVersion version) {
499513 return CBUtil.sizeOfLongString(msg.query);
500514 }
@@ -516,12 +530,14 @@
516530 static class Register extends Message.Request {
517531
518532 static final Message.Coder<Register> coder = new Message.Coder<Register>() {
533+ @Override
519534 public void encode(Register msg, ByteBuf dest, ProtocolVersion version) {
520535 dest.writeShort(msg.eventTypes.size());
521536 for (ProtocolEvent.Type type : msg.eventTypes)
522537 CBUtil.writeEnumValue(type, dest);
523538 }
524539
540+ @Override
525541 public int encodedSize(Register msg, ProtocolVersion version) {
526542 int size = 2;
527543 for (ProtocolEvent.Type type : msg.eventTypes)
@@ -547,10 +563,12 @@
547563
548564 static final Message.Coder<AuthResponse> coder = new Message.Coder<AuthResponse>() {
549565
566+ @Override
550567 public void encode(AuthResponse response, ByteBuf dest, ProtocolVersion version) {
551568 CBUtil.writeValue(response.token, dest);
552569 }
553570
571+ @Override
554572 public int encodedSize(AuthResponse response, ProtocolVersion version) {
555573 return CBUtil.sizeOfValue(response.token);
556574 }
modified driver-core/src/main/java/com/datastax/driver/core/Responses.java +12 −0
@@ -154,6 +154,7 @@
154154 static class Ready extends Message.Response {
155155
156156 static final Message.Decoder<Ready> decoder = new Message.Decoder<Ready>() {
157+ @Override
157158 public Ready decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
158159 // TODO: Would it be cool to return a singleton? Check we don't need to
159160 // set the streamId or something
@@ -174,6 +175,7 @@
174175 static class Authenticate extends Message.Response {
175176
176177 static final Message.Decoder<Authenticate> decoder = new Message.Decoder<Authenticate>() {
178+ @Override
177179 public Authenticate decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
178180 String authenticator = CBUtil.readString(body);
179181 return new Authenticate(authenticator);
@@ -196,6 +198,7 @@
196198 static class Supported extends Message.Response {
197199
198200 static final Message.Decoder<Supported> decoder = new Message.Decoder<Supported>() {
201+ @Override
199202 public Supported decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
200203 return new Supported(CBUtil.readStringToStringListMap(body));
201204 }
@@ -232,6 +235,7 @@
232235 static abstract class Result extends Message.Response {
233236
234237 static final Message.Decoder<Result> decoder = new Message.Decoder<Result>() {
238+ @Override
235239 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
236240 Kind kind = Kind.fromId(body.readInt());
237241 return kind.subDecoder.decode(body, version, codecRegistry);
@@ -290,6 +294,7 @@
290294 }
291295
292296 static final Message.Decoder<Result> subcodec = new Message.Decoder<Result>() {
297+ @Override
293298 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
294299 return new Void();
295300 }
@@ -310,6 +315,7 @@
310315 }
311316
312317 static final Message.Decoder<Result> subcodec = new Message.Decoder<Result>() {
318+ @Override
313319 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
314320 return new SetKeyspace(CBUtil.readString(body));
315321 }
@@ -429,6 +435,7 @@
429435 }
430436
431437 static final Message.Decoder<Result> subcodec = new Message.Decoder<Result>() {
438+ @Override
432439 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
433440
434441 Metadata metadata = Metadata.decode(body, version, codecRegistry);
@@ -495,6 +502,7 @@
495502 static class Prepared extends Result {
496503
497504 static final Message.Decoder<Result> subcodec = new Message.Decoder<Result>() {
505+ @Override
498506 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
499507 MD5Digest id = MD5Digest.wrap(CBUtil.readBytes(body));
500508 boolean withPkIndices = version.compareTo(V4) >= 0;
@@ -545,6 +553,7 @@
545553 final List<String> targetSignature;
546554
547555 static final Message.Decoder<Result> subcodec = new Message.Decoder<Result>() {
556+ @Override
548557 public Result decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
549558 // Note: the CREATE KEYSPACE/TABLE/TYPE SCHEMA_CHANGE response is different from the SCHEMA_CHANGE EVENT type
550559 Change change;
@@ -595,6 +604,7 @@
595604 static class Event extends Message.Response {
596605
597606 static final Message.Decoder<Event> decoder = new Message.Decoder<Event>() {
607+ @Override
598608 public Event decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
599609 return new Event(ProtocolEvent.deserialize(body, version));
600610 }
@@ -616,6 +626,7 @@
616626 static class AuthChallenge extends Message.Response {
617627
618628 static final Message.Decoder<AuthChallenge> decoder = new Message.Decoder<AuthChallenge>() {
629+ @Override
619630 public AuthChallenge decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
620631 ByteBuffer b = CBUtil.readValue(body);
621632 if (b == null)
@@ -638,6 +649,7 @@
638649 static class AuthSuccess extends Message.Response {
639650
640651 static final Message.Decoder<AuthSuccess> decoder = new Message.Decoder<AuthSuccess>() {
652+ @Override
641653 public AuthSuccess decode(ByteBuf body, ProtocolVersion version, CodecRegistry codecRegistry) {
642654 ByteBuffer b = CBUtil.readValue(body);
643655 if (b == null)
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +13 −0
@@ -63,6 +63,7 @@
6363 this.poolsState = new HostConnectionPool.PoolState();
6464 }
6565
66+ @Override
6667 public Session init() {
6768 try {
6869 return Uninterruptibles.getUninterruptibly(initAsync());
@@ -71,6 +72,7 @@
7172 }
7273 }
7374
75+ @Override
7476 public ListenableFuture<Session> initAsync() {
7577 // If we haven't initialized the cluster, do it now
7678 cluster.init();
@@ -118,6 +120,7 @@
118120 return Futures.allAsList(futures);
119121 }
120122
123+ @Override
121124 public String getLoggedKeyspace() {
122125 return poolsState.keyspace;
123126 }
@@ -154,6 +157,7 @@
154157 return toPreparedStatement(query, future);
155158 }
156159
160+ @Override
157161 public CloseFuture closeAsync() {
158162 CloseFuture future = closeFuture.get();
159163 if (future != null)
@@ -173,20 +177,24 @@
173177 : closeFuture.get(); // We raced, it's ok, return the future that was actually set
174178 }
175179
180+ @Override
176181 public boolean isClosed() {
177182 return closeFuture.get() != null;
178183 }
179184
185+ @Override
180186 public Cluster getCluster() {
181187 return cluster;
182188 }
183189
190+ @Override
184191 public Session.State getState() {
185192 return new State(this);
186193 }
187194
188195 private ListenableFuture<PreparedStatement> toPreparedStatement(final String query, final Connection.Future future) {
189196 return Futures.transform(future, new AsyncFunction<Response, PreparedStatement>() {
197+ @Override
190198 public ListenableFuture<PreparedStatement> apply(Response response) {
191199 switch (response.type) {
192200 case RESULT:
@@ -694,24 +702,29 @@
694702 return -1;
695703 }
696704
705+ @Override
697706 public Session getSession() {
698707 return session;
699708 }
700709
710+ @Override
701711 public Collection<Host> getConnectedHosts() {
702712 return connectedHosts;
703713 }
704714
715+ @Override
705716 public int getOpenConnections(Host host) {
706717 int i = getIdx(host);
707718 return i < 0 ? 0 : openConnections[i];
708719 }
709720
721+ @Override
710722 public int getTrashedConnections(Host host) {
711723 int i = getIdx(host);
712724 return i < 0 ? 0 : trashedConnections[i];
713725 }
714726
727+ @Override
715728 public int getInFlightQueries(Host host) {
716729 int i = getIdx(host);
717730 return i < 0 ? 0 : inFlightQueries[i];
modified driver-core/src/main/java/com/datastax/driver/core/TableOrView.java +2 −0
@@ -27,12 +27,14 @@
2727 abstract class TableOrView {
2828
2929 static final Comparator<ColumnMetadata> columnMetadataComparator = new Comparator<ColumnMetadata>() {
30+ @Override
3031 public int compare(ColumnMetadata c1, ColumnMetadata c2) {
3132 return c1.getName().compareTo(c2.getName());
3233 }
3334 };
3435
3536 static final Predicate<ClusteringOrder> isAscending = new Predicate<ClusteringOrder>() {
37+ @Override
3638 public boolean apply(ClusteringOrder o) {
3739 return o == ClusteringOrder.ASC;
3840 }
modified driver-core/src/main/java/com/datastax/driver/core/UDTValue.java +3 −0
@@ -27,10 +27,12 @@
2727 this.definition = definition;
2828 }
2929
30+ @Override
3031 protected DataType getType(int i) {
3132 return definition.byIdx[i].getType();
3233 }
3334
35+ @Override
3436 protected String getName(int i) {
3537 return definition.byIdx[i].getName();
3638 }
@@ -40,6 +42,7 @@
4042 return definition.getCodecRegistry();
4143 }
4244
45+ @Override
4346 protected int[] getAllIndexesOf(String name) {
4447 int[] indexes = definition.byName.get(Metadata.handleId(name));
4548 if (indexes == null)
modified driver-core/src/main/java/com/datastax/driver/core/VersionNumber.java +1 −0
@@ -171,6 +171,7 @@
171171 return new VersionNumber(major, minor, patch, dsePatch, null, null);
172172 }
173173
174+ @Override
174175 public int compareTo(VersionNumber other) {
175176 if (major < other.major)
176177 return -1;
modified driver-core/src/main/java/com/datastax/driver/core/policies/EC2MultiRegionAddressTranslator.java +1 −0
@@ -107,6 +107,7 @@
107107 return null;
108108 }
109109
110+ @Override
110111 public void close() {
111112 try {
112113 ctx.close();
modified driver-core/src/main/java/com/datastax/driver/core/policies/IdentityTranslator.java +1 −0
@@ -39,6 +39,7 @@
3939 * @param address the address of a node as returned by Cassandra.
4040 * @return {@code address} unmodified.
4141 */
42+ @Override
4243 public InetSocketAddress translate(InetSocketAddress address) {
4344 return address;
4445 }
modified driver-core/src/main/java/com/datastax/driver/core/policies/LatencyAwarePolicy.java +1 −0
@@ -387,6 +387,7 @@
387387 private final ConcurrentMap<Host, HostLatencyTracker> latencies = new ConcurrentHashMap<Host, HostLatencyTracker>();
388388 private volatile long cachedMin = -1L;
389389
390+ @Override
390391 public void update(Host host, Statement statement, Exception exception, long newLatencyNanos) {
391392 if (shouldConsiderNewLatency(statement, exception)) {
392393 HostLatencyTracker hostTracker = latencies.get(host);
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Select.java +7 −0
@@ -311,6 +311,7 @@
311311 *
312312 * @return this in-build SELECT statement.
313313 */
314+ @Override
314315 public Selection distinct() {
315316 this.isDistinct = true;
316317 return this;
@@ -424,6 +425,7 @@
424425 * @return an in-build SELECT statement.
425426 * @throws IllegalStateException if some columns had already been selected for this builder.
426427 */
428+ @Override
427429 public Builder all() {
428430 if (columnNames != null)
429431 throw new IllegalStateException(String.format("Some columns (%s) have already been selected.", columnNames));
@@ -439,6 +441,7 @@
439441 * @return an in-build SELECT statement.
440442 * @throws IllegalStateException if some columns had already been selected for this builder.
441443 */
444+ @Override
442445 public Builder countAll() {
443446 if (columnNames != null)
444447 throw new IllegalStateException(String.format("Some columns (%s) have already been selected.", columnNames));
@@ -455,6 +458,7 @@
455458 * @param name the new column name to add.
456459 * @return this in-build SELECT statement
457460 */
461+ @Override
458462 public SelectionOrAlias column(String name) {
459463 return queueName(name);
460464 }
@@ -482,6 +486,7 @@
482486 * @param name the name of the column to select the write time of.
483487 * @return this in-build SELECT statement
484488 */
489+ @Override
485490 public SelectionOrAlias writeTime(String name) {
486491 return queueName(new Utils.FCall("writetime", new Utils.CName(name)));
487492 }
@@ -494,6 +499,7 @@
494499 * @param name the name of the column to select the ttl of.
495500 * @return this in-build SELECT statement
496501 */
502+ @Override
497503 public SelectionOrAlias ttl(String name) {
498504 return queueName(new Utils.FCall("ttl", new Utils.CName(name)));
499505 }
@@ -509,6 +515,7 @@
509515 * {@link QueryBuilder#column} method, and so
510516 * {@code fcall("textToBlob", QueryBuilder.column(foo)}.
511517 */
518+ @Override
512519 public SelectionOrAlias fcall(String name, Object... parameters) {
513520 return queueName(new Utils.FCall(name, parameters));
514521 }
modified driver-core/src/main/java/com/datastax/driver/core/schemabuilder/TableOptions.java +2 −0
@@ -1038,10 +1038,12 @@
10381038 super(Algorithm.NONE);
10391039 }
10401040
1041+ @Override
10411042 public CompressionOptions withChunkLengthInKb(Integer chunkLengthInKb) {
10421043 return this;
10431044 }
10441045
1046+ @Override
10451047 public CompressionOptions withCRCCheckChance(Double crcCheckChance) {
10461048 return this;
10471049 }
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +180 −14
@@ -51,9 +51,11 @@
5151
5252 public static final String IP_PREFIX;
5353
54- static final String CASSANDRA_VERSION;
54+ private static final String CASSANDRA_VERSION;
5555
56- static final String CASSANDRA_INSTALL_ARGS;
56+ private static final String CASSANDRA_INSTALL_ARGS;
57+
58+ private static final boolean IS_DSE;
5759
5860 public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "cassandra1sfun";
5961 public static final String DEFAULT_CLIENT_TRUSTSTORE_PATH = "/client.truststore";
@@ -89,6 +91,49 @@
8991 */
9092 private static final Map<String, String> ENVIRONMENT_MAP;
9193
94+ /**
95+ * A mapping of full DSE versions to their C* counterpart. This is not meant to be comprehensive. Used by
96+ * {@link #getCassandraVersion()}. If C* version cannot be derived, the method makes a 'best guess'.
97+ */
98+ private static final Map<String, String> dseToCassandraVersions = ImmutableMap.<String, String>builder()
99+ .put("5.0", "3.0")
100+ .put("4.8.3", "2.1.11")
101+ .put("4.8.2", "2.1.11")
102+ .put("4.8.1", "2.1.11")
103+ .put("4.8", "2.1.9")
104+ .put("4.7.6", "2.1.11")
105+ .put("4.7.5", "2.1.11")
106+ .put("4.7.4", "2.1.11")
107+ .put("4.7.3", "2.1.8")
108+ .put("4.7.2", "2.1.8")
109+ .put("4.7.1", "2.1.5")
110+ .put("4.6.11", "2.0.16")
111+ .put("4.6.10", "2.0.16")
112+ .put("4.6.9", "2.0.16")
113+ .put("4.6.8", "2.0.16")
114+ .put("4.6.7", "2.0.14")
115+ .put("4.6.6", "2.0.14")
116+ .put("4.6.5", "2.0.14")
117+ .put("4.6.4", "2.0.14")
118+ .put("4.6.3", "2.0.12")
119+ .put("4.6.2", "2.0.12")
120+ .put("4.6.1", "2.0.12")
121+ .put("4.6", "2.0.11")
122+ .put("4.5.9", "2.0.16")
123+ .put("4.5.8", "2.0.14")
124+ .put("4.5.7", "2.0.12")
125+ .put("4.5.6", "2.0.12")
126+ .put("4.5.5", "2.0.12")
127+ .put("4.5.4", "2.0.11")
128+ .put("4.5.3", "2.0.11")
129+ .put("4.5.2", "2.0.10")
130+ .put("4.5.1", "2.0.8")
131+ .put("4.5", "2.0.8")
132+ .put("4.0", "2.0")
133+ .put("3.2", "1.2")
134+ .put("3.1", "1.2")
135+ .build();
136+
92137 /**
93138 * The command to use to launch CCM
94139 */
@@ -98,14 +143,30 @@
98143 CASSANDRA_VERSION = System.getProperty("cassandra.version");
99144 String installDirectory = System.getProperty("cassandra.directory");
100145 String branch = System.getProperty("cassandra.branch");
146+
147+ String dseProperty = System.getProperty("dse");
148+ // If -Ddse, if the value is empty interpret it as enabled,
149+ // otherwise if there is a value, parse as boolean.
150+ IS_DSE = dseProperty != null && (dseProperty.isEmpty() || Boolean.parseBoolean(dseProperty));
151+
152+ StringBuilder installArgs = new StringBuilder();
101153 if (installDirectory != null && !installDirectory.trim().isEmpty()) {
102- CASSANDRA_INSTALL_ARGS = "--install-dir=" + new File(installDirectory).getAbsolutePath();
154+ installArgs.append("--install-dir=");
155+ installArgs.append(new File(installDirectory).getAbsolutePath());
103156 } else if (branch != null && !branch.trim().isEmpty()) {
104- CASSANDRA_INSTALL_ARGS = "-v " + branch.replaceAll("\"", "");
157+ installArgs.append("-v git:");
158+ installArgs.append(branch.trim().replaceAll("\"", ""));
105159 } else {
106- CASSANDRA_INSTALL_ARGS = "-v " + CASSANDRA_VERSION;
160+ installArgs.append("-v");
161+ installArgs.append(CASSANDRA_VERSION);
107162 }
108163
164+ if (IS_DSE) {
165+ installArgs.append(" --dse");
166+ }
167+
168+ CASSANDRA_INSTALL_ARGS = installArgs.toString();
169+
109170 String ip_prefix = System.getProperty("ipprefix");
110171 if (ip_prefix == null || ip_prefix.isEmpty()) {
111172 ip_prefix = "127.0.1.";
@@ -136,6 +197,14 @@
136197 envMap.put("JAVA_HOME", ccmJavaHome);
137198 }
138199 ENVIRONMENT_MAP = ImmutableMap.copyOf(envMap);
200+
201+ if (CCMBridge.isDSE()) {
202+ logger.info("Tests requiring CCM will use DSE version {} (C* {}, install arguments: {})",
203+ CCMBridge.getDSEVersion(), CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
204+ } else {
205+ logger.info("Tests requiring CCM will use Cassandra version {} (install arguments: {})",
206+ CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
207+ }
139208 }
140209
141210 /**
@@ -151,8 +220,68 @@
151220
152221 private final File ccmDir;
153222
154- private CCMBridge() {
223+ private final boolean isDSE;
224+
225+ private CCMBridge(boolean isDSE) {
155226 this.ccmDir = Files.createTempDir();
227+ this.isDSE = isDSE;
228+ }
229+
230+ /**
231+ * @return The configured cassandra version. If -Ddse=true was used, this value is derived from the
232+ * DSE version provided. If the DSE version can't be derived the following logic is used:
233+ * <ol>
234+ * <li>If <= 3.X, use C* 1.2</li>
235+ * <li>If 4.X, use 2.1 for >= 4.7, 2.0 otherwise.</li>
236+ * <li>Otherwise 3.0</li>
237+ * </ol>
238+ */
239+ public static String getCassandraVersion() {
240+ if (isDSE()) {
241+ String cassandraVersion = dseToCassandraVersions.get(CASSANDRA_VERSION);
242+ if (cassandraVersion != null) {
243+ return cassandraVersion;
244+ } else if (CASSANDRA_VERSION.startsWith("3.") || CASSANDRA_VERSION.compareTo("3") <= 0) {
245+ return "1.2";
246+ } else if (CASSANDRA_VERSION.startsWith("4.")) {
247+ if (CASSANDRA_VERSION.compareTo("4.7") >= 0) {
248+ return "2.1";
249+ } else {
250+ return "2.0";
251+ }
252+ } else {
253+ // Fallback on 3.0 by default.
254+ return "3.0";
255+ }
256+
257+ } else {
258+ return CASSANDRA_VERSION;
259+ }
260+ }
261+
262+ /**
263+ * @return The configured DSE version if '-Ddse=true' specified, otherwise null.
264+ */
265+ public static String getDSEVersion() {
266+ if (isDSE()) {
267+ return CASSANDRA_VERSION;
268+ } else {
269+ return null;
270+ }
271+ }
272+
273+ /**
274+ * @return Whether or not DSE was configured via '-Ddse=true'.
275+ */
276+ public static boolean isDSE() {
277+ return IS_DSE;
278+ }
279+
280+ /**
281+ * @return The install arguments to pass to CCM when creating the cluster.
282+ */
283+ public static String getInstallArguments() {
284+ return CASSANDRA_INSTALL_ARGS;
156285 }
157286
158287 /**
@@ -220,9 +349,14 @@
220349 execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto", n);
221350 }
222351
223- public void start(int n, String jvmArg) {
224- logger.info("Starting: " + IP_PREFIX + n + " with " + jvmArg);
225- execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto --jvm_arg=%s", n, jvmArg);
352+ public void start(int n, String... jvmArg) {
353+ StringBuilder jvmArgs = new StringBuilder("");
354+ for (int i = 0; i < jvmArg.length; i++) {
355+ jvmArgs.append(" --jvm_arg=");
356+ jvmArgs.append(jvmArg[i]);
357+ }
358+ logger.info("Starting: " + IP_PREFIX + n + " with " + jvmArgs);
359+ execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto %s", n, jvmArgs.toString());
226360 }
227361
228362 public void stop(int n) {
@@ -261,9 +395,9 @@
261395
262396 public void bootstrapNode(int n, String dc) {
263397 if (dc == null)
264- execute(CCM_COMMAND + " add node%d -i %s%d -j %d -r %d -b -s", n, IP_PREFIX, n, 7000 + 100 * n, 8000 + 100 * n);
398+ execute(CCM_COMMAND + " add node%d -i %s%d -j %d -r %d -b -s" + (isDSE ? " --dse" : ""), n, IP_PREFIX, n, 7000 + 100 * n, 8000 + 100 * n);
265399 else
266- execute(CCM_COMMAND + " add node%d -i %s%d -j %d -b -d %s -s", n, IP_PREFIX, n, 7000 + 100 * n, dc);
400+ execute(CCM_COMMAND + " add node%d -i %s%d -j %d -b -d %s -s" + (isDSE ? " --dse" : ""), n, IP_PREFIX, n, 7000 + 100 * n, dc);
267401 execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto", n);
268402 }
269403
@@ -272,7 +406,7 @@
272406 String storageItf = IP_PREFIX + n + ":" + storagePort;
273407 String binaryItf = IP_PREFIX + n + ":" + binaryPort;
274408 String remoteLogItf = IP_PREFIX + n + ":" + remoteDebugPort;
275- execute(CCM_COMMAND + " add node%d -i %s%d -b -t %s -l %s --binary-itf %s -j %d -r %s -s",
409+ execute(CCM_COMMAND + " add node%d -i %s%d -b -t %s -l %s --binary-itf %s -j %d -r %s -s" + (isDSE ? " --dse" : ""),
276410 n, IP_PREFIX, n, thriftItf, storageItf, binaryItf, jmxPort, remoteLogItf);
277411 if (option == null) start(n);
278412 else start(n, option);
@@ -290,6 +424,18 @@
290424 execute(CCM_COMMAND + " updateconf " + confStr);
291425 }
292426
427+ public void updateDSEConfig(Map<String, String> configs) {
428+ StringBuilder confStr = new StringBuilder();
429+ for (Map.Entry<String, String> entry : configs.entrySet()) {
430+ confStr.append(entry.getKey() + ":" + entry.getValue() + " ");
431+ }
432+ execute(CCM_COMMAND + " updatedseconf " + confStr);
433+ }
434+
435+ public void setWorkload(int node, String workload) {
436+ execute(CCM_COMMAND + " node%d setworkload %s", node, workload);
437+ }
438+
293439 private void execute(String command, Object... args) {
294440
295441 String fullCommand = String.format(command, args) + " --config-dir=" + ccmDir;
@@ -391,6 +537,7 @@
391537 }
392538
393539 public static class TerminationHook extends Thread {
540+ @Override
394541 public void run() {
395542 logger.debug("shut down hook task..");
396543
@@ -627,10 +774,14 @@
627774 private final String clusterName;
628775 private Integer[] nodes = {1};
629776 private boolean start = true;
777+ private boolean isDSE = IS_DSE;
630778 private String cassandraInstallArgs = CASSANDRA_INSTALL_ARGS;
631779 private String[] startOptions = new String[0];
780+
632781 private Map<String, String> cassandraConfiguration = Maps.newHashMap();
633782
783+ private Map<String, String> dseConfiguration = Maps.newHashMap();
784+
634785
635786 Builder(String clusterName) {
636787 this.clusterName = clusterName;
@@ -674,6 +825,13 @@
674825 */
675826 public Builder withCassandraVersion(String cassandraVersion) {
676827 this.cassandraInstallArgs = "-v " + cassandraVersion;
828+ this.isDSE = false;
829+ return this;
830+ }
831+
832+ public Builder withDSEVersion(String dseVersion) {
833+ this.cassandraInstallArgs = "-v " + dseVersion + " --dse";
834+ this.isDSE = true;
677835 return this;
678836 }
679837
@@ -693,10 +851,18 @@
693851 return this;
694852 }
695853
854+ public Builder withDSEConfiguration(String key, String value) {
855+ this.dseConfiguration.put(key, value);
856+ return this;
857+ }
858+
696859 public CCMBridge build() {
697- CCMBridge ccm = new CCMBridge();
860+ CCMBridge ccm = new CCMBridge(isDSE);
698861 ccm.execute(buildCreateCommand());
699- ccm.updateConfig(cassandraConfiguration);
862+ if (!cassandraConfiguration.isEmpty())
863+ ccm.updateConfig(cassandraConfiguration);
864+ if (!dseConfiguration.isEmpty())
865+ ccm.updateDSEConfig(dseConfiguration);
700866 if (start)
701867 ccm.start();
702868 return ccm;
modified driver-core/src/test/java/com/datastax/driver/core/TestListener.java +47 −10
@@ -16,6 +16,7 @@
1616 package com.datastax.driver.core;
1717
1818 import com.datastax.driver.core.utils.CassandraVersion;
19+import com.datastax.driver.core.utils.DseVersion;
1920 import org.testng.*;
2021 import org.testng.internal.ConstructorOrMethod;
2122
@@ -27,10 +28,6 @@
2728 private long start_time = System.nanoTime();
2829 private int test_index = 0;
2930
30- static {
31- System.out.println("[CCMBridge] Using Cassandra version: " + CCMBridge.CASSANDRA_VERSION + " (install arguments: " + CCMBridge.CASSANDRA_INSTALL_ARGS + ")");
32- }
33-
3431 @Override
3532 public void onTestFailure(ITestResult tr) {
3633 long elapsedTime = TimeUnit.NANOSECONDS.toSeconds((System.nanoTime() - start_time));
@@ -90,15 +87,27 @@
9087 ConstructorOrMethod constructorOrMethod = testNgMethod.getConstructorOrMethod();
9188
9289 Class<?> clazz = testNgMethod.getInstance().getClass();
93- if (clazz != null && clazz.isAnnotationPresent(CassandraVersion.class)) {
94- CassandraVersion cassandraVersion = clazz.getAnnotation(CassandraVersion.class);
95- TestUtils.versionCheck(cassandraVersion.major(), cassandraVersion.minor(), cassandraVersion.description());
90+ if (clazz != null) {
91+ if (clazz.isAnnotationPresent(CassandraVersion.class)) {
92+ CassandraVersion cassandraVersion = clazz.getAnnotation(CassandraVersion.class);
93+ cassandraVersionCheck(cassandraVersion);
94+ }
95+ if (clazz.isAnnotationPresent(DseVersion.class)) {
96+ DseVersion dseVersion = clazz.getAnnotation(DseVersion.class);
97+ dseVersionCheck(dseVersion);
98+ }
9699 }
97100
98101 Method method = constructorOrMethod.getMethod();
99- if (method != null && method.isAnnotationPresent(CassandraVersion.class)) {
100- CassandraVersion cassandraVersion = method.getAnnotation(CassandraVersion.class);
101- TestUtils.versionCheck(cassandraVersion.major(), cassandraVersion.minor(), cassandraVersion.description());
102+ if (method != null) {
103+ if (method.isAnnotationPresent(CassandraVersion.class)) {
104+ CassandraVersion cassandraVersion = method.getAnnotation(CassandraVersion.class);
105+ cassandraVersionCheck(cassandraVersion);
106+ }
107+ if (method.isAnnotationPresent(DseVersion.class)) {
108+ DseVersion dseVersion = method.getAnnotation(DseVersion.class);
109+ dseVersionCheck(dseVersion);
110+ }
102111 }
103112 }
104113
@@ -106,4 +115,32 @@
106115 public void afterInvocation(IInvokedMethod testMethod, ITestResult testResult) {
107116 // Do nothing
108117 }
118+
119+ private static void cassandraVersionCheck(CassandraVersion version) {
120+ versionCheck(CCMBridge.getCassandraVersion(), version.major(), version.minor(), version.description());
121+ }
122+
123+ private static void dseVersionCheck(DseVersion version) {
124+ if (CCMBridge.isDSE()) {
125+ versionCheck(CCMBridge.getDSEVersion(), version.major(), version.minor(), version.description());
126+ } else {
127+ throw new SkipException("Skipping test because not configured for DataStax Enterprise cluster.");
128+ }
129+ }
130+
131+ private static void versionCheck(String version, double majorCheck, int minorCheck, String skipString) {
132+ if (version == null) {
133+ throw new SkipException("Skipping test because provided version is null");
134+ } else {
135+ String[] versionArray = version.split("\\.|-");
136+ double major = Double.parseDouble(versionArray[0] + "." + versionArray[1]);
137+ // If there is no minor version, assume latest version of whatever was provided.
138+ int minor = versionArray.length >= 3 ? Integer.parseInt(versionArray[2]) : Integer.MAX_VALUE;
139+
140+ if (major < majorCheck || (major == majorCheck && minor < minorCheck)) {
141+ throw new SkipException("Version >= " + majorCheck + "." + minorCheck + " required. " +
142+ "Description: " + skipString);
143+ }
144+ }
145+ }
109146 }
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +0 −11
@@ -24,7 +24,6 @@
2424 import org.scassandra.ScassandraFactory;
2525 import org.slf4j.Logger;
2626 import org.slf4j.LoggerFactory;
27-import org.testng.SkipException;
2827
2928 import java.io.IOException;
3029 import java.math.BigDecimal;
@@ -560,16 +559,6 @@
560559 return testForDown ? !host.isUp() : host.isUp();
561560 }
562561
563- public static void versionCheck(double majorCheck, int minorCheck, String skipString) {
564- String version = System.getProperty("cassandra.version");
565- String[] versionArray = version.split("\\.|-");
566- double major = Double.parseDouble(versionArray[0] + "." + versionArray[1]);
567- int minor = Integer.parseInt(versionArray[2]);
568-
569- if (major < majorCheck || (major == majorCheck && minor < minorCheck)) {
570- throw new SkipException("Version >= " + majorCheck + "." + minorCheck + " required. Description: " + skipString);
571- }
572- }
573562
574563 public static Host findOrWaitForHost(Cluster cluster, int node, long duration, TimeUnit unit) {
575564 return findOrWaitForHost(cluster, CCMBridge.ipOfNode(node), duration, unit);
modified driver-core/src/test/java/com/datastax/driver/core/utils/CassandraVersion.java +4 −4
@@ -19,7 +19,7 @@
1919 import java.lang.annotation.RetentionPolicy;
2020
2121 /**
22- * <p>Annotation for a Class or Method that defines a Cassandra Version requirement. If the cassandra verison in used
22+ * <p>Annotation for a Class or Method that defines a Cassandra Version requirement. If the cassandra version in use
2323 * does not meet the version requirement, the test is skipped.</p>
2424 *
2525 * @see {@link com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)} for usage.
@@ -29,15 +29,15 @@
2929 /**
3030 * @return The major version required to execute this test, i.e. "2.0"
3131 */
32- public double major();
32+ double major();
3333
3434 /**
3535 * @return The minor version required to execute this test, i.e. "0"
3636 */
37- public int minor() default 0;
37+ int minor() default 0;
3838
3939 /**
4040 * @return The description returned if this version requirement is not met.
4141 */
42- public String description() default "Does not meet minimum version requirement.";
42+ String description() default "Does not meet minimum version requirement.";
4343 }
added driver-core/src/test/java/com/datastax/driver/core/utils/DseVersion.java +43 −0
@@ -0,0 +1,43 @@
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.utils;
17+
18+import java.lang.annotation.Retention;
19+import java.lang.annotation.RetentionPolicy;
20+
21+/**
22+ * <p>Annotation for a Class or Method that defines a DataStax Enterprise Version requirement.
23+ * If the version in use does not meet the version requirement or DSE is not used, the test is skipped.</p>
24+ *
25+ * @see {@link com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)} for usage.
26+ */
27+@Retention(RetentionPolicy.RUNTIME)
28+public @interface DseVersion {
29+ /**
30+ * @return The major version required to execute this test, i.e. "4.8"
31+ */
32+ double major() default 0.0;
33+
34+ /**
35+ * @return The minor version required to execute this test, i.e. "3"
36+ */
37+ int minor() default 0;
38+
39+ /**
40+ * @return The description returned if this version requirement is not met.
41+ */
42+ String description() default "Does not meet minimum version requirement.";
43+}
modified driver-examples/stress/src/main/java/com/datastax/driver/stress/BlockingConsumer.java +1 −0
@@ -52,6 +52,7 @@
5252 super("Consumer Threads");
5353 }
5454
55+ @Override
5556 public void run() {
5657 try {
5758 while (requests.hasNext())
modified driver-examples/stress/src/main/java/com/datastax/driver/stress/Generators.java +9 −0
@@ -26,6 +26,7 @@
2626
2727 public class Generators {
2828 private static ThreadLocal<Random> random = new ThreadLocal<Random>() {
29+ @Override
2930 protected Random initialValue() {
3031 return new Random();
3132 }
@@ -62,10 +63,12 @@
6263
6364 public static final QueryGenerator.Builder INSERTER = new QueryGenerator.Builder() {
6465
66+ @Override
6567 public String name() {
6668 return "insert";
6769 }
6870
71+ @Override
6972 public OptionParser addOptions(OptionParser parser) {
7073 String msg = "Simple insertion of CQL3 rows (using prepared statements unless the --no-prepare option is used). "
7174 + "The inserted rows have a fixed set of columns but no clustering columns.";
@@ -78,6 +81,7 @@
7881 return parser;
7982 }
8083
84+ @Override
8185 public void prepare(OptionSet options, Session session) {
8286
8387 try {
@@ -100,6 +104,7 @@
100104 session.execute(sb.toString());
101105 }
102106
107+ @Override
103108 public QueryGenerator create(int id, int iterations, OptionSet options, Session session) {
104109
105110 return options.has("no-prepare")
@@ -159,10 +164,12 @@
159164
160165 public static final QueryGenerator.Builder READER = new QueryGenerator.Builder() {
161166
167+ @Override
162168 public String name() {
163169 return "read";
164170 }
165171
172+ @Override
166173 public OptionParser addOptions(OptionParser parser) {
167174 String msg = "Read the rows inserted with the insert generator. Use prepared statements unless the --no-prepare option is used.";
168175 parser.formatHelpWith(Stress.Help.formatFor(name(), msg));
@@ -171,6 +178,7 @@
171178 return parser;
172179 }
173180
181+ @Override
174182 public void prepare(OptionSet options, Session session) {
175183 KeyspaceMetadata ks = session.getCluster().getMetadata().getKeyspace("stress");
176184 if (ks == null || ks.getTable("standard1") == null) {
@@ -181,6 +189,7 @@
181189 session.execute("USE stress");
182190 }
183191
192+ @Override
184193 public QueryGenerator create(int id, int iterations, OptionSet options, Session session) {
185194 return options.has("no-prepare")
186195 ? createRegular(id, iterations, session)
modified driver-examples/stress/src/main/java/com/datastax/driver/stress/QueryGenerator.java +4 −0
@@ -59,10 +59,12 @@
5959 this.statement = statement;
6060 }
6161
62+ @Override
6263 public ResultSet execute(Session session) {
6364 return session.execute(statement);
6465 }
6566
67+ @Override
6668 public ResultSetFuture executeAsync(Session session) {
6769 return session.executeAsync(statement);
6870 }
@@ -76,10 +78,12 @@
7678 this.query = query;
7779 }
7880
81+ @Override
7982 public ResultSet execute(Session session) {
8083 return session.execute(query);
8184 }
8285
86+ @Override
8387 public ResultSetFuture executeAsync(Session session) {
8488 return session.executeAsync(query);
8589 }
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AccessorInvocationHandler.java +1 −0
@@ -49,6 +49,7 @@
4949 methodMap.put(method.method, method);
5050 }
5151
52+ @Override
5253 public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
5354 if (m.equals(TO_STRING))
5455 return mapper.daoClass.getSimpleName() + " implementation generated by the Cassandra driver mapper";
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AccessorReflectionMapper.java +1 −0
@@ -47,6 +47,7 @@
4747 }
4848
4949 private static class AccessorReflectionFactory implements Factory {
50+ @Override
5051 public <T> AccessorMapper<T> create(Class<T> daoClass, List<MethodMapper> methods) {
5152 return new AccessorReflectionMapper<T>(daoClass, methods);
5253 }
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationParser.java +1 −0
@@ -37,6 +37,7 @@
3737 class AnnotationParser {
3838
3939 private static final Comparator<Field> fieldComparator = new Comparator<Field>() {
40+ @Override
4041 public int compare(Field f1, Field f2) {
4142 return position(f1) - position(f2);
4243 }
modified driver-mapping/src/main/java/com/datastax/driver/mapping/Mapper.java +5 −0
@@ -77,16 +77,19 @@
7777
7878 this.protocolVersion = manager.getSession().getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
7979 this.mapOneFunction = new Function<ResultSet, T>() {
80+ @Override
8081 public T apply(ResultSet rs) {
8182 return Mapper.this.mapAliased(rs).one();
8283 }
8384 };
8485 this.mapOneFunctionWithoutAliases = new Function<ResultSet, T>() {
86+ @Override
8587 public T apply(ResultSet rs) {
8688 return Mapper.this.map(rs).one();
8789 }
8890 };
8991 this.mapAllFunctionWithoutAliases = new Function<ResultSet, Result<T>>() {
92+ @Override
9093 public Result<T> apply(ResultSet rs) {
9194 return Mapper.this.map(rs);
9295 }
@@ -830,6 +833,7 @@
830833 this.ttlValue = value;
831834 }
832835
836+ @Override
833837 void appendTo(Insert.Options usings) {
834838 usings.and(QueryBuilder.ttl(QueryBuilder.bindMarker()));
835839 }
@@ -1033,6 +1037,7 @@
10331037 return false;
10341038 }
10351039
1040+ @Override
10361041 public int hashCode() {
10371042 return Objects.hashCode(queryType, optionTypes, columns);
10381043 }
modified driver-mapping/src/main/java/com/datastax/driver/mapping/ReflectionMapper.java +2 −0
@@ -84,11 +84,13 @@
8484
8585 private static class ReflectionFactory implements Factory {
8686
87+ @Override
8788 public <T> EntityMapper<T> create(Class<T> entityClass, String keyspace, String table, ConsistencyLevel writeConsistency, ConsistencyLevel readConsistency) {
8889 return new ReflectionMapper<T>(entityClass, keyspace, table, writeConsistency, readConsistency);
8990 }
9091
9192 @SuppressWarnings({"unchecked", "rawtypes"})
93+ @Override
9294 public <T> ColumnMapper<T> createColumnMapper(Class<T> entityClass, Field field, int position, MappingManager mappingManager, AtomicInteger columnCounter) {
9395 String fieldName = field.getName();
9496 try {
modified driver-mapping/src/main/java/com/datastax/driver/mapping/Result.java +5 −1
@@ -119,18 +119,22 @@
119119 * @return an iterator that will consume and return the remaining rows of
120120 * this mapped result set.
121121 */
122- public Iterator<T> iterator() {
122+ @Override
123+ public Iterator<T> iterator() {
123124 return new Iterator<T>() {
124125 private final Iterator<Row> rowIterator = rs.iterator();
125126
127+ @Override
126128 public boolean hasNext() {
127129 return rowIterator.hasNext();
128130 }
129131
132+ @Override
130133 public T next() {
131134 return map(rowIterator.next());
132135 }
133136
137+ @Override
134138 public void remove() {
135139 throw new UnsupportedOperationException();
136140 }
modified upgrade_guide/README.md +2 −1
@@ -449,7 +449,8 @@
449449
450450 4. The internal initialization sequence of the Cluster object has been slightly changed:
451451 some fields that were previously initialized in the constructor are now set when
452- the `init()` method is called. This is unlikely to affect regular driver users.
452+ the `init()` method is called. In particular, `Cluster#getMetrics()` will return
453+ `null` until the cluster is initialized.
453454
454455 ### 1.0 to 2.0
455456