Class Topology
The topology is a snapshot of the current state of the replication domain. It contains the list of replicas and their coordinates, as well as the domain state.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Represents the domain state.static class
Represents the location of a replica.static enum
The status of a replica.static final record
Represents the coordinates of a replica.static final record
The information of a replica returned by the topology. -
Constructor Summary
ConstructorsConstructorDescriptionTopology
(Map<ReplicaId, Topology.ReplicaInfo> replicas, Topology.DomainState domainState) Constructor of a new Topology. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current state of the domain.Returns the information of replicas participating in the topology.getReplicasToFetchFrom
(ReplicaId fetchingReplica) Returns the set of replica IDs from which the specified fetching replica should fetch changes.getReplicasToFetchInsteadOf
(ReplicaId unreachableReplica, ReplicaId fetchingReplica) Returns the set of replica IDs from which the specified fetching replica should fetch changes instead of the unreachable replica.
-
Constructor Details
-
Topology
Constructor of a new Topology.- Parameters:
replicas
- the information of replicas participating in the topologydomainState
- the current state of the domain
-
-
Method Details
-
getReplicas
Returns the information of replicas participating in the topology.- Returns:
- the information of replicas participating in the topology.
-
getDomainState
Returns the current state of the domain.- Returns:
- the current state of the domain.
-
getReplicasToFetchFrom
Returns the set of replica IDs from which the specified fetching replica should fetch changes.A replica must always fetch changes from all replicas in the same location. Additionally, if the replica is the leader of a location branch level, it must also fetch changes from the leaders of location branch levels with the same parent branch level.
The leader is the replica with the minimum replica ID amongst the replicas in the same location branch level.
- Parameters:
fetchingReplica
- the ID of the replica that is fetching changes- Returns:
- a set of replica IDs from which the specified fetching replica should fetch changes
- See Also:
-
for more information about location branch levels and leaders computation
-
getReplicasToFetchInsteadOf
public Set<ReplicaId> getReplicasToFetchInsteadOf(ReplicaId unreachableReplica, ReplicaId fetchingReplica) Returns the set of replica IDs from which the specified fetching replica should fetch changes instead of the unreachable replica.If the unreachable replica is the leader of a location branch level, the fetching replica should fetch from the next leader of that location branch level instead. If the fetching replica is the new leader for that location branch level, it must behave as the leader and fetch from leaders of location branch levels with the same parent.
The leader is defined as the replica with the lowest replica ID amongst the replicas in the same location branch level.
- Parameters:
unreachableReplica
- the ID of the unreachable replicafetchingReplica
- the ID of the replica that is fetching changes- Returns:
- a set of replica IDs from which the specified fetching replica should fetch changes instead of the unreachable replica
- See Also:
-
for more information about location branch levels and leaders computation
-