public interface DseSession extends Session
Session
with DSE-specific features.Session.State
Modifier and Type | Method and Description |
---|---|
GraphResultSet |
executeGraph(GraphStatement statement)
Executes the provided graph query.
|
GraphResultSet |
executeGraph(String query)
Executes the provided graph query.
|
GraphResultSet |
executeGraph(String query,
Map<String,Object> values)
Executes the provided graph query with the provided named parameters.
|
com.google.common.util.concurrent.ListenableFuture<GraphResultSet> |
executeGraphAsync(GraphStatement statement)
Executes the provided Graph query asynchronously.
|
com.google.common.util.concurrent.ListenableFuture<GraphResultSet> |
executeGraphAsync(String query)
Executes the provided graph query asynchronously.
|
com.google.common.util.concurrent.ListenableFuture<GraphResultSet> |
executeGraphAsync(String query,
Map<String,Object> values)
Executes the provided graph query asynchronously with the specified parameters.
|
DseCluster |
getCluster()
Returns the
DseCluster object this session is part of. |
String |
getLoggedKeyspace()
The keyspace to which this Session is currently logged in, if any.
|
DseSession |
init()
Forces the initialization of this instance if it hasn't been
initialized yet.
|
com.google.common.util.concurrent.ListenableFuture<Session> |
initAsync()
Initialize this session asynchronously.
|
close, closeAsync, execute, execute, execute, execute, executeAsync, executeAsync, executeAsync, executeAsync, getState, isClosed, prepare, prepare, prepareAsync, prepareAsync
DseCluster getCluster()
DseCluster
object this session is part of.getCluster
in interface Session
DseCluster
object this session is part of.DseSession init()
DseCluster.connect()
to create your
session, the returned object will be already initialized. Even if you create a non-initialized session through
DseCluster.newSession()
, that session will get automatically initialized the first time it is used for
querying. This method is thus only useful if you use DseCluster.newSession()
and want to explicitly force
initialization without querying.
Session initialization consists in connecting to the known Cassandra hosts (at least those that should not be
ignored due to the LoadBalancingPolicy
in place).
If the DseCluster
instance this session depends on is not itself initialized, it will be initialized by
this method.
If the session is already initialized, this method is a no-op.init
in interface Session
NoHostAvailableException
- if this initialization triggers the cluster initialization and no host amongst
the contact points can be reached.AuthenticationException
- if this initialization triggers the cluster initialization and an authentication
error occurs while contacting the initial contact points.com.google.common.util.concurrent.ListenableFuture<Session> initAsync()
Session
object returned by the future's get
method can be safely cast
to DseSession
.String getLoggedKeyspace()
Cluster.connect(String)
, or to the
last keyspace logged into through a "USE" CQL query if one was used.
The keyspace name returned by this method is only relevant for CQL queries; for graph queries, the graph to
target is determined by the graph name specified via GraphStatement.setGraphName(String)
} or
GraphOptions.setGraphName(String)
.getLoggedKeyspace
in interface Session
null
if the session is logged to no keyspace.GraphResultSet executeGraph(String query)
execute(new SimpleGraphStatement(query))
.query
- the graph query to execute.NoHostAvailableException
- if no host in the cluster can be contacted successfully to execute this query.GraphResultSet executeGraph(String query, Map<String,Object> values)
execute(new SimpleGraphStatement(query, values))
.query
- the graph query to execute.values
- the named parameters to send associated to the query. You can use Guava's
ImmutableMap
to build the map with a one-liner:
ImmutableMap.<String, Object>of("key1", value1, "key2", value2)
.NoHostAvailableException
- if no host in the cluster can be contacted successfully to execute this query.GraphResultSet executeGraph(GraphStatement statement)
statement
- the statement to execute.NoHostAvailableException
- if no host in the cluster can be
contacted successfully to execute this query.QueryExecutionException
- if the query triggered an execution
exception, i.e. an exception thrown by Cassandra when it cannot execute
the query with the requested consistency level successfully.QueryValidationException
- if the query if invalid (syntax error,
unauthorized or any other validation problem).com.google.common.util.concurrent.ListenableFuture<GraphResultSet> executeGraphAsync(String query)
ListenableFuture
.
Note that for queries that don't return a result, you will need to
access the Future's get
method to make sure the query was successful.query
- the graph query to execute.com.google.common.util.concurrent.ListenableFuture<GraphResultSet> executeGraphAsync(String query, Map<String,Object> values)
ListenableFuture
.
Note that for queries that don't return a result, you will need to
access the Future's get
method to make sure the query was successful.query
- the graph query to execute.values
- the named parameters to send associated to the query. You can use Guava's
ImmutableMap
to build the map with a one-liner:
ImmutableMap.<String, Object>of("key1", value1, "key2", value2)
.com.google.common.util.concurrent.ListenableFuture<GraphResultSet> executeGraphAsync(GraphStatement statement)
ListenableFuture
.
Note that for queries that don't return a result, you will need to
access the Future's get
method to make sure the query was successful.statement
- the statement to execute.