org.apache.ignite.internal.processors.cache

## Class GridCachePreloaderAdapter<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter<K,V>

All Implemented Interfaces:
  GridCachePreloader<K,V>

Direct Known Subclasses:
  GridDhtPreloader

    public class GridCachePreloaderAdapter<K,V>
    extends Object
    implements GridCachePreloader<K,V>

Adapter for preloading which always assumes that preloading finished.

### Field Summary

Fields
`protected AffinityFunction` `aff` Affinity.
`protected GridCacheContext<K,V>` `cctx` Cache context.
`protected IgniteLogger` `log` Logger.
`protected IgnitePredicate<GridCacheEntryInfo>` `preloadPred` Preload predicate.

### Constructor Summary

Constructors
Constructor and Description
`GridCachePreloaderAdapter(GridCacheContext<K,V> cctx)`

### Method Summary

Methods
`void` `addAssignments(GridDhtPreloaderAssignments<K,V> assignments, boolean forcePreload)` Adds assignments to preloader.
`GridDhtPreloaderAssignments<K,V>` `assign(GridDhtPartitionsExchangeFuture exchFut)`
`void` `forcePreload()` Force preload process.
`void` `onExchangeFutureAdded()` Callback by exchange manager when new exchange future is added to worker.
`void` `onInitialExchangeComplete(Throwable err)` Callback by exchange manager when initial partition exchange is complete.
`void` `onKernalStart()` Kernal start callback.
`void` `onKernalStop()` Kernal stop callback.
`IgnitePredicate<GridCacheEntryInfo>` `preloadPredicate()`
`void` `preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)`
`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.
`void` `updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut)` Updates last exchange future.

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

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

### Field Detail

#### cctx

    protected final GridCacheContext<K,V> 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<K,V> cctx)

Parameters:
  `cctx` - Cache context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts preloading.

Specified by:
  `start` in interface `GridCachePreloader<K,V>`
Throws:
  `IgniteCheckedException` - If start failed.

#### stop

    public void stop()

Stops preloading.

Specified by:
  `stop` in interface `GridCachePreloader<K,V>`

#### onKernalStart

    public void onKernalStart()
                       throws IgniteCheckedException

Kernal start callback.

Specified by:
  `onKernalStart` in interface `GridCachePreloader<K,V>`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStop

    public void onKernalStop()

Kernal stop callback.

Specified by:
  `onKernalStop` in interface `GridCachePreloader<K,V>`

#### forcePreload

    public void forcePreload()

Force preload process.

Specified by:
  `forcePreload` in interface `GridCachePreloader<K,V>`

#### preloadPredicate

    public void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred)

Specified by:
  `preloadPredicate` in interface `GridCachePreloader<K,V>`
Parameters:
  `preloadPred` - Preload predicate.

#### preloadPredicate

    public IgnitePredicate<GridCacheEntryInfo> preloadPredicate()

Specified by:
  `preloadPredicate` in interface `GridCachePreloader<K,V>`
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<K,V>`
Returns:
  Future which will complete when preloader is safe to use.

#### syncFuture

    public IgniteInternalFuture<?> syncFuture()

Specified by:
  `syncFuture` in interface `GridCachePreloader<K,V>`
Returns:
  Future which will complete when preloading is finished.

#### unwindUndeploys

    public void unwindUndeploys()

Unwinds undeploys.

Specified by:
  `unwindUndeploys` in interface `GridCachePreloader<K,V>`

#### 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<K,V>`
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<K,V>`
Parameters:
  `err` - Error, if any happened on initial exchange.

#### onExchangeFutureAdded

    public void onExchangeFutureAdded()

Callback by exchange manager when new exchange future is added to worker.

Specified by:
  `onExchangeFutureAdded` in interface `GridCachePreloader<K,V>`

#### updateLastExchangeFuture

    public void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut)

Description copied from interface: `GridCachePreloader`
Updates last exchange future.

Specified by:
  `updateLastExchangeFuture` in interface `GridCachePreloader<K,V>`
Parameters:
  `lastFut` - Last future.

#### assign

    public GridDhtPreloaderAssignments<K,V> assign(GridDhtPartitionsExchangeFuture exchFut)

Specified by:
  `assign` in interface `GridCachePreloader<K,V>`
Parameters:
  `exchFut` - Exchange future to assign.
Returns:
  Assignments.

#### addAssignments

    public void addAssignments(GridDhtPreloaderAssignments<K,V> assignments,
                      boolean forcePreload)

Adds assignments to preloader.

Specified by:
  `addAssignments` in interface `GridCachePreloader<K,V>`
Parameters:
  `assignments` - Assignments to add.
  `forcePreload` - Force preload flag.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015