Interface AvailabilityStrategy
- All Known Implementing Classes:
PreferAvailabilityStrategy
,PreferConsistencyStrategy
public interface AvailabilityStrategy
Implementations decide what to do when the cache membership changes, either because new nodes joined, nodes left,
or there was a merge. The decision is then applied by calling one of the
AvailabilityStrategyContext
methods.
The strategy can also queue actions until the current rebalance ends, and execute them on
onRebalanceEnd(AvailabilityStrategyContext)
.
Method invocations are synchronized, so it's not possible to have concurrent invocations.- Since:
- 7.0
- Author:
- Mircea Markus, Dan Berindei
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isDataLost
(ConsistentHash consistentHash, Collection<Address> members) Checks that all segments have, at least, one owner online to ensure data availability.static <T> boolean
isDataLost
(ConsistentHash consistentHash, Collection<T> members, Function<Address, T> addressMapper) Checks that all segments have, at least, one owner online to ensure data availability.void
onClusterViewChange
(AvailabilityStrategyContext context, List<Address> clusterMembers) Called when the cluster view changed (e.g. because one or more nodes left abruptly).void
onGracefulLeave
(AvailabilityStrategyContext context, Address leaver) Called when a node leaves gracefully.void
onJoin
(AvailabilityStrategyContext context, Address joiner) Called when a node joins.void
onManualAvailabilityChange
(AvailabilityStrategyContext context, AvailabilityMode newAvailabilityMode) Called when the administrator manually changes the availability status.void
onPartitionMerge
(AvailabilityStrategyContext context, Map<Address, CacheStatusResponse> statusResponseMap) Called when two or more partitions merge, to compute the stable and current cache topologies for the merged cluster.void
Called when a rebalance ends.static ConsistentHash
ownersConsistentHash
(CacheTopology topology, ConsistentHashFactory chFactory) Compute the read consistent hash for a topology with anull
union consistent hash.
-
Method Details
-
ownersConsistentHash
Compute the read consistent hash for a topology with anull
union consistent hash. -
onJoin
Called when a node joins. -
onGracefulLeave
Called when a node leaves gracefully. -
onClusterViewChange
Called when the cluster view changed (e.g. because one or more nodes left abruptly). -
onPartitionMerge
void onPartitionMerge(AvailabilityStrategyContext context, Map<Address, CacheStatusResponse> statusResponseMap) Called when two or more partitions merge, to compute the stable and current cache topologies for the merged cluster. -
onRebalanceEnd
Called when a rebalance ends. Can be used to re-assess the state of the cache and apply pending changes. -
onManualAvailabilityChange
void onManualAvailabilityChange(AvailabilityStrategyContext context, AvailabilityMode newAvailabilityMode) Called when the administrator manually changes the availability status. -
isDataLost
static <T> boolean isDataLost(ConsistentHash consistentHash, Collection<T> members, Function<Address, T> addressMapper) Checks that all segments have, at least, one owner online to ensure data availability.- Type Parameters:
T
- The type of themembers
collection.- Parameters:
consistentHash
- TheConsistentHash
with the ownership.members
- The current online members.addressMapper
- AFunction
to map theAddress
to a different type, matching themembers
collection type.- Returns:
true
if some data is lost andfalse
otherwise.
-
isDataLost
Checks that all segments have, at least, one owner online to ensure data availability.This is a syntactic sugar for
isDataLost(ConsistentHash, Collection, Function)
when the type is anAddress
.- Parameters:
consistentHash
- TheConsistentHash
with the ownership.members
- The current online members.- Returns:
true
if some data is lost andfalse
otherwise.
-