org.apache.ignite.internal.processors.cache.distributed.dht.preloader

## Class GridDhtPreloader

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter
  - - org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader

All Implemented Interfaces:
  GridCachePreloader

    public class GridDhtPreloader
    extends GridCachePreloaderAdapter

DHT cache preloader.

### Field Summary

Fields
`static long` `DFLT_PRELOAD_RESEND_TIMEOUT` Default preload resend timeout.

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter

`ctx, grp, log`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtPreloader(CacheGroupContext grp)`

### Method Summary

All Methods Instance Methods Concrete Methods
`GridDhtPartitionDemander.RebalanceFuture` `addAssignments(GridDhtPreloaderAssignments assignments, boolean forceRebalance, long rebalanceId, GridDhtPartitionDemander.RebalanceFuture next, @Nullable GridCompoundFuture<Boolean,Boolean> forcedRebFut, GridCompoundFuture<Boolean,Boolean> compatibleRebFut)` Adds assignments to preloader.
`boolean` `disableRebalancingCancellationOptimization()`
`IgniteInternalFuture<Boolean>` `forceRebalance()` Force Rebalance process.
`GridDhtPreloaderAssignments` `generateAssignments(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut)`
`void` `handleDemandMessage(int idx, UUID nodeId, GridDhtPartitionDemandMessage d)` Handles Demand message.
`void` `handleSupplyMessage(UUID nodeId, GridDhtPartitionSupplyMessage s)` Handles Supply message.
`boolean` `needForceKeys()`
`void` `onInitialExchangeComplete(@Nullable Throwable err)` Callback by exchange manager when initial partition exchange is complete.
`void` `onKernalStop()` Kernal stop callback.
`void` `onPartitionEvicted(GridDhtLocalPartition part, boolean updateSeq)` Resends partitions on partition evict within configured timeout.
`void` `onReconnected()` Client reconnected callback.
`void` `onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)`
`void` `pause()` Pause preloader.
`IgniteInternalFuture<Boolean>` `rebalanceFuture()`
`boolean` `rebalanceRequired(GridDhtPartitionsExchangeFuture exchFut)`
`GridDhtFuture<Object>` `request(GridCacheContext cctx, Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer)` Requests that preloader sends the request for the key.
`GridDhtFuture<Object>` `request(GridCacheContext cctx, GridNearAtomicAbstractUpdateRequest req, AffinityTopologyVersion topVer)` Requests that preloader sends the request for the key.
`void` `resume()` Resume preloader.
`void` `start()` Starts preloading.
`IgniteInternalFuture<Object>` `startFuture()`
`IgniteInternalFuture<?>` `syncFuture()`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter

`batchesPrefetchCount, batchSize, dumpDebugInfo, throttle, timeout`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DFLT_PRELOAD_RESEND_TIMEOUT

    public static final long DFLT_PRELOAD_RESEND_TIMEOUT

Default preload resend timeout.

See Also:
  Constant Field Values

### Constructor Detail

#### GridDhtPreloader

    public GridDhtPreloader(CacheGroupContext grp)

Parameters:
  `grp` - Cache group.

### Method Detail

#### start

    public void start()

Starts preloading.

Specified by:
  `start` in interface `GridCachePreloader`
Overrides:
  `start` in class `GridCachePreloaderAdapter`

#### onKernalStop

    public void onKernalStop()

Kernal stop callback.

Specified by:
  `onKernalStop` in interface `GridCachePreloader`
Overrides:
  `onKernalStop` in class `GridCachePreloaderAdapter`

#### disableRebalancingCancellationOptimization

    public boolean disableRebalancingCancellationOptimization()

Returns:
  Rebalance cancellation optimization flag.

#### onInitialExchangeComplete

    public void onInitialExchangeComplete(@Nullable
                                          @Nullable Throwable err)

Callback by exchange manager when initial partition exchange is complete.

Specified by:
  `onInitialExchangeComplete` in interface `GridCachePreloader`
Overrides:
  `onInitialExchangeComplete` in class `GridCachePreloaderAdapter`
Parameters:
  `err` - Error, if any happened on initial exchange.

#### onTopologyChanged

    public void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)

Specified by:
  `onTopologyChanged` in interface `GridCachePreloader`
Overrides:
  `onTopologyChanged` in class `GridCachePreloaderAdapter`
Parameters:
  `lastFut` - Last future.

#### rebalanceRequired

    public boolean rebalanceRequired(GridDhtPartitionsExchangeFuture exchFut)

Specified by:
  `rebalanceRequired` in interface `GridCachePreloader`
Overrides:
  `rebalanceRequired` in class `GridCachePreloaderAdapter`
Parameters:
  `exchFut` - Completed exchange future.
Returns:
  `True` if rebalance should be started (previous will be interrupted).

#### generateAssignments

    public GridDhtPreloaderAssignments generateAssignments(GridDhtPartitionExchangeId exchId,
                                                           GridDhtPartitionsExchangeFuture exchFut)

Specified by:
  `generateAssignments` in interface `GridCachePreloader`
Overrides:
  `generateAssignments` in class `GridCachePreloaderAdapter`
Parameters:
  `exchId` - Exchange ID.
  `exchFut` - Completed exchange future. Can be `null` if forced or reassigned generation occurs.
Returns:
  Partition assignments which will be requested from supplier nodes.

#### onReconnected

    public void onReconnected()

Client reconnected callback.

Specified by:
  `onReconnected` in interface `GridCachePreloader`
Overrides:
  `onReconnected` in class `GridCachePreloaderAdapter`

#### handleSupplyMessage

    public void handleSupplyMessage(UUID nodeId,
                                    GridDhtPartitionSupplyMessage s)

Handles Supply message.

Specified by:
  `handleSupplyMessage` in interface `GridCachePreloader`
Overrides:
  `handleSupplyMessage` in class `GridCachePreloaderAdapter`
Parameters:
  `nodeId` - Node Id.
  `s` - Supply message.

#### handleDemandMessage

    public void handleDemandMessage(int idx,
                                    UUID nodeId,
                                    GridDhtPartitionDemandMessage d)

Handles Demand message.

Specified by:
  `handleDemandMessage` in interface `GridCachePreloader`
Overrides:
  `handleDemandMessage` in class `GridCachePreloaderAdapter`
Parameters:
  `idx` - Index.
  `nodeId` - Node Id.
  `d` - Demand message.

#### addAssignments

    public GridDhtPartitionDemander.RebalanceFuture addAssignments(GridDhtPreloaderAssignments assignments,
                                                                   boolean forceRebalance,
                                                                   long rebalanceId,
                                                                   GridDhtPartitionDemander.RebalanceFuture next,
                                                                   @Nullable
                                                                   @Nullable GridCompoundFuture<Boolean,Boolean> forcedRebFut,
                                                                   GridCompoundFuture<Boolean,Boolean> compatibleRebFut)

Adds assignments to preloader.

Specified by:
  `addAssignments` in interface `GridCachePreloader`
Overrides:
  `addAssignments` in class `GridCachePreloaderAdapter`
Parameters:
  `assignments` - Assignments to add.
  `forceRebalance` - `True` if preload requested by `ForceRebalanceExchangeTask`.
  `rebalanceId` - Rebalance id created by exchange thread.
  `next` - Rebalance's 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.

#### startFuture

    public IgniteInternalFuture<Object> startFuture()

Description copied from class: `GridCachePreloaderAdapter`

Specified by:
  `startFuture` in interface `GridCachePreloader`
Overrides:
  `startFuture` in class `GridCachePreloaderAdapter`
Returns:
  Start future.

#### syncFuture

    public IgniteInternalFuture<?> syncFuture()

Specified by:
  `syncFuture` in interface `GridCachePreloader`
Overrides:
  `syncFuture` in class `GridCachePreloaderAdapter`
Returns:
  Future which will complete when initial preloading is finished.

#### rebalanceFuture

    public IgniteInternalFuture<Boolean> rebalanceFuture()

Specified by:
  `rebalanceFuture` in interface `GridCachePreloader`
Overrides:
  `rebalanceFuture` in class `GridCachePreloaderAdapter`
Returns:
  Future which will complete when preloading finishes on current topology. Future result is `true` in case rebalancing successfully finished at current topology. Future result is `false` in case rebalancing cancelled or finished with missed partitions and will be restarted at current or pending topology.

#### onPartitionEvicted

    public void onPartitionEvicted(GridDhtLocalPartition part,
                                   boolean updateSeq)

Resends partitions on partition evict within configured timeout.

Parameters:
  `part` - Evicted partition.
  `updateSeq` - Update sequence.

#### needForceKeys

    public boolean needForceKeys()

Specified by:
  `needForceKeys` in interface `GridCachePreloader`
Overrides:
  `needForceKeys` in class `GridCachePreloaderAdapter`
Returns:
  `true` if there is no need to force keys preloading (e.g. rebalancing has been completed).

#### request

    public GridDhtFuture<Object> request(GridCacheContext cctx,
                                         GridNearAtomicAbstractUpdateRequest req,
                                         AffinityTopologyVersion topVer)

Requests that preloader sends the request for the key.

Specified by:
  `request` in interface `GridCachePreloader`
Overrides:
  `request` in class `GridCachePreloaderAdapter`
Parameters:
  `cctx` - Cache context.
  `req` - Message with keys to request.
  `topVer` - Topology version, `-1` if not required.
Returns:
  Future to complete when all keys are preloaded.

#### request

    public GridDhtFuture<Object> request(GridCacheContext cctx,
                                         Collection<KeyCacheObject> keys,
                                         AffinityTopologyVersion topVer)

Description copied from class: `GridCachePreloaderAdapter`
Requests that preloader sends the request for the key.

Specified by:
  `request` in interface `GridCachePreloader`
Overrides:
  `request` in class `GridCachePreloaderAdapter`
Parameters:
  `keys` - Keys to request.
  `cctx` - Cache context.
  `topVer` - Topology version, `-1` if not required.
Returns:
  Future for request.

#### forceRebalance

    public IgniteInternalFuture<Boolean> forceRebalance()

Force Rebalance process.

Specified by:
  `forceRebalance` in interface `GridCachePreloader`
Overrides:
  `forceRebalance` in class `GridCachePreloaderAdapter`

#### pause

    public void pause()

Pause preloader.

Specified by:
  `pause` in interface `GridCachePreloader`
Overrides:
  `pause` in class `GridCachePreloaderAdapter`

#### resume

    public void resume()

Resume preloader.

Specified by:
  `resume` in interface `GridCachePreloader`
Overrides:
  `resume` in class `GridCachePreloaderAdapter`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020