org.apache.tinkerpop.gremlin.driver

## 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 and Description
    --- | ---
    `static class` | `Cluster.Builder`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<Host>` | `allHosts()` Gets a list of all the configured hosts.
    `List<URI>` | `availableHosts()` Gets the list of hosts that the `Cluster` was able to connect to.
    `static Cluster.Builder` | `build()`
    `static Cluster.Builder` | `build(File configurationFile)`
    `static Cluster.Builder` | `build(String address)`
    `void` | `close()`
    `CompletableFuture<Void>` | `closeAsync()`
    `<T extends Client> T` | `connect()` Creates a `Client.ClusteredClient` instance to this `Cluster`, 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> T` | `connect(Client.Settings settings)` Creates a new `Client` based on the settings provided.
    `<T extends Client> T` | `connect(String sessionId)` Creates a `Client.SessionedClient` instance to this `Cluster`, 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> T` | `connect(String sessionId, boolean manageTransactions)` Creates a `Client.SessionedClient` instance to this `Cluster`, meaning requests will be routed to a single server (randomly selected from the cluster), where the same bindings will be available on each request.
    `String` | `getChannelizer()` Gets the `Channelizer` implementation to use on the client when creating a `Connection`.
    `long` | `getConnectionSetupTimeout()` Gets time duration of time in milliseconds provided for connection setup to complete which includes WebSocket handshake and SSL handshake.
    `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.
    `Class<? extends LoadBalancingStrategy>` | `getLoadBalancingStrategy()` Specifies the load balancing strategy to use on the client side.
    `int` | `getMaxContentLength()` Gets the maximum size in bytes of any request sent to the server.
    `int` | `getMaxInProcessPerConnection()` Gets the maximum number of in-flight requests that can occur on a `Connection`.
    `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.
    `int` | `getMinInProcessPerConnection()` Gets the minimum number of in-flight requests that can occur on a `Connection` before it is considered for closing on return to the `ConnectionPool`.
    `int` | `getNioPoolSize()` Size of the pool for handling request/response operations.
    `String` | `getPath()` Gets the path to the Gremlin service.
    `int` | `getPort()` Gets the port that the Gremlin Servers will be listening on.
    `int` | `getReconnectInterval()` Gets time in milliseconds to wait between retries when attempting to reconnect to a dead host.
    `int` | `getResultIterationBatchSize()` Gets the override for the server setting that determines how many results are returned per batch.
    `String[]` | `getSerializers()` Get the `MessageSerializer` MIME types supported.
    `int` | `getWorkerPoolSize()` Size of the pool for handling background work.
    `void` | `init()`
    `boolean` | `isClosed()` Determines if the `Cluster` has completed its closing process after a call to `close()` or `closeAsync()`.
    `boolean` | `isClosing()` Determines if the `Cluster` is in the process of closing given a call to `close()` or `closeAsync()`.
    `boolean` | `isSslEnabled()` Determines if connectivity over SSL is enabled.
    `int` | `maxConnectionPoolSize()` Gets the maximum size that the `ConnectionPool` can grow.
    `int` | `maxSimultaneousUsagePerConnection()` Gets the maximum number of times that a `Connection` can be borrowed from the pool simultaneously.
    `int` | `minConnectionPoolSize()` Gets the minimum size of the `ConnectionPool`.
    `int` | `minSimultaneousUsagePerConnection()` Gets the minimum number of times that a `Connection` should be borrowed from the pool before it falls under consideration for closing.
    `static Cluster` | `open()` Create a `Cluster` with all default settings which will connect to one contact point at `localhost`.
    `static Cluster` | `open(org.apache.commons.configuration2.Configuration conf)` Create a `Cluster` from Apache Configurations.
    `static Cluster` | `open(String configurationFile)` Create a `Cluster` using a YAML-based configuration file.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### init

          public void init()

    - #### connect

          public <T extends Client> T connect()

      Creates a `Client.ClusteredClient` instance to this `Cluster`, 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 the `Cluster` and that server is not available an error will not be raised at this point. Connections get initialized in the `Client` when a request is submitted or can be directly initialized via `Client.init()`.

    - #### connect

          public <T extends Client> T connect(String sessionId)

      Creates a `Client.SessionedClient` instance to this `Cluster`, 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 the `Cluster` and that server is not available an error will not be raised at this point. Connections get initialized in the `Client` when a request is submitted or can be directly initialized via `Client.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 `Client.SessionedClient` instance to this `Cluster`, 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. If `manageTransactions` is set to `false` then transactions are managed by the user and must be committed or rolled-back manually. When set to `true` 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 the `Cluster` and that server is not available an error will not be raised at this point. Connections get initialized in the `Client` when a request is submitted or can be directly initialized via `Client.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

    - #### connect

          public <T extends Client> T connect(Client.Settings settings)

      Creates a new `Client` based on the settings provided.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### build

          public static Cluster.Builder build()

    - #### build

          public static Cluster.Builder build(String address)

    - #### build

          public static Cluster.Builder build(File configurationFile)
                                       throws FileNotFoundException

      Throws:
        `FileNotFoundException`

    - #### open

          public static Cluster open()

      Create a `Cluster` with all default settings which will connect to one contact point at `localhost`.

    - #### open

          public static Cluster open(org.apache.commons.configuration2.Configuration conf)

      Create a `Cluster` from Apache Configurations.

    - #### open

          public static Cluster open(String configurationFile)
                              throws Exception

      Create a `Cluster` 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()

      Determines if the `Cluster` is in the process of closing given a call to `close()` or `closeAsync()`.

    - #### isClosed

          public boolean isClosed()

      Determines if the `Cluster` has completed its closing process after a call to `close()` or `closeAsync()`.

    - #### availableHosts

          public List<URI> availableHosts()

      Gets the list of hosts that the `Cluster` was able to connect to. A `Host` is assumed unavailable until a connection to it is proven to be present. This will not happen until the `Client` submits requests that succeed in reaching a server at the `Host` or `Client.init()` is called which initializes the `ConnectionPool` for the `Client` 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.

    - #### getNioPoolSize

          public int getNioPoolSize()

      Size of the pool for handling request/response operations.

    - #### getWorkerPoolSize

          public int getWorkerPoolSize()

      Size of the pool for handling background work.

    - #### getSerializers

          public String[] getSerializers()

      Get the `MessageSerializer` MIME types supported.

    - #### isSslEnabled

          public boolean isSslEnabled()

      Determines if connectivity over SSL is enabled.

    - #### getMinInProcessPerConnection

          public int getMinInProcessPerConnection()

      Gets the minimum number of in-flight requests that can occur on a `Connection` before it is considered for closing on return to the `ConnectionPool`.

    - #### getMaxInProcessPerConnection

          public int getMaxInProcessPerConnection()

      Gets the maximum number of in-flight requests that can occur on a `Connection`.

    - #### maxSimultaneousUsagePerConnection

          public int maxSimultaneousUsagePerConnection()

      Gets the maximum number of times that a `Connection` can be borrowed from the pool simultaneously.

    - #### minSimultaneousUsagePerConnection

          public int minSimultaneousUsagePerConnection()

      Gets the minimum number of times that a `Connection` should be borrowed from the pool before it falls under consideration for closing.

    - #### maxConnectionPoolSize

          public int maxConnectionPoolSize()

      Gets the maximum size that the `ConnectionPool` can grow.

    - #### minConnectionPoolSize

          public int minConnectionPoolSize()

      Gets the minimum size of the `ConnectionPool`.

    - #### 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.

    - #### getMaxContentLength

          public int getMaxContentLength()

      Gets the maximum size in bytes of any request sent to the server.

    - #### getChannelizer

          public String getChannelizer()

      Gets the `Channelizer` implementation to use on the client when creating a `Connection`.

    - #### getReconnectInterval

          public int getReconnectInterval()

      Gets time in milliseconds to wait between retries when attempting to reconnect to a dead host.

    - #### getKeepAliveInterval

          public 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.

    - #### getConnectionSetupTimeout

          public 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.

    - #### 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.

Copyright © 2013–2022 Apache Software Foundation. All rights reserved.