public class DefaultBridgedReactiveSession extends Object implements ReactiveSession
ReactiveSession. This implementation bridges asynchronous CqlSession
methods to reactive execution patterns.
Calls are deferred until a subscriber subscribes to the resulting Publisher. The calls
are executed by subscribing to CompletionStage and returning the result as calls complete.
Elements are emitted on netty EventLoop threads. AsyncResultSet allows AsyncPagingIterable.fetchNextPage()
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.oss.driver.api.core.CqlSession session)
Create a new
DefaultBridgedReactiveSession for a CqlSession. |
| 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.oss.driver.api.core.cql.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.oss.driver.api.core.context.DriverContext |
getContext()
Returns a context that provides access to all the policies used by this driver instance.
|
boolean |
isClosed()
Whether this Session instance has been closed.
|
reactor.core.publisher.Mono<com.datastax.oss.driver.api.core.cql.PreparedStatement> |
prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement statement)
Prepares the provided query.
|
reactor.core.publisher.Mono<com.datastax.oss.driver.api.core.cql.PreparedStatement> |
prepare(String query)
Prepares the provided query string.
|
public DefaultBridgedReactiveSession(com.datastax.oss.driver.api.core.CqlSession session)
DefaultBridgedReactiveSession for a CqlSession.session - 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.oss.driver.api.core.context.DriverContext getContext()
ReactiveSessiongetContext in interface ReactiveSessionpublic 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.newInstance(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.newInstance(String, Map) for more details.public reactor.core.publisher.Mono<ReactiveResultSet> execute(com.datastax.oss.driver.api.core.cql.Statement<?> statement)
ReactiveSessionexecute in interface ReactiveSessionstatement - the CQL query to execute (that can be any Statement).public reactor.core.publisher.Mono<com.datastax.oss.driver.api.core.cql.PreparedStatement> prepare(String query)
ReactiveSessionprepare in interface ReactiveSessionquery - the CQL query string to preparequery.public reactor.core.publisher.Mono<com.datastax.oss.driver.api.core.cql.PreparedStatement> prepare(com.datastax.oss.driver.api.core.cql.SimpleStatement 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:
Statement toPrepare = SimpleStatement.newInstance("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()
ReactiveSessionclose in interface Closeableclose in interface AutoCloseableclose in interface ReactiveSessionCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.