Elffuss BraidHub

kikocis/java-driver public

Merge AsyncInitSession into Session.
Changesetb75301e0042a5cda6e0e3a0d75e625ed5a803244e09542b45c3b77671adecd15
Authorolim7t <omichallat+github@gmail.com> · 2015-10-07 14:51 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-10-07 14:58 +02:00
Parentsff3956c82b44

Browse the files at this changeset

5 files changed

modified driver-core/src/main/java/com/datastax/driver/core/AbstractSession.java +1 −1
@@ -29,7 +29,7 @@
2929 *
3030 * This is primarly intended to make mocking easier.
3131 */
32-public abstract class AbstractSession implements Session, AsyncInitSession {
32+public abstract class AbstractSession implements Session {
3333
3434 /**
3535 * {@inheritDoc}
deleted driver-core/src/main/java/com/datastax/driver/core/AsyncInitSession.java +0 −36
@@ -1,36 +0,0 @@
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-}
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +2 −2
@@ -336,7 +336,7 @@
336336 public ListenableFuture<Session> connectAsync(String keyspace) {
337337 checkNotClosed(manager);
338338 init();
339- AsyncInitSession session = manager.newSession(keyspace);
339+ Session session = manager.newSession(keyspace);
340340 return session.initAsync();
341341 }
342342
@@ -1499,7 +1499,7 @@
14991499 return translated == null ? sa : translated;
15001500 }
15011501
1502- private AsyncInitSession newSession(String keyspace) {
1502+ private Session newSession(String keyspace) {
15031503 SessionManager session = new SessionManager(Cluster.this, keyspace);
15041504 sessions.add(session);
15051505 return session;
modified driver-core/src/main/java/com/datastax/driver/core/Session.java +34 −25
@@ -49,7 +49,7 @@
4949 * @return the name of the keyspace to which this Session is currently
5050 * logged in, or {@code null} if the session is logged to no keyspace.
5151 */
52- public String getLoggedKeyspace();
52+ String getLoggedKeyspace();
5353
5454 /**
5555 * Force the initialization of this Session instance if it hasn't been
@@ -82,7 +82,16 @@
8282 * Cluster initialization and an authentication error occurs while contacting
8383 * the initial contact points.
8484 */
85- public Session init();
85+ Session init();
86+
87+ /**
88+ * Initialize this session asynchronously.
89+ *
90+ * @return a future that will complete when the session is fully initialized.
91+ *
92+ * @see #init()
93+ */
94+ ListenableFuture<Session> initAsync();
8695
8796 /**
8897 * Executes the provided query.
@@ -101,7 +110,7 @@
101110 * @throws QueryValidationException if the query if invalid (syntax error,
102111 * unauthorized or any other validation problem).
103112 */
104- public ResultSet execute(String query);
113+ ResultSet execute(String query);
105114
106115 /**
107116 * Executes the provided query using the provided value.
@@ -125,7 +134,7 @@
125134 * is in use (i.e. if you've force version 1 through {@link Cluster.Builder#withProtocolVersion}
126135 * or you use Cassandra 1.2).
127136 */
128- public ResultSet execute(String query, Object... values);
137+ ResultSet execute(String query, Object... values);
129138
130139 /**
131140 * Executes the provided query.
@@ -153,7 +162,7 @@
153162 * the version protocol 1 include: BatchStatement, ResultSet paging and binary
154163 * values in RegularStatement.
155164 */
156- public ResultSet execute(Statement statement);
165+ ResultSet execute(Statement statement);
157166
158167 /**
159168 * Executes the provided query asynchronously.
@@ -163,7 +172,7 @@
163172 * @param query the CQL query to execute.
164173 * @return a future on the result of the query.
165174 */
166- public ResultSetFuture executeAsync(String query);
175+ ResultSetFuture executeAsync(String query);
167176
168177 /**
169178 * Executes the provided query asynchronously using the provided values.
@@ -179,7 +188,7 @@
179188 * is in use (i.e. if you've force version 1 through {@link Cluster.Builder#withProtocolVersion}
180189 * or you use Cassandra 1.2).
181190 */
182- public ResultSetFuture executeAsync(String query, Object... values);
191+ ResultSetFuture executeAsync(String query, Object... values);
183192
184193 /**
185194 * Builds, but does not execute, a simple statement containing the provided query.
@@ -191,7 +200,7 @@
191200 * @param query the CQL query to execute.
192201 * @return the simple statement.
193202 */
194- public SimpleStatement newSimpleStatement(String query);
203+ SimpleStatement newSimpleStatement(String query);
195204
196205 /**
197206 * Builds, but does not execute, a simple statement containing the provided query with
@@ -241,7 +250,7 @@
241250 * @param values values required for the execution of {@code query}.
242251 * @return the simple statement.
243252 */
244- public SimpleStatement newSimpleStatement(String query, Object... values);
253+ SimpleStatement newSimpleStatement(String query, Object... values);
245254
246255 /**
247256 * Executes the provided query asynchronously.
@@ -264,7 +273,7 @@
264273 * the version protocol 1 include: BatchStatement, ResultSet paging and binary
265274 * values in RegularStatement.
266275 */
267- public ResultSetFuture executeAsync(Statement statement);
276+ ResultSetFuture executeAsync(Statement statement);
268277
269278 /**
270279 * Prepares the provided query string.
@@ -275,7 +284,7 @@
275284 * @throws NoHostAvailableException if no host in the cluster can be
276285 * contacted successfully to prepare this query.
277286 */
278- public PreparedStatement prepare(String query);
287+ PreparedStatement prepare(String query);
279288
280289 /**
281290 * Prepares the provided query.
@@ -305,7 +314,7 @@
305314 * though the {@link PreparedStatement#bind} method or through a corresponding
306315 * {@link BoundStatement}).
307316 */
308- public PreparedStatement prepare(RegularStatement statement);
317+ PreparedStatement prepare(RegularStatement statement);
309318
310319 /**
311320 * Prepares the provided query string asynchronously.
@@ -317,7 +326,7 @@
317326 * @param query the CQL query string to prepare
318327 * @return a future on the prepared statement corresponding to {@code query}.
319328 */
320- public ListenableFuture<PreparedStatement> prepareAsync(String query);
329+ ListenableFuture<PreparedStatement> prepareAsync(String query);
321330
322331 /**
323332 * Prepares the provided query asynchronously.
@@ -346,7 +355,7 @@
346355 * though the {@link PreparedStatement#bind} method or through a corresponding
347356 * {@link BoundStatement}).
348357 */
349- public ListenableFuture<PreparedStatement> prepareAsync(RegularStatement statement);
358+ ListenableFuture<PreparedStatement> prepareAsync(RegularStatement statement);
350359
351360 /**
352361 * Initiates a shutdown of this session instance.
@@ -372,7 +381,7 @@
372381 *
373382 * @return a future on the completion of the shutdown process.
374383 */
375- public CloseFuture closeAsync();
384+ CloseFuture closeAsync();
376385
377386 /**
378387 * Initiates a shutdown of this session instance and blocks until
@@ -387,7 +396,7 @@
387396 * If you want to do so, use {@link Cluster#close}, but note that it will
388397 * close all sessions created from that cluster.
389398 */
390- public void close();
399+ void close();
391400
392401 /**
393402 * Whether this Session instance has been closed.
@@ -401,14 +410,14 @@
401410 * @return {@code true} if this Session instance has been closed, {@code false}
402411 * otherwise.
403412 */
404- public boolean isClosed();
413+ boolean isClosed();
405414
406415 /**
407416 * Returns the {@code Cluster} object this session is part of.
408417 *
409418 * @return the {@code Cluster} object this session is part of.
410419 */
411- public Cluster getCluster();
420+ Cluster getCluster();
412421
413422 /**
414423 * Return a snapshot of the state of this Session.
@@ -420,7 +429,7 @@
420429 *
421430 * @return a snapshot of the state of this Session.
422431 */
423- public State getState();
432+ State getState();
424433
425434 /**
426435 * The state of a Session.
@@ -428,13 +437,13 @@
428437 * This mostly exposes information on the connections maintained by a Session:
429438 * which host it is connected to, how many connection is has for each host, etc...
430439 */
431- public interface State {
440+ interface State {
432441 /**
433442 * The Session to which this State corresponds to.
434443 *
435444 * @return the Session to which this State corresponds to.
436445 */
437- public Session getSession();
446+ Session getSession();
438447
439448 /**
440449 * The hosts to which the session is currently connected (more precisely, at the time
@@ -447,7 +456,7 @@
447456 *
448457 * @return an immutable collection of the hosts to which the session is connected.
449458 */
450- public Collection<Host> getConnectedHosts();
459+ Collection<Host> getConnectedHosts();
451460
452461 /**
453462 * The number of open connections to a given host.
@@ -459,7 +468,7 @@
459468 * @return The number of open connections to {@code host}. If the session
460469 * is not connected to that host, 0 is returned.
461470 */
462- public int getOpenConnections(Host host);
471+ int getOpenConnections(Host host);
463472
464473 /**
465474 * The number of "trashed" connections to a given host.
@@ -473,7 +482,7 @@
473482 * @return The number of trashed connections to {@code host}. If the session
474483 * is not connected to that host, 0 is returned.
475484 */
476- public int getTrashedConnections(Host host);
485+ int getTrashedConnections(Host host);
477486
478487 /**
479488 * The number of queries that are currently being executed though a given host.
@@ -487,6 +496,6 @@
487496 * @return the number of currently (as in 'at the time the state was grabbed') executing
488497 * queries to {@code host}.
489498 */
490- public int getInFlightQueries(Host host);
499+ int getInFlightQueries(Host host);
491500 }
492501 }
modified upgrade_guide/README.md +4 −0
@@ -197,6 +197,10 @@
197197 they match the schema, in anticipation for the schema generation features
198198 that will be added in a future version.
199199
200+18. `AsyncInitSession` has been removed, `initAsync()` is now part of the
201+ `Session` interface (the only purpose of the extra interface was to preserve
202+ binary compatibility on the 2.1 branch).
203+
200204
201205 ### 2.1.7
202206