Class Cluster.Builder

java.lang.Object
org.apache.tinkerpop.gremlin.driver.Cluster.Builder
Enclosing class:
Cluster

public static final class Cluster.Builder extends Object
  • Method Details

    • nioPoolSize

      public Cluster.Builder nioPoolSize(int nioPoolSize)
      Size of the pool for handling request/response operations. Defaults to the number of available processors.
    • workerPoolSize

      public Cluster.Builder workerPoolSize(int workerPoolSize)
      Size of the pool for handling background work. Defaults to the number of available processors multiplied by 2
    • path

      public Cluster.Builder path(String path)
      The path to the Gremlin service on the host which is "/gremlin" by default.
    • responseSerializer

      public Cluster.Builder responseSerializer(String mimeType)
      Set the MessageSerializer used to deserialize responses from the server given the exact name of a Serializers enum. This selects the encoding requested via the Accept header; requests are always sent as JSON regardless of this setting. Note that setting this value this way will not allow specific configuration of the serializer itself. If specific configuration is required please use responseSerializer(MessageSerializer).
    • responseSerializer

      public Cluster.Builder responseSerializer(Serializers mimeType)
      Set the MessageSerializer used to deserialize responses from the server via the Serializers enum. This selects the encoding requested via the Accept header; requests are always sent as JSON regardless of this setting. If specific configuration is required please use responseSerializer(MessageSerializer).
    • responseSerializer

      public Cluster.Builder responseSerializer(MessageSerializer<?> responseSerializer)
      Sets the MessageSerializer used to deserialize responses from the server. This selects the encoding requested via the Accept header; requests are always sent as JSON regardless of this setting.
    • enableSsl

      public Cluster.Builder enableSsl(boolean enable)
      Enables connectivity over SSL - note that the server should be configured with SSL turned on for this setting to work properly.
    • ssl

      public Cluster.Builder ssl(io.netty.handler.ssl.SslContext sslContext)
      Explicitly set the SslContext to use for SSL connections. When set, all other SSL-related builder settings (key store, trust store, ciphers, protocols, skip-cert-validation) are ignored.
    • keyStore

      public Cluster.Builder keyStore(String keyStore)
      The file location of the private key in JKS or PKCS#12 format.
    • keyStorePassword

      public Cluster.Builder keyStorePassword(String keyStorePassword)
      The password of the keyStore, or null if it's not password-protected.
    • trustStore

      public Cluster.Builder trustStore(String trustStore)
      The file location for a SSL Certificate Chain to use when SSL is enabled. If this value is not provided and SSL is enabled, the default TrustManager will be used, which will have a set of common public certificates installed to it.
    • trustStorePassword

      public Cluster.Builder trustStorePassword(String trustStorePassword)
      The password of the trustStore, or null if it's not password-protected.
    • keyStoreType

      public Cluster.Builder keyStoreType(String keyStoreType)
      The format of the keyStore, either JKS or PKCS12
    • trustStoreType

      public Cluster.Builder trustStoreType(String trustStoreType)
      The format of the trustStore, either JKS or PKCS12
    • sslEnabledProtocols

      public Cluster.Builder sslEnabledProtocols(List<String> sslEnabledProtocols)
      A list of SSL protocols to enable. @see JSSE Protocols
    • sslCipherSuites

      public Cluster.Builder sslCipherSuites(List<String> sslCipherSuites)
      A list of cipher suites to enable. @see Cipher Suites
    • sslSkipCertValidation

      public Cluster.Builder sslSkipCertValidation(boolean sslSkipCertValidation)
      If true, trust all certificates and do not perform any validation.
    • maxConnections

      public Cluster.Builder maxConnections(int maxConnections)
      The maximum size that the ConnectionPool can grow.
    • batchSize

      public Cluster.Builder batchSize(int size)
      Sets the default for the per-request batch size, used when a request does not specify its own batchSize via RequestOptions. Defaults to 64.
    • maxWaitForConnection

      public Cluster.Builder maxWaitForConnection(int maxWait)
      The maximum amount of time to wait for a connection to be borrowed from the connection pool.
    • maxWaitForClose

      public Cluster.Builder maxWaitForClose(int maxWait)
      The amount of time in milliseconds to wait the connection to close before timing out where the default value is 3000. This timeout allows for a delay to occur in waiting for remaining messages that may still be returning from the server while a Client.close() is called.
    • maxResponseHeaderBytes

      public Cluster.Builder maxResponseHeaderBytes(int maxResponseHeaderBytes)
      The maximum size in bytes allowed for the HTTP response headers. Defaults to 8192. Exposes the underlying Netty HttpClientCodec max header size.
    • readTimeoutMillis

      public Cluster.Builder readTimeoutMillis(long readTimeout)
      Sets the idle-read timeout in milliseconds that bounds the time between inbound response chunks. The clock is reset on each chunk received, so it bounds idle gaps rather than the total response time. A value of 0 (the default) disables the feature.
    • readTimeout

      public Cluster.Builder readTimeout(Duration readTimeout)
      Sets the idle-read timeout that bounds the time between inbound response chunks. Equivalent to readTimeoutMillis(long) with the duration expressed as a Duration. Duration.ZERO disables the feature.
    • compression

      public Cluster.Builder compression(Compression compression)
      Sets the wire Compression algorithm negotiated with the server. Defaults to Compression.DEFLATE (compression on). Set Compression.NONE to disable.
    • proxy

      public Cluster.Builder proxy(ProxyOptions proxyOptions)
      Routes connections through the supplied HTTP proxy. A Netty HttpProxyHandler is inserted into the pipeline before the SSL handler.
    • validationRequest

      public Cluster.Builder validationRequest(String script)
      Specify a valid Gremlin script that can be used to test remote operations. This script should be designed to return quickly with the least amount of overhead possible. By default, the script sends g.inject(0).
    • reconnectInterval

      public Cluster.Builder reconnectInterval(int interval)
      Time in milliseconds to wait between retries when attempting to reconnect to a dead host.
    • loadBalancingStrategy

      public Cluster.Builder loadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy)
      Specifies the load balancing strategy to use on the client side.
    • interceptors

      public Cluster.Builder interceptors(List<RequestInterceptor> interceptors)
      Sets the list of RequestInterceptor instances that will be run in order to allow modification of the HttpRequest prior to its being sent to the server.
    • interceptors

      public Cluster.Builder interceptors(RequestInterceptor... interceptors)
      Sets the list of RequestInterceptor instances that will be run in order.
    • auth

      public Cluster.Builder auth(Auth auth)
      Adds an Auth RequestInterceptor that will always be appended to the end of the interceptor list when the Cluster is created, regardless of the order in which builder methods are called.
    • addContactPoint

      public Cluster.Builder addContactPoint(String address)
      Adds the address of a Gremlin Server to the list of servers a Client will try to contact to send requests to. The address should be parseable by InetAddress.getByName(String). That's the only validation performed at this point. No connection to the host is attempted.
    • addContactPoints

      public Cluster.Builder addContactPoints(String... addresses)
      Add one or more the addresses of a Gremlin Servers to the list of servers a Client will try to contact to send requests to. The address should be parseable by InetAddress.getByName(String). That's the only validation performed at this point. No connection to the host is attempted.
    • port

      public Cluster.Builder port(int port)
      Sets the port that the Gremlin Servers will be listening on.
    • url

      public Cluster.Builder url(String url)
      Configures the endpoint from a single URL string. The URL is parsed and applied to the builder as follows: the scheme selects SSL (https enables SSL, http disables it; other or absent schemes leave the current SSL setting unchanged), the host is added as a contact point, an explicit port is applied via port(int), and a non-empty path is applied via path(String). This is a convenience for the common single-host case; use addContactPoint(String) / addContactPoints(String...) along with port(int) and path(String) for multi-host configurations.

      Because this is a single-endpoint convenience, it must not be combined with the multi-host contact point methods: calling it after a contact point has already been added throws IllegalArgumentException.

      Parameters:
      url - a full URL such as https://gremlin.example.com:8182/gremlin
      Throws:
      IllegalArgumentException - if the URL cannot be parsed, has no host, or a contact point already exists
    • connectTimeoutMillis

      public Cluster.Builder connectTimeoutMillis(int connectTimeout)
      Sets the duration of time in milliseconds that bounds TCP connection establishment (transport setup, including the SSL handshake). Beyond this duration an exception would be thrown. This is a transport establishment timeout, not an HTTP request/response timeout. Defaults to 5000.
    • connectTimeout

      public Cluster.Builder connectTimeout(Duration connectTimeout)
      Sets the TCP connection-establishment timeout. Equivalent to connectTimeoutMillis(int) with the duration expressed as a Duration. The value is applied via Netty's int-typed CONNECT_TIMEOUT_MILLIS, so it must not exceed Integer.MAX_VALUE milliseconds.
    • idleTimeoutMillis

      public Cluster.Builder idleTimeoutMillis(long idleTimeout)
      Sets the time in milliseconds that the driver will allow a channel to not receive read or writes before it automatically closes.
    • idleTimeout

      public Cluster.Builder idleTimeout(Duration idleTimeout)
      Sets the idle-connection pool timeout. Equivalent to idleTimeoutMillis(long) with the duration expressed as a Duration. Duration.ZERO disables idle-connection detection.
    • keepAliveTimeMillis

      public Cluster.Builder keepAliveTimeMillis(long keepAliveTime)
      Sets the idle time in milliseconds before TCP keep-alive probes begin on an otherwise idle connection. When set to a positive value the SO_KEEPALIVE socket option is enabled and, where supported by the platform/JDK (JDK 11+ on Linux/macOS via TCP_KEEPIDLE), the per-socket idle time is configured. On platforms/JDKs where the per-socket idle time cannot be set, SO_KEEPALIVE is still enabled and the OS default idle time is used. Defaults to 30000. Set this value to 0 to disable the feature.
    • keepAliveTime

      public Cluster.Builder keepAliveTime(Duration keepAliveTime)
      Sets the idle time before TCP keep-alive probes begin. Equivalent to keepAliveTimeMillis(long) with the duration expressed as a Duration. Duration.ZERO disables the feature.
    • enableUserAgentOnConnect

      public Cluster.Builder enableUserAgentOnConnect(boolean enableUserAgentOnConnect)
      Configures whether cluster will send a user agent during web socket handshakes
      Parameters:
      enableUserAgentOnConnect - true enables the useragent. false disables the useragent.
    • bulkResults

      public Cluster.Builder bulkResults(boolean bulkResults)
      Configures whether cluster will enable result bulking to optimize performance.
      Parameters:
      bulkResults - true enables bulking.
    • create

      public Cluster create()