Skip to content

Commit 5274d8e

Browse files
committed
Merge branch '2.1' into 2.2
2 parents 3f019f3 + 7c8afa1 commit 5274d8e

116 files changed

Lines changed: 7274 additions & 1758 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ notes
1313
*.iml
1414

1515
/driver-core/dependency-reduced-pom.xml
16+
.java-version
17+

changelog/README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
## Changelog
22

3+
### 2.2.0-rc4 (in progress)
4+
5+
Merged from 2.0 branch:
6+
7+
- [improvement] Log streamid at the trace level on sending request and receiving response (JAVA-718)
8+
- [bug] Fix SpeculativeExecutionPolicy.init() and close() are never called (JAVA-796)
9+
- [improvement] Suppress unnecessary warning at shutdown (JAVA-710)
10+
- [improvement] Allow DNS name with multiple A-records as contact point (#340)
11+
- [bug] Allow tracing across multiple result pages (JAVA-794)
12+
- [bug] DowngradingConsistencyRetryPolicy ignores write timeouts (JAVA-737)
13+
- [bug] Forbid bind marker in QueryBuilder add/append/prepend (JAVA-736)
14+
- [bug] Prevent QueryBuilder.quote() from applying duplicate double quotes (JAVA-712)
15+
- [bug] Prevent QueryBuilder from trying to serialize raw string (JAVA-688)
16+
- [bug] Support bind marker in QueryBuilder DELETE's list index (JAVA-679)
17+
- [improvement] Improve QueryBuilder API for SELECT DISTINCT (JAVA-475)
18+
- [improvement] Create values() function for Insert builder using List (JAVA-225)
19+
- [improvement] Warn when ReplicationStrategy encounters invalid
20+
replication factors (JAVA-702)
21+
- [improvement] Add PoolingOptions method to set both core and max
22+
connections (JAVA-662).
23+
- [improvement] Do not include epoll JAR in binary distribution (JAVA-766)
24+
- [improvement] Optimize internal copies of Request objects (JAVA-726)
25+
- [bug] Preserve tracing across retries (JAVA-815)
26+
- [improvement] New RetryDecision.tryNextHost() (JAVA-709)
27+
- [bug] Handle function calls and raw strings as non-idempotent in QueryBuilder (JAVA-733)
28+
- [improvement] Provide API to retrieve values of a Parameterized SimpleStatement (JAVA-765)
29+
- [improvement] implement UPDATE ... IF EXISTS in QueryBuilder (JAVA-827)
30+
- [improvement] Randomize contact points list to prevent hotspots (JAVA-618)
31+
- [improvement] Surface the coordinator used on query failure (JAVA-720)
32+
- [bug] Handle contact points removed during init (JAVA-792)
33+
- [improvement] Allow PlainTextAuthProvider to change its credentials at runtime (JAVA-719)
34+
- [new feature] Make it possible to register for SchemaChange Events (JAVA-151)
35+
- [improvement] Downgrade "Asked to rebuild table" log from ERROR to INFO level (JAVA-861)
36+
- [improvement] Provide an option to prepare statements only on one node (JAVA-797)
37+
- [improvement] Provide an option to not re-prepare all statements in onUp (JAVA-658)
38+
- [improvement] Customizable creation of netty timer (JAVA-853)
39+
- [bug] Avoid quadratic ring processing with invalid replication factors (JAVA-859)
40+
- [improvement] Debounce control connection queries (JAVA-657)
41+
- [bug] LoadBalancingPolicy.distance() called before init() (JAVA-784)
42+
- [new feature] Make driver-side metadata optional (JAVA-828)
43+
- [improvement] Allow hosts to remain partially up (JAVA-544)
44+
- [improvement] Remove internal blocking calls and expose async session
45+
creation (JAVA-821, JAVA-822)
46+
- [improvement] Use parallel calls when re-preparing statement on other
47+
hosts (JAVA-725)
48+
- [bug] Don't use connection timeout for unrelated internal queries (JAVA-629)
49+
- [bug] Fix NPE in speculative executions when metrics disabled
50+
(JAVA-892)
51+
52+
353
### 2.2.0-rc3
454

555
- [bug] Propagate CodecRegistry to nested UDTs (JAVA-847)
@@ -346,8 +396,9 @@ Merged from 2.0 branch: everything up to 2.0.3 (included), and the following.
346396
- [bug] Make metadata parsing more lenient (JAVA-377, JAVA-391)
347397

348398

349-
### 2.0.11 (in progress)
399+
### 2.0.11
350400

401+
- [improvement] Log streamid at the trace level on sending request and receiving response (JAVA-718)
351402
- [bug] Fix SpeculativeExecutionPolicy.init() and close() are never called (JAVA-796)
352403
- [improvement] Suppress unnecessary warning at shutdown (JAVA-710)
353404
- [improvement] Allow DNS name with multiple A-records as contact point (#340)
@@ -368,6 +419,29 @@ Merged from 2.0 branch: everything up to 2.0.3 (included), and the following.
368419
- [bug] Preserve tracing across retries (JAVA-815)
369420
- [improvement] New RetryDecision.tryNextHost() (JAVA-709)
370421
- [bug] Handle function calls and raw strings as non-idempotent in QueryBuilder (JAVA-733)
422+
- [improvement] Provide API to retrieve values of a Parameterized SimpleStatement (JAVA-765)
423+
- [improvement] implement UPDATE ... IF EXISTS in QueryBuilder (JAVA-827)
424+
- [improvement] Randomize contact points list to prevent hotspots (JAVA-618)
425+
- [improvement] Surface the coordinator used on query failure (JAVA-720)
426+
- [bug] Handle contact points removed during init (JAVA-792)
427+
- [improvement] Allow PlainTextAuthProvider to change its credentials at runtime (JAVA-719)
428+
- [new feature] Make it possible to register for SchemaChange Events (JAVA-151)
429+
- [improvement] Downgrade "Asked to rebuild table" log from ERROR to INFO level (JAVA-861)
430+
- [improvement] Provide an option to prepare statements only on one node (JAVA-797)
431+
- [improvement] Provide an option to not re-prepare all statements in onUp (JAVA-658)
432+
- [improvement] Customizable creation of netty timer (JAVA-853)
433+
- [bug] Avoid quadratic ring processing with invalid replication factors (JAVA-859)
434+
- [improvement] Debounce control connection queries (JAVA-657)
435+
- [bug] LoadBalancingPolicy.distance() called before init() (JAVA-784)
436+
- [new feature] Make driver-side metadata optional (JAVA-828)
437+
- [improvement] Allow hosts to remain partially up (JAVA-544)
438+
- [improvement] Remove internal blocking calls and expose async session
439+
creation (JAVA-821, JAVA-822)
440+
- [improvement] Use parallel calls when re-preparing statement on other
441+
hosts (JAVA-725)
442+
- [bug] Don't use connection timeout for unrelated internal queries (JAVA-629)
443+
- [bug] Fix NPE in speculative executions when metrics disabled
444+
(JAVA-892)
371445

372446
Merged from 2.0.10_fixes branch:
373447

driver-core/src/main/java/com/datastax/driver/core/AbstractReconnectionHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ abstract class AbstractReconnectionHandler implements Runnable {
4040

4141
private static final Logger logger = LoggerFactory.getLogger(AbstractReconnectionHandler.class);
4242

43+
private final String name;
4344
private final ScheduledExecutorService executor;
4445
private final ReconnectionPolicy.ReconnectionSchedule schedule;
4546
/**
@@ -53,11 +54,12 @@ abstract class AbstractReconnectionHandler implements Runnable {
5354

5455
private final CountDownLatch ready = new CountDownLatch(1);
5556

56-
public AbstractReconnectionHandler(ScheduledExecutorService executor, ReconnectionPolicy.ReconnectionSchedule schedule, AtomicReference<ListenableFuture<?>> currentAttempt) {
57-
this(executor, schedule, currentAttempt, -1);
57+
public AbstractReconnectionHandler(String name, ScheduledExecutorService executor, ReconnectionPolicy.ReconnectionSchedule schedule, AtomicReference<ListenableFuture<?>> currentAttempt) {
58+
this(name, executor, schedule, currentAttempt, -1);
5859
}
5960

60-
public AbstractReconnectionHandler(ScheduledExecutorService executor, ReconnectionPolicy.ReconnectionSchedule schedule, AtomicReference<ListenableFuture<?>> currentAttempt, long initialDelayMs) {
61+
public AbstractReconnectionHandler(String name, ScheduledExecutorService executor, ReconnectionPolicy.ReconnectionSchedule schedule, AtomicReference<ListenableFuture<?>> currentAttempt, long initialDelayMs) {
62+
this.name = name;
6163
this.executor = executor;
6264
this.schedule = schedule;
6365
this.currentAttempt = currentAttempt;
@@ -92,7 +94,7 @@ public void start() {
9294
break;
9395
}
9496
if (currentAttempt.compareAndSet(previous, handlerFuture)) {
95-
logger.debug("Becoming the active handler");
97+
Host.statesLogger.debug("[{}] starting reconnection attempt", name);
9698
break;
9799
}
98100
}
@@ -176,6 +178,7 @@ private void reschedule(long nextDelay) {
176178
return;
177179
}
178180

181+
Host.statesLogger.debug("[{}] next reconnection attempt in {} ms", name, nextDelay);
179182
handlerFuture.nextTry = executor.schedule(this, nextDelay, TimeUnit.MILLISECONDS);
180183
}
181184

driver-core/src/main/java/com/datastax/driver/core/AbstractSession.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* This is primarly intended to make mocking easier.
3131
*/
32-
public abstract class AbstractSession implements Session {
32+
public abstract class AbstractSession implements Session, AsyncInitSession {
3333

3434
/**
3535
* {@inheritDoc}
@@ -95,7 +95,7 @@ public PreparedStatement prepare(String query) {
9595
try {
9696
return Uninterruptibles.getUninterruptibly(prepareAsync(query));
9797
} catch (ExecutionException e) {
98-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
98+
throw DriverThrowables.propagateCause(e);
9999
}
100100
}
101101

@@ -107,7 +107,7 @@ public PreparedStatement prepare(RegularStatement statement) {
107107
try {
108108
return Uninterruptibles.getUninterruptibly(prepareAsync(statement));
109109
} catch (ExecutionException e) {
110-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
110+
throw DriverThrowables.propagateCause(e);
111111
}
112112
}
113113

@@ -163,7 +163,7 @@ public void close() {
163163
try {
164164
closeAsync().get();
165165
} catch (ExecutionException e) {
166-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
166+
throw DriverThrowables.propagateCause(e);
167167
} catch (InterruptedException e) {
168168
Thread.currentThread().interrupt();
169169
}

driver-core/src/main/java/com/datastax/driver/core/AggregateMetadata.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121

22+
import com.google.common.base.Objects;
2223
import com.google.common.collect.ImmutableList;
2324
import com.google.common.collect.Lists;
2425

@@ -289,4 +290,29 @@ public FunctionMetadata getStateFunc() {
289290
public DataType getStateType() {
290291
return stateType;
291292
}
293+
294+
@Override
295+
public boolean equals(Object other) {
296+
if (other instanceof AggregateMetadata) {
297+
AggregateMetadata that = (AggregateMetadata)other;
298+
return this.keyspace.getName().equals(that.keyspace.getName()) &&
299+
this.fullName.equals(that.fullName) &&
300+
this.argumentTypes.equals(that.argumentTypes) &&
301+
Objects.equal(this.finalFuncFullName, that.finalFuncFullName) &&
302+
// Note: this might be a problem if a custom codec has been registered for the initCond's type, with a target Java type that
303+
// does not properly implement equals. We don't have any control over this, at worst this would lead to spurious change
304+
// notifications.
305+
Objects.equal(this.initCond, that.initCond) &&
306+
this.returnType.equals(that.returnType) &&
307+
this.stateFuncFullName.equals(that.stateFuncFullName) &&
308+
this.stateType.equals(that.stateType);
309+
}
310+
return false;
311+
}
312+
313+
@Override
314+
public int hashCode() {
315+
return Objects.hashCode(this.keyspace.getName(), this.fullName, this.argumentTypes,
316+
this.finalFuncFullName, this.initCond, this.returnType, this.stateFuncFullName, this.stateType);
317+
}
292318
}

driver-core/src/main/java/com/datastax/driver/core/ArrayBackedResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private void prepareNextRow() {
294294
try {
295295
Uninterruptibles.getUninterruptibly(fetchMoreResults());
296296
} catch (ExecutionException e) {
297-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
297+
throw DriverThrowables.propagateCause(e);
298298
}
299299
}
300300
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2012-2015 DataStax Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.datastax.driver.core;
17+
18+
import com.google.common.util.concurrent.ListenableFuture;
19+
20+
/**
21+
* A {@link Session} that can be initialized asynchronously.
22+
*
23+
* This interface exists only for backward compatibility reasons: {@link #initAsync()} should really be
24+
* defined by {@link Session}, but adding it after the fact would break binary compatibility.
25+
*
26+
* By default, all sessions returned by the driver implement this interface. The only way you would get
27+
* sessions that don't is if you use a custom {@link Cluster} subclass.
28+
*/
29+
public interface AsyncInitSession extends Session {
30+
/**
31+
* Initialize this session asynchronously.
32+
*
33+
* @return a future that will complete when the session is fully initialized.
34+
*/
35+
ListenableFuture<Session> initAsync();
36+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (C) 2012-2015 DataStax Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.datastax.driver.core;
17+
18+
import java.util.concurrent.ExecutionException;
19+
import java.util.concurrent.TimeUnit;
20+
import java.util.concurrent.TimeoutException;
21+
22+
import com.google.common.util.concurrent.AbstractFuture;
23+
import com.google.common.util.concurrent.FutureCallback;
24+
import com.google.common.util.concurrent.Futures;
25+
import com.google.common.util.concurrent.Uninterruptibles;
26+
27+
/**
28+
* A {@code ResultSetFuture} that will complete when its source future completes.
29+
*/
30+
class ChainedResultSetFuture extends AbstractFuture<ResultSet> implements ResultSetFuture {
31+
32+
private volatile ResultSetFuture source;
33+
34+
void setSource(ResultSetFuture source) {
35+
if (this.isCancelled())
36+
source.cancel(false);
37+
this.source = source;
38+
Futures.addCallback(source, new FutureCallback<ResultSet>() {
39+
@Override
40+
public void onSuccess(ResultSet result) {
41+
ChainedResultSetFuture.this.set(result);
42+
}
43+
44+
@Override
45+
public void onFailure(Throwable t) {
46+
ChainedResultSetFuture.this.setException(t);
47+
}
48+
});
49+
}
50+
51+
@Override
52+
public boolean cancel(boolean mayInterruptIfRunning) {
53+
return (source == null || source.cancel(mayInterruptIfRunning))
54+
&& super.cancel(mayInterruptIfRunning);
55+
}
56+
57+
@Override
58+
public ResultSet getUninterruptibly() {
59+
try {
60+
return Uninterruptibles.getUninterruptibly(this);
61+
} catch (ExecutionException e) {
62+
throw DriverThrowables.propagateCause(e);
63+
}
64+
}
65+
66+
@Override
67+
public ResultSet getUninterruptibly(long timeout, TimeUnit unit) throws TimeoutException {
68+
try {
69+
return Uninterruptibles.getUninterruptibly(this, timeout, unit);
70+
} catch (ExecutionException e) {
71+
throw DriverThrowables.propagateCause(e);
72+
}
73+
}
74+
}
75+

0 commit comments

Comments
 (0)