Class Client
java.lang.Object
org.apache.tinkerpop.gremlin.driver.Client
- All Implemented Interfaces:
RequestSubmitter,RequestSubmitterAsync
- Direct Known Subclasses:
Client.AliasClusteredClient,Client.ClusteredClient,Client.PinnedClient
A
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.- Author:
- Stephen Mallette (http://stephen.genoprime.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUses aClient.ClusteredClientthat rebinds requests to a specifiedGraphorTraversalSourceinstances on the server-side.static final classAClientimplementation.static class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCreate a newClientthat aliases the specifiedGraphorTraversalSourcename on the server to a variable called "g" for the context of the requests made through thatClient.org.apache.tinkerpop.gremlin.util.message.RequestMessage.BuilderbuildMessage(org.apache.tinkerpop.gremlin.util.message.RequestMessage.Builder builder) Makes any initial changes to the builder and returns the constructedRequestMessage.protected abstract org.apache.tinkerpop.gremlin.driver.ConnectionchooseConnection(org.apache.tinkerpop.gremlin.util.message.RequestMessage msg) Chooses aConnectionto write the message to.protected Hostvoidclose()Closes the client by making a synchronous call tocloseAsync().abstract CompletableFuture<Void>Asynchronous close of theClient.Gets theClusterthat spawned thisClient.init()Initializes the client which typically means that a connection is established to the server.protected abstract voidCalled in theinit()method.abstract booleanSubmits a Gremlin script to the server and returns aResultSetonce the write of the request is complete.Submits a Gremlin script and bound parameters to the server and returns aResultSetonce the write of the request is complete.submit(String gremlin, RequestOptions options) Submits a Gremlin script to the server and returns aResultSetonce the write of the request is complete.submitAsync(String gremlin) The asynchronous version ofsubmit(String)where the returned future will complete when the write of the request completes.Deprecated.submitAsync(String gremlin, Map<String, Object> parameters) The asynchronous version ofsubmit(String, Map)} where the returned future will complete when the write of the request completes.submitAsync(String gremlin, RequestOptions options) The asynchronous version ofsubmit(String, RequestOptions)} where the returned future will complete when the write of the request completes.submitAsync(org.apache.tinkerpop.gremlin.util.message.RequestMessage msg) A low-level method that allows the submission of a manually constructedRequestMessage.
-
Field Details
-
TOO_MANY_IN_FLIGHT_REQUESTS
- See Also:
-
cluster
-
initialized
protected volatile boolean initialized
-
-
Method Details
-
buildMessage
public org.apache.tinkerpop.gremlin.util.message.RequestMessage.Builder buildMessage(org.apache.tinkerpop.gremlin.util.message.RequestMessage.Builder builder) Makes any initial changes to the builder and returns the constructedRequestMessage. Implementers may choose to override this message to append data to the request before sending. By default, this method will simply return thebuilderpassed in by the caller. -
initializeImplementation
protected abstract void initializeImplementation()Called in theinit()method. -
chooseConnection
protected abstract org.apache.tinkerpop.gremlin.driver.Connection chooseConnection(org.apache.tinkerpop.gremlin.util.message.RequestMessage msg) throws TimeoutException, org.apache.tinkerpop.gremlin.driver.exception.ConnectionException Chooses aConnectionto write the message to.- Throws:
TimeoutExceptionorg.apache.tinkerpop.gremlin.driver.exception.ConnectionException
-
closeAsync
Asynchronous close of theClient. -
alias
Create a newClientthat aliases the specifiedGraphorTraversalSourcename on the server to a variable called "g" for the context of the requests made through thatClient.- Parameters:
graphOrTraversalSource- rebinds the specified global Gremlin Server variable to "g"
-
init
Initializes the client which typically means that a connection is established to the server. Depending on the implementation and configuration this blocking call may take some time. This method will be called automatically if it is not called directly and multiple calls will not have effect. -
submit
Submits a Gremlin script to the server and returns aResultSetonce the write of the request is complete.- Specified by:
submitin interfaceRequestSubmitter- Parameters:
gremlin- the gremlin script to execute- Returns:
- the results of the script execution
-
submit
Submits a Gremlin script and bound parameters to the server and returns aResultSetonce 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 tosubmit(String). Parameterized scripts will perform better.- Specified by:
submitin interfaceRequestSubmitter- Parameters:
gremlin- the gremlin script to executeparameters- a map of parameters that will be bound to the script on execution- Returns:
- the results of the script execution
-
submit
Submits a Gremlin script to the server and returns aResultSetonce the write of the request is complete.- Specified by:
submitin interfaceRequestSubmitter- Parameters:
gremlin- the gremlin script to executeoptions- for the request- Returns:
- the results of the script execution
-
submitAsync
The asynchronous version ofsubmit(String)where the returned future will complete when the write of the request completes.- Specified by:
submitAsyncin interfaceRequestSubmitterAsync- Parameters:
gremlin- the gremlin script to execute- Returns:
- a future that completes with the results when the request write is complete
-
submitAsync
The asynchronous version ofsubmit(String, Map)} where the returned future will complete when the write of the request completes.- Specified by:
submitAsyncin interfaceRequestSubmitterAsync- Parameters:
gremlin- the gremlin script to executeparameters- a map of parameters that will be bound to the script on execution- Returns:
- a future that completes with the results when the request write is complete
-
submitAsync
@Deprecated public CompletableFuture<ResultSet> submitAsync(String gremlin, String graphOrTraversalSource, Map<String, Object> parameters) Deprecated.As of release 3.4.0, replaced bysubmitAsync(String, RequestOptions).The asynchronous version ofsubmit(String, Map)} where the returned future will complete when the write of the request completes.- Parameters:
gremlin- the gremlin script to executeparameters- a map of parameters that will be bound to the script on executiongraphOrTraversalSource- rebinds the specified global Gremlin Server variable to "g"
-
submitAsync
The asynchronous version ofsubmit(String, RequestOptions)} where the returned future will complete when the write of the request completes.- Specified by:
submitAsyncin interfaceRequestSubmitterAsync- Parameters:
gremlin- the gremlin script to executeoptions- the options to supply for this request- Returns:
- a future that completes with the results when the request write is complete
-
submitAsync
public CompletableFuture<ResultSet> submitAsync(org.apache.tinkerpop.gremlin.util.message.RequestMessage msg) A low-level method that allows the submission of a manually constructedRequestMessage. -
isClosing
public abstract boolean isClosing() -
close
public void close()Closes the client by making a synchronous call tocloseAsync(). -
getCluster
Gets theClusterthat spawned thisClient. -
chooseRandomHost
-
submitAsync(String, RequestOptions).