public interface Member
This interface provides metadata and operations related to a specific member of a Copycat cluster.
Each server in a Cluster has a view of the cluster state and can reference and operate on
specific members of the cluster via this API.
Each member in the cluster has an associated Member.Type and Member.Status. The
Member.Type is indicative of the manner in which the member interacts with other members of
the cluster. The Member.Status is indicative of the leader's ability to communicate with the
member. Additionally, each member is identified by an address and unique ID
which is generated from the Address hash code. The member's Address represents the
address through which the server communicates with other servers and not through which clients
communicate with the member (which may be a different Address).
Users can listen for Member.Type and Member.Status changes via the
onTypeChange(Consumer) and onStatusChange(Consumer) methods respectively. Member types
can be modified by virtually any member of the cluster via the promote() and demote()
methods. This allows servers to modify the way dead nodes interact with the cluster and modify the
Raft quorum size without requiring the member being modified to be available. The member status is
controlled only by the cluster leader. When the leader fails to contact a
member for a few rounds of heartbeats, the leader will commit a configuration change marking that
member as Member.Status.UNAVAILABLE. Once the member can be reached again, the leader will
update its status back to Member.Status.AVAILABLE.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Member.Status
Indicates the availability of a member from the perspective of the cluster
leader. |
static class |
Member.Type
Indicates how the member participates in voting and replication.
|
| Modifier and Type | Method and Description |
|---|---|
Address |
address()
Returns the member server address.
|
Address |
clientAddress()
Returns the member client address.
|
CompletableFuture<Void> |
demote()
Demotes the member to the next lowest type.
|
CompletableFuture<Void> |
demote(Member.Type type)
Demotes the member to the given type.
|
int |
id()
Returns the member ID.
|
Listener<Member.Status> |
onStatusChange(Consumer<Member.Status> callback)
Registers a callback to be called when the member's status changes.
|
Listener<Member.Type> |
onTypeChange(Consumer<Member.Type> callback)
Registers a callback to be called when the member's type changes.
|
CompletableFuture<Void> |
promote()
Promotes the member to the next highest type.
|
CompletableFuture<Void> |
promote(Member.Type type)
Promotes the member to the given type.
|
CompletableFuture<Void> |
remove()
Removes the member from the configuration.
|
Address |
serverAddress()
Returns the member server address.
|
Member.Status |
status()
Returns the member status.
|
Member.Type |
type()
Returns the member type.
|
Instant |
updated()
Returns the time at which the member was updated.
|
int id()
The member ID is calculated as the hash of the member's server Address and is therefore
equivalent to the return value of Address.hashCode(). The member ID simply provides a more
compact identifier to send on the wire when communicating between servers.
Address address()
This is the primary address through which servers in the cluster identify and communicate with one another. The server address is guaranteed to be unique to each member in the cluster.
serverAddress().Address clientAddress()
THis is the address through which clients communicate with the member. Depending on the member's configuration,
the client address may or may not be the same as the serverAddress(), but it will always be non-null.
Address serverAddress()
The server address is the primary address through which servers in the cluster communicate with one another. The server address is guaranteed to be unique to each member in the cluster.
Member.Type type()
The member type is indicative of the member's level of participation in the Raft consensus algorithm and
asynchronous replication within the cluster. Member types may change throughout the lifetime of the cluster.
Types can be changed by promoting or demoting the member. Member
types for a given member are guaranteed to change in the same order on all nodes, but the type of a member
may be different from the perspective of different nodes at any given time.
Listener<Member.Type> onTypeChange(Consumer<Member.Type> callback)
The type change callback will be called when the local server receives notification of the change in type to this member. Type changes may occur at different times from the perspective of different servers but are guaranteed to occur in the same order on all servers.
callback - The callback to be called when the member's type changes.Member.Status status()
The status is indicative of the leader's ability to communicate with this member. If this member is a local
member, the member's status will be Member.Status.AVAILABLE while the server is alive and will not change
regardless of the leader's ability to communicate with the local member. Similarly, if the local server is
partitioned from the leader then changes in statuses seen on other nodes may not be visible to this node.
Status changes are guaranteed to occur in the same order on all nodes but without a real-time constraint.
Instant updated()
The member update time is not guaranteed to be consistent across servers or consistent across server restarts. The update time is guaranteed to be monotonically increasing.
Listener<Member.Status> onStatusChange(Consumer<Member.Status> callback)
The status change callback will be called when the local server receives notification of the change in status to this member. Status changes may occur at different times from the perspective of different servers but are guaranteed to occur in the same order on all servers.
callback - The callback to be called when the member's status changes.CompletableFuture<Void> promote()
If the member is promoted to Member.Type.ACTIVE the Raft quorum size will increase.
CompletableFuture<Void> promote(Member.Type type)
If the member is promoted to Member.Type.ACTIVE the Raft quorum size will increase.
type - The type to which to promote the member.CompletableFuture<Void> demote()
If the member is an Member.Type.ACTIVE member then demoting it will impact the Raft quorum size.
CompletableFuture<Void> demote(Member.Type type)
If the member is an Member.Type.ACTIVE member then demoting it will impact the Raft quorum size.
type - The type to which to demote the member.CompletableFuture<Void> remove()
If the member is a part of the current Raft quorum (is an Member.Type.ACTIVE member) then the
quorum will be impacted by removing the member.
Copyright © 2013–2016. All rights reserved.