Class IgniteClient.Builder

java.lang.Object
org.apache.ignite.client.IgniteClient.Builder
Enclosing interface:
IgniteClient

public static class IgniteClient.Builder extends Object
Client builder.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addresses

      public IgniteClient.Builder addresses(String... addrs)
      Sets the addresses of Ignite server nodes within a cluster. An address can be an IP address or a hostname, with or without port. If port is not set then Ignite will use the default one - see IgniteClientConfiguration.DFLT_PORT.
      Parameters:
      addrs - Addresses.
      Returns:
      This instance.
    • retryPolicy

      public IgniteClient.Builder retryPolicy(@Nullable @Nullable RetryPolicy retryPolicy)
      Sets the retry policy. When a request fails due to a connection error, and multiple server connections are available, Ignite will retry the request if the specified policy allows it.

      Default is RetryReadPolicy.

      Parameters:
      retryPolicy - Retry policy.
      Returns:
      This instance.
    • loggerFactory

      public IgniteClient.Builder loggerFactory(@Nullable @Nullable LoggerFactory loggerFactory)
      Sets the logger factory. This factory will be used to create a logger instance when needed.

      When null (default), System.getLogger(java.lang.String) is used.

      Parameters:
      loggerFactory - A factory.
      Returns:
      This instance.
    • connectTimeout

      public IgniteClient.Builder connectTimeout(long connectTimeout)
      Sets the socket connection timeout, in milliseconds.

      Default is IgniteClientConfiguration.DFLT_CONNECT_TIMEOUT.

      Parameters:
      connectTimeout - Socket connection timeout, in milliseconds.
      Returns:
      This instance.
      Throws:
      IllegalArgumentException - When value is less than zero.
    • addressFinder

      public IgniteClient.Builder addressFinder(IgniteClientAddressFinder addressFinder)
      Sets the address finder.
      Parameters:
      addressFinder - Address finder.
      Returns:
      This instance.
    • backgroundReconnectInterval

      public IgniteClient.Builder backgroundReconnectInterval(long backgroundReconnectInterval)
      Sets the background reconnect interval, in milliseconds. Set to 0 to disable background reconnect.

      Ignite balances requests across all healthy connections (when multiple endpoints are configured). Ignite also repairs connections on demand (when a request is made). However, "secondary" connections can be lost (due to network issues, or node restarts). This property controls how ofter Ignite client will check all configured endpoints and try to reconnect them in case of failure.

      Parameters:
      backgroundReconnectInterval - Reconnect interval, in milliseconds.
      Returns:
      This instance.
      Throws:
      IllegalArgumentException - When value is less than zero.
    • asyncContinuationExecutor

      public IgniteClient.Builder asyncContinuationExecutor(Executor asyncContinuationExecutor)
      Sets the async continuation executor.

      When null (default), ForkJoinPool.commonPool() is used.

      When async client operation completes, corresponding CompletableFuture continuations (such as CompletableFuture.thenApply(Function)) will be invoked using this executor.

      Server responses are handled by a dedicated network thread. To ensure optimal performance, this thread should not perform any extra work, so user-defined continuations are offloaded to the specified executor.

      Parameters:
      asyncContinuationExecutor - Async continuation executor.
      Returns:
      This instance.
    • heartbeatInterval

      public IgniteClient.Builder heartbeatInterval(long heartbeatInterval)
      Sets the heartbeat message interval, in milliseconds. Default is 30_000.

      When server-side idle timeout is not zero, effective heartbeat interval is set to min(heartbeatInterval, idleTimeout / 3).

      When thin client connection is idle (no operations are performed), heartbeat messages are sent periodically to keep the connection alive and detect potential half-open state.

      Parameters:
      heartbeatInterval - Heartbeat interval.
      Returns:
      This instance.
    • heartbeatTimeout

      public IgniteClient.Builder heartbeatTimeout(long heartbeatTimeout)
      Sets the heartbeat message timeout, in milliseconds. Default is 5000.

      When a server does not respond to a heartbeat within the specified timeout, client will close the connection.

      Parameters:
      heartbeatTimeout - Heartbeat timeout.
      Returns:
      This instance.
    • ssl

      public IgniteClient.Builder ssl(@Nullable @Nullable SslConfiguration sslConfiguration)
      Sets the SSL configuration.
      Parameters:
      sslConfiguration - SSL configuration.
      Returns:
      This instance.
    • metricsEnabled

      public IgniteClient.Builder metricsEnabled(boolean metricsEnabled)
      Enables or disables JMX metrics.

      When enabled, Ignite client will expose JMX metrics via the platform MBean server with bean name "org.apache.ignite:group=metrics,name=client".

      Use jconsole or any other JMX client to view the metrics.

      To get metrics programmatically: MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), new ObjectName("org.apache.ignite:group=metrics,name=client"), DynamicMBean.class, false).getAttribute("ConnectionsActive")

      See Java Management Extensions (JMX) for more information.

      Parameters:
      metricsEnabled - Metrics enabled flag.
      Returns:
      This instance.
    • authenticator

      public IgniteClient.Builder authenticator(@Nullable @Nullable IgniteClientAuthenticator authenticator)
      Sets the authenticator.

      See also: BasicAuthenticator.

      Parameters:
      authenticator - Authenticator.
      Returns:
      This instance.
    • operationTimeout

      public IgniteClient.Builder operationTimeout(long operationTimeout)
      Sets the operation timeout, in milliseconds. Default is 0 (no timeout).

      An "operation" is a single client request to the server. Some public API calls may involve multiple operations, in which case the operation timeout is applied to each individual network call.

      Parameters:
      operationTimeout - Operation timeout, in milliseconds.
      Returns:
      This instance.
      Throws:
      IllegalArgumentException - When value is less than zero.
    • cache

      public IgniteClient.Builder cache(@Nullable @Nullable ClientCacheConfiguration cacheConfiguration)
      Sets the cache configuration.
      Parameters:
      cacheConfiguration - Cache configuration.
      Returns:
      This instance.
    • build

      public IgniteClient build()
      Builds the client.
      Returns:
      Ignite client.
    • buildAsync

      public CompletableFuture<IgniteClient> buildAsync()
      Builds the client.
      Returns:
      Ignite client.