Package com.arangodb

Class ArangoDB.Builder

java.lang.Object
com.arangodb.ArangoDB.Builder
Enclosing interface:
ArangoDB

public static class ArangoDB.Builder extends Object
Builder class to build an instance of ArangoDB.
Author:
Mark Vollmary
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public ArangoDB build()
      Returns an instance of ArangoDB.
      Returns:
      ArangoDB
    • loadProperties

      public ArangoDB.Builder loadProperties(ArangoConfigProperties properties)
    • protocol

      public ArangoDB.Builder protocol(Protocol protocol)
    • host

      public ArangoDB.Builder host(String host, int port)
      Adds a host to connect to. Multiple hosts can be added to provide fallbacks.
      Parameters:
      host - address of the host
      port - port of the host
      Returns:
      ArangoDB.Builder
    • timeout

      public ArangoDB.Builder timeout(Integer timeout)
      Sets the connection and request timeout in milliseconds.
      Parameters:
      timeout - timeout in milliseconds
      Returns:
      ArangoDB.Builder
    • user

      public ArangoDB.Builder user(String user)
      Sets the username to use for authentication.
      Parameters:
      user - the user in the database (default: root)
      Returns:
      ArangoDB.Builder
    • password

      public ArangoDB.Builder password(String password)
      Sets the password for the user for authentication.
      Parameters:
      password - the password of the user in the database (default: null)
      Returns:
      ArangoDB.Builder
    • jwt

      public ArangoDB.Builder jwt(String jwt)
      Sets the JWT for the user authentication.
      Parameters:
      jwt - token to use (default: null)
      Returns:
      ArangoDB.Builder
    • useSsl

      public ArangoDB.Builder useSsl(Boolean useSsl)
      If set to true SSL will be used when connecting to an ArangoDB server.
      Parameters:
      useSsl - whether or not use SSL (default: false)
      Returns:
      ArangoDB.Builder
    • sslContext

      public ArangoDB.Builder sslContext(SSLContext sslContext)
      Sets the SSL context to be used when true is passed through useSsl(Boolean).
      Parameters:
      sslContext - SSL context to be used
      Returns:
      ArangoDB.Builder
    • verifyHost

      public ArangoDB.Builder verifyHost(Boolean verifyHost)
      Set whether hostname verification is enabled
      Parameters:
      verifyHost - true if enabled
      Returns:
      ArangoDB.Builder
    • chunkSize

      public ArangoDB.Builder chunkSize(Integer chunkSize)
      Sets the chunk size when Protocol.VST is used.
      Parameters:
      chunkSize - size of a chunk in bytes
      Returns:
      ArangoDB.Builder
    • maxConnections

      public ArangoDB.Builder maxConnections(Integer maxConnections)
      Sets the maximum number of connections the built in connection pool will open per host.

      Defaults:

       Protocol.VST == 1
       Protocol.HTTP_JSON == 20
       Protocol.HTTP_VPACK == 20
       
      Parameters:
      maxConnections - max number of connections
      Returns:
      ArangoDB.Builder
    • connectionTtl

      public ArangoDB.Builder connectionTtl(Long connectionTtl)
      Set the time to live of an inactive connection. After this time of inactivity the connection will be closed automatically.
      Parameters:
      connectionTtl - the time to live of a connection in milliseconds
      Returns:
      ArangoDB.Builder
    • keepAliveInterval

      public ArangoDB.Builder keepAliveInterval(Integer keepAliveInterval)
      Set the keep-alive interval for VST connections. If set, every VST connection will perform a no-op request every keepAliveInterval seconds, to avoid to be closed due to inactivity by the server (or by the external environment, eg. firewall, intermediate routers, operating system).
      Parameters:
      keepAliveInterval - interval in seconds
      Returns:
      ArangoDB.Builder
    • acquireHostList

      public ArangoDB.Builder acquireHostList(Boolean acquireHostList)
      Whether the driver should acquire a list of available coordinators in an ArangoDB cluster or a single server with active failover. In case of Active-Failover deployment set to true to enable automatic master discovery.

      The host list will be used for failover and load balancing.

      Parameters:
      acquireHostList - whether automatically acquire a list of available hosts (default: false)
      Returns:
      ArangoDB.Builder
    • acquireHostListInterval

      public ArangoDB.Builder acquireHostListInterval(Integer acquireHostListInterval)
      Setting the Interval for acquireHostList
      Parameters:
      acquireHostListInterval - Interval in milliseconds
      Returns:
      ArangoDB.Builder
    • loadBalancingStrategy

      public ArangoDB.Builder loadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy)
      Sets the load balancing strategy to be used in an ArangoDB cluster setup. In case of Active-Failover deployment set to LoadBalancingStrategy.NONE or not set at all, since that would be the default.
      Parameters:
      loadBalancingStrategy - the load balancing strategy to be used (default: LoadBalancingStrategy.NONE
      Returns:
      ArangoDB.Builder
    • responseQueueTimeSamples

      public ArangoDB.Builder responseQueueTimeSamples(Integer responseQueueTimeSamples)
      Setting the amount of samples kept for queue time metrics
      Parameters:
      responseQueueTimeSamples - amount of samples to keep
      Returns:
      ArangoDB.Builder
    • serde

      public ArangoDB.Builder serde(ArangoSerde serde)
      Sets the serde for the user data. This is used to serialize and deserialize all the data payload such as: - documents, vertexes, edges - AQL bind vars - body payload of requests and responses in ArangoDB.execute(Request, Class)

      However, note that the following types will always be serialized and deserialized using the internal serde: - JsonNode - RawJson - RawBytes - BaseDocument - BaseEdgeDocument

      Parameters:
      serde - custom serde for the user data
      Returns:
      ArangoDB.Builder
    • serdeProviderClass

      public ArangoDB.Builder serdeProviderClass(Class<? extends ArangoSerdeProvider> serdeProviderClass)
      Sets the serde provider to be used to instantiate the user data serde. Ignored if serde(ArangoSerde) is used.
      Parameters:
      serdeProviderClass - class of the serde provider, it must have a public no-args constructor
      Returns:
      ArangoDB.Builder
    • asyncExecutor

      @Deprecated public ArangoDB.Builder asyncExecutor(Executor executor)
      Deprecated.
      for removal. To consume the responses in a custom executor use async CompletableFuture methods.
      Sets the downstream async executor that will be used to consume the responses of the async API, that are returned as CompletableFuture
      Parameters:
      executor - async downstream executor
      Returns:
      ArangoDB.Builder
    • compression

      public ArangoDB.Builder compression(Compression compression)
      Sets the content-encoding and accept-encoding to use for HTTP requests and the related algorithm to encode and decode the transferred data. (default: Compression.NONE)
      Parameters:
      compression - format
      Returns:
      ArangoDB.Builder
      Since:
      ArangoDB 3.12
    • compressionThreshold

      public ArangoDB.Builder compressionThreshold(Integer threshold)
      Sets the minimum HTTP request body size (in bytes) to trigger compression. (default: 1024)
      Parameters:
      threshold - body size (in bytes)
      Returns:
      ArangoDB.Builder
      Since:
      ArangoDB 3.12
    • compressionLevel

      public ArangoDB.Builder compressionLevel(Integer level)
      Sets the compression level. (default: 6)
      Parameters:
      level - compression level between 0 and 9
      Returns:
      ArangoDB.Builder
      Since:
      ArangoDB 3.12
    • protocolConfig

      public ArangoDB.Builder protocolConfig(ProtocolConfig protocolConfig)
      Configuration specific for ProtocolProvider.
      Returns:
      ArangoDB.Builder
    • protocolProvider

      protected ProtocolProvider protocolProvider(Protocol protocol)
    • createHostHandler

      protected HostHandler createHostHandler(HostResolver hostResolver)
    • createHostResolver

      protected HostResolver createHostResolver(Collection<Host> hosts, ConnectionFactory connectionFactory)
    • createHostList

      protected Collection<Host> createHostList(ConnectionFactory connectionFactory)