org.apache.ignite.internal.processors.cache

## Interface GridCachePreloader

All Known Implementing Classes:
  GridCachePreloaderAdapter, GridDhtPreloader

    public interface GridCachePreloader

Cache preloader that is responsible for loading cache entries either from remote nodes (for distributed cache) or anywhere else at cache startup.

### Method Summary

Methods
`Runnable` `addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload, int cnt, Runnable next, GridCompoundFuture<Boolean,Boolean> forcedRebFut)` Adds assignments to preloader.
`GridDhtPreloaderAssignments` `assign(GridDhtPartitionsExchangeFuture exchFut)`
`void` `dumpDebugInfo()` Dumps debug information.
`void` `evictPartitionAsync(GridDhtLocalPartition part)` Evicts partition asynchronously.
`IgniteInternalFuture<Boolean>` `forceRebalance()` Force Rebalance process.
`void` `handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d)` Handles Demand message.
`void` `handleSupplyMessage(int idx, UUID id, GridDhtPartitionSupplyMessage 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` `onReconnected()` Client reconnected callback.
`void` `onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)`
`IgnitePredicate<GridCacheEntryInfo>` `preloadPredicate()`
`void` `preloadPredicate(IgnitePredicate<GridCacheEntryInfo> p)`
`IgniteInternalFuture<Boolean>` `rebalanceFuture()`
`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` `start()` Starts preloading.
`IgniteInternalFuture<Object>` `startFuture()`
`IgniteInternalFuture<?>` `syncFuture()`
`void` `unwindUndeploys()` Unwinds undeploys.

### Method Detail

#### start

    void start()
               throws IgniteCheckedException

Starts preloading.

Throws:
  `IgniteCheckedException` - If start failed.

#### onKernalStop

    void onKernalStop()

Kernal stop callback.

#### onReconnected

    void onReconnected()

Client reconnected callback.

#### onInitialExchangeComplete

    void onInitialExchangeComplete(@Nullable
                                 Throwable err)

Callback by exchange manager when initial partition exchange is complete.

Parameters:
  `err` - Error, if any happened on initial exchange.

#### assign

    @Nullable
    GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut)

Parameters:
  `exchFut` - Exchange future to assign.
Returns:
  Assignments or `null` if detected that there are pending exchanges.

#### addAssignments

    Runnable addAssignments(GridDhtPreloaderAssignments assignments,
                          boolean forcePreload,
                          int cnt,
                          Runnable next,
                          @Nullable
                          GridCompoundFuture<Boolean,Boolean> forcedRebFut)

Adds assignments to preloader.

Parameters:
  `assignments` - Assignments to add.
  `forcePreload` - Force preload flag.
  `cnt` - Counter.
  `next` - Runnable responsible for cache rebalancing start.
Returns:
  Rebalancing runnable.

#### preloadPredicate

    void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> p)

Parameters:
  `p` - Preload predicate.

#### preloadPredicate

    IgnitePredicate<GridCacheEntryInfo> preloadPredicate()

Returns:
  Preload predicate. If not `null`, will evaluate each preloaded entry during send and receive, and if predicate evaluates to `false`, entry will be skipped.

#### startFuture

    IgniteInternalFuture<Object> startFuture()

Returns:
  Future which will complete when preloader is safe to use.

#### syncFuture

    IgniteInternalFuture<?> syncFuture()

Returns:
  Future which will complete when preloading is finished.

#### rebalanceFuture

    IgniteInternalFuture<Boolean> rebalanceFuture()

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.

#### needForceKeys

    boolean needForceKeys()

Returns:
  `true` if there is no need to force keys preloading (e.g. rebalancing has been completed).

#### request

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

Requests that preloader sends the request for the key.

Parameters:
  `cctx` - Cache context.
  `keys` - Keys to request.
  `topVer` - Topology version, `-1` if not required.
Returns:
  Future to complete when all keys are preloaded.

#### request

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

Requests that preloader sends the request for the key.

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.

#### forceRebalance

    IgniteInternalFuture<Boolean> forceRebalance()

Force Rebalance process.

#### unwindUndeploys

    void unwindUndeploys()

Unwinds undeploys.

#### handleSupplyMessage

    void handleSupplyMessage(int idx,
                           UUID id,
                           GridDhtPartitionSupplyMessage s)

Handles Supply message.

Parameters:
  `idx` - Index.
  `id` - Node Id.
  `s` - Supply message.

#### handleDemandMessage

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

Handles Demand message.

Parameters:
  `idx` - Index.
  `id` - Node Id.
  `d` - Demand message.

#### evictPartitionAsync

    void evictPartitionAsync(GridDhtLocalPartition part)

Evicts partition asynchronously.

Parameters:
  `part` - Partition.

#### onTopologyChanged

    void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)

Parameters:
  `lastFut` - Last future.

#### dumpDebugInfo

    void dumpDebugInfo()

Dumps debug information.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017