Elffuss BraidHub

kikocis/java-driver public

dd1b91eb9438 · 4.7 KiBRawPermalink
1Upgrade Guide to 2.1
2====================
3
4The purpose of this guide is to detail the changes made by version 2.1 of
5the Java Driver.
6
72.1.0
8-----
9
10User API Changes
11~~~~~~~~~~~~~~~~
12
131. The ``getCaching`` method of ``TableMetadata#Options`` now returns a
14 ``Map`` to account for changes to Cassandra 2.1. Also, the
15 ``getIndexInterval`` method now returns an ``Integer`` instead of an ``int``
16 which will be ``null`` when connected to Cassandra 2.1 nodes.
17
182. ``BoundStatement`` variables that have not been set explicitly will no
19 longer default to ``null``. Instead, all variables must be bound explicitly,
20 otherwise the execution of the statement will fail (this also applies to
21 statements inside of a ``BatchStatement``). For variables that map to a
22 primitive Java type, a new ``setToNull`` method has been added.
23 We made this change because the driver might soon distinguish between unset
24 and null variables, so we don't want clients relying on the "leave unset to
25 set to ``null``" behavior.
26
27
28Internal API Changes
29~~~~~~~~~~~~~~~~~~~~
30
31The changes listed in this section should normally not impact end users of the
32driver, but rather third-party frameworks and tools.
33
341. The ``serialize`` and ``deserialize`` methods in ``DataType`` now take an
35 additional parameter: the protocol version. As explained in the javadoc,
36 if unsure, the proper value to use for this parameter is the protocol version
37 in use by the driver, i.e. the value returned by
38 ``cluster.getConfiguration().getProtocolOptions().getProtocolVersion()``.
39
402. The ``parse`` method in ``DataType`` now returns a Java object, not a
41 ``ByteBuffer``. The previous behavior can be obtained by calling the
42 ``serialize`` method on the returned object.
43
443. The ``getValues`` method of ``RegularStatement`` now takes the protocol
45 version as a parameter. As above, the proper value if unsure is almost surely
46 the protocol version in use
47 (``cluster.getConfiguration().getProtocolOptions().getProtocolVersion()``).
48
49
502.1.1
51-----
52
53Internal API Changes
54~~~~~~~~~~~~~~~~~~~~
55
561. The ``ResultSet`` interface has a new ``wasApplied()`` method. This will
57 only affect clients that provide their own implementation of this interface.
58
59
602.1.2
61-----
62
632.1.2 brings important internal changes with native protocol v3 support, but
64the impact on the public API has been kept as low as possible.
65
66User API Changes
67~~~~~~~~~~~~~~~~
68
691. The native protocol version is now modelled as an enum: ``ProtocolVersion``.
70 Most public methods that take it as an argument have a backward-compatible
71 version that takes an ``int`` (the exception being ``RegularStatement``,
72 described below). For new code, prefer the enum version.
73
74Internal API Changes
75~~~~~~~~~~~~~~~~~~~~
76
771. ``RegularStatement.getValues`` now takes the protocol version as a
78 ``ProtocolVersion`` instead of an ``int``. This is transparent for callers
79 since there is a backward-compatible alternative, but if you happened to
80 extend the class you'll need to update your implementation.
81
822. ``BatchStatement.setSerialConsistencyLevel`` now returns ``BatchStatement``
83 instead of ``Statement``. Again, this only matters if you extended this
84 class (if so, it might be a good idea to also have a covariant return in
85 your child class).
86
873. The constructor of ``UnsupportedFeatureException`` now takes a
88 ``ProtocolVersion`` as a parameter. This should impact few users, as there's
89 hardly any reason to build instances of that class from client code.
90
91New features
92~~~~~~~~~~~~
93
94These features are only active when the native protocol v3 is in use.
95
961. The driver now uses a single connection per host (as opposed to a pool in
97 2.1.1). Most options in ``PoolingOptions`` are ignored, except for a new one
98 called ``maxSimultaneousRequestsPerHostThreshold``. See the class's Javadocs
99 for detailed explanations.
100
1012. You can now provide a default timestamp with each query (but it will be
102 ignored if the CQL query string already contains a ``USING TIMESTAMP``
103 clause). This can be done on a per-statement basis with
104 ``Statement.setDefaultTimestamp``, or automatically with a
105 ``TimestampGenerator`` specified with
106 ``Cluster.Builder.withTimestampGenerator`` (two implementations are
107 provided: ``ThreadLocalMonotonicTimestampGenerator`` and
108 ``AtomicMonotonicTimestampGenerator``). If you specify both, the statement's
109 timestamp takes precedence over the generator. By default, the driver has
110 the same behavior as 2.1.1 (no generator, timestamps are assigned by
111 Cassandra unless ``USING TIMESTAMP`` was specified).
112
1133. ``BatchStatement.setSerialConsistencyLevel`` no longer throws an exception,
114 it will honor the serial consistency level for the batch.