Class ClientFailoverConfig

Direct Known Subclasses:
ClientFailoverClasspathXmlConfig, ClientFailoverClasspathYamlConfig

public class ClientFailoverConfig
extends Object
Config class to configure multiple client configs to be used by single client instance. The client will try to connect them in given order. When the connected cluster fails or the client blacklisted from the cluster via the Management Center, the client will search for alternative clusters with given configs.

The client configurations must be exactly the same except the following configuration options:

  • clusterName
  • SecurityConfig
  • NetworkConfig.Addresses
  • NetworkConfig.SocketInterceptorConfig
  • NetworkConfig.SSLConfig
  • NetworkConfig.AwsConfig
  • NetworkConfig.GcpConfig
  • NetworkConfig.AzureConfig
  • NetworkConfig.KubernetesConfig
  • NetworkConfig.EurekaConfig
  • NetworkConfig.CloudConfig
  • NetworkConfig.DiscoveryConfig
  • Constructor Details

  • Method Details

    • load

      public static ClientFailoverConfig load()
      Populates Hazelcast ClientFailoverConfig object from an external configuration file.

      It tries to load Hazelcast Failover Client configuration from a list of well-known locations. When no location contains Hazelcast Failover Client configuration then it returns default.

      Note that the same mechanism is used when calling HazelcastClient.newHazelcastFailoverClient().

      ClientFailoverConfig created from a file when exists, otherwise default.
    • addClientConfig

      public ClientFailoverConfig addClientConfig​(ClientConfig clientConfig)
      Adds the client config to the end of the alternative client configurations list.
      clientConfig - the ClientConfig to add
      this for chaining
    • setTryCount

      public ClientFailoverConfig setTryCount​(int tryCount)
      Sets the count of attempts to connect to a cluster. For each alternative cluster, the client will try to connect to the cluster respecting related ConnectionRetryConfig.

      When the client can not connect a cluster, it will try to connect tryCount times going over the alternative client configs in a round-robin fashion. This is triggered at the start and also when the client disconnects from the cluster and can not connect back to it by exhausting attempts described in ConnectionRetryConfig. In that case, the client will continue from where it is left off in ClientConfig lists, and try the next one again in round-robin tryCount times.

      For example, if two alternative clusters are given in the ClientConfig list and the tryCount is set as 4, the maximum number of subsequent connection attempts done by the client is 4 x 2 = 8.

      tryCount - the count of attempts
      this for chaining
    • getClientConfigs

      public List<ClientConfig> getClientConfigs()
      Gets the configured list of alternative client configurations.
      the list of configured ClientConfigs
    • setClientConfigs

      public ClientFailoverConfig setClientConfigs​(List<ClientConfig> clientConfigs)
      Sets the configured list of alternative client configurations.

      Note: this method replaces previously configured alternative client configurations with the given list.

      clientConfigs - the list of ClientConfigs to be used
      this for chaining
    • getTryCount

      public int getTryCount()
      Returns the count of attempts to connect to a cluster. Default value is Integer.MAX_VALUE.
      the count of attempts
    • toString

      public String toString()
      toString in class Object