org.apache.ignite.internal.processors.cache

## 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
`protected AffinityFunction` `aff` Affinity.
`protected GridCacheContext<?,?>` `cctx` Cache context.
`protected IgniteLogger` `log` Logger.
`protected IgnitePredicate<GridCacheEntryInfo>` `preloadPred` Preload predicate.

### Constructor Summary

Constructors
Constructor and Description
`GridCachePreloaderAdapter(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` `onKernalStart()` Kernal start callback.
`void` `onKernalStop()` Kernal stop callback.
`void` `onReconnected()` Client reconnected callback.
`void` `onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)`
`IgnitePredicate<GridCacheEntryInfo>` `preloadPredicate()`
`void` `preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)`
`IgniteInternalFuture<Boolean>` `rebalanceFuture()`
`IgniteInternalFuture<Object>` `request(Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer)` Requests that preloader sends the request for the key.
`void` `start()` Starts preloading.
`IgniteInternalFuture<Object>` `startFuture()`
`void` `stop()` Stops preloading.
`IgniteInternalFuture<?>` `syncFuture()`
`void` `unwindUndeploys()` Unwinds undeploys.

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

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

### Field Detail

#### cctx

    protected final GridCacheContext<?,?> cctx

Cache context.

#### log

    protected final IgniteLogger log

Logger.

#### aff

    protected final AffinityFunction aff

Affinity.

#### preloadPred

    protected IgnitePredicate<GridCacheEntryInfo> preloadPred

Preload predicate.

### Constructor Detail

#### GridCachePreloaderAdapter

    public GridCachePreloaderAdapter(GridCacheContext<?,?> cctx)

Parameters:
  `cctx` - Cache context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts preloading.

Specified by:
  `start` in interface `GridCachePreloader`
Throws:
  `IgniteCheckedException` - If start failed.

#### stop

    public void stop()

Stops preloading.

Specified by:
  `stop` in interface `GridCachePreloader`

#### onKernalStart

    public void onKernalStart()
                       throws IgniteCheckedException

Kernal start callback.

Specified by:
  `onKernalStart` in interface `GridCachePreloader`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStop

    public void onKernalStop()

Kernal stop callback.

Specified by:
  `onKernalStop` in interface `GridCachePreloader`

#### forcePreload

    public void forcePreload()

Force preload process.

Specified by:
  `forcePreload` in interface `GridCachePreloader`

#### needForceKeys

    public boolean needForceKeys()

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

#### onReconnected

    public void onReconnected()

Client reconnected callback.

Specified by:
  `onReconnected` in interface `GridCachePreloader`

#### preloadPredicate

    public void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)

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

#### preloadPredicate

    public IgnitePredicate<GridCacheEntryInfo> preloadPredicate()

Specified by:
  `preloadPredicate` in interface `GridCachePreloader`
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

    public IgniteInternalFuture<Object> startFuture()

Specified by:
  `startFuture` in interface `GridCachePreloader`
Returns:
  Future which will complete when preloader is safe to use.

#### syncFuture

    public IgniteInternalFuture<?> syncFuture()

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

#### rebalanceFuture

    public IgniteInternalFuture<Boolean> rebalanceFuture()

Specified by:
  `rebalanceFuture` in interface `GridCachePreloader`
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.

#### unwindUndeploys

    public void unwindUndeploys()

Unwinds undeploys.

Specified by:
  `unwindUndeploys` in interface `GridCachePreloader`

#### handleSupplyMessage

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

Handles Supply message.

Specified by:
  `handleSupplyMessage` in interface `GridCachePreloader`
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`
Parameters:
  `idx` - Index.
  `id` - Node Id.
  `d` - Demand message.

#### request

    public IgniteInternalFuture<Object> request(Collection<KeyCacheObject> keys,
                                       AffinityTopologyVersion topVer)

Requests that preloader sends the request for the key.

Specified by:
  `request` in interface `GridCachePreloader`
Parameters:
  `keys` - Keys to request.
  `topVer` - Topology version, `-1` if not required.
Returns:
  Future to complete when all keys are preloaded.

#### onInitialExchangeComplete

    public void onInitialExchangeComplete(@Nullable
                                 Throwable err)

Callback by exchange manager when initial partition exchange is complete.

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

#### assign

    public GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut)

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

#### addAssignments

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

Adds assignments to preloader.

Specified by:
  `addAssignments` in interface `GridCachePreloader`
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.

#### evictPartitionAsync

    public void evictPartitionAsync(GridDhtLocalPartition part)

Evicts partition asynchronously.

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

#### onTopologyChanged

    public void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut)

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

#### dumpDebugInfo

    public void dumpDebugInfo()

Dumps debug information.

Specified by:
  `dumpDebugInfo` in interface `GridCachePreloader`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016