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

## Interface GridDhtTopologyFuture

All Superinterfaces:
  IgniteInternalFuture<AffinityTopologyVersion>

All Known Implementing Classes:
  ClientCacheDhtTopologyFuture, GridDhtPartitionsExchangeFuture, GridDhtTopologyFutureAdapter

    public interface GridDhtTopologyFuture
    extends IgniteInternalFuture<AffinityTopologyVersion>

Future that implements a barrier after which dht topology is safe to use. Topology is considered to be safe to use when all transactions that involve moving primary partitions are completed and partition map exchange is also completed.

When new cache operation is started, it will wait for this future before acquiring new locks on particular topology version.

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `changedAffinity()`
`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.
`AffinityTopologyVersion` `initialVersion()` Returns topology version when exchange started.
`AffinityTopologyVersion` `topologyVersion()` Gets result topology version of this future.
`@Nullable CacheInvalidStateException` `validateCache(GridCacheContext cctx, boolean recovery, boolean read, @Nullable Object key, @Nullable Collection<?> keys)` Returns error is cache topology is not valid.

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

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

### Method Detail

#### initialVersion

    AffinityTopologyVersion initialVersion()

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.

Returns:
  Topology version when exchange started.

#### topologyVersion

    AffinityTopologyVersion topologyVersion()

Gets result topology version of this future. Result version can differ from initial exchange version if exchanges 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.

Returns:
  Result topology version.

#### exchangeDone

    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.

Returns:
  `True` if exchange is finished and result topology version can be used.

#### validateCache

    @Nullable
    @Nullable CacheInvalidStateException validateCache(GridCacheContext cctx,
                                                                 boolean recovery,
                                                                 boolean read,
                                                                 @Nullable
                                                                 @Nullable Object key,
                                                                 @Nullable
                                                                 @Nullable Collection<?> keys)

Returns error is cache topology is not valid.

Parameters:
  `cctx` - Cache context.
  `recovery` - `True` if cache operation is done in recovery mode. Then it will only check for cache active state and topology validator result.
  `read` - `True` if validating read operation, `false` if validating write.
  `key` - Key (optimization to avoid collection creation).
  `keys` - Keys involved in a cache operation.
Returns:
  Not null exception if a cache is in invalid state.

#### changedAffinity

    boolean changedAffinity()

Returns:
  `True` if this exchange changed affinity.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020