Skip to content

Commit 3632eda

Browse files
author
Alexandre Dutra
committed
Merge branch '3.1.x' into 3.x
Conflicts: README.md build.yaml
2 parents 9e10e44 + cec7777 commit 3632eda

108 files changed

Lines changed: 5709 additions & 1041 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.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ not yet have been released. You can find the documentation for latest
88
version through [Java driver
99
docs](http://datastax.github.io/java-driver/) or via the release tags,
1010
[e.g.
11-
3.1.0](https://github.com/datastax/java-driver/tree/3.1.0).*
11+
3.1.3](https://github.com/datastax/java-driver/tree/3.1.3).*
1212

1313
A modern, [feature-rich](manual/) and highly tunable Java client
1414
library for Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using
@@ -55,7 +55,7 @@ The driver contains the following modules:
5555
start material and technical details about the driver and its features.
5656
- API: http://www.datastax.com/drivers/java/3.1
5757
- [changelog](changelog/)
58-
- [binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.0.tar.gz)
58+
- [binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.3.tar.gz)
5959

6060
**Feeback requested:** help us focus our efforts, provide your input on the [Platform and Runtime Survey](http://goo.gl/forms/qwUE6qnL7U) (we kept it short).
6161

@@ -68,7 +68,7 @@ it in your application using the following Maven dependency:
6868
<dependency>
6969
<groupId>com.datastax.cassandra</groupId>
7070
<artifactId>cassandra-driver-core</artifactId>
71-
<version>3.1.0</version>
71+
<version>3.1.3</version>
7272
</dependency>
7373
```
7474

@@ -78,7 +78,7 @@ Note that the object mapper is published as a separate artifact:
7878
<dependency>
7979
<groupId>com.datastax.cassandra</groupId>
8080
<artifactId>cassandra-driver-mapping</artifactId>
81-
<version>3.1.0</version>
81+
<version>3.1.3</version>
8282
</dependency>
8383
```
8484

@@ -88,7 +88,7 @@ The 'extras' module is also published as a separate artifact:
8888
<dependency>
8989
<groupId>com.datastax.cassandra</groupId>
9090
<artifactId>cassandra-driver-extras</artifactId>
91-
<version>3.1.0</version>
91+
<version>3.1.3</version>
9292
</dependency>
9393
```
9494

@@ -97,12 +97,12 @@ We also provide a [shaded JAR](manual/shaded_jar/)
9797
to avoid the explicit dependency to Netty.
9898

9999
If you can't use a dependency management tool, a
100-
[binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.0.tar.gz)
100+
[binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.3.tar.gz)
101101
is available for download.
102102

103103
## Compatibility
104104

105-
The Java client driver 3.1.0 ([branch 3.x](https://github.com/datastax/java-driver/tree/3.x)) is compatible with Apache
105+
The Java client driver 3.1.3 ([branch 3.x](https://github.com/datastax/java-driver/tree/3.x)) is compatible with Apache
106106
Cassandra 1.2, 2.0, 2.1, 2.2 and 3.0 (see [this page](http://datastax.github.io/java-driver/manual/native_protocol) for
107107
the most up-to-date compatibility information).
108108

build.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ schedules:
44
schedule: per_commit
55
matrix:
66
exclude:
7-
- java: [openjdk6, oraclejdk7]
7+
# Exclude all java 7 builds
8+
- java: oraclejdk7
9+
# Exclude java6 with all versions except latest
10+
- java: openjdk6
11+
cassandra: ['1.2', '2.0', '2.1', '2.2', '3.0']
12+
# Exclude 2.2 and 3.0 always since 3.X provides latest protocol version
813
- cassandra: ['2.2', '3.0']
914
env_vars: |
1015
TEST_GROUP="short"
@@ -39,6 +44,7 @@ build:
3944
cassandra.version=$CCM_CASSANDRA_VERSION
4045
ccm.java.home=$CCM_JAVA_HOME
4146
ccm.path=$CCM_JAVA_HOME/bin
47+
ccm.maxNumberOfNodes=3
4248
failIfNoTests=false
4349
maven.test.failure.ignore=true
4450
maven.javadoc.skip=true
@@ -51,6 +57,7 @@ build:
5157
cassandra.version=$CCM_CASSANDRA_VERSION
5258
ccm.java.home=$CCM_JAVA_HOME
5359
ccm.path=$CCM_JAVA_HOME/bin
60+
ccm.maxNumberOfNodes=3
5461
failIfNoTests=false
5562
maven.test.failure.ignore=true
5663
maven.javadoc.skip=true

changelog/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
## Changelog
22

3+
### 3.1.3
4+
5+
Merged from 3.0.x branch:
6+
7+
- [bug] JAVA-1330: Add un/register for SchemaChangeListener in DelegatingCluster
8+
- [bug] JAVA-1351: Include Custom Payload in Request.copy.
9+
- [bug] JAVA-1346: Reset heartbeat only on client reads (not writes).
10+
- [improvement] JAVA-866: Support tuple notation in QueryBuilder.eq/in.
11+
12+
13+
### 3.1.2
14+
15+
- [bug] JAVA-1321: Wrong OSGi dependency version for Guava.
16+
17+
Merged from 3.0.x branch:
18+
19+
- [bug] JAVA-1312: QueryBuilder modifies selected columns when manually selected.
20+
- [improvement] JAVA-1303: Add missing BoundStatement.setRoutingKey(ByteBuffer...)
21+
- [improvement] JAVA-262: Make internal executors customizable
22+
23+
24+
### 3.1.1
25+
26+
- [bug] JAVA-1284: ClockFactory should check system property before attempting to load Native class.
27+
- [bug] JAVA-1255: Allow nested UDTs to be used in Mapper.
28+
- [bug] JAVA-1279: Mapper should exclude Groovy's "metaClass" property when looking for mapped properties
29+
30+
Merged from 3.0.x branch:
31+
32+
- [improvement] JAVA-1246: Driver swallows the real exception in a few cases
33+
- [improvement] JAVA-1261: Throw error when attempting to page in I/O thread.
34+
- [bug] JAVA-1258: Regression: Mapper cannot map a materialized view after JAVA-1126.
35+
- [bug] JAVA-1101: Batch and BatchStatement should consider inner statements to determine query idempotence
36+
- [improvement] JAVA-1262: Use ParseUtils for quoting & unquoting.
37+
- [improvement] JAVA-1275: Use Netty's default thread factory
38+
- [bug] JAVA-1285: QueryBuilder routing key auto-discovery should handle case-sensitive column names.
39+
- [bug] JAVA-1283: Don't cache failed query preparations in the mapper.
40+
- [improvement] JAVA-1277: Expose AbstractSession.checkNotInEventLoop.
41+
- [bug] JAVA-1272: BuiltStatement not able to print its query string if it contains mapped UDTs.
42+
- [bug] JAVA-1292: 'Adjusted frame length' error breaks driver's ability to read data.
43+
- [improvement] JAVA-1293: Make DecoderForStreamIdSize.MAX_FRAME_LENGTH configurable.
44+
- [improvement] JAVA-1053: Add a metric for authentication errors
45+
- [improvement] JAVA-1263: Eliminate unnecessary memory copies in FrameCompressor implementations.
46+
- [improvement] JAVA-893: Make connection pool non-blocking
47+
48+
349
### 3.1.0
450

551
- [new feature] JAVA-1153: Add PER PARTITION LIMIT to Select QueryBuilder.
@@ -70,6 +116,33 @@ Merged from 2.1 branch:
70116
- [improvement] JAVA-444: Add Java process information to UUIDs.makeNode() hash.
71117

72118

119+
### 3.0.5
120+
121+
- [bug] JAVA-1312: QueryBuilder modifies selected columns when manually selected.
122+
- [improvement] JAVA-1303: Add missing BoundStatement.setRoutingKey(ByteBuffer...)
123+
- [improvement] JAVA-262: Make internal executors customizable
124+
- [bug] JAVA-1320: prevent unnecessary task creation on empty pool
125+
126+
127+
### 3.0.4
128+
129+
- [improvement] JAVA-1246: Driver swallows the real exception in a few cases
130+
- [improvement] JAVA-1261: Throw error when attempting to page in I/O thread.
131+
- [bug] JAVA-1258: Regression: Mapper cannot map a materialized view after JAVA-1126.
132+
- [bug] JAVA-1101: Batch and BatchStatement should consider inner statements to determine query idempotence
133+
- [improvement] JAVA-1262: Use ParseUtils for quoting & unquoting.
134+
- [improvement] JAVA-1275: Use Netty's default thread factory
135+
- [bug] JAVA-1285: QueryBuilder routing key auto-discovery should handle case-sensitive column names.
136+
- [bug] JAVA-1283: Don't cache failed query preparations in the mapper.
137+
- [improvement] JAVA-1277: Expose AbstractSession.checkNotInEventLoop.
138+
- [bug] JAVA-1272: BuiltStatement not able to print its query string if it contains mapped UDTs.
139+
- [bug] JAVA-1292: 'Adjusted frame length' error breaks driver's ability to read data.
140+
- [improvement] JAVA-1293: Make DecoderForStreamIdSize.MAX_FRAME_LENGTH configurable.
141+
- [improvement] JAVA-1053: Add a metric for authentication errors
142+
- [improvement] JAVA-1263: Eliminate unnecessary memory copies in FrameCompressor implementations.
143+
- [improvement] JAVA-893: Make connection pool non-blocking
144+
145+
73146
### 3.0.3
74147

75148
- [improvement] JAVA-1147: Upgrade Netty to 4.0.37.

clirr-ignores.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
2020
</difference>
2121

22-
2322
<difference>
2423
<differenceType>1001</differenceType> <!-- decreased visibility -->
2524
<className>com/datastax/driver/mapping/ColumnMapper$Kind</className>
@@ -136,4 +135,16 @@
136135
<justification>Introduced more generic parent type PercentileTracker (API was marked as beta and still subject to change)</justification>
137136
</difference>
138137

138+
<difference>
139+
<differenceType>8001</differenceType> <!-- class removed -->
140+
<className>com/datastax/driver/core/FrameCompressor$SnappyCompressor</className>
141+
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
142+
</difference>
143+
144+
<difference>
145+
<differenceType>8001</differenceType> <!-- class removed -->
146+
<className>com/datastax/driver/core/FrameCompressor$LZ4Compressor</className>
147+
<justification>False positive, the enclosing class is package-private so this was never exposed</justification>
148+
</difference>
149+
139150
</differences>

driver-core/pom.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.datastax.cassandra</groupId>
2222
<artifactId>cassandra-driver-parent</artifactId>
23-
<version>3.2.0-SNAPSHOT</version>
23+
<version>3.1.4-SNAPSHOT</version>
2424
</parent>
2525
<artifactId>cassandra-driver-core</artifactId>
2626
<packaging>bundle</packaging>
@@ -200,7 +200,7 @@
200200
<_include>-osgi.bnd</_include>
201201
<Import-Package>
202202
<!-- JNR does not provide OSGi bundles, so exclude it; the driver can live without it -->
203-
<![CDATA[com.google.common*;version="[14.0,20)",!jnr.*,*]]></Import-Package>
203+
<![CDATA[com.google.common*;version="[${guava.version},20)",!jnr.*,*]]></Import-Package>
204204
</instructions>
205205
<supportedProjectTypes>
206206
<supportedProjectType>jar</supportedProjectType>
@@ -224,7 +224,7 @@
224224
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
225225
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
226226
-->
227-
<![CDATA[com.google.common.*;version="[14.0,19)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
227+
<![CDATA[com.google.common.*;version="[${guava.version},20)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
228228
<Private-Package>com.datastax.shaded.*</Private-Package>
229229
</instructions>
230230
</configuration>
@@ -342,6 +342,8 @@
342342
<include>**/ControlConnectionTest.java</include>
343343
<include>**/ExtendedPeerCheckDisabledTest.java</include>
344344
<include>**/UUIDsPID*.java</include>
345+
<include>**/FrameLengthTest.java</include>
346+
<include>**/HeapCompressionTest.java</include>
345347
</includes>
346348
</configuration>
347349
</plugin>

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.util.concurrent.Futures;
2020
import com.google.common.util.concurrent.ListenableFuture;
2121
import com.google.common.util.concurrent.Uninterruptibles;
22+
import io.netty.util.concurrent.EventExecutor;
2223

2324
import java.nio.ByteBuffer;
2425
import java.util.Map;
@@ -31,6 +32,9 @@
3132
*/
3233
public abstract class AbstractSession implements Session {
3334

35+
private static final boolean CHECK_IO_DEADLOCKS = SystemProperties.getBoolean(
36+
"com.datastax.driver.CHECK_IO_DEADLOCKS", true);
37+
3438
/**
3539
* {@inheritDoc}
3640
*/
@@ -131,12 +135,12 @@ public ListenableFuture<PreparedStatement> prepareAsync(final RegularStatement s
131135
if (statement.hasValues())
132136
throw new IllegalArgumentException("A statement to prepare should not have values");
133137

134-
ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.getQueryString(), statement.getOutgoingPayload());
138+
final CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
139+
ListenableFuture<PreparedStatement> prepared = prepareAsync(statement.getQueryString(codecRegistry), statement.getOutgoingPayload());
135140
return Futures.transform(prepared, new Function<PreparedStatement, PreparedStatement>() {
136141
@Override
137142
public PreparedStatement apply(PreparedStatement prepared) {
138143
ProtocolVersion protocolVersion = getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
139-
CodecRegistry codecRegistry = getCluster().getConfiguration().getCodecRegistry();
140144
ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
141145
if (routingKey != null)
142146
prepared.setRoutingKey(routingKey);
@@ -179,9 +183,30 @@ public void close() {
179183
/**
180184
* Checks that the current thread is not one of the Netty I/O threads used by the driver.
181185
* <p/>
182-
* This is called from the synchronous methods of this class to prevent deadlock issues.
186+
* This method is called from all the synchronous methods of this class to prevent deadlock issues.
187+
* <p/>
188+
* User code extending this class can also call this method at any time to check if any code
189+
* making blocking calls is being wrongly executed on a Netty I/O thread.
190+
* <p/>
191+
* Note that the check performed by this method has a small overhead; if
192+
* that is an issue, checks can be disabled by setting the System property
193+
* {@code com.datastax.driver.CHECK_IO_DEADLOCKS} to {@code false}.
194+
*
195+
* @throws IllegalStateException if the current thread is one of the Netty I/O thread used by the driver.
183196
*/
184-
protected void checkNotInEventLoop() {
185-
// This method is concrete only to avoid a breaking change. See subclass for the actual implementation.
197+
public void checkNotInEventLoop() {
198+
Connection.Factory connectionFactory = getCluster().manager.connectionFactory;
199+
if (!CHECK_IO_DEADLOCKS || connectionFactory == null)
200+
return;
201+
for (EventExecutor executor : connectionFactory.eventLoopGroup) {
202+
if (executor.inEventLoop()) {
203+
throw new IllegalStateException(
204+
"Detected a synchronous call on an I/O thread, this can cause deadlocks or unpredictable " +
205+
"behavior. This generally happens when a Future callback calls a synchronous Session " +
206+
"method (execute() or prepare()), or iterates a result set past the fetch size " +
207+
"(causing an internal synchronous fetch of the next page of results). " +
208+
"Avoid this in your callbacks, or schedule them on a different executor.");
209+
}
210+
}
186211
}
187212
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ private void prepareNextRow() {
307307
// We need to know if there is more result, so fetch the next page and
308308
// wait on it.
309309
try {
310+
session.checkNotInEventLoop();
310311
Uninterruptibles.getUninterruptibly(fetchMoreResults());
311312
} catch (ExecutionException e) {
312313
throw DriverThrowables.propagateCause(e);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ IdAndValues getIdAndValues(ProtocolVersion protocolVersion, CodecRegistry codecR
9090
if (statement instanceof RegularStatement) {
9191
RegularStatement st = (RegularStatement) statement;
9292
ByteBuffer[] vals = st.getValues(protocolVersion, codecRegistry);
93-
String query = st.getQueryString();
93+
String query = st.getQueryString(codecRegistry);
9494
idAndVals.ids.add(query);
9595
idAndVals.values.add(vals == null ? Collections.<ByteBuffer>emptyList() : Arrays.asList(vals));
9696
} else {
@@ -243,6 +243,14 @@ public String getKeyspace() {
243243
return null;
244244
}
245245

246+
@Override
247+
public Boolean isIdempotent() {
248+
if (idempotent != null) {
249+
return idempotent;
250+
}
251+
return isBatchIdempotent(statements);
252+
}
253+
246254
void ensureAllSet() {
247255
for (Statement statement : statements)
248256
if (statement instanceof BoundStatement)

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,24 @@ public BoundStatement setRoutingKey(ByteBuffer routingKey) {
270270
return this;
271271
}
272272

273+
/**
274+
* Sets the routing key for this bound statement, when the query partition key is composite and the routing key must
275+
* be built from multiple values.
276+
* <p/>
277+
* This is useful when the routing key can neither be set on the {@code PreparedStatement} this bound statement
278+
* was built from, nor automatically computed from bound variables. In particular, this is the case if the
279+
* partition key is composite and only some of its components are bound.
280+
*
281+
* @param routingKeyComponents the raw (binary) values to compose to obtain
282+
* the routing key.
283+
* @return this {@code BoundStatement} object.
284+
* @see BoundStatement#getRoutingKey
285+
*/
286+
public BoundStatement setRoutingKey(ByteBuffer... routingKeyComponents) {
287+
this.routingKey = SimpleStatement.compose(routingKeyComponents);
288+
return this;
289+
}
290+
273291
/**
274292
* {@inheritDoc}
275293
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ClockFactory {
4848
private static final String USE_NATIVE_CLOCK_SYSTEM_PROPERTY = "com.datastax.driver.USE_NATIVE_CLOCK";
4949

5050
static Clock newInstance() {
51-
if (Native.isGettimeofdayAvailable() && SystemProperties.getBoolean(USE_NATIVE_CLOCK_SYSTEM_PROPERTY, true)) {
51+
if (SystemProperties.getBoolean(USE_NATIVE_CLOCK_SYSTEM_PROPERTY, true) && Native.isGettimeofdayAvailable()) {
5252
LOGGER.info("Using native clock to generate timestamps.");
5353
return new NativeClock();
5454
} else {
@@ -82,7 +82,7 @@ public long currentTimeMicros() {
8282
* to get the current time, which is good enough an accuracy for our purpose (see CASSANDRA-6106).
8383
* <p/>
8484
* This reduces the cost of the call to {@link NativeClock#currentTimeMicros()} to levels comparable
85-
* to those of a call to {@link System#currentTimeMillis()}.
85+
* to those of a call to {@link System#nanoTime()}.
8686
*/
8787
class NativeClock implements Clock {
8888

0 commit comments

Comments
 (0)