Elffuss BraidHub

kikocis/java-driver public

Migrate upgrade guide to generated docs.
Changeset65c9a6af0e517e12e3af6553d10feeee53a0e6e34c3f689575740d1b5209214b
Authorolim7t <omichallat+github@gmail.com> · 2015-05-28 09:14 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-05-28 10:28 +02:00
Parents4815760f4ac6

Browse the files at this changeset

3 files changed

modified docs.yaml +5 −0
@@ -14,6 +14,11 @@
1414 sources:
1515 - type: markdown
1616 files: 'changelog/**/*.md'
17+ - title: Upgrading
18+ prefix: /upgrade_guide
19+ sources:
20+ - type: markdown
21+ files: 'upgrade_guide/**/*.md'
1722 links:
1823 - title: Code
1924 href: https://github.com/datastax/java-driver/
deleted driver-core/Upgrade_guide_to_2.0.rst +0 −224
@@ -1,224 +0,0 @@
1-Upgrade Guide to 2.0
2-====================
3-
4-The purpose of this guide is to detail the changes made by version 2.0 of
5-the Java Driver.
6-
7-
8-1.0 to 2.0
9-----------
10-
11-We used the opportunity of a major version bump to incorporate your feedback
12-and improve the API, to fix a number of inconsistencies and remove cruft.
13-Unfortunately this means there are some breaking changes, but the new API should
14-be both simpler and more complete.
15-
16-The following describes the changes for 2.0 that are breaking changes of the
17-1.0 API. For ease of use, we distinguish two categories of API changes: the "main"
18-ones and the "other" ones.
19-
20-The "main" API changes are the ones that are either
21-likely to affect most upgraded apps or are incompatible changes that, even if minor,
22-will not be detected at compile time. Upgraders are highly encouraged to check
23-this list of "main" changes while upgrading their application to 2.0 (even
24-though most applications are likely to be affected by only a handful of
25-changes).
26-
27-The "other" list is, well, other changes: those that are likely to
28-affect a minor number of applications and will be detected by compile time
29-errors anyway. It is ok to skip those initially and only come back to them if
30-you have trouble compiling your application after an upgrade.
31-
32-Main API changes
33-~~~~~~~~~~~~~~~~
34-
35-1. The ``Query`` class has been renamed into ``Statement`` (it was confusing to some
36- that the ``BoundStatement`` was not a ``Statement``).
37-
38- To allow this, the old ``Statement`` class has been renamed to ``RegularStatement``.
39-
40-2. The ``Cluster`` and ``Session`` shutdown API has changed. There is now a ``closeAsync``
41- that is asynchronous but returns a ``Future`` on the completion of the shutdown
42- process.
43-
44- There is also a ``close`` shortcut that does the same but blocks.
45- Also, ``close`` now waits for ongoing queries to complete by default (but you
46- can force the closing of all connections if you want to).
47-
48-3. ``NoHostAvailableException#getErrors`` now returns the full exception objects for
49- each node instead of just a message. In other words, it returns a
50- ``Map<InetAddress, Throwable>`` instead of a ``Map<InetAddress, String>``.
51-
52-4. ``Statement#getConsistencyLevel`` (previously ``Query#getConsistencyLevel``, see
53- first point) will now return ``null`` by default (instead of ``CL.ONE``), with the
54- meaning of "use the default consistency level".
55-
56- The default consistency level can now be configured through the new ``QueryOptions``
57- object in the cluster ``Configuration``.
58-
59-5. The ``Metrics`` class now uses the Codahale metrics library version 3 (version 2 was
60- used previously). This new major version of the library has many API changes
61- compared to its version 2 (see http://metrics.codahale.com/about/release-notes/ for details),
62- which can thus impact consumers of the Metrics class.
63- Furthermore, the default JmxReporter now includes a name specific to the
64- cluster instance (to avoid conflicts when multiple Cluster instances are created
65- in the same JVM). As a result, tools that were polling JMX info will
66- have to be updated accordingly.
67-
68-6. The ``QueryBuilder#in`` method now has the following special case: using
69- ``QueryBuilder.in(QueryBuilder.bindMarker())`` will generate the string ``IN ?``,
70- not ``IN (?)`` as was the case in 1.0. The reasoning being that the former
71- syntax, made valid by https://issues.apache.org/jira/browse/CASSANDRA-4210
72- is a lot more useful than "IN (?)", as the latter can more simply use an
73- equality.
74-
75- Note that if you really want to output "IN (?)" with the query
76- builder, you can use QueryBuilder.in(QueryBuilder.raw("?")).
77-
78-7. When binding values by name in ``BoundStatement`` (i.e. using the
79- ``setX(String, X)`` methods), if more than one variable have the same name,
80- then all values corresponding to that variable
81- name are set instead of just the first occurrence.
82-
83-8. The ``QueryBuilder#raw`` method does not automatically add quotes anymore, but
84- rather output its result without any change (as the raw name implies).
85-
86- This means for instance that ``eq("x", raw(foo))`` will output ``x = foo``,
87- not ``x = 'foo'`` (you don't need the raw method to output the latter string).
88-
89-
90-9. The ``QueryBuilder`` will now sometime use the new ability to send value as
91- bytes instead of serializing everything to string. In general the QueryBuilder
92- will do the right thing, but if you were calling the ``getQueryString()`` method
93- on a Statement created with a QueryBuilder (for other reasons than to prepare a query)
94- then the returned string may contain bind markers in place of some of the values
95- provided (and in that case, ``getValues()`` will contain the values corresponding
96- to those markers). If need be, it is possible to force the old behavior by
97- using the new ``setForceNoValues()`` method.
98-
99-
100-Other API Changes
101-~~~~~~~~~~~~~~~~~
102-
103-1. Creating a Cluster instance (through Cluster#buildFrom or the
104- Cluster.Builder#build method) **does not create any connection right away
105- anymore** (and thus cannot throw a NoHostAvailableException or an
106- AuthenticationException). Instead, the initial contact points are checked
107- the first time a call to ``Cluster#connect`` is done. If for some reason you
108- want to emulate the previous behavior, you can use the new method
109- Cluster#init: Cluster.builder().build() in 1.0 is equivalent to
110- Cluster.builder().build().init() in 2.0.
111-
112-2. Methods from Metadata, KeyspaceMetadata and TableMetadata now use by default
113- case insensitive identifiers (for keyspace, table and column names in
114- parameter). You can double-quote an identifier if you want it to be a
115- case sensitive one (as you would do in CQL) and there is a Metadata.quote
116- helper method for that.
117-
118-3. The TableMetadata#getClusteringKey method has been renamed
119- TableMetadata#getClusteringColumns to match the "official" vocabulary.
120-
121-4. The UnavailableException#getConsistency method has been renamed to
122- UnavailableException#getConsistencyLevel for consistency with the method of
123- QueryTimeoutException.
124-
125-5. The RegularStatement class (ex-Statement class, see above) must now
126- implement two additional methods: RegularStatement#getKeyspace and
127- RegularStatement#getValues. If you had extended this class, you will have to
128- implement those new methods, but both can return null if they are not useful
129- in your case.
130-
131-6. The Cluster.Initializer interface should now implement 2 new methods:
132- Cluster.Initializer#getInitialListeners (which can return an empty
133- collection) and Cluster.Initializer#getClusterName (which can return null).
134-
135-7. The Metadata#getReplicas method now takes 2 arguments. On top of the
136- partition key, you must now provide the keyspace too. The previous behavior
137- was buggy: it's impossible to properly return the full list of replica for a
138- partition key without knowing the keyspace since replication may depend on
139- the keyspace).
140-
141-8. The method LoadBalancingPolicy#newQueryPlan() method now takes the currently
142- logged keyspace as 2nd argument. This information is necessary to do proper
143- token aware balancing (see preceding point).
144-
145-9. The ResultSetFuture#set and ResultSetFuture#setException methods have been
146- removed (from the public API at least). They were never meant to be exposed
147- publicly: a resultSetFuture is always set by the driver itself and should
148- not be set manually.
149-
150-10. The deprecated since 1.0.2 Host.HealthMonitor class has been removed. You
151- will now need to use Host#isUp and Cluster#register if you were using that
152- class.
153-
154-
155-2.0.10
156-------
157-
158-1. LatencyTracker#update now has a different signature and takes two new
159- parameters: the statement that has been executed (never null), and the exception
160- thrown while executing the query (or null, if the query executed successfully).
161- Existing implementations of this interface, once upgraded to the new method
162- signature, should continue to work as before.
163-
164-2. SocketOptions#getTcpNoDelay() is now TRUE by default (it was previously undefined).
165- This reflects the new behavior of Netty (which was upgraded from version 3.9.0 to
166- 4.0.27): TCP_NODELAY is now turned on by default, instead of depending on the OS
167- default like in previous versions.
168-
169-3. Netty is not shaded anymore in the default Maven artifact. However we publish a
170- shaded artifact under a different classifier. See `Using the shaded JAR<http://datastax.github.io/java-driver/features/shaded_jar/>`_
171- for more information.
172-
173-4. The internal initialization sequence of the Cluster object has been slightly changed:
174- some fields that were previously initialized in the constructor are now set when
175- the init() method is called. This is unlikely to affect regular driver users.
176-
177-
178-Features available only with Cassandra 2.0
179-------------------------------------------
180-
181-This section details the biggest additions to 2.0 API wise. It is not an
182-exhaustive list of new features in 2.0.
183-
184-1. The new ``BatchStatement`` class allows to group any type of insert Statements
185- (BoundStatement or RegularStatement) for execution as a batch. For instance,
186- you can do something like::
187-
188- List<String> values = ...;
189- PreparedStatement ps = session.prepare("INSERT INTO myTable(value) VALUES (?)");
190- BatchStatement bs = new BatchStatement();
191- for (String value : values)
192- bs.add(ps.bind(value));
193- session.execute(bs);
194-
195-2. ``SimpleStatement`` can now take a list of values in addition to the query. This
196- allows to do the equivalent of a prepare+execute but with only one round-trip
197- to the server and without keeping the prepared statement after the
198- execution.
199-
200- This is typically useful if a given query should be executed only
201- once (i.e. you don't want to prepare it) but you also don't want to
202- serialize all values into strings. Shortcut Session#execute() and
203- Session#executeAsync() methods are also provided so you that you can do::
204-
205- String imgName = ...;
206- ByteBuffer imgBytes = ...;
207- session.execute("INSERT INTO images(name, bytes) VALUES (?, ?)", imgName, imgBytes);
208-
209-3. SELECT queries are now "paged" under the hood. In other words, if a query
210- yields a very large result, only the beginning of the ResultSet will be fetch
211- initially, the rest being fetch "on-demand". In practice, this means that::
212-
213- for (Row r : session.execute("SELECT * FROM mytable"))
214- ... process r ...
215-
216- should not timeout or OOM the server anymore even if "mytable" contains a lot
217- of data. In general paging should be transparent for the application (as in
218- the example above), but the implementation provides a number of knobs to
219- fine tune the behavior of that paging:
220-
221- * the size of each "page" can be set per-query (Statement#setFetchSize())
222- * the ResultSet object provides 2 methods to check the state of paging
223- (ResultSet#getAvailableWithoutFetching and ResultSet#isFullyFetched)
224- as well as a mean to force the pre-fetching of the next page (ResultSet#fetchMoreResults).
added upgrade_guide/README.md +220 −0
@@ -0,0 +1,220 @@
1+## Upgrade guide
2+
3+The purpose of this guide is to detail changes made by successive
4+versions of the Java driver.
5+
6+### 2.0.x to 2.0.10
7+
8+We try to avoid breaking changes within a branch (2.0.x to 2.0.y), but
9+2.0.10 saw a lot of new features and internal improvements. There is one
10+breaking change:
11+
12+1. `LatencyTracker#update` now has a different signature and takes two new
13+ parameters: the statement that has been executed (never null), and the exception
14+ thrown while executing the query (or null, if the query executed successfully).
15+ Existing implementations of this interface, once upgraded to the new method
16+ signature, should continue to work as before.
17+
18+The following might also be of interest:
19+
20+2. `SocketOptions#getTcpNoDelay()` is now TRUE by default (it was previously undefined).
21+ This reflects the new behavior of Netty (which was upgraded from version 3.9.0 to
22+ 4.0.27): `TCP_NODELAY` is now turned on by default, instead of depending on the OS
23+ default like in previous versions.
24+
25+3. Netty is not shaded anymore in the default Maven artifact. However we publish a
26+ [shaded artifact](../features/shaded_jar/) under a different classifier.
27+
28+4. The internal initialization sequence of the Cluster object has been slightly changed:
29+ some fields that were previously initialized in the constructor are now set when
30+ the `init()` method is called. This is unlikely to affect regular driver users.
31+
32+### 1.0 to 2.0
33+
34+We used the opportunity of a major version bump to incorporate your feedback
35+and improve the API, to fix a number of inconsistencies and remove cruft.
36+Unfortunately this means there are some breaking changes, but the new API should
37+be both simpler and more complete.
38+
39+The following describes the changes for 2.0 that are breaking changes of the
40+1.0 API. For ease of use, we distinguish two categories of API changes: the "main"
41+ones and the "other" ones.
42+
43+The "main" API changes are the ones that are either
44+likely to affect most upgraded apps or are incompatible changes that, even if minor,
45+will not be detected at compile time. Upgraders are highly encouraged to check
46+this list of "main" changes while upgrading their application to 2.0 (even
47+though most applications are likely to be affected by only a handful of
48+changes).
49+
50+The "other" list is, well, other changes: those that are likely to
51+affect a minor number of applications and will be detected by compile time
52+errors anyway. It is ok to skip those initially and only come back to them if
53+you have trouble compiling your application after an upgrade.
54+
55+#### Main API changes
56+
57+1. The `Query` class has been renamed into `Statement` (it was confusing
58+ to some that the `BoundStatement` was not a `Statement`). To allow
59+ this, the old `Statement` class has been renamed to `RegularStatement`.
60+
61+2. The `Cluster` and `Session` shutdown API has changed. There is now a
62+ `closeAsync` that is asynchronous but returns a `Future` on the
63+ completion of the shutdown process. There is also a `close` shortcut
64+ that does the same but blocks. Also, `close` now waits for ongoing
65+ queries to complete by default (but you can force the closing of all
66+ connections if you want to).
67+
68+3. `NoHostAvailableException#getErrors` now returns the full exception objects for
69+ each node instead of just a message. In other words, it returns a
70+ `Map<InetAddress, Throwable>` instead of a `Map<InetAddress, String>`.
71+
72+4. `Statement#getConsistencyLevel` (previously `Query#getConsistencyLevel`, see
73+ first point) will now return `null` by default (instead of `CL.ONE`), with the
74+ meaning of "use the default consistency level".
75+ The default consistency level can now be configured through the new `QueryOptions`
76+ object in the cluster `Configuration`.
77+
78+5. The `Metrics` class now uses the Codahale metrics library version 3 (version 2 was
79+ used previously). This new major version of the library has many API changes
80+ compared to its version 2 (see the [release notes](https://dropwizard.github.io/metrics/3.1.0/about/release-notes/) for details),
81+ which can thus impact consumers of the Metrics class.
82+ Furthermore, the default `JmxReporter` now includes a name specific to the
83+ cluster instance (to avoid conflicts when multiple Cluster instances are created
84+ in the same JVM). As a result, tools that were polling JMX info will
85+ have to be updated accordingly.
86+
87+6. The `QueryBuilder#in` method now has the following special case: using
88+ `QueryBuilder.in(QueryBuilder.bindMarker())` will generate the string `IN ?`,
89+ not `IN (?)` as was the case in 1.0. The reasoning being that the former
90+ syntax, made valid by [CASSANDRA-4210](https://issues.apache.org/jira/browse/CASSANDRA-4210)
91+ is a lot more useful than `IN (?)`, as the latter can more simply use an
92+ equality.
93+ Note that if you really want to output `IN (?)` with the query
94+ builder, you can use `QueryBuilder.in(QueryBuilder.raw("?"))`.
95+
96+7. When binding values by name in `BoundStatement` (i.e. using the
97+ `setX(String, X)` methods), if more than one variable have the same name,
98+ then all values corresponding to that variable
99+ name are set instead of just the first occurrence.
100+
101+8. The `QueryBuilder#raw` method does not automatically add quotes anymore, but
102+ rather output its result without any change (as the raw name implies).
103+ This means for instance that `eq("x", raw(foo))` will output `x = foo`,
104+ not `x = 'foo'` (you don't need the raw method to output the latter string).
105+
106+
107+9. The `QueryBuilder` will now sometimes use the new ability to send value as
108+ bytes instead of serializing everything to string. In general the QueryBuilder
109+ will do the right thing, but if you were calling the `getQueryString()` method
110+ on a Statement created with a QueryBuilder (for other reasons than to prepare a query)
111+ then the returned string may contain bind markers in place of some of the values
112+ provided (and in that case, `getValues()` will contain the values corresponding
113+ to those markers). If need be, it is possible to force the old behavior by
114+ using the new `setForceNoValues()` method.
115+
116+#### Other API Changes
117+
118+1. Creating a Cluster instance (through `Cluster#buildFrom` or the
119+ `Cluster.Builder#build` method) **does not create any connection right away
120+ anymore** (and thus cannot throw a `NoHostAvailableException` or an
121+ `AuthenticationException`). Instead, the initial contact points are checked
122+ the first time a call to `Cluster#connect` is done. If for some reason you
123+ want to emulate the previous behavior, you can use the new method
124+ `Cluster#init`: `Cluster.builder().build()` in 1.0 is equivalent to
125+ `Cluster.builder().build().init()` in 2.0.
126+
127+2. Methods from `Metadata`, `KeyspaceMetadata` and `TableMetadata` now use by default
128+ case insensitive identifiers (for keyspace, table and column names in
129+ parameter). You can double-quote an identifier if you want it to be a
130+ case sensitive one (as you would do in CQL) and there is a `Metadata.quote`
131+ helper method for that.
132+
133+3. The `TableMetadata#getClusteringKey` method has been renamed
134+ `TableMetadata#getClusteringColumns` to match the "official" vocabulary.
135+
136+4. The `UnavailableException#getConsistency` method has been renamed to
137+ `UnavailableException#getConsistencyLevel` for consistency with the method of
138+ `QueryTimeoutException`.
139+
140+5. The `RegularStatement` class (ex-`Statement` class, see above) must now
141+ implement two additional methods: `RegularStatement#getKeyspace` and
142+ `RegularStatement#getValues`. If you had extended this class, you will have to
143+ implement those new methods, but both can return null if they are not useful
144+ in your case.
145+
146+6. The `Cluster.Initializer` interface should now implement 2 new methods:
147+ `Cluster.Initializer#getInitialListeners` (which can return an empty
148+ collection) and `Cluster.Initializer#getClusterName` (which can return null).
149+
150+7. The `Metadata#getReplicas` method now takes 2 arguments. On top of the
151+ partition key, you must now provide the keyspace too. The previous behavior
152+ was buggy: it's impossible to properly return the full list of replica for a
153+ partition key without knowing the keyspace since replication may depend on
154+ the keyspace).
155+
156+8. The method `LoadBalancingPolicy#newQueryPlan()` method now takes the currently
157+ logged keyspace as 2nd argument. This information is necessary to do proper
158+ token aware balancing (see preceding point).
159+
160+9. The `ResultSetFuture#set` and `ResultSetFuture#setException` methods have been
161+ removed (from the public API at least). They were never meant to be exposed
162+ publicly: a `resultSetFuture` is always set by the driver itself and should
163+ not be set manually.
164+
165+10. The deprecated since 1.0.2 `Host.HealthMonitor` class has been removed. You
166+ will now need to use `Host#isUp` and `Cluster#register` if you were using that
167+ class.
168+
169+#### Features available only with Cassandra 2.0
170+
171+This section details the biggest additions to 2.0 API wise. It is not an
172+exhaustive list of new features in 2.0.
173+
174+1. The new `BatchStatement` class allows to group any type of insert Statements
175+ (`BoundStatement` or `RegularStatement`) for execution as a batch. For instance,
176+ you can do something like:
177+
178+ ```java
179+ List<String> values = ...;
180+ PreparedStatement ps = session.prepare("INSERT INTO myTable(value) VALUES (?)");
181+ BatchStatement bs = new BatchStatement();
182+ for (String value : values)
183+ bs.add(ps.bind(value));
184+ session.execute(bs);
185+ ```
186+
187+2. `SimpleStatement` can now take a list of values in addition to the query. This
188+ allows to do the equivalent of a prepare+execute but with only one round-trip
189+ to the server and without keeping the prepared statement after the
190+ execution.
191+
192+ This is typically useful if a given query should be executed only
193+ once (i.e. you don't want to prepare it) but you also don't want to
194+ serialize all values into strings. Shortcut `Session#execute()` and
195+ `Session#executeAsync()` methods are also provided so you that you can do:
196+
197+ ```java
198+ String imgName = ...;
199+ ByteBuffer imgBytes = ...;
200+ session.execute("INSERT INTO images(name, bytes) VALUES (?, ?)", imgName, imgBytes);
201+ ```
202+
203+3. SELECT queries are now "paged" under the hood. In other words, if a query
204+ yields a very large result, only the beginning of the `ResultSet` will be fetch
205+ initially, the rest being fetch "on-demand". In practice, this means that:
206+
207+ ```java
208+ for (Row r : session.execute("SELECT * FROM mytable"))
209+ ... process r ...
210+ ```
211+
212+ should not timeout or OOM the server anymore even if "mytable" contains a lot
213+ of data. In general paging should be transparent for the application (as in
214+ the example above), but the implementation provides a number of knobs to
215+ fine tune the behavior of that paging:
216+
217+ * the size of each "page" can be set per-query (`Statement#setFetchSize()`)
218+ * the `ResultSet` object provides 2 methods to check the state of paging
219+ (`ResultSet#getAvailableWithoutFetching` and `ResultSet#isFullyFetched`)
220+ as well as a mean to force the pre-fetching of the next page (`ResultSet#fetchMoreResults`).