public abstract class Client extends Object
Client
is constructed from a Cluster
and represents a way to send messages to Gremlin Server.
This class itself is a base class as there are different implementations that provide differing kinds of
functionality. See the implementations for specifics on their individual usage.
The Client
is designed to be re-used and shared across threads.Modifier and Type | Class and Description |
---|---|
static class |
Client.ClusteredClient
A
Client implementation that does not operate in a session. |
static class |
Client.SessionedClient
A
Client implementation that operates in the context of a session. |
Modifier and Type | Field and Description |
---|---|
protected Cluster |
cluster |
protected boolean |
initialized |
Modifier and Type | Method and Description |
---|---|
org.apache.tinkerpop.gremlin.driver.message.RequestMessage |
buildMessage(org.apache.tinkerpop.gremlin.driver.message.RequestMessage.Builder builder)
Makes any final changes to the builder and returns the constructed
RequestMessage . |
protected abstract org.apache.tinkerpop.gremlin.driver.Connection |
chooseConnection(org.apache.tinkerpop.gremlin.driver.message.RequestMessage msg)
Chooses a
Connection to write the message to. |
void |
close()
Closes the client by making a synchronous call to
closeAsync() . |
abstract CompletableFuture<Void> |
closeAsync()
Asynchronous close of the
Client . |
Client |
init()
Initializes the client which typically means that a connection is established to the server.
|
protected abstract void |
initializeImplementation()
Called in the
init() method. |
ResultSet |
submit(String gremlin)
Submits a Gremlin script to the server and returns a
ResultSet once the write of the request is
complete. |
ResultSet |
submit(String gremlin,
Map<String,Object> parameters)
Submits a Gremlin script and bound parameters to the server and returns a
ResultSet once the write of
the request is complete. |
CompletableFuture<ResultSet> |
submitAsync(org.apache.tinkerpop.gremlin.driver.message.RequestMessage msg)
A low-level method that allows the submission of a manually constructed
RequestMessage . |
CompletableFuture<ResultSet> |
submitAsync(String gremlin)
The asynchronous version of
submit(String) where the returned future will complete when the
write of the request completes. |
CompletableFuture<ResultSet> |
submitAsync(String gremlin,
Map<String,Object> parameters)
The asynchronous version of
submit(String, Map) } where the returned future will complete when the
write of the request completes. |
protected final Cluster cluster
protected volatile boolean initialized
public org.apache.tinkerpop.gremlin.driver.message.RequestMessage buildMessage(org.apache.tinkerpop.gremlin.driver.message.RequestMessage.Builder builder)
RequestMessage
. Implementers
may choose to override this message to append data to the request before sending. By default, this method
will simply call the RequestMessage.Builder.create()
and return
the RequestMessage
.protected abstract void initializeImplementation()
init()
method.protected abstract org.apache.tinkerpop.gremlin.driver.Connection chooseConnection(org.apache.tinkerpop.gremlin.driver.message.RequestMessage msg) throws TimeoutException, org.apache.tinkerpop.gremlin.driver.exception.ConnectionException
Connection
to write the message to.TimeoutException
org.apache.tinkerpop.gremlin.driver.exception.ConnectionException
public abstract CompletableFuture<Void> closeAsync()
Client
.public Client init()
public ResultSet submit(String gremlin)
ResultSet
once the write of the request is
complete.public ResultSet submit(String gremlin, Map<String,Object> parameters)
ResultSet
once the write of
the request is complete. If a script is to be executed repeatedly with slightly different arguments, prefer
this method to concatenating a Gremlin script from dynamically produced strings and sending it to
submit(String)
. Parameterized scripts will perform better.public CompletableFuture<ResultSet> submitAsync(String gremlin)
submit(String)
where the returned future will complete when the
write of the request completes.public CompletableFuture<ResultSet> submitAsync(String gremlin, Map<String,Object> parameters)
submit(String, Map)
} where the returned future will complete when the
write of the request completes.public CompletableFuture<ResultSet> submitAsync(org.apache.tinkerpop.gremlin.driver.message.RequestMessage msg)
RequestMessage
.public void close()
closeAsync()
.Copyright © 2013–2015 Apache Software Foundation. All rights reserved.