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 SummaryNested Classes Modifier and Type Class Description static classCluster.Builder
 - 
Method SummaryAll 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 theClusterwas able to connect to.static Cluster.Builderbuild()static Cluster.Builderbuild(File configurationFile)static Cluster.Builderbuild(String address)voidclose()CompletableFuture<Void>closeAsync()<T extends Client>
 Tconnect()Creates aClient.ClusteredClientinstance to thisCluster, meaning requests will be routed to one or more servers (depending on the cluster configuration), where each request represents the entirety of a transaction.<T extends Client>
 Tconnect(String sessionId)Creates aClient.SessionedClientinstance 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 aClient.SessionedClientinstance 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(Client.Settings settings)Creates a newClientbased on the settings provided.StringgetChannelizer()Gets theChannelizerimplementation to use on the client when creating aConnection.longgetConnectionSetupTimeout()Gets time duration of time in milliseconds provided for connection setup to complete which includes WebSocket handshake and SSL handshake.longgetKeepAliveInterval()Gets time in milliseconds to wait after the last message is sent over a connection before sending a keep-alive message to the server.Class<? extends LoadBalancingStrategy>getLoadBalancingStrategy()Specifies the load balancing strategy to use on the client side.intgetMaxContentLength()Gets the maximum size in bytes of any request sent to the server.intgetMaxInProcessPerConnection()Gets the maximum number of in-flight requests that can occur on aConnection.intgetMaxWaitForClose()Gets how long a connection will wait for all pending messages to be returned from the server before closing.intgetMaxWaitForConnection()Gets the maximum amount of time to wait for a connection to be borrowed from the connection pool.intgetMinInProcessPerConnection()Gets the minimum number of in-flight requests that can occur on aConnectionbefore it is considered for closing on return to theConnectionPool.intgetNioPoolSize()Size of the pool for handling request/response operations.StringgetPath()Gets the path to the Gremlin service.intgetPort()Gets the port that the Gremlin Servers will be listening on.intgetReconnectInterval()Gets time in milliseconds to wait between retries when attempting to reconnect to a dead host.intgetResultIterationBatchSize()Gets the override for the server setting that determines how many results are returned per batch.String[]getSerializers()Get theMessageSerializerMIME types supported.intgetWorkerPoolSize()Size of the pool for handling background work.voidinit()booleanisClosed()Determines if theClusterhas completed its closing process after a call toclose()orcloseAsync().booleanisClosing()booleanisSslEnabled()Determines if connectivity over SSL is enabled.booleanisUserAgentOnConnectEnabled()Checks if cluster is configured to send a User Agent header in the web socket handshakeintmaxConnectionPoolSize()Gets the maximum size that theConnectionPoolcan grow.intmaxSimultaneousUsagePerConnection()Gets the maximum number of times that aConnectioncan be borrowed from the pool simultaneously.intminConnectionPoolSize()Gets the minimum size of theConnectionPool.intminSimultaneousUsagePerConnection()Gets the minimum number of times that aConnectionshould be borrowed from the pool before it falls under consideration for closing.static Clusteropen()Create aClusterwith all default settings which will connect to one contact point atlocalhost.static Clusteropen(String configurationFile)Create aClusterusing a YAML-based configuration file.static Clusteropen(org.apache.commons.configuration2.Configuration conf)Create aClusterfrom Apache Configurations.StringtoString()
 
- 
- 
- 
Method Detail- 
initpublic void init() 
 - 
connectpublic <T extends Client> T connect() Creates aClient.ClusteredClientinstance to thisCluster, meaning requests will be routed to one or more servers (depending on the cluster configuration), where each request represents the entirety of a transaction. A commit or rollback (in case of error) is automatically executed at the end of the 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 theClusterand that server is not available an error will not be raised at this point. Connections get initialized in theClientwhen a request is submitted or can be directly initialized viaClient.init().
 - 
connectpublic <T extends Client> T connect(String sessionId) Creates aClient.SessionedClientinstance 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 theClusterand that server is not available an error will not be raised at this point. Connections get initialized in theClientwhen 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).
 
 - 
connectpublic <T extends Client> T connect(String sessionId, boolean manageTransactions) Creates aClient.SessionedClientinstance 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. IfmanageTransactionsis set tofalsethen transactions are managed by the user and must be committed or rolled-back manually. When set totruethe 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 theClusterand that server is not available an error will not be raised at this point. Connections get initialized in theClientwhen 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
 
 - 
connectpublic <T extends Client> T connect(Client.Settings settings) Creates a newClientbased on the settings provided.
 - 
buildpublic static Cluster.Builder build() 
 - 
