public enum CommunicationStrategy extends Enum<CommunicationStrategy>
Selection strategies prioritize communication with certain servers over others. When the client loses its connection or cluster membership changes, the client will request a list of servers to which the client can connect. The address list should be prioritized.
| Enum Constant and Description |
|---|
ANY
The
ANY selection strategy allows the client to connect to any server in the cluster. |
FOLLOWERS
The
FOLLOWERS selection strategy forces the client to connect only to followers. |
LEADER
The
LEADER selection strategy forces the client to attempt to connect to the cluster's leader. |
| Modifier and Type | Method and Description |
|---|---|
abstract List<io.atomix.cluster.MemberId> |
selectConnections(io.atomix.cluster.MemberId leader,
List<io.atomix.cluster.MemberId> members)
Returns a prioritized list of servers to which the client can connect and submit operations.
|
static CommunicationStrategy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static CommunicationStrategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CommunicationStrategy ANY
ANY selection strategy allows the client to connect to any server in the cluster. Clients
will attempt to connect to a random server, and the client will persist its connection with the first server
through which it is able to communicate. If the client becomes disconnected from a server, it will attempt
to connect to the next random server again.public static final CommunicationStrategy LEADER
LEADER selection strategy forces the client to attempt to connect to the cluster's leader.
Connecting to the leader means the client's operations are always handled by the first server to receive
them. However, clients connected to the leader will not significantly benefit from operations
with lower consistency levels, and more clients connected to the leader could mean more load on a single
point in the cluster.
If the client is unable to find a leader in the cluster, the client will connect to a random server.
public static final CommunicationStrategy FOLLOWERS
FOLLOWERS selection strategy forces the client to connect only to followers. Connecting to
followers ensures that the leader is not overloaded with direct client requests. This strategy should be
used when clients frequently submit operations with lower consistency levels that don't need to
be forwarded to the cluster leader. For clients that frequently submit commands or queries with linearizable
consistency, the LEADER ConnectionStrategy may be more performant.public static CommunicationStrategy[] values()
for (CommunicationStrategy c : CommunicationStrategy.values()) System.out.println(c);
public static CommunicationStrategy valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic abstract List<io.atomix.cluster.MemberId> selectConnections(io.atomix.cluster.MemberId leader, List<io.atomix.cluster.MemberId> members)
The client will iterate the provided MemberId list in order, attempting to connect to
each listed server until all servers have been exhausted. Implementations should provide a
complete list of servers with which the client can communicate. Limiting the server list
only to a single server such as the leader may result in the client failing, such as in
the event that no leader exists or the client is partitioned from the leader.
leader - The current cluster leader. The leader may be null if no current
leader exists.members - The full list of available servers. The provided server list is representative
of the most recent membership update received by the client. The server list
may evolve over time as the structure of the cluster changes.Copyright © 2013–2018. All rights reserved.