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 classCluster.Builder
-
Field Summary
Fields Modifier and Type Field Description static StringSERIALIZER_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 theClusterwas able to connect to.static Cluster.Builderbuild()static Cluster.Builderbuild(File configurationFile)static Cluster.Builderbuild(String address)static Cluster.Builderbuild(RequestInterceptor serializingInterceptor)voidclose()CompletableFuture<Void>closeAsync()<T extends Client>
Tconnect()Creates a newClientbased on the settings provided.longgetIdleConnectionTimeout()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.longgetMaxResponseContentLength()Gets the maximum size in bytes of any request received from the server.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.StringgetPath()Gets the path to the Gremlin service.intgetPort()Gets the port that the Gremlin Servers will be listening on.intgetResultIterationBatchSize()Gets the override for the server setting that determines how many results are returned per batch.String[]getSerializers()Get theMessageSerializerMIME types supported.voidinit()booleanisBulkResultsEnabled()Checks if cluster is configured to bulk resultsbooleanisClosed()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.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()voidtrackTransaction(org.apache.tinkerpop.gremlin.driver.remote.HttpRemoteTransaction tx)RemoteTransactiontransact()Creates a newTransactionusing the server's default traversal source.RemoteTransactiontransact(String graphOrTraversalSource)Creates a newTransactionbound to the specified graph or traversal source.voiduntrackTransaction(org.apache.tinkerpop.gremlin.driver.remote.HttpRemoteTransaction tx)
-
-
-
Field Detail
-
SERIALIZER_INTERCEPTOR_NAME
public static final String SERIALIZER_INTERCEPTOR_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
-
transact
public RemoteTransaction transact()
Creates a newTransactionusing the server's default traversal source. The server will bind to "g" by default when no traversal source is specified.
-
transact
public RemoteTransaction transact(String graphOrTraversalSource)
Creates a newTransactionbound to the specified graph or traversal source.- Parameters:
graphOrTraversalSource- the graph/traversal source alias, or null to use the server default
-
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 aClusterwith all default settings which will connect to one contact point atlocalhost.
-
open
public static Cluster open(org.apache.commons.configuration2.Configuration conf)
Create aClusterfrom Apache Configurations.
-
open
public 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
-
close
public void close()
-
closeAsync
public CompletableFuture<Void> closeAsync()
-
isClosing
public boolean isClosing()
-
isClosed
public boolean isClosed()
Determines if theClusterhas completed its closing process after a call toclose()orcloseAsync().
-
availableHosts
public 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.
-
getPath
public String getPath()
Gets the path to the Gremlin service.
-
getSerializers
public String[] getSerializers()
Get theMessageSerializerMIME types supported.
-
isSslEnabled
public boolean isSslEnabled()
Determines if connectivity over SSL is enabled.
-
maxConnectionPoolSize
public int maxConnectionPoolSize()
Gets the maximum size that theConnectionPoolcan 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.
-
trackTransaction
public void trackTransaction(org.apache.tinkerpop.gremlin.driver.remote.HttpRemoteTransaction tx)
-
untrackTransaction
public void untrackTransaction(org.apache.tinkerpop.gremlin.driver.remote.HttpRemoteTransaction tx)
-
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
-
-