buildpublic static Cluster.Builder build(String address) 
 - 
buildpublic static Cluster.Builder build(File configurationFile) throws FileNotFoundException - Throws:
- FileNotFoundException
 
 - 
openpublic static Cluster open() Create aClusterwith all default settings which will connect to one contact point atlocalhost.
 - 
openpublic static Cluster open(org.apache.commons.configuration2.Configuration conf) Create aClusterfrom Apache Configurations.
 - 
openpublic static Cluster open(String configurationFile) throws Exception Create aClusterusing a YAML-based configuration file. First try to read the file from the file system and then from resources.- Throws:
- Exception
 
 - 
closepublic void close() 
 - 
closeAsyncpublic CompletableFuture<Void> closeAsync() 
 - 
isClosingpublic boolean isClosing() 
 - 
isClosedpublic boolean isClosed() Determines if theClusterhas completed its closing process after a call toclose()orcloseAsync().
 - 
availableHostspublic List<URI> availableHosts() Gets the list of hosts that theClusterwas able to connect to. AHostis assumed unavailable until a connection to it is proven to be present. This will not happen until theClientsubmits requests that succeed in reaching a server at theHostorClient.init()is called which initializes theConnectionPoolfor theClientitself. The number of available hosts returned from this method will change as different servers come on and offline.
 - 
getPathpublic String getPath() Gets the path to the Gremlin service.
 - 
getNioPoolSizepublic int getNioPoolSize() Size of the pool for handling request/response operations.
 - 
getWorkerPoolSizepublic int getWorkerPoolSize() Size of the pool for handling background work.
 - 
getSerializerspublic String[] getSerializers() Get theMessageSerializerMIME types supported.
 - 
isSslEnabledpublic boolean isSslEnabled() Determines if connectivity over SSL is enabled.
 - 
getMinInProcessPerConnectionpublic int getMinInProcessPerConnection() Gets the minimum number of in-flight requests that can occur on aConnectionbefore it is considered for closing on return to theConnectionPool.
 - 
getMaxInProcessPerConnectionpublic int getMaxInProcessPerConnection() Gets the maximum number of in-flight requests that can occur on aConnection.
 - 
maxSimultaneousUsagePerConnectionpublic int maxSimultaneousUsagePerConnection() Gets the maximum number of times that aConnectioncan be borrowed from the pool simultaneously.
 - 
minSimultaneousUsagePerConnectionpublic int minSimultaneousUsagePerConnection() Gets the minimum number of times that aConnectionshould be borrowed from the pool before it falls under consideration for closing.
 - 
maxConnectionPoolSizepublic int maxConnectionPoolSize() Gets the maximum size that theConnectionPoolcan grow.
 - 
minConnectionPoolSizepublic int minConnectionPoolSize() Gets the minimum size of theConnectionPool.
 - 
getResultIterationBatchSizepublic int getResultIterationBatchSize() Gets the override for the server setting that determines how many results are returned per batch.
 - 
getMaxWaitForConnectionpublic int getMaxWaitForConnection() Gets the maximum amount of time to wait for a connection to be borrowed from the connection pool.
 - 
getMaxWaitForClosepublic int getMaxWaitForClose() Gets how long a connection will wait for all pending messages to be returned from the server before closing.
 - 
getMaxContentLengthpublic int getMaxContentLength() Gets the maximum size in bytes of any request sent to the server.
 - 
getChannelizerpublic String getChannelizer() Gets theChannelizerimplementation to use on the client when creating aConnection.
 - 
getReconnectIntervalpublic int getReconnectInterval() Gets time in milliseconds to wait between retries when attempting to reconnect to a dead host.
 - 
getKeepAliveIntervalpublic long getKeepAliveInterval() Gets time in milliseconds to wait after the last message is sent over a connection before sending a keep-alive message to the server.
 - 
getConnectionSetupTimeoutpublic long getConnectionSetupTimeout() Gets time duration of time in milliseconds provided for connection setup to complete which includes WebSocket handshake and SSL handshake. Beyond this duration an exception would be thrown if the handshake is not complete by then.
 - 
getLoadBalancingStrategypublic Class<? extends LoadBalancingStrategy> getLoadBalancingStrategy() Specifies the load balancing strategy to use on the client side.
 - 
getPortpublic int getPort() Gets the port that the Gremlin Servers will be listening on.
 - 
allHostspublic Collection<Host> allHosts() Gets a list of all the configured hosts.
 - 
isUserAgentOnConnectEnabledpublic boolean isUserAgentOnConnectEnabled() Checks if cluster is configured to send a User Agent header in the web socket handshake
 
- 
 
-