Class ClientFailoverConfig
- Direct Known Subclasses:
ClientFailoverClasspathXmlConfig
,ClientFailoverClasspathYamlConfig
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddClientConfig
(ClientConfig clientConfig) Adds the client config to the end of the alternative client configurations list.Gets the configured list of alternative client configurations.int
Sets the count that the client iterates over the given list of alternative clusters.static ClientFailoverConfig
load()
Populates HazelcastClientFailoverConfig
object from an external configuration file.setClientConfigs
(List<ClientConfig> clientConfigs) Sets the configured list of alternative client configurations.setTryCount
(int tryCount) Sets the count that the client iterates over the given list of alternative clusters.toString()
-
Constructor Details
-
ClientFailoverConfig
public ClientFailoverConfig()
-
-
Method Details
-
load
Populates HazelcastClientFailoverConfig
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()
.- Returns:
- ClientFailoverConfig created from a file when exists, otherwise default.
-
addClientConfig
Adds the client config to the end of the alternative client configurations list.- Parameters:
clientConfig
- the ClientConfig to add- Returns:
- this for chaining
-
setTryCount
Sets the count that the client iterates over the given list of alternative clusters. 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 X number of alternative cluster times.
Example: Assume that 3 alternative clusters are given in the ClientConfig list. Let's call them cluster A , B and C . When the tryCount is set as 2, the maximum number of subsequent connection attempts done by the client is 3 x 2 = 6. They will be tried in the following order as long as the client can not connect to any of them: A -> B -> C -> A -> B -> C -> Client Shutdown. Trial 1 -> Trial 2 -> Client Shutdown.
Assume that client was connected to cluster B, and then it is disconnected from it. In that case, the trial oder will be as follows: C -> A -> B -> C -> A -> B -> Client Shutdown. Trial 1 -> Trial 2 -> Client Shutdown.
- Parameters:
tryCount
- the count of attempts- Returns:
- this for chaining
-
getClientConfigs
Gets the configured list of alternative client configurations.- Returns:
- the list of configured ClientConfigs
-
setClientConfigs
Sets the configured list of alternative client configurations.Note: this method replaces previously configured alternative client configurations with the given list.
- Parameters:
clientConfigs
- the list of ClientConfigs to be used- Returns:
- this for chaining
-
getTryCount
public int getTryCount()Sets the count that the client iterates over the given list of alternative clusters. For each alternative cluster, the client will try to connect to the cluster respecting related ConnectionRetryConfig. Default value isInteger.MAX_VALUE
.- Returns:
- the max try count
-
toString
-