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.
`static IgniteProductVersion` `REBALANCING_VER_2_SINCE` Rebalancing was refactored at version 1.5.0, but backward compatibility to previous implementation was saved.

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

`aff, cctx, log, preloadPred`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtPreloader(GridCacheContext<?,?> cctx)`

### Method Summary

Methods
`Callable<Boolean>` `addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload, Collection<String> caches, int cnt)` Adds assignments to preloader.
`GridDhtPreloaderAssignments` `assign(GridDhtPartitionsExchangeFuture exchFut)`
`void` `dumpDebugInfo()` Dumps debug information.
`void` `evictPartitionAsync(GridDhtLocalPartition part)` Evicts partition asynchronously.
`void` `forcePreload()` Force preload process.
`void` `handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d)` Handles Demand message.
`void` `handleSupplyMessage(int idx, UUID id, GridDhtPartitionSupplyMessageV2 s)` Handles Supply message.
`boolean` `needForceKeys()`
`void` `onInitialExchangeComplete(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` `preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)`
`IgniteInternalFuture<Boolean>` `rebalanceFuture()`
`GridDhtFuture<Object>` `request(Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer)` Requests that preloader sends the request for the key.
`void` `start()` Starts preloading.
`IgniteInternalFuture<Object>` `startFuture()`
`IgniteInternalFuture<?>` `syncFuture()`
`void` `unwindUndeploys()` Unwinds undeploys.

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

`onKernalStart, preloadPredicate, stop`

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

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

### Field Detail

#### REBALANCING_VER_2_SINCE

    public static final IgniteProductVersion REBALANCING_VER_2_SINCE

Rebalancing was refactored at version 1.5.0, but backward compatibility to previous implementation was saved. Node automatically chose communication protocol depends on remote node's version. Backward compatibility may be removed at Ignite 2.x.

#### 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(GridCacheContext<?,?> cctx)

Parameters:
  `cctx` - Cache context.

### Method Detail

#### start

    public void start()

Starts preloading.

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

#### preloadPredicate

    public void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)

Specified by:
  `preloadPredicate` in interface `GridCachePreloader`
Overrides:
  `preloadPredicate` in class `GridCachePreloaderAdapter`
Parameters:
  `preloadPred` - Preload predicate.

#### onKernalStop

    public void onKernalStop()

Kernal stop callback.

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

#### onInitialExchangeComplete

    public void onInitialExchangeComplete(@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.

#### assign

    public GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut)

Specified by:
  `assign` in interface `GridCachePreloader`
Overrides:
  `assign` in class `GridCachePreloaderAdapter`
Parameters:
  `exchFut` - Exchange future to assign.
Returns:
  Assignments or `null` if detected that there are pending exchanges.

#### onReconnected

    public void onReconnected()

Client reconnected callback.

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

#### handleSupplyMessage

    public void handleSupplyMessage(int idx,
                           UUID id,
                           GridDhtPartitionSupplyMessageV2 s)

Handles Supply message.

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

#### handleDemandMessage

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

Handles Demand message.

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

#### addAssignments

    public Callable<Boolean> addAssignments(GridDhtPreloaderAssignments assignments,
                                   boolean forcePreload,
                                   Collection<String> caches,
                                   int cnt)

Adds assignments to preloader.

Specified by:
  `addAssignments` in interface `GridCachePreloader`
Overrides:
  `addAssignments` in class `GridCachePreloaderAdapter`
Parameters:
  `assignments` - Assignments to add.
  `forcePreload` - Force preload flag.
  `caches` - Rebalancing of these caches will be finished before this started.
  `cnt` - Counter.
Returns:
  Rebalancing closure.

#### 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 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. Note that topology change creates new futures and finishes previous.

#### 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(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.
  `topVer` - Topology version, `-1` if not required.
Returns:
  Future for request.

#### forcePreload

    public void forcePreload()

Force preload process.

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

#### unwindUndeploys

    public void unwindUndeploys()

Unwinds undeploys.

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

#### evictPartitionAsync

    public void evictPartitionAsync(GridDhtLocalPartition part)

Evicts partition asynchronously.

Specified by:
  `evictPartitionAsync` in interface `GridCachePreloader`
Overrides:
  `evictPartitionAsync` in class `GridCachePreloaderAdapter`
Parameters:
  `part` - Partition.

#### dumpDebugInfo

    public void dumpDebugInfo()

Dumps debug information.

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

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.6.0
Release Date | : May 18 2016