@GridToStringExclude public class GridDhtPartitionTopologyImpl extends Object implements GridDhtPartitionTopology
| Modifier and Type | Class and Description |
|---|---|
static interface |
GridDhtPartitionTopologyImpl.PartitionFactory
Partition factory used for (re-)creating partitions during their lifecycle.
|
| Constructor and Description |
|---|
GridDhtPartitionTopologyImpl(GridCacheSharedContext ctx,
CacheGroupContext grp) |
| 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 affReady,
boolean updateMoving)
Pre-initializes this topology.
|
void |
collectUpdateCounters(CachePartitionPartialCountersMap cntrMap)
Collects update counters collected during exchange.
|
Iterable<GridDhtLocalPartition> |
currentLocalPartitions() |
boolean |
detectLostPartitions(AffinityTopologyVersion resTopVer,
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() |
GridDhtLocalPartition |
getOrCreatePartition(int p)
Creates partition with id
p if it doesn't exist or evicted. |
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() |
GridDhtLocalPartition |
localPartition(int part) |
@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 |
onCacheStopped(int cacheId) |
void |
onExchangeDone(@Nullable GridDhtPartitionsExchangeFuture fut,
AffinityAssignment assignment,
boolean updateRebalanceVer)
Callback on exchange done.
|
void |
onReconnected() |
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.
|
void |
partitionFactory(GridDhtPartitionTopologyImpl.PartitionFactory factory)
Set partition factory to use.
|
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 resTopVer)
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.
|
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 incomeCntrMap,
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,
@NotNull DiscoCache discoCache,
long updSeq,
boolean stopping)
Updates topology version.
|
public GridDhtPartitionTopologyImpl(GridCacheSharedContext ctx, CacheGroupContext grp)
ctx - Cache shared context.grp - Cache group.public void partitionFactory(GridDhtPartitionTopologyImpl.PartitionFactory factory)
factory - Factory.public int partitions()
partitions in interface GridDhtPartitionTopologypublic int groupId()
groupId in interface GridDhtPartitionTopologypublic void onReconnected()
public 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, @NotNull @NotNull 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) throws IgniteInterruptedCheckedException
initPartitionsWhenAffinityReady in interface GridDhtPartitionTopologyaffVer - Affinity version.exchFut - Exchange future.True if partitions must be refreshed.IgniteInterruptedCheckedException - If interrupted.public void beforeExchange(GridDhtPartitionsExchangeFuture exchFut, boolean affReady, boolean updateMoving) throws IgniteCheckedException
beforeExchange in interface GridDhtPartitionTopologyexchFut - Exchange future.affReady - 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)
afterExchange in interface GridDhtPartitionTopologyexchFut - Exchange future.True if mapping was changed.@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 getOrCreatePartition(int p)
p if it doesn't exist or evicted.
In other case returns existing partition.p - Partition number.public GridDhtLocalPartition forceCreatePartition(int p) throws IgniteCheckedException
forceCreatePartition in interface GridDhtPartitionTopologyp - Partition ID.IgniteCheckedException - If failed.public void releasePartitions(int... parts)
releasePartitions in interface GridDhtPartitionTopologyparts - Partitions to release (should be reserved before).public GridDhtLocalPartition localPartition(int part)
localPartition in interface GridDhtPartitionTopologypart - Partition number.public List<GridDhtLocalPartition> localPartitions()
localPartitions in interface GridDhtPartitionTopologypublic Iterable<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 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 incomeCntrMap,
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.incomeCntrMap - 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(@Nullable
@Nullable GridDhtPartitionsExchangeFuture fut,
AffinityAssignment assignment,
boolean updateRebalanceVer)
onExchangeDone in interface GridDhtPartitionTopologyassignment - New affinity assignment.updateRebalanceVer - True if need check rebalance state.public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, GridDhtPartitionsExchangeFuture fut)
detectLostPartitions in interface GridDhtPartitionTopologyresTopVer - Exchange result version.fut - Exchange futute for topology events to detect.True if partitions state got updated.public void resetLostPartitions(AffinityTopologyVersion resTopVer)
resetLostPartitions in interface GridDhtPartitionTopologyresTopVer - Exchange result version.public Set<Integer> lostPartitions()
lostPartitions in interface GridDhtPartitionTopologypublic 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 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 void finalizeUpdateCounters(Set<Integer> parts)
finalizeUpdateCounters in interface GridDhtPartitionTopologyparts - Partitions.public CachePartitionFullCountersMap fullUpdateCounters()
fullUpdateCounters in interface GridDhtPartitionTopologypublic CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros)
localUpdateCounters in interface GridDhtPartitionTopologyskipZeros - True to exclude zero counters from map.public Map<Integer,Long> partitionSizes()
partitionSizes in interface GridDhtPartitionTopologypublic 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 onCacheStopped(int cacheId)
cacheId - Cache ID.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.1 Release Date : December 20 2021