@GridToStringExclude public class GridClientPartitionTopology extends Object implements GridDhtPartitionTopology
| Constructor and Description |
|---|
GridClientPartitionTopology(GridCacheSharedContext<?,?> cctx,
DiscoCache discoCache,
int grpId,
int parts,
Object similarAffKey,
PartitionLossPolicy partLossPlc) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
afterExchange(GridDhtPartitionsExchangeFuture exchFut)
Post-initializes this topology.
|
void |
afterStateRestored(AffinityTopologyVersion topVer)
Initializes local data structures after partitions are restored from persistence.
|
List<List<ClusterNode>> |
allOwners() |
void |
applyUpdateCounters()
Applies update counters collected during exchange on coordinator.
|
void |
beforeExchange(GridDhtPartitionsExchangeFuture exchFut,
boolean initParts,
boolean updateMoving)
Pre-initializes this topology.
|
void |
collectUpdateCounters(CachePartitionPartialCountersMap cntrMap)
Collects update counters collected during exchange.
|
Collection<GridDhtLocalPartition> |
currentLocalPartitions() |
boolean |
detectLostPartitions(AffinityTopologyVersion affVer,
GridDhtPartitionsExchangeFuture fut)
Checks if there is at least one owner for each partition in the cache topology for a local node.
|
void |
finalizeUpdateCounters(Set<Integer> parts)
Pre-processes partition update counters before exchange.
|
GridDhtLocalPartition |
forceCreatePartition(int p)
Unconditionally creates partition during restore of persisted partition state.
|
CachePartitionFullCountersMap |
fullUpdateCounters() |
@Nullable Map<Integer,Long> |
globalPartSizes() |
void |
globalPartSizes(@Nullable Map<Integer,Long> partSizes) |
int |
groupId() |
boolean |
hasMovingPartitions() |
boolean |
holdsLock() |
boolean |
initialized() |
boolean |
initPartitionsWhenAffinityReady(AffinityTopologyVersion affVer,
GridDhtPartitionsExchangeFuture exchFut) |
AffinityTopologyVersion |
lastTopologyChangeVersion() |
long |
lastUpdateSequence() |
GridDhtLocalPartition |
localPartition(int p) |
@Nullable GridDhtLocalPartition |
localPartition(int p,
AffinityTopologyVersion topVer,
boolean create) |
@Nullable GridDhtLocalPartition |
localPartition(int p,
AffinityTopologyVersion topVer,
boolean create,
boolean showRenting) |
GridDhtPartitionMap |
localPartitionMap() |
List<GridDhtLocalPartition> |
localPartitions() |
CachePartitionPartialCountersMap |
localUpdateCounters(boolean skipZeros) |
Set<Integer> |
lostPartitions() |
List<ClusterNode> |
moving(int p) |
@Nullable List<ClusterNode> |
nodes(int p,
AffinityAssignment affAssignment,
List<ClusterNode> affNodes) |
List<ClusterNode> |
nodes(int p,
AffinityTopologyVersion topVer) |
void |
onExchangeDone(GridDhtPartitionsExchangeFuture fut,
AffinityAssignment assignment,
boolean updateRebalanceVer)
Callback on exchange done.
|
void |
onRemoved(GridDhtCacheEntry e) |
boolean |
own(GridDhtLocalPartition part) |
List<ClusterNode> |
owners(int p) |
List<ClusterNode> |
owners(int p,
AffinityTopologyVersion topVer) |
void |
ownMoving()
Owns all moving partitions.
|
GridDhtPartitionFullMap |
partitionMap(boolean onlyActive) |
int |
partitions() |
@Nullable GridDhtPartitionMap |
partitions(UUID nodeId) |
Map<Integer,Long> |
partitionSizes() |
GridDhtPartitionState |
partitionState(UUID nodeId,
int part) |
void |
printMemoryStats(int threshold)
Prints memory stats.
|
void |
readLock()
Locks the topology, usually during mapping on locks or transactions.
|
void |
readUnlock()
Unlocks topology locked by
GridDhtPartitionTopology.readLock() method. |
AffinityTopologyVersion |
readyTopologyVersion() |
boolean |
rebalanceFinished(AffinityTopologyVersion topVer) |
void |
releasePartitions(int... parts) |
boolean |
rent(int p)
Rents a partition and updates a partition map if the partition was switched to RENTING.
|
void |
resetLostPartitions(AffinityTopologyVersion affVer)
Resets the state of all LOST partitions to OWNING.
|
Map<UUID,Set<Integer>> |
resetOwners(Map<Integer,Set<UUID>> ownersByUpdCounters,
Set<Integer> haveHist,
GridDhtPartitionsExchangeFuture exchFut)
Calculates nodes and partitions which have non-actual state (based on LWM value) and must be rebalanced.
|
@Nullable Object |
similarAffinityKey() |
boolean |
stopping() |
GridDhtTopologyFuture |
topologyVersionFuture()
Gets a future that will be completed when partition exchange map for this
particular topology version is done.
|
boolean |
tryFinishEviction(GridDhtLocalPartition part) |
boolean |
update(@Nullable AffinityTopologyVersion exchangeVer,
GridDhtPartitionFullMap partMap,
@Nullable CachePartitionFullCountersMap cntrMap,
Set<Integer> partsToReload,
@Nullable Map<Integer,Long> partSizes,
@Nullable AffinityTopologyVersion msgTopVer,
@Nullable GridDhtPartitionsExchangeFuture exchFut,
@Nullable Set<Integer> lostParts) |
boolean |
update(@Nullable GridDhtPartitionExchangeId exchId,
GridDhtPartitionMap parts,
boolean force) |
long |
updateSequence() |
void |
updateTopologyVersion(GridDhtTopologyFuture exchFut,
DiscoCache discoCache,
long updSeq,
boolean stopping)
Updates topology version.
|
public GridClientPartitionTopology(GridCacheSharedContext<?,?> cctx, DiscoCache discoCache, int grpId, int parts, Object similarAffKey, PartitionLossPolicy partLossPlc)
cctx - Context.discoCache - Discovery data cache.grpId - Group ID.parts - Number of partitions in the group.similarAffKey - Key to find caches with similar affinity.partLossPlc - Loss policy.public int partitions()
partitions in interface GridDhtPartitionTopology@Nullable public @Nullable Object similarAffinityKey()
public int groupId()
groupId in interface GridDhtPartitionTopologypublic void readLock()
readLock in interface GridDhtPartitionTopologypublic void readUnlock()
GridDhtPartitionTopology.readLock() method.readUnlock in interface GridDhtPartitionTopologypublic boolean holdsLock()
holdsLock in interface GridDhtPartitionTopologyTrue if locked by current thread.public void updateTopologyVersion(GridDhtTopologyFuture exchFut, DiscoCache discoCache, long updSeq, boolean stopping) throws IgniteInterruptedCheckedException
updateTopologyVersion in interface GridDhtPartitionTopologyexchFut - Exchange future.discoCache - Discovery data cache.updSeq - Update sequence.stopping - Stopping flag.IgniteInterruptedCheckedException - If interrupted.public boolean initialized()
initialized in interface GridDhtPartitionTopologyTrue If ready version initialized. False If not initialized.public AffinityTopologyVersion readyTopologyVersion()
readyTopologyVersion in interface GridDhtPartitionTopologypublic AffinityTopologyVersion lastTopologyChangeVersion()
lastTopologyChangeVersion in interface GridDhtPartitionTopologypublic GridDhtTopologyFuture topologyVersionFuture()
topologyVersionFuture in interface GridDhtPartitionTopologypublic boolean stopping()
stopping in interface GridDhtPartitionTopologyTrue if cache is being stopped.public boolean initPartitionsWhenAffinityReady(AffinityTopologyVersion affVer, GridDhtPartitionsExchangeFuture exchFut)
initPartitionsWhenAffinityReady in interface GridDhtPartitionTopologyaffVer - Affinity version.exchFut - Exchange future.True if partitions must be refreshed.public void beforeExchange(GridDhtPartitionsExchangeFuture exchFut, boolean initParts, boolean updateMoving) throws IgniteCheckedException
beforeExchange in interface GridDhtPartitionTopologyexchFut - Exchange future.initParts - Affinity ready flag.updateMoving - True to initialize partition maps with moving partitions.IgniteCheckedException - If failed.public void afterStateRestored(AffinityTopologyVersion topVer)
afterStateRestored in interface GridDhtPartitionTopologytopVer - Topology version.public boolean afterExchange(GridDhtPartitionsExchangeFuture exchFut) throws IgniteCheckedException
afterExchange in interface GridDhtPartitionTopologyexchFut - Exchange future.True if mapping was changed.IgniteCheckedException - If failed.@Nullable public @Nullable GridDhtLocalPartition localPartition(int p, AffinityTopologyVersion topVer, boolean create) throws GridDhtInvalidPartitionException
localPartition in interface GridDhtPartitionTopologyp - Partition ID.topVer - Topology version at the time of creation.create - If true, then partition will be created if it's not there.GridDhtInvalidPartitionException - If partition is evicted or absent and
does not belong to this node.@Nullable public @Nullable GridDhtLocalPartition localPartition(int p, AffinityTopologyVersion topVer, boolean create, boolean showRenting) throws GridDhtInvalidPartitionException
localPartition in interface GridDhtPartitionTopologyp - Partition ID.topVer - Topology version at the time of creation.create - If true, then partition will be created if it's not there.GridDhtInvalidPartitionException - If partition is evicted or absent and
does not belong to this node.public GridDhtLocalPartition forceCreatePartition(int p) throws IgniteCheckedException
forceCreatePartition in interface GridDhtPartitionTopologyp - Partition ID.IgniteCheckedException - If failed.public GridDhtLocalPartition localPartition(int p)
localPartition in interface GridDhtPartitionTopologyp - Partition number.public void releasePartitions(int... parts)
releasePartitions in interface GridDhtPartitionTopologyparts - Partitions to release (should be reserved before).public List<GridDhtLocalPartition> localPartitions()
localPartitions in interface GridDhtPartitionTopologypublic Collection<GridDhtLocalPartition> currentLocalPartitions()
currentLocalPartitions in interface GridDhtPartitionTopologypublic void onRemoved(GridDhtCacheEntry e)
onRemoved in interface GridDhtPartitionTopologye - Entry removed from cache.public GridDhtPartitionMap localPartitionMap()
localPartitionMap in interface GridDhtPartitionTopologypublic GridDhtPartitionState partitionState(UUID nodeId, int part)
partitionState in interface GridDhtPartitionTopologynodeId - Node ID.part - Partition.@Nullable public @Nullable List<ClusterNode> nodes(int p, AffinityAssignment affAssignment, List<ClusterNode> affNodes)
nodes in interface GridDhtPartitionTopologyp - Partition ID.affAssignment - Assignments.affNodes - Node assigned for given partition by affinity.public List<ClusterNode> nodes(int p, AffinityTopologyVersion topVer)
nodes in interface GridDhtPartitionTopologyp - Partition ID.topVer - Topology version.public List<ClusterNode> owners(int p, AffinityTopologyVersion topVer)
owners in interface GridDhtPartitionTopologyp - Partition ID.topVer - Topology version.own this partition.public List<ClusterNode> owners(int p)
owners in interface GridDhtPartitionTopologyp - Partition ID.own this partition.public List<List<ClusterNode>> allOwners()
allOwners in interface GridDhtPartitionTopologypublic List<ClusterNode> moving(int p)
moving in interface GridDhtPartitionTopologyp - Partition ID.are preloading this partition.public long updateSequence()
updateSequence in interface GridDhtPartitionTopologypublic long lastUpdateSequence()
public GridDhtPartitionFullMap partitionMap(boolean onlyActive)
partitionMap in interface GridDhtPartitionTopologyonlyActive - If true, then only active partitions will be returned.public boolean update(@Nullable
@Nullable AffinityTopologyVersion exchangeVer,
GridDhtPartitionFullMap partMap,
@Nullable
@Nullable CachePartitionFullCountersMap cntrMap,
Set<Integer> partsToReload,
@Nullable
@Nullable Map<Integer,Long> partSizes,
@Nullable
@Nullable AffinityTopologyVersion msgTopVer,
@Nullable
@Nullable GridDhtPartitionsExchangeFuture exchFut,
@Nullable
@Nullable Set<Integer> lostParts)
update in interface GridDhtPartitionTopologyexchangeVer - Result topology version for exchange. Value should be greater than previously passed. Null value
means full map received is not related to exchangepartMap - Update partition map.cntrMap - Partition update counters.partsToReload - Set of partitions that need to be reloaded.partSizes - Global partition sizes.msgTopVer - Topology version from incoming message. This value is not null only for case message is not
related to exchange. Value should be not less than previous 'Topology version from exchange'.exchFut - Future which is not null for initial partition update on exchange.lostParts - Lost partitions.True if local state was changed.public void collectUpdateCounters(CachePartitionPartialCountersMap cntrMap)
collectUpdateCounters in interface GridDhtPartitionTopologycntrMap - Counters map.public void applyUpdateCounters()
applyUpdateCounters in interface GridDhtPartitionTopologypublic boolean update(@Nullable
@Nullable GridDhtPartitionExchangeId exchId,
GridDhtPartitionMap parts,
boolean force)
update in interface GridDhtPartitionTopologyexchId - Exchange ID.parts - Partitions.force - True to skip stale update check.True if local state was changed.public void onExchangeDone(GridDhtPartitionsExchangeFuture fut, AffinityAssignment assignment, boolean updateRebalanceVer)
onExchangeDone in interface GridDhtPartitionTopologyassignment - New affinity assignment.updateRebalanceVer - True if need check rebalance state.public boolean detectLostPartitions(AffinityTopologyVersion affVer, GridDhtPartitionsExchangeFuture fut)
detectLostPartitions in interface GridDhtPartitionTopologyaffVer - Exchange result version.fut - Exchange futute for topology events to detect.True if partitions state got updated.public void resetLostPartitions(AffinityTopologyVersion affVer)
resetLostPartitions in interface GridDhtPartitionTopologyaffVer - Exchange result version.public Set<Integer> lostPartitions()
lostPartitions in interface GridDhtPartitionTopologypublic boolean own(GridDhtLocalPartition part)
own in interface GridDhtPartitionTopologypart - Partition to own.True if owned.public void ownMoving()
ownMoving in interface GridDhtPartitionTopologypublic boolean tryFinishEviction(GridDhtLocalPartition part)
tryFinishEviction in interface GridDhtPartitionTopologypart - Evicted partition.True if a partition was destroyed by this call.@Nullable public @Nullable GridDhtPartitionMap partitions(UUID nodeId)
partitions in interface GridDhtPartitionTopologynodeId - Node to get partitions for.public Map<UUID,Set<Integer>> resetOwners(Map<Integer,Set<UUID>> ownersByUpdCounters, Set<Integer> haveHist, GridDhtPartitionsExchangeFuture exchFut)
ownersByUpdCounters will be reset to MOVING.
Called on coordinator during assignment of partition states.resetOwners in interface GridDhtPartitionTopologyownersByUpdCounters - Map (partition, set of node IDs that have most actual state about partition
(update counter is maximal) and should hold OWNING state for such partition).haveHist - Set of partitions which have WAL history to rebalance.exchFut - Exchange future for operation.public CachePartitionFullCountersMap fullUpdateCounters()
fullUpdateCounters in interface GridDhtPartitionTopologypublic CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros)
localUpdateCounters in interface GridDhtPartitionTopologyskipZeros - True to exclude zero counters from map.public void finalizeUpdateCounters(Set<Integer> parts)
finalizeUpdateCounters in interface GridDhtPartitionTopologyparts - Partitions.public Map<Integer,Long> partitionSizes()
partitionSizes in interface GridDhtPartitionTopology@Nullable public @Nullable Map<Integer,Long> globalPartSizes()
globalPartSizes in interface GridDhtPartitionTopologypublic void globalPartSizes(@Nullable
@Nullable Map<Integer,Long> partSizes)
globalPartSizes in interface GridDhtPartitionTopologypartSizes - Sizes of up-to-date partition versions in topology.public boolean rebalanceFinished(AffinityTopologyVersion topVer)
rebalanceFinished in interface GridDhtPartitionTopologytopVer - Topology version.True if rebalance process finished.public boolean hasMovingPartitions()
hasMovingPartitions in interface GridDhtPartitionTopologyTrue If one of cache nodes has partitions in GridDhtPartitionState.MOVING state.public void printMemoryStats(int threshold)
printMemoryStats in interface GridDhtPartitionTopologythreshold - Threshold for number of entries.public boolean rent(int p)
rent in interface GridDhtPartitionTopologyp - Partition ID.True if the partition was switched to RENTING.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.11.0 Release Date : September 11 2021