Class Cluster
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.driver.Cluster
-
public final class Cluster extends Object
A connection to a set of one or more Gremlin Server instances.- Author:
- Stephen Mallette (http://stephen.genoprime.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Cluster.Builder
-
Field Summary
Fields Modifier and Type Field Description static String
SERIALIZER_INTERCEPTOR_NAME
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Host>
allHosts()
Gets a list of all the configured hosts.List<URI>
availableHosts()
Gets the list of hosts that theCluster
was able to connect to.static Cluster.Builder
build()
static Cluster.Builder
build(File configurationFile)
static Cluster.Builder
build(String address)
static Cluster.Builder
build(RequestInterceptor serializingInterceptor)
void
close()
CompletableFuture<Void>
closeAsync()
<T extends Client>
Tconnect()
Creates a newClient
based on the settings provided.<T extends Client>
Tconnect(String sessionId)
Creates a SessionedClient instance to thisCluster
, meaning requests will be routed to a single server (randomly selected from the cluster), where the same bindings will be available on each request.<T extends Client>
Tconnect(String sessionId, boolean manageTransactions)
Creates a SessionedClient instance to thisCluster
, meaning requests will be routed to a single server (randomly selected from the cluster), where the same bindings will be available on each request.long
getIdleConnectionTimeout()
Get time in milliseconds that the driver will allow a channel to not receive read or writes before it automatically closes.Class<? extends LoadBalancingStrategy>
getLoadBalancingStrategy()
Specifies the load balancing strategy to use on the client side.long
getMaxResponseContentLength()
Gets the maximum size in bytes of any request received from the server.int
getMaxWaitForClose()
Gets how long a connection will wait for all pending messages to be returned from the server before closing.int
getMaxWaitForConnection()
Gets the maximum amount of time to wait for a connection to be borrowed from the connection pool.String
getPath()
Gets the path to the Gremlin service.int
getPort()
Gets the port that the Gremlin Servers will be listening on.int
getResultIterationBatchSize()
Gets the override for the server setting that determines how many results are returned per batch.String[]
getSerializers()
Get theMessageSerializer
MIME types supported.void
init()
boolean
isBulkResultsEnabled()
Checks if cluster is configured to bulk resultsboolean
isClosed()
Determines if theCluster
has completed its closing process after a call toclose()
orcloseAsync()
.boolean
isClosing()
boolean
isSslEnabled()
Determines if connectivity over SSL is enabled.boolean
isUserAgentOnConnectEnabled()
Checks if cluster is configured to send a User Agent header in the web socket handshakeint
maxConnectionPoolSize()
Gets the maximum size that theConnectionPool
can grow.static Cluster
open()
Create aCluster
with all default settings which will connect to one contact point atlocalhost
.static Cluster
open(String configurationFile)
Create aCluster
using a YAML-based configuration file.static Cluster
open(org.apache.commons.configuration2.Configuration conf)
Create aCluster
from Apache Configurations.String
toString()
-
-
-
Field Detail
-
SERIALIZER_INTERCEPTOR_NAME
public static final String SERIALIZER_INTERCEPTOR_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
-
connect
public <T extends Client> T connect(String sessionId)
Creates a SessionedClient instance to thisCluster
, meaning requests will be routed to a single server (randomly selected from the cluster), where the same bindings will be available on each request. Requests are bound to the same thread on the server and thus transactions may extend beyond the bounds of a single request. The transactions are managed by the user and must be committed or rolled-back manually. Note that calling this method does not imply that a connection is made to the server itself at this point. Therefore, if there is only one server specified in theCluster
and that server is not available an error will not be raised at this point. Connections get initialized in theClient
when a request is submitted or can be directly initialized viaClient.init()
.- Parameters:
sessionId
- user supplied id for the session which should be unique (a UUID is ideal).
-
connect
public <T extends Client> T connect(String sessionId, boolean manageTransactions)
Creates a SessionedClient instance to thisCluster
, meaning requests will be routed to a single server (randomly selected from the cluster), where the same bindings will be available on each request. Requests are bound to the same thread on the server and thus transactions may extend beyond the bounds of a single request. IfmanageTransactions
is set tofalse
then transactions are managed by the user and must be committed or rolled-back manually. When set totrue
the transaction is committed or rolled-back at the end of each request. Note that calling this method does not imply that a connection is made to the server itself at this point. Therefore, if there is only one server specified in theCluster
and that server is not available an error will not be raised at this point. Connections get initialized in theClient
when a request is submitted or can be directly initialized viaClient.init()
.- Parameters:
sessionId
- user supplied id for the session which should be unique (a UUID is ideal).manageTransactions
- enables auto-transactions when set to true
-
build
public static Cluster.Builder build()
-
build
public static Cluster.Builder build(String address)
-
build
public static Cluster.Builder build(RequestInterceptor serializingInterceptor)
-
build
public static Cluster.Builder build(File configurationFile) throws FileNotFoundException
- Throws:
FileNotFoundException
-
open
public static Cluster open()
Create aCluster
with all default settings which will connect to one contact point atlocalhost
.
-
open
public static Cluster open(org.apache.commons.configuration2.Configuration conf)
Create aCluster
from Apache Configurations.
-
open
public static Cluster open(String configurationFile) throws Exception
Create aCluster
using a YAML-based configuration file. First try to read the file from the file system and then from resources.- Throws:
Exception
-
close
public void close()
-
closeAsync
public CompletableFuture<Void> closeAsync()
-
isClosing
public boolean isClosing()
-
isClosed
public boolean isClosed()
Determines if theCluster
has completed its closing process after a call toclose()
orcloseAsync()
.
-
availableHosts
public List<URI> availableHosts()
Gets the list of hosts that theCluster
was able to connect to. AHost
is assumed unavailable until a connection to it is proven to be present. This will not happen until theClient
submits requests that succeed in reaching a server at theHost
orClient.init()
is called which initializes theConnectionPool
for theClient
itself. The number of available hosts returned from this method will change as different servers come on and offline.
-
getPath
public String getPath()
Gets the path to the Gremlin service.
-
getSerializers
public String[] getSerializers()
Get theMessageSerializer
MIME types supported.
-
isSslEnabled
public boolean isSslEnabled()
Determines if connectivity over SSL is enabled.
-
maxConnectionPoolSize
public int maxConnectionPoolSize()
Gets the maximum size that theConnectionPool
can grow.
-
getResultIterationBatchSize
public int getResultIterationBatchSize()
Gets the override for the server setting that determines how many results are returned per batch.
-
getMaxWaitForConnection
public int getMaxWaitForConnection()
Gets the maximum amount of time to wait for a connection to be borrowed from the connection pool.
-
getMaxWaitForClose
public int getMaxWaitForClose()
Gets how long a connection will wait for all pending messages to be returned from the server before closing.
-
getMaxResponseContentLength
public long getMaxResponseContentLength()
Gets the maximum size in bytes of any request received from the server.
-
getIdleConnectionTimeout
public long getIdleConnectionTimeout()
Get time in milliseconds that the driver will allow a channel to not receive read or writes before it automatically closes.
-
getLoadBalancingStrategy
public Class<? extends LoadBalancingStrategy> getLoadBalancingStrategy()
Specifies the load balancing strategy to use on the client side.
-
getPort
public int getPort()
Gets the port that the Gremlin Servers will be listening on.
-
allHosts
public Collection<Host> allHosts()
Gets a list of all the configured hosts.
-
isUserAgentOnConnectEnabled
public boolean isUserAgentOnConnectEnabled()
Checks if cluster is configured to send a User Agent header in the web socket handshake
-
isBulkResultsEnabled
public boolean isBulkResultsEnabled()
Checks if cluster is configured to bulk results
-
-