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

## Class GridDhtPartitionsExchangeFuture

- java.lang.Object
- - org.apache.ignite.internal.util.future.GridFutureAdapter<AffinityTopologyVersion>
  - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter
    - - org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture

All Implemented Interfaces:
  Comparable<GridDhtPartitionsExchangeFuture>, IgniteDiagnosticAware, IgniteInternalFuture<AffinityTopologyVersion>, CachePartitionExchangeWorkerTask, GridDhtTopologyFuture

    public class GridDhtPartitionsExchangeFuture
    extends GridDhtTopologyFutureAdapter
    implements Comparable<GridDhtPartitionsExchangeFuture>, CachePartitionExchangeWorkerTask, IgniteDiagnosticAware

Future for exchanging partition maps.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter

`GridDhtTopologyFutureAdapter.CacheValidation`

### Field Summary

Fields
`static String` `EXCHANGE_LOG`

### Fields inherited from class org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter

`grpValidRes`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtPartitionsExchangeFuture(GridCacheSharedContext cctx, ReadWriteLock busyLock, GridDhtPartitionExchangeId exchId, ExchangeActions exchActions, CacheAffinityChangeMessage affChangeMsg)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `activateCluster()`
`void` `addDiagnosticRequest(IgniteDiagnosticPrepareContext diagCtx)`
`void` `affinityChangeMessage(CacheAffinityChangeMessage affChangeMsg)`
`boolean` `cacheAddedOnExchange(int cacheId, UUID rcvdFrom)`
`boolean` `cacheGroupAddedOnExchange(int grpId, UUID rcvdFrom)`
`boolean` `changedBaseline()`
`void` `cleanUp()` Cleans up resources to avoid excessive memory usage.
`int` `compareTo(GridDhtPartitionsExchangeFuture fut)`
`ExchangeContext` `context()`
`boolean` `dynamicCacheGroupStarted(int grpId)`
`boolean` `equals(Object o)`
`ExchangeDiscoveryEvents` `events()`
`void` `exchangeActions(ExchangeActions exchActions)`
`boolean` `exchangeDone()` Ready affinity future (`GridCachePartitionExchangeManager.affinityReadyFuture(AffinityTopologyVersion)` is completed before `GridFutureAdapter.onDone(Object, Throwable)` is called on `GridDhtPartitionsExchangeFuture`, it is guaranteed that this method will return `true` if affinity ready future is finished.
`GridDhtPartitionExchangeId` `exchangeId()`
`void` `finishMerged()` Finish merged future to allow GridCachePartitionExchangeManager.ExchangeFutureSet cleanup.
`DiscoveryEvent` `firstEvent()`
`DiscoCache` `firstEventCache()`
`int` `hashCode()`
`void` `init(boolean newCrd)` Starts activity.
`AffinityTopologyVersion` `initialVersion()` Returns topology version when exchange started.
`boolean` `localJoinExchange()`
`boolean` `mergeJoinExchange(GridDhtPartitionsExchangeFuture fut)` Merges this exchange with given one.
`GridDhtPartitionsSingleMessage` `mergeJoinExchangeOnDone(GridDhtPartitionsExchangeFuture fut)`
`Object` `mutex()`
`static long` `nextDumpTimeout(int step, long timeout)`
`boolean` `onAdded()`
`void` `onAffinityChangeMessage(ClusterNode node, CacheAffinityChangeMessage msg)` Affinity change message callback, processed from the same thread as `onNodeLeft(org.apache.ignite.cluster.ClusterNode)`.
`boolean` `onDone(AffinityTopologyVersion res, Throwable err)` Callback to notify that future is finished.
`void` `onEvent(GridDhtPartitionExchangeId exchId, DiscoveryEvent discoEvt, DiscoCache discoCache)` Event callback.
`void` `onNodeLeft(ClusterNode node)` Node left callback, processed from the same thread as `onAffinityChangeMessage(org.apache.ignite.cluster.ClusterNode, org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage)`.
`void` `onReceiveFullMessage(ClusterNode node, GridDhtPartitionsFullMessage msg)`
`void` `onReceivePartitionRequest(ClusterNode node, GridDhtPartitionsSingleRequest msg)`
`void` `onReceiveSingleMessage(ClusterNode node, GridDhtPartitionsSingleMessage msg)` Processing of received single message.
`UUID` `partitionHistorySupplier(int grpId, int partId)`
`boolean` `reconnectOnError(Throwable e)`
`boolean` `serverNodeDiscoveryEvent()`
`GridCacheSharedContext` `sharedContext()`
`String` `shortInfo()`
`boolean` `skipForExchangeMerge()`
`AffinityTopologyVersion` `topologyVersion()` Gets result topology version of this future.
`String` `toString()`
`void` `waitAndReplyToNode(UUID nodeId, GridDhtPartitionsSingleMessage msg)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter

`validateCache, validateCacheGroup`

### Methods inherited from class org.apache.ignite.internal.util.future.GridFutureAdapter

`cancel, chain, chain, error, get, get, get, getUninterruptibly, ignoreInterrupts, isCancelled, isDone, isFailed, listen, logger, onCancelled, onDone, onDone, onDone, onDone, reset, result`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.IgniteInternalFuture

`cancel, chain, chain, error, get, get, get, getUninterruptibly, isCancelled, isDone, listen, result`

### Field Detail

#### EXCHANGE_LOG

    public static final String EXCHANGE_LOG

See Also:
  Constant Field Values

### Constructor Detail

#### GridDhtPartitionsExchangeFuture

    public GridDhtPartitionsExchangeFuture(GridCacheSharedContext cctx,
                                           ReadWriteLock busyLock,
                                           GridDhtPartitionExchangeId exchId,
                                           ExchangeActions exchActions,
                                           CacheAffinityChangeMessage affChangeMsg)

Parameters:
  `cctx` - Cache context.
  `busyLock` - Busy lock.
  `exchId` - Exchange ID.
  `exchActions` - Cache change requests.
  `affChangeMsg` - Affinity change message.

### Method Detail

#### mutex

    public Object mutex()

Returns:
  Future mutex.

#### sharedContext

    public GridCacheSharedContext sharedContext()

Returns:
  Shared cache context.

#### skipForExchangeMerge

    public boolean skipForExchangeMerge()

Specified by:
  `skipForExchangeMerge` in interface `CachePartitionExchangeWorkerTask`
Returns:
  `False` if exchange merge should stop if this task is found in exchange worker queue.

#### context

    public ExchangeContext context()

Returns:
  Exchange context.

#### exchangeActions

    public void exchangeActions(ExchangeActions exchActions)

Parameters:
  `exchActions` - Exchange actions.

#### affinityChangeMessage

    public void affinityChangeMessage(CacheAffinityChangeMessage affChangeMsg)

Parameters:
  `affChangeMsg` - Affinity change message.

#### initialVersion

    public AffinityTopologyVersion initialVersion()

Description copied from interface: `GridDhtTopologyFuture`
Returns topology version when exchange started. It can differ from result topology version if exchanges for multiple discovery events are merged. Initial version should not be used as version for cache operation since it is possible affinity for this version is never calculated.

Specified by:
  `initialVersion` in interface `GridDhtTopologyFuture`
Returns:
  Initial exchange version.

#### topologyVersion

    public AffinityTopologyVersion topologyVersion()

Gets result topology version of this future. Result version can differ from initial exchange version if excanges for multiple discovery events are merged, in this case result version is version of last discovery event.

This method should be called only for finished topology future since result version is not known before exchange finished.

Specified by:
  `topologyVersion` in interface `GridDhtTopologyFuture`
Returns:
  Result topology version.

#### partitionHistorySupplier

    @Nullable
    public UUID partitionHistorySupplier(int grpId,
                                                   int partId)

Parameters:
  `grpId` - Cache group ID.
  `partId` - Partition ID.
Returns:
  ID of history supplier node or null if it doesn't exist.

#### cacheAddedOnExchange

    public boolean cacheAddedOnExchange(int cacheId,
                                        UUID rcvdFrom)

Parameters:
  `cacheId` - Cache ID.
  `rcvdFrom` - Node ID cache was received from.
Returns:
  `True` if cache was added during this exchange.

#### cacheGroupAddedOnExchange

    public boolean cacheGroupAddedOnExchange(int grpId,
                                             UUID rcvdFrom)

Parameters:
  `grpId` - Cache group ID.
  `rcvdFrom` - Node ID cache group was received from.
Returns:
  `True` if cache group was added during this exchange.

#### dynamicCacheGroupStarted

    public boolean dynamicCacheGroupStarted(int grpId)

Parameters:
  `grpId` - Cache group ID.
Returns:
  `True` if non-client cache group was added during this exchange.

#### onAdded

    public boolean onAdded()

Returns:
  `True`

#### onEvent

    public void onEvent(GridDhtPartitionExchangeId exchId,
                        DiscoveryEvent discoEvt,
                        DiscoCache discoCache)

Event callback.

Parameters:
  `exchId` - Exchange ID.
  `discoEvt` - Discovery event.
  `discoCache` - Discovery data cache.

#### activateCluster

    public boolean activateCluster()

Returns:
  `True` if activate cluster exchange.

#### changedBaseline

    public boolean changedBaseline()

#### firstEvent

    public DiscoveryEvent firstEvent()

Returns:
  First event discovery event.

#### firstEventCache

    public DiscoCache firstEventCache()

Returns:
  Discovery cache for first event.

#### events

    public ExchangeDiscoveryEvents events()

Returns:
  Events processed in this exchange.

#### exchangeId

    public GridDhtPartitionExchangeId exchangeId()

Returns:
  Exchange ID.

#### init

    public void init(boolean newCrd)
              throws IgniteInterruptedCheckedException

Starts activity.

Parameters:
  `newCrd` - `True` if node become coordinator on this exchange.
Throws:
  `IgniteInterruptedCheckedException` - If interrupted.

#### localJoinExchange

    public boolean localJoinExchange()

Returns:
  `True` if exchange for local node join.

#### serverNodeDiscoveryEvent

    public boolean serverNodeDiscoveryEvent()

Returns:
  `True` if exchange triggered by server node join or fail.

#### exchangeDone

    public boolean exchangeDone()

Ready affinity future (`GridCachePartitionExchangeManager.affinityReadyFuture(AffinityTopologyVersion)` is completed before `GridFutureAdapter.onDone(Object, Throwable)` is called on `GridDhtPartitionsExchangeFuture`, it is guaranteed that this method will return `true` if affinity ready future is finished.

Also this method returns `false` for merged exchange futures.

Specified by:
  `exchangeDone` in interface `GridDhtTopologyFuture`
Returns:
  `True` if exchange is finished and result topology version can be used.

#### finishMerged

    public void finishMerged()

Finish merged future to allow GridCachePartitionExchangeManager.ExchangeFutureSet cleanup.

#### onDone

    public boolean onDone(@Nullable
                          AffinityTopologyVersion res,
                          @Nullable
                          Throwable err)

Callback to notify that future is finished. Note that if non-`null` exception is passed in the result value will be ignored.

Overrides:
  `onDone` in class `GridFutureAdapter<AffinityTopologyVersion>`
Parameters:
  `res` - Optional result.
  `err` - Optional error.
Returns:
  `True` if result was set by this call.

#### cleanUp

    public void cleanUp()

Cleans up resources to avoid excessive memory usage.

#### mergeJoinExchange

    public boolean mergeJoinExchange(GridDhtPartitionsExchangeFuture fut)

Merges this exchange with given one.

Parameters:
  `fut` - Current exchange to merge with.
Returns:
  `True` if need wait for message from joined server node.

#### mergeJoinExchangeOnDone

    @Nullable
    public GridDhtPartitionsSingleMessage mergeJoinExchangeOnDone(GridDhtPartitionsExchangeFuture fut)

Parameters:
  `fut` - Current future.
Returns:
  Pending join request if any.

#### onReceiveSingleMessage

    public void onReceiveSingleMessage(ClusterNode node,
                                       GridDhtPartitionsSingleMessage msg)

Processing of received single message. Actual processing in future may be delayed if init method was not completed, see `initDone()`

Parameters:
  `node` - Sender node.
  `msg` - Single partition info.

#### waitAndReplyToNode

    public void waitAndReplyToNode(UUID nodeId,
                                   GridDhtPartitionsSingleMessage msg)

Parameters:
  `nodeId` - Node ID.
  `msg` - Client's message.

#### onReceiveFullMessage

    public void onReceiveFullMessage(ClusterNode node,
                                     GridDhtPartitionsFullMessage msg)

Parameters:
  `node` - Sender node.
  `msg` - Full partition info.

#### onReceivePartitionRequest

    public void onReceivePartitionRequest(ClusterNode node,
                                          GridDhtPartitionsSingleRequest msg)

Parameters:
  `node` - Sender node.
  `msg` - Message with full partition info.

#### onAffinityChangeMessage

    public void onAffinityChangeMessage(ClusterNode node,
                                        CacheAffinityChangeMessage msg)

Affinity change message callback, processed from the same thread as `onNodeLeft(org.apache.ignite.cluster.ClusterNode)`.

Parameters:
  `node` - Message sender node.
  `msg` - Message.

#### onNodeLeft

    public void onNodeLeft(ClusterNode node)

Node left callback, processed from the same thread as `onAffinityChangeMessage(org.apache.ignite.cluster.ClusterNode, org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage)`.

Parameters:
  `node` - Left node.

#### reconnectOnError

    public boolean reconnectOnError(Throwable e)

Parameters:
  `e` - Exception.
Returns:
  `True` if local node should try reconnect in case of error.

#### compareTo

    public int compareTo(GridDhtPartitionsExchangeFuture fut)

Specified by:
  `compareTo` in interface `Comparable<GridDhtPartitionsExchangeFuture>`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### addDiagnosticRequest

    public void addDiagnosticRequest(IgniteDiagnosticPrepareContext diagCtx)

Specified by:
  `addDiagnosticRequest` in interface `IgniteDiagnosticAware`
Parameters:
  `diagCtx` - Context.

#### shortInfo

    public String shortInfo()

Returns:
  Short information string.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridFutureAdapter<AffinityTopologyVersion>`

#### nextDumpTimeout

    public static long nextDumpTimeout(int step,
                                       long timeout)

Parameters:
  `step` - Exponent coefficient.
  `timeout` - Base timeout.
Returns:
  Time to wait before next debug dump.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.4.0
Release Date | : March 5 2018