Skip to content

Commit 7c8afa1

Browse files
committed
Merge branch '2.0' into 2.1
2 parents a61ec45 + dc32a6d commit 7c8afa1

113 files changed

Lines changed: 6858 additions & 1613 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: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
## Changelog
22

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

556
- [bug] Special case check for 'null' string in index_options column (JAVA-834)
@@ -262,8 +313,9 @@ Merged from 2.0 branch: everything up to 2.0.3 (included), and the following.
262313
- [bug] Make metadata parsing more lenient (JAVA-377, JAVA-391)
263314

264315

265-
### 2.0.11 (in progress)
316+
### 2.0.11
266317

318+
- [improvement] Log streamid at the trace level on sending request and receiving response (JAVA-718)
267319
- [bug] Fix SpeculativeExecutionPolicy.init() and close() are never called (JAVA-796)
268320
- [improvement] Suppress unnecessary warning at shutdown (JAVA-710)
269321
- [improvement] Allow DNS name with multiple A-records as contact point (#340)
@@ -284,6 +336,29 @@ Merged from 2.0 branch: everything up to 2.0.3 (included), and the following.
284336
- [bug] Preserve tracing across retries (JAVA-815)
285337
- [improvement] New RetryDecision.tryNextHost() (JAVA-709)
286338
- [bug] Handle function calls and raw strings as non-idempotent in QueryBuilder (JAVA-733)
339+
- [improvement] Provide API to retrieve values of a Parameterized SimpleStatement (JAVA-765)
340+
- [improvement] implement UPDATE ... IF EXISTS in QueryBuilder (JAVA-827)
341+
- [improvement] Randomize contact points list to prevent hotspots (JAVA-618)
342+
- [improvement] Surface the coordinator used on query failure (JAVA-720)
343+
- [bug] Handle contact points removed during init (JAVA-792)
344+
- [improvement] Allow PlainTextAuthProvider to change its credentials at runtime (JAVA-719)
345+
- [new feature] Make it possible to register for SchemaChange Events (JAVA-151)
346+
- [improvement] Downgrade "Asked to rebuild table" log from ERROR to INFO level (JAVA-861)
347+
- [improvement] Provide an option to prepare statements only on one node (JAVA-797)
348+
- [improvement] Provide an option to not re-prepare all statements in onUp (JAVA-658)
349+
- [improvement] Customizable creation of netty timer (JAVA-853)
350+
- [bug] Avoid quadratic ring processing with invalid replication factors (JAVA-859)
351+
- [improvement] Debounce control connection queries (JAVA-657)
352+
- [bug] LoadBalancingPolicy.distance() called before init() (JAVA-784)
353+
- [new feature] Make driver-side metadata optional (JAVA-828)
354+
- [improvement] Allow hosts to remain partially up (JAVA-544)
355+
- [improvement] Remove internal blocking calls and expose async session
356+
creation (JAVA-821, JAVA-822)
357+
- [improvement] Use parallel calls when re-preparing statement on other
358+
hosts (JAVA-725)
359+
- [bug] Don't use connection timeout for unrelated internal queries (JAVA-629)
360+
- [bug] Fix NPE in speculative executions when metrics disabled
361+
(JAVA-892)
287362

288363
Merged from 2.0.10_fixes branch:
289364

clirr-ignores.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,22 @@
2929
<justification>False positive: HostConnectionPool is not exposed to clients</justification>
3030
</difference>
3131

32+
<difference>
33+
<differenceType>1001</differenceType> <!-- decreased visibility -->
34+
<className>com/datastax/driver/core/ConvictionPolicy$Factory</className>
35+
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
36+
</difference>
37+
38+
<difference>
39+
<differenceType>8001</differenceType> <!-- class removed -->
40+
<className>com/datastax/driver/core/ConvictionPolicy$Simple</className>
41+
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
42+
</difference>
43+
44+
<difference>
45+
<differenceType>8001</differenceType> <!-- class removed -->
46+
<className>com/datastax/driver/core/ConvictionPolicy$Simple$Factory</className>
47+
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
48+
</difference>
49+
3250
</differences>

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
@@ -26,7 +26,7 @@
2626
*
2727
* This is primarly intended to make mocking easier.
2828
*/
29-
public abstract class AbstractSession implements Session {
29+
public abstract class AbstractSession implements Session, AsyncInitSession {
3030

3131
/**
3232
* {@inheritDoc}
@@ -76,7 +76,7 @@ public PreparedStatement prepare(String query) {
7676
try {
7777
return Uninterruptibles.getUninterruptibly(prepareAsync(query));
7878
} catch (ExecutionException e) {
79-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
79+
throw DriverThrowables.propagateCause(e);
8080
}
8181
}
8282

@@ -88,7 +88,7 @@ public PreparedStatement prepare(RegularStatement statement) {
8888
try {
8989
return Uninterruptibles.getUninterruptibly(prepareAsync(statement));
9090
} catch (ExecutionException e) {
91-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
91+
throw DriverThrowables.propagateCause(e);
9292
}
9393
}
9494

@@ -125,7 +125,7 @@ public void close() {
125125
try {
126126
closeAsync().get();
127127
} catch (ExecutionException e) {
128-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
128+
throw DriverThrowables.propagateCause(e);
129129
} catch (InterruptedException e) {
130130
Thread.currentThread().interrupt();
131131
}

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
@@ -282,7 +282,7 @@ private void prepareNextRow() {
282282
try {
283283
Uninterruptibles.getUninterruptibly(fetchMoreResults());
284284
} catch (ExecutionException e) {
285-
throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
285+
throw DriverThrowables.propagateCause(e);
286286
}
287287
}
288288
}
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)