Class GridCachePartitionExchangeManager<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter<K,V>
-
- org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager<K,V>
-
- All Implemented Interfaces:
GridCacheSharedManager<K,V>
public class GridCachePartitionExchangeManager<K,V> extends GridCacheSharedManagerAdapter<K,V>
Partition exchange manager.
-
-
Field Summary
Fields Modifier and Type Field Description static intDFLT_DIAGNOSTIC_WARN_LIMITstatic intDFLT_EXCHANGE_HISTORY_SIZEstatic intDFLT_EXCHANGE_MERGE_DELAYstatic StringFAILED_DUMP_MSGPrefix of error message for dumping long running operations.-
Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
cctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description GridCachePartitionExchangeManager()
-
Method Summary
-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
context, isStopping, kernalStartInfo, kernalStopInfo, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toString
-
-
-
-
Field Detail
-
FAILED_DUMP_MSG
public static final String FAILED_DUMP_MSG
Prefix of error message for dumping long running operations.- See Also:
- Constant Field Values
-
DFLT_EXCHANGE_HISTORY_SIZE
public static final int DFLT_EXCHANGE_HISTORY_SIZE
-
DFLT_EXCHANGE_MERGE_DELAY
public static final int DFLT_EXCHANGE_MERGE_DELAY
-
DFLT_DIAGNOSTIC_WARN_LIMIT
public static final int DFLT_DIAGNOSTIC_WARN_LIMIT
-
-
Method Detail
-
start0
protected void start0() throws IgniteCheckedException- Overrides:
start0in classGridCacheSharedManagerAdapter<K,V>- Throws:
IgniteCheckedException- If failed.
-
onCoordinatorInitialized
public void onCoordinatorInitialized()
-
onLocalJoin
public void onLocalJoin(DiscoveryEvent evt, DiscoCache cache)
Callback for local join event (needed since regular event for local join is not generated).- Parameters:
evt- Event.cache- Cache.
-
reconnectExchangeFuture
public IgniteInternalFuture<?> reconnectExchangeFuture()
- Returns:
- Reconnect partition exchange future.
-
onKernalStart
public AffinityTopologyVersion onKernalStart(boolean active, boolean reconnect) throws IgniteCheckedException
- Parameters:
active- Cluster state.reconnect- Reconnect flag.- Returns:
- Topology version of local join exchange if cluster is active. Topology version NONE if cluster is not active or reconnect.
- Throws:
IgniteCheckedException- If failed.
-
exchangeProtocolVersion
public static int exchangeProtocolVersion(IgniteProductVersion ver)
- Parameters:
ver- Node version.- Returns:
- Supported exchange protocol version.
-
rebalanceTopic
public static Object rebalanceTopic(int idx)
- Parameters:
idx- Index.- Returns:
- Topic for index.
-
onKernalStop0
protected void onKernalStop0(boolean cancel)
- Overrides:
onKernalStop0in classGridCacheSharedManagerAdapter<K,V>- Parameters:
cancel- Cancel flag.
-
stop0
protected void stop0(boolean cancel)
- Overrides:
stop0in classGridCacheSharedManagerAdapter<K,V>- Parameters:
cancel- Cancel flag.
-
clientTopologyIfExists
@Nullable public @Nullable GridDhtPartitionTopology clientTopologyIfExists(int grpId)
- Parameters:
grpId- Cache group ID.- Returns:
- Topology.
-
clientTopology
public GridDhtPartitionTopology clientTopology(int grpId, DiscoCache discoCache)
- Parameters:
grpId- Cache group ID.discoCache- Discovery data cache.- Returns:
- Topology.
-
clientTopologies
public Collection<GridClientPartitionTopology> clientTopologies()
- Returns:
- Collection of client topologies.
-
clearClientTopology
public GridClientPartitionTopology clearClientTopology(int grpId)
- Parameters:
grpId- Cache group ID.- Returns:
- Client partition topology.
-
readyAffinityVersion
public AffinityTopologyVersion readyAffinityVersion()
- Returns:
- Topology version of latest completed partition exchange.
-
lastTopologyFuture
public GridDhtPartitionsExchangeFuture lastTopologyFuture()
- Returns:
- Last initialized topology future.
-
lastFinishedFuture
@Nullable public @Nullable GridDhtPartitionsExchangeFuture lastFinishedFuture()
- Returns:
- Last finished topology future.
-
lastFinishedFuture
public void lastFinishedFuture(GridDhtPartitionsExchangeFuture fut)
- Parameters:
fut- Finished future.
-
affinityReadyFuture
@NotNull public @NotNull IgniteInternalFuture<AffinityTopologyVersion> affinityReadyFuture(AffinityTopologyVersion ver)
- Parameters:
ver- Topology version.- Returns:
- Future or
nullis future is already completed.
-
exchangeFutures
public List<GridDhtPartitionsExchangeFuture> exchangeFutures()
- Returns:
- Exchange futures.
-
hasPendingExchange
public boolean hasPendingExchange()
- Returns:
Trueif pending future queue contains exchange task.
-
hasPendingServerExchange
public boolean hasPendingServerExchange()
- Returns:
Trueif pending future queue contains server exchange task.
-
lastAffinityChangedTopologyVersion
public AffinityTopologyVersion lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer)
- Parameters:
topVer- Topology version.- Returns:
- Last topology version before the provided one when affinity was modified.
-
lastAffinityChangedTopologyVersion
public boolean lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer, AffinityTopologyVersion lastAffTopVer)
- Parameters:
topVer- Topology version.lastAffTopVer- Last topology version before the provided one when affinity was modified.- Returns:
Trueif data was modified.
-
forceReassign
public void forceReassign(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture fut)
- Parameters:
exchId- Exchange ID.
-
forceRebalance
public IgniteInternalFuture<Boolean> forceRebalance(GridDhtPartitionExchangeId exchId)
- Parameters:
exchId- Exchange ID.- Returns:
- Rebalance future.
-
finishPreloading
public void finishPreloading(AffinityTopologyVersion topVer, int grpId, long rebalanceId)
- Parameters:
topVer- Topology version.grpId- Group id.rebalanceId- Rebalance id.
-
deferStopCachesOnClientReconnect
public IgniteInternalFuture<Void> deferStopCachesOnClientReconnect(Collection<GridCacheAdapter> caches)
- Parameters:
caches- Caches to stop.- Returns:
- Future that will be completed when caches are stopped from the exchange thread.
-
scheduleResendPartitions
public void scheduleResendPartitions()
Schedules next full partitions update.
-
registerExchangeAwareComponent
public void registerExchangeAwareComponent(PartitionsExchangeAware comp)
Registers component that will be notified on every partition map exchange.- Parameters:
comp- Component to be registered.
-
unregisterExchangeAwareComponent
public void unregisterExchangeAwareComponent(PartitionsExchangeAware comp)
Removes exchange aware component from list of listeners.- Parameters:
comp- Component to be registered.
-
exchangeAwareComponents
public List<PartitionsExchangeAware> exchangeAwareComponents()
- Returns:
- List of registered exchange listeners.
-
refreshPartitions
public void refreshPartitions(@NotNull @NotNull Collection<CacheGroupContext> grps)Partition refresh callback for selected cache groups. For coordinator causesFullMessagessend, for non coordinator -SingleMessagessend- Parameters:
grps- Cache groups for partitions refresh.
-
refreshPartitions
public void refreshPartitions()
Partition refresh callback. For coordinator causesFullMessagessend, for non coordinator -SingleMessagessend
-
createPartitionsFullMessage
public GridDhtPartitionsFullMessage createPartitionsFullMessage(boolean compress, boolean newCntrMap, @Nullable @Nullable GridDhtPartitionExchangeId exchId, @Nullable @Nullable GridCacheVersion lastVer, @Nullable @Nullable IgniteDhtPartitionHistorySuppliersMap partHistSuppliers, @Nullable @Nullable IgniteDhtPartitionsToReloadMap partsToReload)
Creates partitions full message for all cache groups.- Parameters:
compress-Trueif possible to compress message (properly work only if prepareMarshall/ finishUnmarshall methods are called).newCntrMap-Trueif possible to useCachePartitionFullCountersMap.exchId- Non-null exchange ID if message is created for exchange.lastVer- Last version.partHistSuppliers- Partition history suppliers map.partsToReload- Partitions to reload map.- Returns:
- Message.
-
createPartitionsFullMessage
public GridDhtPartitionsFullMessage createPartitionsFullMessage(boolean compress, boolean newCntrMap, @Nullable @Nullable GridDhtPartitionExchangeId exchId, @Nullable @Nullable GridCacheVersion lastVer, @Nullable @Nullable IgniteDhtPartitionHistorySuppliersMap partHistSuppliers, @Nullable @Nullable IgniteDhtPartitionsToReloadMap partsToReload, Collection<CacheGroupContext> grps)
Creates partitions full message for selected cache groups.- Parameters:
compress-Trueif possible to compress message (properly work only if prepareMarshall/ finishUnmarshall methods are called).newCntrMap-Trueif possible to useCachePartitionFullCountersMap.exchId- Non-null exchange ID if message is created for exchange.lastVer- Last version.partHistSuppliers- Partition history suppliers map.partsToReload- Partitions to reload map.grps- Selected cache groups.- Returns:
- Message.
-
createPartitionsSingleMessage
public GridDhtPartitionsSingleMessage createPartitionsSingleMessage(@Nullable @Nullable GridDhtPartitionExchangeId exchangeId, boolean clientOnlyExchange, boolean sndCounters, boolean newCntrMap, ExchangeActions exchActions)
Creates partitions single message for all cache groups.- Parameters:
exchangeId- Exchange ID.clientOnlyExchange- Client exchange flag.sndCounters-Trueif need send partition update counters.newCntrMap-Trueif possible to useCachePartitionPartialCountersMap.- Returns:
- Message.
-
createPartitionsSingleMessage
public GridDhtPartitionsSingleMessage createPartitionsSingleMessage(@Nullable @Nullable GridDhtPartitionExchangeId exchangeId, boolean clientOnlyExchange, boolean sndCounters, boolean newCntrMap, ExchangeActions exchActions, Collection<CacheGroupContext> grps)
Creates partitions single message for selected cache groups.- Parameters:
exchangeId- Exchange ID.clientOnlyExchange- Client exchange flag.sndCounters-Trueif need send partition update counters.newCntrMap-Trueif possible to useCachePartitionPartialCountersMap.grps- Selected cache groups.- Returns:
- Message.
-
onExchangeDone
public void onExchangeDone(AffinityTopologyVersion topVer, AffinityTopologyVersion initTopVer, @Nullable @Nullable Throwable err)
- Parameters:
topVer- Exchange result topology version.initTopVer- Exchange initial version.err- Error.
-
processFullPartitionUpdate
public void processFullPartitionUpdate(ClusterNode node, GridDhtPartitionsFullMessage msg)
- Parameters:
node- Sender cluster node.msg- Message.
-
latch
public ExchangeLatchManager latch()
- Returns:
- Latch manager instance.
-
dumpDebugInfo
public void dumpDebugInfo(@Nullable @Nullable GridDhtPartitionsExchangeFuture exchFut) throws Exception- Parameters:
exchFut- Optional current exchange future.- Throws:
Exception- If failed.
-
checkRebalanceState
public void checkRebalanceState()
Force checking of rebalance state.
-
dumpLongRunningOperations
public void dumpLongRunningOperations(long timeout)
- Parameters:
timeout- Operation timeout.
-
mergeExchangesTestWaitVersion
public void mergeExchangesTestWaitVersion(AffinityTopologyVersion exchMergeTestWaitVer, @Nullable @Nullable List mergedEvtsForTest)
For testing only.- Parameters:
exchMergeTestWaitVer- Version to wait for.mergedEvtsForTest- List to collect discovery events with merged exchanges.
-
mergeExchangesTestWaitVersion
public AffinityTopologyVersion mergeExchangesTestWaitVersion()
For testing only.- Returns:
- Current version to wait for.
-
mergeExchanges
public boolean mergeExchanges(GridDhtPartitionsExchangeFuture curFut, GridDhtPartitionsFullMessage msg) throws IgniteInterruptedCheckedException
- Parameters:
curFut- Current exchange future.msg- Message.- Returns:
Trueif node is stopping.- Throws:
IgniteInterruptedCheckedException- If interrupted.
-
mergeExchangesOnCoordinator
public boolean mergeExchangesOnCoordinator(GridDhtPartitionsExchangeFuture curFut, @Nullable @Nullable AffinityTopologyVersion threshold)
- Parameters:
curFut- Current active exchange future.- Returns:
Falseif need wait messages for merged exchanges.
-
exchangerUpdateHeartbeat
public void exchangerUpdateHeartbeat()
InvokesGridWorker.updateHeartbeat()for exchange worker.
-
exchangerBlockingSectionBegin
public void exchangerBlockingSectionBegin()
InvokesGridWorker.blockingSectionBegin()for exchange worker. Should be called from exchange worker thread.
-
exchangerBlockingSectionEnd
public void exchangerBlockingSectionEnd()
InvokesGridWorker.blockingSectionEnd()for exchange worker. Should be called from exchange worker thread.
-
affinityChanged
public boolean affinityChanged(AffinityTopologyVersion from, AffinityTopologyVersion to)
-
durationHistogram
public HistogramMetricImpl durationHistogram()
- Returns:
- Histogram of PME durations metric.
-
blockingDurationHistogram
public HistogramMetricImpl blockingDurationHistogram()
- Returns:
- Histogram of blocking PME durations metric.
-
clusterRebalancedMetric
public BooleanMetricImpl clusterRebalancedMetric()
- Returns:
- Metric that shows whether cluster is in fully rebalanced state.
-
-