public class DefaultBridgedReactiveSession extends Object implements ReactiveSession
ReactiveSession. This implementation bridges asynchronous Session methods
to reactive execution patterns.
Calls are deferred until a subscriber subscribes to the resulting Publisher. The calls
are executed by subscribing to ListenableFuture and returning the result as calls complete.
Elements are emitted on netty EventLoop threads. ResultSet allows asynchronous requesting of subsequent pages. The next page is requested after emitting all elements of the previous
page. However, this is an intermediate solution until Datastax can provide a fully reactive driver.
All CQL operations performed by this class are logged at debug level, using
org.springframework.data.cassandra.core.cql.DefaultBridgedReactiveSession as log category.
Mono,
ReactiveResultSet,
Scheduler,
ReactiveSession| Constructor and Description |
|---|
DefaultBridgedReactiveSession(com.datastax.driver.core.Session session)
Create a new
DefaultBridgedReactiveSession for a Session. |
DefaultBridgedReactiveSession(com.datastax.driver.core.Session session,
reactor.core.scheduler.Scheduler scheduler)
Deprecated.
since 2.1. Use
DefaultBridgedReactiveSession(Session) as a Scheduler is no longer
required to off-load ResultSet's blocking behavior. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Initiates a shutdown of this session instance and blocks until that shutdown completes.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
execute(com.datastax.driver.core.Statement statement)
Executes the provided query.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
execute(String query)
Executes the provided query.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
execute(String query,
Map<String,Object> values)
Executes the provided query using the provided named values.
|
reactor.core.publisher.Mono<ReactiveResultSet> |
execute(String query,
Object... values)
Executes the provided query using the provided values.
|
com.datastax.driver.core.Cluster |
getCluster()
Returns the
Cluster object this session is part of. |
boolean |
isClosed()
Whether this Session instance has been closed.
|
reactor.core.publisher.Mono<com.datastax.driver.core.PreparedStatement> |
prepare(com.datastax.driver.core.RegularStatement statement)
Prepares the provided query.
|
reactor.core.publisher.Mono<com.datastax.driver.core.PreparedStatement> |
prepare(String query)
Prepares the provided query string.
|
public DefaultBridgedReactiveSession(com.datastax.driver.core.Session session)
DefaultBridgedReactiveSession for a Session.session - must not be null.@Deprecated public DefaultBridgedReactiveSession(com.datastax.driver.core.Session session, reactor.core.scheduler.Scheduler scheduler)
DefaultBridgedReactiveSession(Session) as a Scheduler is no longer
required to off-load ResultSet's blocking behavior.session - must not be null.scheduler - must not be null.public boolean isClosed()
ReactiveSessionclose() and wait
until it returns (or call the get method on closeAsync() with a very short timeout and check this doesn't
timeout).isClosed in interface ReactiveSessiontrue if this Session instance has been closed, false otherwise.public com.datastax.driver.core.Cluster getCluster()
ReactiveSessionCluster object this session is part of.getCluster in interface ReactiveSessionCluster object this session is part of.public reactor.core.publisher.Mono<ReactiveResultSet> execute(String query)
ReactiveSessionexecute(new SimpleStatement(query)).execute in interface ReactiveSessionquery - the CQL query to execute.public reactor.core.publisher.Mono<ReactiveResultSet> execute(String query, Object... values)
ReactiveSessionexecute(new SimpleStatement(query, values)).execute in interface ReactiveSessionquery - the CQL query to execute.values - values required for the execution of query. See
SimpleStatement#SimpleStatement(String, Object...) for more details.public reactor.core.publisher.Mono<ReactiveResultSet> execute(String query, Map<String,Object> values)
ReactiveSessionexecute(new SimpleStatement(query, values)).execute in interface ReactiveSessionquery - the CQL query to execute.values - values required for the execution of query. See
SimpleStatement#SimpleStatement(String, Map) for more details.public reactor.core.publisher.Mono<ReactiveResultSet> execute(com.datastax.driver.core.Statement statement)
ReactiveSessionexecute in interface ReactiveSessionstatement - the CQL query to execute (that can be any Statement).public reactor.core.publisher.Mono<com.datastax.driver.core.PreparedStatement> prepare(String query)
ReactiveSessionprepare in interface ReactiveSessionquery - the CQL query string to preparequery.public reactor.core.publisher.Mono<com.datastax.driver.core.PreparedStatement> prepare(com.datastax.driver.core.RegularStatement statement)
ReactiveSessionReactiveSession.prepare(String), but note that the resulting PreparedStatement will
inherit the query properties set on statement. Concretely, this means that in the following code:
RegularStatement toPrepare = new SimpleStatement("SELECT * FROM test WHERE k=?")
.setConsistencyLevel(ConsistencyLevel.QUORUM);
PreparedStatement prepared = session.prepare(toPrepare);
session.execute(prepared.bind("someValue"));
the final execution will be performed with Quorum consistency.
Please note that if the same CQL statement is prepared more than once, all calls to this method will return the
same PreparedStatement object but the method will still apply the properties of the prepared
Statement to this object.prepare in interface ReactiveSessionstatement - the statement to preparestatement.public void close()
ReactiveSessioncloseAsync().get().
Note that this method does not close the corresponding Cluster instance (which holds additional resources,
in particular internal executors that must be shut down in order for the client program to terminate). If you want
to do so, use Cluster.close(), but note that it will close all sessions created from that cluster.close in interface Closeableclose in interface AutoCloseableclose in interface ReactiveSessionCopyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.