Skip to content

Commit d2542a2

Browse files
committed
Merge AsyncInitSession into Session.
1 parent 2a17731 commit d2542a2

5 files changed

Lines changed: 41 additions & 64 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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}

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public ListenableFuture<Session> connectAsync() {
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 @@ InetSocketAddress translateAddress(InetAddress address) {
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;

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

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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 @@ public interface Session extends Closeable {
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,21 +429,21 @@ public interface Session extends Closeable {
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.
427436
* <p>
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 @@ public interface State {
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 @@ public interface State {
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 @@ public interface State {
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 @@ public interface State {
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
}

upgrade_guide/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ We've also seized the opportunity to remove code that was deprecated in 2.1.
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

0 commit comments

Comments
 (0)