Class GridCachePreloaderAdapter
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter
-
- All Implemented Interfaces:
GridCachePreloader
- Direct Known Subclasses:
GridDhtPreloader
public class GridCachePreloaderAdapter extends Object implements GridCachePreloader
Adapter for preloading which always assumes that preloading finished.
-
-
Field Summary
Fields Modifier and Type Field Description protected GridCacheSharedContextctxprotected CacheGroupContextgrpprotected IgniteLoggerlogLogger.
-
Constructor Summary
Constructors Constructor Description GridCachePreloaderAdapter(CacheGroupContext grp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbatchesPrefetchCount()The number of batches generated by supply node at rebalancing procedure start.intbatchSize()The supply message size in bytes to be loaded within a single rebalance batch.voiddumpDebugInfo()Dumps debug information.voidfinishPreloading(AffinityTopologyVersion topVer, long rebalanceId)Finish preloading for given topology version.IgniteInternalFuture<Boolean>forceRebalance()Force Rebalance process.GridDhtPreloaderAssignmentsgenerateAssignments(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut)voidhandleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d)Handles Demand message.voidhandleSupplyMessage(UUID id, GridDhtPartitionSupplyMessage s)Handles Supply message.booleanneedForceKeys()voidonInitialExchangeComplete(@Nullable Throwable err)Callback by exchange manager when initial partition exchange is complete.voidonKernalStop()Kernal stop callback.voidonReconnected()Client reconnected callback.voidonTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)voidpause()Pause preloader.GridDhtPartitionDemander.RebalanceFutureprepare(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut, long rebalanceId, GridDhtPartitionDemander.RebalanceFuture next, @Nullable GridCompoundFuture<Boolean,Boolean> forcedRebFut, GridCompoundFuture<Boolean,Boolean> compatibleRebFut)IgniteInternalFuture<Boolean>rebalanceFuture()GridDhtFuture<Object>request(GridCacheContext ctx, Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer)Requests that preloader sends the request for the key.GridDhtFuture<Object>request(GridCacheContext ctx, GridNearAtomicAbstractUpdateRequest req, AffinityTopologyVersion topVer)Requests that preloader sends the request for the key.voidresume()Resume preloader.voidstart()Starts preloading.IgniteInternalFuture<Object>startFuture()IgniteInternalFuture<?>syncFuture()longthrottle()Time in milliseconds to wait between rebalance messages to avoid overloading of CPU or network.longtimeout()Rebalance timeout for supply and demand messages in milliseconds.
-
-
-
Field Detail
-
grp
protected final CacheGroupContext grp
-
ctx
protected final GridCacheSharedContext ctx
-
log
protected final IgniteLogger log
Logger.
-
-
Constructor Detail
-
GridCachePreloaderAdapter
public GridCachePreloaderAdapter(CacheGroupContext grp)
- Parameters:
grp- Cache group.
-
-
Method Detail
-
start
public void start() throws IgniteCheckedExceptionStarts preloading.- Specified by:
startin interfaceGridCachePreloader- Throws:
IgniteCheckedException- If start failed.
-
onKernalStop
public void onKernalStop()
Kernal stop callback.- Specified by:
onKernalStopin interfaceGridCachePreloader
-
forceRebalance
public IgniteInternalFuture<Boolean> forceRebalance()
Force Rebalance process.- Specified by:
forceRebalancein interfaceGridCachePreloader
-
needForceKeys
public boolean needForceKeys()
- Specified by:
needForceKeysin interfaceGridCachePreloader- Returns:
trueif there is no need to force keys preloading (e.g. rebalancing has been completed).
-
onReconnected
public void onReconnected()
Client reconnected callback.- Specified by:
onReconnectedin interfaceGridCachePreloader
-
startFuture
public IgniteInternalFuture<Object> startFuture()
- Specified by:
startFuturein interfaceGridCachePreloader- Returns:
- Future which will complete when preloader is safe to use.
-
syncFuture
public IgniteInternalFuture<?> syncFuture()
- Specified by:
syncFuturein interfaceGridCachePreloader- Returns:
- Future which will complete when initial preloading is finished.
-
rebalanceFuture
public IgniteInternalFuture<Boolean> rebalanceFuture()
- Specified by:
rebalanceFuturein interfaceGridCachePreloader- Returns:
- Future which will complete when preloading finishes on current topology.
Future result is
truein case rebalancing successfully finished at current topology. Future result isfalsein case rebalancing cancelled or finished with missed partitions and will be restarted at current or pending topology.
-
handleSupplyMessage
public void handleSupplyMessage(UUID id, GridDhtPartitionSupplyMessage s)
Handles Supply message.- Specified by:
handleSupplyMessagein interfaceGridCachePreloader- Parameters:
id- Node Id.s- Supply message.
-
handleDemandMessage
public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d)Handles Demand message.- Specified by:
handleDemandMessagein interfaceGridCachePreloader- Parameters:
idx- Index.id- Node Id.d- Demand message.
-
request
public GridDhtFuture<Object> request(GridCacheContext ctx, Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer)
Requests that preloader sends the request for the key.- Specified by:
requestin interfaceGridCachePreloader- Parameters:
ctx- Cache context.keys- Keys to request.topVer- Topology version,-1if not required.- Returns:
- Future to complete when all keys are preloaded.
-
request
public GridDhtFuture<Object> request(GridCacheContext ctx, GridNearAtomicAbstractUpdateRequest req, AffinityTopologyVersion topVer)
Requests that preloader sends the request for the key.- Specified by:
requestin interfaceGridCachePreloader- Parameters:
ctx- Cache context.req- Message with keys to request.topVer- Topology version,-1if not required.- Returns:
- Future to complete when all keys are preloaded.
-
onInitialExchangeComplete
public void onInitialExchangeComplete(@Nullable @Nullable Throwable err)Callback by exchange manager when initial partition exchange is complete.- Specified by:
onInitialExchangeCompletein interfaceGridCachePreloader- Parameters:
err- Error, if any happened on initial exchange.
-
generateAssignments
public GridDhtPreloaderAssignments generateAssignments(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut)
- Parameters:
exchId- Exchange ID.exchFut- Completed exchange future. Can benullif forced or reassigned generation occurs.- Returns:
- Partition assignments which will be requested from supplier nodes.
-
prepare
public GridDhtPartitionDemander.RebalanceFuture prepare(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut, long rebalanceId, GridDhtPartitionDemander.RebalanceFuture next, @Nullable @Nullable GridCompoundFuture<Boolean,Boolean> forcedRebFut, GridCompoundFuture<Boolean,Boolean> compatibleRebFut)
- Specified by:
preparein interfaceGridCachePreloader- Parameters:
exchId- Exchange ID.exchFut- Completed exchange future. Can benullif forced or reassigned generation occurs.rebalanceId- Rebalance id created by exchange thread.next- Rebalance future follows after the current one.forcedRebFut- External future for forced rebalance.compatibleRebFut- Future for waiting for compatible rebalances.- Returns:
- Future if rebalance was planned or null.
-
onTopologyChanged
public void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)
- Specified by:
onTopologyChangedin interfaceGridCachePreloader- Parameters:
lastFut- Last future.
-
dumpDebugInfo
public void dumpDebugInfo()
Dumps debug information.- Specified by:
dumpDebugInfoin interfaceGridCachePreloader
-
pause
public void pause()
Pause preloader.- Specified by:
pausein interfaceGridCachePreloader
-
resume
public void resume()
Resume preloader.- Specified by:
resumein interfaceGridCachePreloader
-
timeout
public long timeout()
Rebalance timeout for supply and demand messages in milliseconds.The
IgniteConfiguration.getRebalanceTimeout()will be used by default. If an Ignite's configuration value is not provided than theCacheConfiguration.getRebalanceTimeout()will be used instead.- Specified by:
timeoutin interfaceGridCachePreloader- Returns:
- Rebalance message timeout in milliseconds.
-
batchesPrefetchCount
public long batchesPrefetchCount()
The number of batches generated by supply node at rebalancing procedure start.The
IgniteConfiguration.getRebalanceBatchesPrefetchCount()will be used by default. If an Ignite's configuration value is not provided than theCacheConfiguration.getRebalanceBatchesPrefetchCount()will be used instead.- Specified by:
batchesPrefetchCountin interfaceGridCachePreloader- Returns:
- The number of batches prefetch count.
-
throttle
public long throttle()
Time in milliseconds to wait between rebalance messages to avoid overloading of CPU or network.The
IgniteConfiguration.getRebalanceThrottle()will be used by default. If an Ignite's configuration value is not provided than theCacheConfiguration.getRebalanceThrottle()will be used instead.- Specified by:
throttlein interfaceGridCachePreloader- Returns:
- Time in milliseconds to wait between rebalance messages,
0to disable throttling.
-
batchSize
public int batchSize()
The supply message size in bytes to be loaded within a single rebalance batch.The
IgniteConfiguration.getRebalanceBatchSize()will be used by default. If an Ignite's configuration value is not provided than theCacheConfiguration.getRebalanceBatchSize()will be used instead.- Specified by:
batchSizein interfaceGridCachePreloader- Returns:
- Rebalance message size in bytes.
-
finishPreloading
public void finishPreloading(AffinityTopologyVersion topVer, long rebalanceId)
Finish preloading for given topology version.- Specified by:
finishPreloadingin interfaceGridCachePreloader- Parameters:
topVer- Topology version.rebalanceId- Rebalance id.
-
-