Elffuss BraidHub

kikocis/java-driver public

ff0d4e2c4987 · 29.0 KiBRenderedRawPermalink
1## Upgrade guide
2
3The purpose of this guide is to detail changes made by successive
4versions of the Java driver.
5
6### 2.2.0
7
8This version brings parity with Cassandra 2.2.
9
10It is **not binary compatible** with the driver's 2.1 branch.
11The main changes were introduced by the custom codecs feature (see below).
12We've also seized the opportunity to remove code that was deprecated in 2.1.
13
141. [Custom codecs](../features/custom_codecs/)
15 ([JAVA-721](https://datastax-oss.atlassian.net/browse/JAVA-721))
16 introduce several breaking changes and also modify a few runtime behaviors.
17
18 Here is a detailed list of breaking API changes:
19 * `TypeCodec` was package-private before and is now public.
20 * `DataType` has no more references to `TypeCodec`, so most methods that dealt with serialization and deserialization of data types have been removed:
21 * `ByteBuffer serialize(Object value, ProtocolVersion protocolVersion)`
22 * `ByteBuffer serializeValue(Object value, ProtocolVersion protocolVersion)`
23 * `Object deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)`
24 * `Object deserialize(ByteBuffer bytes, int protocolVersion)`
25 * `Object parse(String value)`
26 * `String format(Object value)`
27 * `Class<?> asJavaClass()`
28 * `GettableByIndexData` (affects `Row`, `BoundStatement`, `TupleValue` and `UDTValue`). The following public methods were added:
29 * `<T> T get(int i, Class<T> targetClass)`
30 * `<T> T get(int i, TypeToken<T> targetType)`
31 * `<T> T get(int i, TypeCodec<T> codec)`
32 * `GettableByNameData` (affects `Row`, `BoundStatement` and `UDTValue`). The following public methods were added:
33 * `<T> T get(String name, Class<T> targetClass)`
34 * `<T> T get(String name, TypeToken<T> targetType)`
35 * `<T> T get(String name, TypeCodec<T> codec)`
36 * `SettableByIndexData` (affects `Row`, `BoundStatement`, `TupleValue` and `UDTValue`). The following public methods were added:
37 * `<V> T set(int i, V v, Class<V> targetClass)`
38 * `<V> T set(int i, V v, TypeToken<V> targetType)`
39 * `<V> T set(int i, V v, TypeCodec<V> codec)`
40 * `SettableByNameData` (affects `Row`, `BoundStatement` and `UDTValue`). The following public methods were added:
41 * `<V> T set(String name, V v, Class<V> targetClass)`
42 * `<V> T set(String name, V v, TypeToken<V> targetType)`
43 * `<V> T set(String name, V v, TypeCodec<V> codec)`
44 * `Session`. The following methods were added:
45 * `newSimpleStatement(String query)`
46 * `newSimpleStatement(String query, Object... values)`
47 * `RegularStatement`. The following public methods were modified:
48 * `getValues()`
49 * `hasValues()`
50 * `SimpleStatement`. Public constructors were removed; users are required to call either:
51 * `Session.newSimpleStatement(String query)` or
52 * `Session.newSimpleStatement(String query, Object... values)`
53 * `QueryBuilder`. This class now has a single, public constructor: `QueryBuilder(Cluster cluster)`.
54 Its fluent API has also changed; instead of e.g.: `QueryBuilder.select(...)`,
55 users should now use the following idiom: `new QueryBuilder(cluster).select(...)`
56 All methods that start a query are now instance methods instead of static ones.
57 * `PreparedStatement`. The following public method was added:
58 * `CodecRegistry getCodecRegistry()`.
59 * `TupleType`. The following public method was deleted:
60 * `TupleType of(DataType... types)`; users should now use `Metadata.newTupleType(DataType...)`.
61
62 <p>The driver runtime behavior changes in the following situations:</p>
63 * `RuntimeException`s thrown during serialization or deserialization might not be
64 the same ones as before, due to the newly-introduced `CodecNotFoundException`
65 and to the dynamic nature of codec search introduced by JAVA-721.
66 * `TypeCodec.format(Object)` now returns the CQL keyword `"NULL"` instead of a `null` reference
67 for `null` inputs.
68
692. The driver now depends on Guava 16.0.1 (instead of 14.0.1).
70 This update has been mainly motivated by Guava's [Issue #1635](https://code.google.com/p/guava-libraries/issues/detail?id=1635),
71 which affects `TypeToken`, and hence all `TypeCodec` implementations handling parameterized types.
72
733. `UDTMapper` (the type previously used to convert `@UDT`-annotated
74 classes to their CQL counterpart) was removed, as well as the
75 corresponding method `MappingManager#udtMapper`.
76
77 The mapper now uses custom codecs to convert UDTs. See more
78 explanations [here](../features/object_mapper/custom_codecs/#implicit-udt-codecs).
79
804. All methods that took the protocol version as an `int` or assumed a
81 default version have been removed (they were already deprecated in
82 2.1):
83 * `AbstractGettableData(int)`
84 * `Cluster.Builder#withProtocolVersion(int)`
85 * in `ProtocolOptions`:
86 * `NEWEST_SUPPORTED_PROTOCOL_VERSION` (replaced by
87 `ProtocolVersion#NEWEST_SUPPORTED`)
88 * `int getProtocolVersion()`
89
90 There are now variants of these methods using the `ProtocolVersion`
91 enum. In addition, `ProtocolOptions#getProtocolVersionEnum` has been
92 renamed to `ProtocolOptions#getProtocolVersion`.
93
945. All methods related to the "suspected" host state have been removed
95 (they had been deprecated in 2.1.6 when the suspicion mechanism was
96 removed):
97 * `Host.StateListener#onSuspected()` (was inherited by
98 `LoadBalancingPolicy`)
99 * `Host#getInitialReconnectionAttemptFuture()`
100
1016. `PoolingOptions#setMinSimultaneousRequestsPerConnectionThreshold(HostDistance,
102 int)` has been removed. The new connection pool resizing algorithm introduced by
103 [JAVA-419](https://datastax-oss.atlassian.net/browse/JAVA-419) does not need this
104 threshold anymore.
105
1067. `AddressTranslater` has been renamed to `AddressTranslator`. All
107 related methods and classes have also been renamed.
108
109 In addition, the `close()` method has been pulled up into
110 `AddressTranslator`, and `CloseableAddressTranslator` has been removed.
111 Existing third-party `AddressTranslator` implementations only need
112 to add an empty `close()` method.
113
1148. The `close()` method has been pulled up into `LoadBalancingPolicy`,
115 and `CloseableLoadBalancingPolicy` has been removed. Existing third-party
116 `LoadBalancingPolicy` implementations only need to add an empty
117 `close()` method.
118
1199. All pluggable components now have callbacks to detect when they get
120 associated with a `Cluster` instance:
121 * `ReconnectionPolicy`, `RetryPolicy`, `AddressTranslator`,
122 and `TimestampGenerator`:
123 * `init(Cluster)`
124 * `close()`
125 * `Host.StateListener` and `LatencyTracker`:
126 * `onRegister(Cluster)`
127 * `onUnregister(Cluster)`
128
129 This gives these components the opportunity to perform
130 initialization / cleanup tasks. Existing third-party implementations
131 only need to add empty methods.
132
13310. `LoadBalancingPolicy` does not extend `Host.StateListener` anymore:
134 callback methods (`onUp`, `onDown`, etc.) have been duplicated. This
135 is unlikely to affect clients.
136
13711. [Client-side timestamp generation](../features/query_timestamps/) is
138 now the default (provided that [native
139 protocol](../features/native_protocol) v3 or higher is in use). The
140 generator used is `AtomicMonotonicTimestampGenerator`.
141
14212. If a DNS name resolves to multiple A-records,
143 `Cluster.Builder#addContactPoint(String)` will now use all of these
144 addresses as contact points. This gives you the possibility of
145 maintaining contact points in DNS configuration, and having a single,
146 static contact point in your Java code.
147
14813. The following methods were added for [Custom payloads](../features/custom_payloads):
149 * in `PreparedStatement`: `getIncomingPayload()`,
150 `getOutgoingPayload()` and
151 `setOutgoingPayload(Map<String,ByteBuffer>)`
152 * `AbstractSession#prepareAsync(String, Map<String,ByteBuffer>)`
153
154 Also, not that `AbstractSession#prepareAsync(Statement)` does not
155 call `AbstractSession#prepareAsync(String)` anymore, they now both
156 delegate to a private method.
157
158 This breaks binary compatibility for these two classes; if you have
159 custom implementations, you will have to adapt them accordingly.
160
16114. Getters and setters have been added to "data-container" classes for
162 new CQL types:
163 * `getByte`/`setByte` for the `TINYINT` type
164 * `getShort`/`setShort` for the `SMALLINT` type
165 * `getTime`/`setTime` for the `TIME` type
166 * `getDate`/`setDate` for the `DATE` type
167
168 The methods for the `TIMESTAMP` CQL type have been renamed to
169 `getTimestamp` and `setTimestamp`.
170
171 This affects `Row`, `BoundStatement`, `TupleValue` and `UDTValue`.
172
17315. New exception types have been added to handle additional server-side
174 errors introduced in Cassandra 2.2:
175 * `ReadFailureException`
176 * `WriteFailureException`
177 * `FunctionExecutionException`
178
179 This is not a breaking change since all driver exceptions are
180 unchecked; but clients might decide to handle these errors in a specific
181 way.
182
183 In addition, `QueryTimeoutException` has been renamed to
184 `QueryExecutionException` (this is an intermediary class in our
185 exception hierarchy, it now has new child classes that are not
186 related to timeouts).
187
18816. `ResultSet#fetchMoreResults()` now returns a `ListenableFuture<ResultSet>`.
189 This makes the API more friendly if you chain transformations on an async
190 query to process all pages (see `AsyncResultSetTest` in the sources for an
191 example).
192
19317. `Frozen` annotations in the mapper are no longer checked at runtime (see
194 [JAVA-843](https://datastax-oss.atlassian.net/browse/JAVA-843) for more
195 explanations). So they become purely informational at this stage.
196 However it is a good idea to keep using these annotations and make sure
197 they match the schema, in anticipation for the schema generation features
198 that will be added in a future version.
199
200
201### 2.1.7
202
203This version brings a few changes in the driver's behavior; none of them break
204binary compatibility.
205
2061. The `DefaultRetryPolicy`'s behaviour has changed in the case of an Unavailable
207 exception received from a request. The new behaviour will cause the driver to
208 process a Retry on a different node at most once, otherwise an exception will
209 be thrown. This change makes sense in the case where the node tried initially
210 for the request happens to be isolated from the rest of the cluster (e.g.
211 because of a network partition) but can still answer to the client normally.
212 In this case, trying another node has a chance of success.
213 The previous behaviour was to always throw an exception.
214
2152. The following properties in `PoolingOptions` were renamed:
216 * `MaxSimultaneousRequestsPerConnectionThreshold` to `NewConnectionThreshold`
217 * `MaxSimultaneousRequestsPerHostThreshold` to `MaxRequestsPerConnection`
218
219 The old getters/setters were deprecated, but they delegate to the new
220 ones.
221
222 Also, note that the connection pool for protocol v3 can now be configured to
223 use multiple connections. See [this page](../features/pooling) for more
224 information.
225
2263. `MappingManager(Session)` will now force the initialization of the `Session`
227 if needed. This is a change from 2.1.6, where if you gave it an uninitialized
228 session (created with `Cluster#newSession()` instead of `Cluster#connect()`),
229 it would only get initialized on the first request.
230
231 If this is a problem for you, `MappingManager(Session, ProtocolVersion)`
232 preserves the previous behavior (see the API docs for more details).
233
234Merged from 2.0.11:
235
2364. The `DefaultRetryPolicy`'s behaviour has changed in the case of an Unavailable
237 exception received from a request. The new behaviour will cause the driver to
238 process a Retry on a different node at most once, otherwise an exception will
239 be thrown. This change makes sense in the case where the node tried initially
240 for the request happens to be isolated from the rest of the cluster (e.g.
241 because of a network partition) but can still answer to the client normally.
242 In this case, trying another node has a chance of success.
243 The previous behaviour was to always throw an exception.
2445. A `BuiltStatement` is now considered non-idempotent whenever a `fcall()`
245 or `raw()` is used to build a value to be inserted in the database.
246 If you know that the CQL functions or expressions are safe, use
247 `setIdempotent(true)` on the statement.
248
249
250### 2.1.6
251
252See [2.0.10](#2-0-x-to-2-0-10).
253
254
255### 2.1.2
256
2572.1.2 brings important internal changes with native protocol v3 support, but
258the impact on the public API has been kept as low as possible.
259
260#### User API Changes
261
2621. The native protocol version is now modelled as an enum: `ProtocolVersion`.
263 Most public methods that take it as an argument have a backward-compatible
264 version that takes an `int` (the exception being `RegularStatement`,
265 described below). For new code, prefer the enum version.
266
267#### Internal API Changes
268
2691. `RegularStatement.getValues` now takes the protocol version as a
270 `ProtocolVersion` instead of an `int`. This is transparent for callers
271 since there is a backward-compatible alternative, but if you happened to
272 extend the class you'll need to update your implementation.
273
2742. `BatchStatement.setSerialConsistencyLevel` now returns `BatchStatement`
275 instead of `Statement`. Again, this only matters if you extended this
276 class (if so, it might be a good idea to also have a covariant return in
277 your child class).
278
2793. The constructor of `UnsupportedFeatureException` now takes a
280 `ProtocolVersion` as a parameter. This should impact few users, as there's
281 hardly any reason to build instances of that class from client code.
282
283#### New features
284
285These features are only active when the native protocol v3 is in use.
286
2871. The driver now uses a single connection per host (as opposed to a pool in
288 2.1.1). Most options in `PoolingOptions` are ignored, except for a new one
289 called `maxSimultaneousRequestsPerHostThreshold`. See the class's Javadocs
290 for detailed explanations.
291
2922. You can now provide a default timestamp with each query (but it will be
293 ignored if the CQL query string already contains a `USING TIMESTAMP`
294 clause). This can be done on a per-statement basis with
295 `Statement.setDefaultTimestamp`, or automatically with a
296 `TimestampGenerator` specified with
297 `Cluster.Builder.withTimestampGenerator` (two implementations are
298 provided: `ThreadLocalMonotonicTimestampGenerator` and
299 `AtomicMonotonicTimestampGenerator`). If you specify both, the statement's
300 timestamp takes precedence over the generator. By default, the driver has
301 the same behavior as 2.1.1 (no generator, timestamps are assigned by
302 Cassandra unless `USING TIMESTAMP` was specified).
303
3043. `BatchStatement.setSerialConsistencyLevel` no longer throws an exception,
305 it will honor the serial consistency level for the batch.
306
307
308### 2.1.1
309
310#### Internal API Changes
311
3121. The `ResultSet` interface has a new `wasApplied()` method. This will
313 only affect clients that provide their own implementation of this interface.
314
315
316### 2.1.0
317
318#### User API Changes
319
3201. The `getCaching` method of `TableMetadata#Options` now returns a
321 `Map` to account for changes to Cassandra 2.1. Also, the
322 `getIndexInterval` method now returns an `Integer` instead of an `int`
323 which will be `null` when connected to Cassandra 2.1 nodes.
324
3252. `BoundStatement` variables that have not been set explicitly will no
326 longer default to `null`. Instead, all variables must be bound explicitly,
327 otherwise the execution of the statement will fail (this also applies to
328 statements inside of a `BatchStatement`). For variables that map to a
329 primitive Java type, a new `setToNull` method has been added.
330 We made this change because the driver might soon distinguish between unset
331 and null variables, so we don't want clients relying on the "leave unset to
332 set to `null`" behavior.
333
334
335#### Internal API Changes
336
337The changes listed in this section should normally not impact end users of the
338driver, but rather third-party frameworks and tools.
339
3401. The `serialize` and `deserialize` methods in `DataType` now take an
341 additional parameter: the protocol version. As explained in the javadoc,
342 if unsure, the proper value to use for this parameter is the protocol version
343 in use by the driver, i.e. the value returned by
344 `cluster.getConfiguration().getProtocolOptions().getProtocolVersion()`.
345
3462. The `parse` method in `DataType` now returns a Java object, not a
347 `ByteBuffer`. The previous behavior can be obtained by calling the
348 `serialize` method on the returned object.
349
3503. The `getValues` method of `RegularStatement` now takes the protocol
351 version as a parameter. As above, the proper value if unsure is almost surely
352 the protocol version in use
353 (`cluster.getConfiguration().getProtocolOptions().getProtocolVersion()`).
354
355
356### 2.0.11
357
3582.0.11 preserves binary compatibility with previous versions. There are a few
359changes in the driver's behavior:
360
3611. The `DefaultRetryPolicy`'s behaviour has changed in the case of an Unavailable
362 exception received from a request. The new behaviour will cause the driver to
363 process a Retry on a different node at most once, otherwise an exception will
364 be thrown. This change makes sense in the case where the node tried initially
365 for the request happens to be isolated from the rest of the cluster (e.g.
366 because of a network partition) but can still answer to the client normally.
367 In this case, trying another node has a chance of success.
368 The previous behaviour was to always throw an exception.
369
3702. A `BuiltStatement` is now considered non-idempotent whenever a `fcall()`
371 or `raw()` is used to build a value to be inserted in the database.
372 If you know that the CQL functions or expressions are safe, use
373 `setIdempotent(true)` on the statement.
374
3753. The list of contact points provided at startup is now shuffled before trying
376 to open the control connection, so that multiple clients with the same contact
377 points don't all pick the same control host. As a result, you can't assume that
378 the driver will try contact points in a deterministic order. In particular, if
379 you use the `DCAwareRoundRobinPolicy` without specifying a primary datacenter
380 name, make sure that you only provide local hosts as contact points.
381
382
383### <a name="2-0-x-to-2-0-10"></a>2.0.x to 2.0.10
384
385We try to avoid breaking changes within a branch (2.0.x to 2.0.y), but
3862.0.10 saw a lot of new features and internal improvements. There is one
387breaking change:
388
3891. `LatencyTracker#update` now has a different signature and takes two new
390 parameters: the statement that has been executed (never null), and the exception
391 thrown while executing the query (or null, if the query executed successfully).
392 Existing implementations of this interface, once upgraded to the new method
393 signature, should continue to work as before.
394
395The following might also be of interest:
396
3972. `SocketOptions#getTcpNoDelay()` is now TRUE by default (it was previously undefined).
398 This reflects the new behavior of Netty (which was upgraded from version 3.9.0 to
399 4.0.27): `TCP_NODELAY` is now turned on by default, instead of depending on the OS
400 default like in previous versions.
401
4023. Netty is not shaded anymore in the default Maven artifact. However we publish a
403 [shaded artifact](../features/shaded_jar/) under a different classifier.
404
4054. The internal initialization sequence of the Cluster object has been slightly changed:
406 some fields that were previously initialized in the constructor are now set when
407 the `init()` method is called. This is unlikely to affect regular driver users.
408
409### 1.0 to 2.0
410
411We used the opportunity of a major version bump to incorporate your feedback
412and improve the API, to fix a number of inconsistencies and remove cruft.
413Unfortunately this means there are some breaking changes, but the new API should
414be both simpler and more complete.
415
416The following describes the changes for 2.0 that are breaking changes of the
4171.0 API. For ease of use, we distinguish two categories of API changes: the "main"
418ones and the "other" ones.
419
420The "main" API changes are the ones that are either
421likely to affect most upgraded apps or are incompatible changes that, even if minor,
422will not be detected at compile time. Upgraders are highly encouraged to check
423this list of "main" changes while upgrading their application to 2.0 (even
424though most applications are likely to be affected by only a handful of
425changes).
426
427The "other" list is, well, other changes: those that are likely to
428affect a minor number of applications and will be detected by compile time
429errors anyway. It is ok to skip those initially and only come back to them if
430you have trouble compiling your application after an upgrade.
431
432#### Main API changes
433
4341. The `Query` class has been renamed into `Statement` (it was confusing
435 to some that the `BoundStatement` was not a `Statement`). To allow
436 this, the old `Statement` class has been renamed to `RegularStatement`.
437
4382. The `Cluster` and `Session` shutdown API has changed. There is now a
439 `closeAsync` that is asynchronous but returns a `Future` on the
440 completion of the shutdown process. There is also a `close` shortcut
441 that does the same but blocks. Also, `close` now waits for ongoing
442 queries to complete by default (but you can force the closing of all
443 connections if you want to).
444
4453. `NoHostAvailableException#getErrors` now returns the full exception objects for
446 each node instead of just a message. In other words, it returns a
447 `Map<InetAddress, Throwable>` instead of a `Map<InetAddress, String>`.
448
4494. `Statement#getConsistencyLevel` (previously `Query#getConsistencyLevel`, see
450 first point) will now return `null` by default (instead of `CL.ONE`), with the
451 meaning of "use the default consistency level".
452 The default consistency level can now be configured through the new `QueryOptions`
453 object in the cluster `Configuration`.
454
4555. The `Metrics` class now uses the Codahale metrics library version 3 (version 2 was
456 used previously). This new major version of the library has many API changes
457 compared to its version 2 (see the [release notes](https://dropwizard.github.io/metrics/3.1.0/about/release-notes/) for details),
458 which can thus impact consumers of the Metrics class.
459 Furthermore, the default `JmxReporter` now includes a name specific to the
460 cluster instance (to avoid conflicts when multiple Cluster instances are created
461 in the same JVM). As a result, tools that were polling JMX info will
462 have to be updated accordingly.
463
4646. The `QueryBuilder#in` method now has the following special case: using
465 `QueryBuilder.in(QueryBuilder.bindMarker())` will generate the string `IN ?`,
466 not `IN (?)` as was the case in 1.0. The reasoning being that the former
467 syntax, made valid by [CASSANDRA-4210](https://issues.apache.org/jira/browse/CASSANDRA-4210)
468 is a lot more useful than `IN (?)`, as the latter can more simply use an
469 equality.
470 Note that if you really want to output `IN (?)` with the query
471 builder, you can use `QueryBuilder.in(QueryBuilder.raw("?"))`.
472
4737. When binding values by name in `BoundStatement` (i.e. using the
474 `setX(String, X)` methods), if more than one variable have the same name,
475 then all values corresponding to that variable
476 name are set instead of just the first occurrence.
477
4788. The `QueryBuilder#raw` method does not automatically add quotes anymore, but
479 rather output its result without any change (as the raw name implies).
480 This means for instance that `eq("x", raw(foo))` will output `x = foo`,
481 not `x = 'foo'` (you don't need the raw method to output the latter string).
482
4839. The `QueryBuilder` will now sometimes use the new ability to send value as
484 bytes instead of serializing everything to string. In general the QueryBuilder
485 will do the right thing, but if you were calling the `getQueryString()` method
486 on a Statement created with a QueryBuilder (for other reasons than to prepare a query)
487 then the returned string may contain bind markers in place of some of the values
488 provided (and in that case, `getValues()` will contain the values corresponding
489 to those markers). If need be, it is possible to force the old behavior by
490 using the new `setForceNoValues()` method.
491
492#### Other API Changes
493
4941. Creating a Cluster instance (through `Cluster#buildFrom` or the
495 `Cluster.Builder#build` method) **does not create any connection right away
496 anymore** (and thus cannot throw a `NoHostAvailableException` or an
497 `AuthenticationException`). Instead, the initial contact points are checked
498 the first time a call to `Cluster#connect` is done. If for some reason you
499 want to emulate the previous behavior, you can use the new method
500 `Cluster#init`: `Cluster.builder().build()` in 1.0 is equivalent to
501 `Cluster.builder().build().init()` in 2.0.
502
5032. Methods from `Metadata`, `KeyspaceMetadata` and `TableMetadata` now use by default
504 case insensitive identifiers (for keyspace, table and column names in
505 parameter). You can double-quote an identifier if you want it to be a
506 case sensitive one (as you would do in CQL) and there is a `Metadata.quote`
507 helper method for that.
508
5093. The `TableMetadata#getClusteringKey` method has been renamed
510 `TableMetadata#getClusteringColumns` to match the "official" vocabulary.
511
5124. The `UnavailableException#getConsistency` method has been renamed to
513 `UnavailableException#getConsistencyLevel` for consistency with the method of
514 `QueryTimeoutException`.
515
5165. The `RegularStatement` class (ex-`Statement` class, see above) must now
517 implement two additional methods: `RegularStatement#getKeyspace` and
518 `RegularStatement#getValues`. If you had extended this class, you will have to
519 implement those new methods, but both can return null if they are not useful
520 in your case.
521
5226. The `Cluster.Initializer` interface should now implement 2 new methods:
523 `Cluster.Initializer#getInitialListeners` (which can return an empty
524 collection) and `Cluster.Initializer#getClusterName` (which can return null).
525
5267. The `Metadata#getReplicas` method now takes 2 arguments. On top of the
527 partition key, you must now provide the keyspace too. The previous behavior
528 was buggy: it's impossible to properly return the full list of replica for a
529 partition key without knowing the keyspace since replication may depend on
530 the keyspace).
531
5328. The method `LoadBalancingPolicy#newQueryPlan()` method now takes the currently
533 logged keyspace as 2nd argument. This information is necessary to do proper
534 token aware balancing (see preceding point).
535
5369. The `ResultSetFuture#set` and `ResultSetFuture#setException` methods have been
537 removed (from the public API at least). They were never meant to be exposed
538 publicly: a `resultSetFuture` is always set by the driver itself and should
539 not be set manually.
540
54110. The deprecated since 1.0.2 `Host.HealthMonitor` class has been removed. You
542 will now need to use `Host#isUp` and `Cluster#register` if you were using that
543 class.
544
545#### Features available only with Cassandra 2.0
546
547This section details the biggest additions to 2.0 API wise. It is not an
548exhaustive list of new features in 2.0.
549
5501. The new `BatchStatement` class allows to group any type of insert Statements
551 (`BoundStatement` or `RegularStatement`) for execution as a batch. For instance,
552 you can do something like:
553
554 ```java
555 List<String> values = ...;
556 PreparedStatement ps = session.prepare("INSERT INTO myTable(value) VALUES (?)");
557 BatchStatement bs = new BatchStatement();
558 for (String value : values)
559 bs.add(ps.bind(value));
560 session.execute(bs);
561 ```
562
5632. `SimpleStatement` can now take a list of values in addition to the query. This
564 allows to do the equivalent of a prepare+execute but with only one round-trip
565 to the server and without keeping the prepared statement after the
566 execution.
567
568 This is typically useful if a given query should be executed only
569 once (i.e. you don't want to prepare it) but you also don't want to
570 serialize all values into strings. Shortcut `Session#execute()` and
571 `Session#executeAsync()` methods are also provided so you that you can do:
572
573 ```java
574 String imgName = ...;
575 ByteBuffer imgBytes = ...;
576 session.execute("INSERT INTO images(name, bytes) VALUES (?, ?)", imgName, imgBytes);
577 ```
578
5793. SELECT queries are now "paged" under the hood. In other words, if a query
580 yields a very large result, only the beginning of the `ResultSet` will be fetched
581 initially, the rest being fetched "on-demand". In practice, this means that:
582
583 ```java
584 for (Row r : session.execute("SELECT * FROM mytable"))
585 ... process r ...
586 ```
587
588 should not timeout or OOM the server anymore even if "mytable" contains a lot
589 of data. In general paging should be transparent for the application (as in
590 the example above), but the implementation provides a number of knobs to
591 fine tune the behavior of that paging:
592 * the size of each "page" can be set per-query (`Statement#setFetchSize()`)
593 * the `ResultSet` object provides 2 methods to check the state of paging
594 (`ResultSet#getAvailableWithoutFetching` and `ResultSet#isFullyFetched`)
595 as well as a mean to force the pre-fetching of the next page (`ResultSet#fetchMoreResults`).