org.apache.ignite.internal.processors.cache

## Class GridCacheUtils

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheUtils

Direct Known Subclasses:
  CU

    public class GridCacheUtils
    extends Object

Cache utility methods.

### Field Summary

Fields
`static String` `ATOMICS_CACHE_NAME` Atomics system cache name.
`static long` `EXPIRE_TIME_CALCULATE` Expire time: must be calculated based on TTL value.
`static long` `EXPIRE_TIME_ETERNAL` Expire time: eternal.
`static int` `KEEP_BINARY_FLAG_MASK` Keep serialized flag.
`static String` `MARSH_CACHE_NAME` Marshaller system cache name.
`static int` `SKIP_STORE_FLAG_MASK` Skip store flag bit mask.
`static String` `SYS_CACHE_HADOOP_MR` Hadoop syste cache name.
`static long` `TTL_ETERNAL` TTL: eternal.
`static long` `TTL_MINIMUM` TTL: minimum positive value.
`static long` `TTL_NOT_CHANGED` TTL: not changed.
`static long` `TTL_ZERO` TTL: zero (immediate expiration).
`static String` `UTILITY_CACHE_NAME` System cache name.

### Constructor Summary

Constructors
`protected` `GridCacheUtils()` Ensure singleton.

### Method Summary

Methods
`static boolean` `affinityNode(ClusterNode node, IgnitePredicate<ClusterNode> filter)`
`static Collection<ClusterNode>` `affinityNodes(GridCacheContext ctx)` Gets all nodes on which cache with the same name is started and the local DHT storage is enabled.
`static Collection<ClusterNode>` `affinityNodes(GridCacheContext ctx, AffinityTopologyVersion topOrder)` Gets DHT affinity nodes.
`static Collection<ClusterNode>` `aliveRemoteServerNodesWithCaches(GridCacheSharedContext ctx, AffinityTopologyVersion topOrder)` Gets alive remote nodes with at least one cache configured.
`static Collection<ClusterNode>` `allNodes(GridCacheContext ctx, AffinityTopologyVersion topOrder)` Gets all nodes on which cache with the same name is started.
`static Collection<ClusterNode>` `allNodes(GridCacheSharedContext ctx, AffinityTopologyVersion topOrder)` Gets all nodes with at least one cache configured.
`static CacheEntryPredicate` `alwaysFalse0()`
`static CacheEntryPredicate[]` `alwaysFalse0Arr()`
`static CacheEntryPredicate` `alwaysTrue0()`
`static Collection<ClusterNode>` `backups(Collection<ClusterNode> nodes)`
`static IgniteReducer<Boolean,Boolean>` `boolReducer()`
`static int` `cacheId(String cacheName)`
`static String` `cacheNameForSwapSpaceName(String swapSpaceName)`
`static <C extends CachePluginConfiguration> C` `cachePluginConfiguration(CacheConfiguration cfg, Class<C> cl)`
`static <T extends CachePluginConfiguration> List<T>` `cachePluginConfigurations(IgniteConfiguration cfg, Class<T> cls)`
`static CacheEntryPredicate` `cachePrimary(Affinity aff, ClusterNode n)`
`static void` `checkAttributeMismatch(IgniteLogger log, CacheConfiguration locCfg, CacheConfiguration rmtCfg, UUID rmtNodeId, T2<String,String> attr, boolean fail)` Checks that local and remove configurations have the same value of given attribute.
`static void` `checkAttributeMismatch(IgniteLogger log, String cfgName, UUID rmtNodeId, String attrName, String attrMsg, Object locVal, Object rmtVal, boolean fail)` Checks that cache configuration attribute has the same value in local and remote cache configurations.
`static void` `checkStore(GridCacheContext<?,?> ctx)` Checks that cache store is present.
`static boolean` `clientNode(ClusterNode node)`
`static boolean` `clientNodeDirect(ClusterNode node)`
`static <T> IgniteReducer<Collection<T>,Collection<T>>` `collectionsReducer(int size)` Gets reducer that aggregates collections.
`static Map<Integer,int[]>` `convertInvalidPartitions(Map<Integer,Set<Integer>> partsMap)`
`static RuntimeException` `convertToCacheException(IgniteCheckedException e)`
`static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]` `empty()`
`static CacheEntryPredicate[]` `empty0()`
`static IgniteClosure<GridCacheEntryEx,KeyCacheObject>` `entry2Key()`
`static IgniteInClosure<IgniteInternalFuture<?>>` `errorLogger(IgniteLogger log, Class<? extends Exception>... excl)`
`static long` `expireTimeInPast()`
`static <K,V> IgniteClosure<Integer,IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]>` `factory()` Entry predicate factory mostly used for deserialization.
`static CacheObject` `failed(boolean err)`
`static CacheObject` `failed(boolean err, CacheObject val)`
`static CacheEntryPredicate[]` `filterArray(CacheEntryPredicate filter)` Create filter array.
`static CacheConfiguration` `hadoopSystemCache()` Create system cache used by Hadoop component.
`static <K,V> IgniteClosure<GridCacheEntryInfo,K>` `info2Key()`
`static <K,V> void` `inTx(Ignite ignite, IgniteCache<K,V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteCache<K,V>> clo)` Execute closure inside cache transaction.
`static <K,V> void` `inTx(IgniteInternalCache<K,V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteInternalCache<K,V>> clo)` Execute closure inside cache transaction.
`static <K,V> void` `invalidate(IgniteCache<K,V> cache, K key)` Invalidate entry in cache.
`static boolean` `isAlwaysFalse0(CacheEntryPredicate[] p)`
`static boolean` `isAlwaysTrue0(CacheEntryPredicate[] p)`
`static boolean` `isAtomicsCache(String cacheName)`
`static boolean` `isHadoopSystemCache(String cacheName)`
`static boolean` `isIgfsCache(IgniteConfiguration cfg, String cacheName)`
`static boolean` `isLockTimeoutOrCancelled(Throwable t)`
`static boolean` `isMarshallerCache(String cacheName)`
`static boolean` `isNearEnabled(CacheConfiguration cfg)` Checks if near cache is enabled for cache configuration.
`static boolean` `isNearEnabled(GridCacheContext ctx)` Checks if near cache is enabled for cache context.
`static boolean` `isSwapEnabled(ClusterNode node)` Checks if swap is enabled on node.
`static boolean` `isSystemCache(String cacheName)`
`static boolean` `isUtilityCache(String cacheName)`
`static IgnitePredicate<KeyCacheObject>` `keyHasMeta(GridCacheContext ctx, int meta)`
`static <K,V> IgniteReducer<Map<K,V>,Map<K,V>>` `mapsReducer(int size)` Gets reducer that aggregates maps into one.
`static byte[]` `marshal(GridCacheContext ctx, Object obj)`
`static byte[]` `marshal(GridCacheSharedContext ctx, boolean depEnabled, Object obj)`
`static String` `mask(String cacheName)` Mask cache name in case it is null.
`static String` `namexx(String name)` Gets public cache name substituting null name by `'default'`.
`static Map<UUID,Collection<ClusterNode>>` `neighbors(Collection<ClusterNode> topSnapshot)` Builds neighborhood map for all nodes in snapshot.
`static Collection<ClusterNode>` `neighborsForNodes(Map<UUID,Collection<ClusterNode>> neighborhood, Iterable<ClusterNode> nodes)` Returns neighbors for all `nodes`.
`static Comparator<ClusterNode>` `nodeComparator(boolean asc)`
`static <T> IgniteReducer<T,Collection<T>>` `objectsReducer()` Gets reducer that aggregates items into collection.
`static ClusterNode` `oldest(Collection<ClusterNode> nodes)`
`static ClusterNode` `oldestAliveCacheServerNode(GridCacheSharedContext ctx, AffinityTopologyVersion topVer)` Gets oldest alive server node with at least one cache configured for specified topology version.
`static <T> T` `outTx(Callable<T> cmd, GridCacheContext ctx)` Method executes any Callable out of scope of transaction.
`static IgniteClosure<GridDhtLocalPartition,GridDhtPartitionState>` `part2state()`
`static ClusterNode` `primary(Iterable<? extends ClusterNode> nodes)`
`static ClusterNode` `primaryNode(GridCacheContext ctx, Object key)` Gets primary node on which given key is cached.
`static <K,V> CacheEntryPredicate[]` `readEntryFilterArray(ObjectInput in)` Reads array from input stream.
`static <K,V> IgnitePredicate<IgniteTxEntry>` `reads()`
`static Collection<ClusterNode>` `remoteNodes(GridCacheSharedContext ctx, AffinityTopologyVersion topVer)` Gets remote nodes with at least one cache configured.
`static String` `replicationTopicReceive(String cacheName)` Get topic to which replication responses are sent.
`static String` `replicationTopicSend()` Get topic to which replication requests are sent.
`static <S> Callable<S>` `retryTopologySafe(Callable<S> c)`
`static Object` `skipValue(Object val, boolean skip)`
`static Collection<CacheStoreSessionListener>` `startStoreSessionListeners(GridKernalContext ctx, javax.cache.configuration.Factory<CacheStoreSessionListener>[] factories)` Creates and starts store session listeners.
`static void` `stopStoreSessionListeners(GridKernalContext ctx, Collection<CacheStoreSessionListener> sesLsnrs)` Stops store session listeners.
`static <K,V> UUID` `subjectId(IgniteInternalTx tx, GridCacheSharedContext<K,V> ctx)` Gets subject ID by transaction.
`static String` `swapSpaceName(GridCacheContext<?,?> ctx)`
`static long` `toExpireTime(long ttl)` Convert TTL to expire time.
`static long` `toTtl(javax.cache.expiry.Duration duration)`
`static TransactionConfiguration` `transactionConfiguration(GridCacheContext sysCacheCtx, IgniteConfiguration cfg)`
`static long` `ttlForLoad(javax.cache.expiry.ExpiryPolicy plc)` Get TTL for load operation.
`static <K,V> IgniteClosure<IgniteInternalTx,GridCacheVersion>` `tx2xidVersion()`
`static IgniteInternalTx` `txStartInternal(GridCacheContext ctx, IgniteInternalCache prj, TransactionConcurrency concurrency, TransactionIsolation isolation)`
`static String` `txString(IgniteInternalTx tx)`
`static <K,V> IgniteBiPredicate<K,V>` `typeFilter(Class<?> keyType, Class<?> valType)` Gets type filter for projections.
`static CacheEntryPredicate` `typeFilter0(Class<?> keyType, Class<?> valType)`
`static String` `unmask(String cacheName)` Unmask cache name.
`static void` `unwindEvicts(GridCacheContext ctx)`
`static <K,V> void` `unwindEvicts(GridCacheSharedContext<K,V> ctx)`
`static void` `validateCacheKey(Object key)` Validates that cache key object has overridden equals and hashCode methods.
`static <T> T` `value(CacheObject cacheObj, GridCacheContext ctx, boolean cpy)`
`static byte[]` `versionToBytes(GridCacheVersion ver)` Converts cache version to byte array.
`static <K,V> IgnitePredicate<IgniteTxEntry>` `writes()`

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

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

### Field Detail

#### SYS_CACHE_HADOOP_MR

    public static final String SYS_CACHE_HADOOP_MR

Hadoop syste cache name.

See Also:
  Constant Field Values

#### UTILITY_CACHE_NAME

    public static final String UTILITY_CACHE_NAME

System cache name.

See Also:
  Constant Field Values

#### ATOMICS_CACHE_NAME

    public static final String ATOMICS_CACHE_NAME

Atomics system cache name.

See Also:
  Constant Field Values

#### MARSH_CACHE_NAME

    public static final String MARSH_CACHE_NAME

Marshaller system cache name.

See Also:
  Constant Field Values

#### TTL_MINIMUM

    public static final long TTL_MINIMUM

TTL: minimum positive value.

See Also:
  Constant Field Values

#### TTL_ETERNAL

    public static final long TTL_ETERNAL

TTL: eternal.

See Also:
  Constant Field Values

#### TTL_NOT_CHANGED

    public static final long TTL_NOT_CHANGED

TTL: not changed.

See Also:
  Constant Field Values

#### TTL_ZERO

    public static final long TTL_ZERO

TTL: zero (immediate expiration).

See Also:
  Constant Field Values

#### EXPIRE_TIME_ETERNAL

    public static final long EXPIRE_TIME_ETERNAL

Expire time: eternal.

See Also:
  Constant Field Values

#### EXPIRE_TIME_CALCULATE

    public static final long EXPIRE_TIME_CALCULATE

Expire time: must be calculated based on TTL value.

See Also:
  Constant Field Values

#### SKIP_STORE_FLAG_MASK

    public static final int SKIP_STORE_FLAG_MASK

Skip store flag bit mask.

See Also:
  Constant Field Values

#### KEEP_BINARY_FLAG_MASK

    public static final int KEEP_BINARY_FLAG_MASK

Keep serialized flag.

See Also:
  Constant Field Values

### Constructor Detail

#### GridCacheUtils

    protected GridCacheUtils()

Ensure singleton.

### Method Detail

#### keyHasMeta

    public static IgnitePredicate<KeyCacheObject> keyHasMeta(GridCacheContext ctx,
                                             int meta)

Parameters:
  `ctx` - Cache context.
  `meta` - Meta name.
Returns:
  Filter for entries with meta.

#### failed

    @Nullable
    public static CacheObject failed(boolean err)
                              throws GridCacheFilterFailedException

Parameters:
  `err` - If `true`, then throw `GridCacheFilterFailedException`, otherwise return `val` passed in.
Returns:
  Always return `null`.
Throws:
  `GridCacheFilterFailedException` - If `err` flag is `true`.

#### failed

    @Nullable
    public static CacheObject failed(boolean err,
                              CacheObject val)
                              throws GridCacheFilterFailedException

Parameters:
  `err` - If `true`, then throw `GridCacheFilterFailedException`, otherwise return `val` passed in.
  `val` - Value for which evaluation happened.
Returns:
  Always return `val` passed in or throw exception.
Throws:
  `GridCacheFilterFailedException` - If `err` flag is `true`.

#### filterArray

    public static CacheEntryPredicate[] filterArray(@Nullable
                                    CacheEntryPredicate filter)

Create filter array.

Parameters:
  `filter` - Filter.
Returns:
  Filter array.

#### factory

    public static <K,V> IgniteClosure<Integer,IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]> factory()

Entry predicate factory mostly used for deserialization.

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Returns:
  Factory instance.

#### checkStore

    public static void checkStore(GridCacheContext<?,?> ctx)
                           throws IgniteCheckedException

Checks that cache store is present.

Parameters:
  `ctx` - Registry.
Throws:
  `IgniteCheckedException` - If cache store is not present.

#### swapSpaceName

    public static String swapSpaceName(GridCacheContext<?,?> ctx)

Parameters:
  `ctx` - Cache registry.
Returns:
  Space name.

#### cacheNameForSwapSpaceName

    public static String cacheNameForSwapSpaceName(String swapSpaceName)

Parameters:
  `swapSpaceName` - Swap space name.
Returns:
  Cache name.

#### namexx

    public static String namexx(@Nullable
                String name)

Gets public cache name substituting null name by `'default'`.

Returns:
  Public cache name substituting null name by `'default'`.

#### part2state

    public static IgniteClosure<GridDhtLocalPartition,GridDhtPartitionState> part2state()

Returns:
  Partition to state transformer.

#### allNodes

    public static Collection<ClusterNode> allNodes(GridCacheContext ctx,
                                   AffinityTopologyVersion topOrder)

Gets all nodes on which cache with the same name is started.

Parameters:
  `ctx` - Cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  All nodes on which cache with the same name is started (including nodes that may have already left).

#### allNodes

    public static Collection<ClusterNode> allNodes(GridCacheSharedContext ctx,
                                   AffinityTopologyVersion topOrder)

Gets all nodes with at least one cache configured.

Parameters:
  `ctx` - Shared cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  All nodes on which cache with the same name is started (including nodes that may have already left).

#### remoteNodes

    public static Collection<ClusterNode> remoteNodes(GridCacheSharedContext ctx,
                                      AffinityTopologyVersion topVer)

Gets remote nodes with at least one cache configured.

Parameters:
  `ctx` - Cache shared context.
  `topVer` - Topology version.
Returns:
  Collection of remote nodes with at least one cache configured.

#### aliveRemoteServerNodesWithCaches

    public static Collection<ClusterNode> aliveRemoteServerNodesWithCaches(GridCacheSharedContext ctx,
                                                           AffinityTopologyVersion topOrder)

Gets alive remote nodes with at least one cache configured.

Parameters:
  `ctx` - Cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  Affinity nodes.

#### affinityNodes

    public static Collection<ClusterNode> affinityNodes(GridCacheContext ctx)

Gets all nodes on which cache with the same name is started and the local DHT storage is enabled.

Parameters:
  `ctx` - Cache context.
Returns:
  All nodes on which cache with the same name is started.

#### affinityNodes

    public static Collection<ClusterNode> affinityNodes(GridCacheContext ctx,
                                        AffinityTopologyVersion topOrder)

Gets DHT affinity nodes.

Parameters:
  `ctx` - Cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  Affinity nodes.

#### isNearEnabled

    public static boolean isNearEnabled(GridCacheContext ctx)

Checks if near cache is enabled for cache context.

Parameters:
  `ctx` - Cache context to check.
Returns:
  `True` if near cache is enabled, `false` otherwise.

#### isNearEnabled

    public static boolean isNearEnabled(CacheConfiguration cfg)

Checks if near cache is enabled for cache configuration.

Parameters:
  `cfg` - Cache configuration to check.
Returns:
  `True` if near cache is enabled, `false` otherwise.

#### oldestAliveCacheServerNode

    @Nullable
    public static ClusterNode oldestAliveCacheServerNode(GridCacheSharedContext ctx,
                                                  AffinityTopologyVersion topVer)

Gets oldest alive server node with at least one cache configured for specified topology version.

Parameters:
  `ctx` - Context.
  `topVer` - Maximum allowed topology version.
Returns:
  Oldest alive cache server node.

#### oldest

    @Nullable
    public static ClusterNode oldest(Collection<ClusterNode> nodes)

Parameters:
  `nodes` - Nodes.
Returns:
  Oldest node for the given topology version.

#### empty

    public static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] empty()

Returns:
  Empty filter.

#### empty0

    public static CacheEntryPredicate[] empty0()

Returns:
  Empty filter.

#### alwaysFalse0

    public static CacheEntryPredicate alwaysFalse0()

Returns:
  Always false filter.

#### alwaysTrue0

    public static CacheEntryPredicate alwaysTrue0()

Returns:
  Always false filter.

#### alwaysFalse0Arr

    public static CacheEntryPredicate[] alwaysFalse0Arr()

Returns:
  Always false filter.

#### isAlwaysFalse0

    public static boolean isAlwaysFalse0(@Nullable
                         CacheEntryPredicate[] p)

Parameters:
  `p` - Predicate.
Returns:
  `True` if always false filter.

#### isAlwaysTrue0

    public static boolean isAlwaysTrue0(@Nullable
                        CacheEntryPredicate[] p)

Parameters:
  `p` - Predicate.
Returns:
  `True` if always false filter.

#### tx2xidVersion

    public static <K,V> IgniteClosure<IgniteInternalTx,GridCacheVersion> tx2xidVersion()

Returns:
  Closure which converts transaction entry xid to XID version.

#### entry2Key

    public static IgniteClosure<GridCacheEntryEx,KeyCacheObject> entry2Key()

Returns:
  Closure that converts entry to key.

#### info2Key

    public static <K,V> IgniteClosure<GridCacheEntryInfo,K> info2Key()

Returns:
  Closure that converts entry info to key.

#### reads

    public static <K,V> IgnitePredicate<IgniteTxEntry> reads()

Returns:
  Filter for transaction reads.

#### writes

    public static <K,V> IgnitePredicate<IgniteTxEntry> writes()

Returns:
  Filter for transaction writes.

#### typeFilter

    public static <K,V> IgniteBiPredicate<K,V> typeFilter(Class<?> keyType,
                                          Class<?> valType)

Gets type filter for projections.

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Parameters:
  `keyType` - Key type.
  `valType` - Value type.
Returns:
  Type filter.

#### typeFilter0

    public static CacheEntryPredicate typeFilter0(Class<?> keyType,
                                  Class<?> valType)

Parameters:
  `keyType` - Key type.
  `valType` - Value type.
Returns:
  Type filter.

#### boolReducer

    public static IgniteReducer<Boolean,Boolean> boolReducer()

Returns:
  Boolean reducer.

#### mapsReducer

    public static <K,V> IgniteReducer<Map<K,V>,Map<K,V>> mapsReducer(int size)

Gets reducer that aggregates maps into one.

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Parameters:
  `size` - Predicted size of the resulting map to avoid resizings.
Returns:
  Reducer.

#### collectionsReducer

    public static <T> IgniteReducer<Collection<T>,Collection<T>> collectionsReducer(int size)

Gets reducer that aggregates collections.

Type Parameters:
  `T` - Collection element type.
Returns:
  Reducer.

#### objectsReducer

    public static <T> IgniteReducer<T,Collection<T>> objectsReducer()

Gets reducer that aggregates items into collection.

Type Parameters:
  `T` - Items type.
Returns:
  Reducer.

#### primary

    public static ClusterNode primary(Iterable<? extends ClusterNode> nodes)

Parameters:
  `nodes` - Set of nodes.
Returns:
  Primary node.

#### backups

    public static Collection<ClusterNode> backups(Collection<ClusterNode> nodes)

Parameters:
  `nodes` - Nodes.
Returns:
  Backup nodes.

#### errorLogger

    public static IgniteInClosure<IgniteInternalFuture<?>> errorLogger(IgniteLogger log,
                                                       Class<? extends Exception>... excl)

Parameters:
  `log` - Logger.
  `excl` - Excludes.
Returns:
  Future listener that logs errors.

#### isLockTimeoutOrCancelled

    public static boolean isLockTimeoutOrCancelled(Throwable t)

Parameters:
  `t` - Exception to check.
Returns:
  `true` if caused by lock timeout or cancellation.

#### marshal

    public static byte[] marshal(GridCacheContext ctx,
                 Object obj)
                          throws IgniteCheckedException

Parameters:
  `ctx` - Cache context.
  `obj` - Object to marshal.
Returns:
  Buffer that contains obtained byte array.
Throws:
  `IgniteCheckedException` - If marshalling failed.

#### marshal

    public static byte[] marshal(GridCacheSharedContext ctx,
                 boolean depEnabled,
                 Object obj)
                          throws IgniteCheckedException

Parameters:
  `ctx` - Cache context.
  `depEnabled` - deployment enabled flag.
  `obj` - Object to marshal.
Returns:
  Buffer that contains obtained byte array.
Throws:
  `IgniteCheckedException` - If marshalling failed.

#### outTx

    public static <T> T outTx(Callable<T> cmd,
              GridCacheContext ctx)
                   throws IgniteCheckedException

Method executes any Callable out of scope of transaction. If transaction started by this thread `cmd` will be executed in another thread.

Parameters:
  `cmd` - Callable.
  `ctx` - Cache context.
Returns:
  T Callable result.
Throws:
  `IgniteCheckedException` - If execution failed.

#### skipValue

    public static Object skipValue(Object val,
                   boolean skip)

Parameters:
  `val` - Value.
  `skip` - Skip value flag.
Returns:
  Value.

#### txStartInternal

    public static IgniteInternalTx txStartInternal(GridCacheContext ctx,
                                   IgniteInternalCache prj,
                                   TransactionConcurrency concurrency,
                                   TransactionIsolation isolation)

Parameters:
  `ctx` - Context.
  `prj` - Projection.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
Returns:
  New transaction.

#### txString

    public static String txString(@Nullable
                  IgniteInternalTx tx)

Parameters:
  `tx` - Transaction.
Returns:
  String view of all safe-to-print transaction properties.

#### unwindEvicts

    public static void unwindEvicts(GridCacheContext ctx)

Parameters:
  `ctx` - Cache context.

#### unwindEvicts

    public static <K,V> void unwindEvicts(GridCacheSharedContext<K,V> ctx)

Parameters:
  `ctx` - Shared cache context.

#### primaryNode

    @Nullable
    public static ClusterNode primaryNode(GridCacheContext ctx,
                                   Object key)

Gets primary node on which given key is cached.

Parameters:
  `ctx` - Cache.
  `key` - Key to find primary node for.
Returns:
  Primary node for the key.

#### nodeComparator

    public static Comparator<ClusterNode> nodeComparator(boolean asc)

Parameters:
  `asc` - `True` for ascending.
Returns:
  Descending order comparator.

#### versionToBytes

    public static byte[] versionToBytes(GridCacheVersion ver)

Converts cache version to byte array.

Parameters:
  `ver` - Version.
Returns:
  Byte array.

#### mask

    public static String mask(String cacheName)

Mask cache name in case it is null.

Parameters:
  `cacheName` - Cache name.
Returns:
  The same cache name or `<default>` in case the name is `null`.

#### unmask

    @Nullable
    public static String unmask(String cacheName)

Unmask cache name.

Parameters:
  `cacheName` - Cache name.
Returns:
  Unmasked cache name, i.e. in case provided parameter was `<default>` then `null` will be returned.

#### replicationTopicSend

    public static String replicationTopicSend()

Get topic to which replication requests are sent.

Returns:
  Topic to which replication requests are sent.

#### replicationTopicReceive

    public static String replicationTopicReceive(String cacheName)

Get topic to which replication responses are sent.

Parameters:
  `cacheName` - Cache name.
Returns:
  Topic to which replication responses are sent.

#### checkAttributeMismatch

    public static void checkAttributeMismatch(IgniteLogger log,
                              CacheConfiguration locCfg,
                              CacheConfiguration rmtCfg,
                              UUID rmtNodeId,
                              T2<String,String> attr,
                              boolean fail)
                                       throws IgniteCheckedException

Checks that local and remove configurations have the same value of given attribute.

Parameters:
  `log` - Logger used to log warning message (used only if fail flag is not set).
  `locCfg` - Local configuration.
  `rmtCfg` - Remote configuration.
  `rmtNodeId` - Remote node.
  `attr` - Attribute name.
  `fail` - If true throws IgniteCheckedException in case of attribute values mismatch, otherwise logs warning.
Throws:
  `IgniteCheckedException` - If attribute values are different and fail flag is true.

#### checkAttributeMismatch

    public static void checkAttributeMismatch(IgniteLogger log,
                              String cfgName,
                              UUID rmtNodeId,
                              String attrName,
                              String attrMsg,
                              @Nullable
                              Object locVal,
                              @Nullable
                              Object rmtVal,
                              boolean fail)
                                       throws IgniteCheckedException

Checks that cache configuration attribute has the same value in local and remote cache configurations.

Parameters:
  `log` - Logger used to log warning message (used only if fail flag is not set).
  `cfgName` - Remote cache name.
  `rmtNodeId` - Remote node.
  `attrName` - Short attribute name for error message.
  `attrMsg` - Full attribute name for error message.
  `locVal` - Local value.
  `rmtVal` - Remote value.
  `fail` - If true throws IgniteCheckedException in case of attribute values mismatch, otherwise logs warning.
Throws:
  `IgniteCheckedException` - If attribute values are different and fail flag is true.

#### validateCacheKey

    public static void validateCacheKey(@Nullable
                        Object key)

Validates that cache key object has overridden equals and hashCode methods.

Parameters:
  `key` - Key.
Throws:
  `IllegalArgumentException` - If equals or hashCode is not implemented.

#### isHadoopSystemCache

    public static boolean isHadoopSystemCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if this is Hadoop system cache.

#### hadoopSystemCache

    public static CacheConfiguration hadoopSystemCache()

Create system cache used by Hadoop component.

Returns:
  Hadoop cache configuration.

#### isMarshallerCache

    public static boolean isMarshallerCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if this is marshaller system cache.

#### isUtilityCache

    public static boolean isUtilityCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if this is utility system cache.

#### isAtomicsCache

    public static boolean isAtomicsCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if this is atomics system cache.

#### isSystemCache

    public static boolean isSystemCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if system cache.

#### cacheId

    public static int cacheId(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  Cache ID.

#### isIgfsCache

    public static boolean isIgfsCache(IgniteConfiguration cfg,
                      @Nullable
                      String cacheName)

Parameters:
  `cfg` - Grid configuration.
  `cacheName` - Cache name.
Returns:
  `True` in this is IGFS data or meta cache.

#### toExpireTime

    public static long toExpireTime(long ttl)

Convert TTL to expire time.

Parameters:
  `ttl` - TTL.
Returns:
  Expire time.

#### inTx

    public static <K,V> void inTx(IgniteInternalCache<K,V> cache,
                  TransactionConcurrency concurrency,
                  TransactionIsolation isolation,
                  IgniteInClosureX<IgniteInternalCache<K,V>> clo)
                     throws IgniteCheckedException

Execute closure inside cache transaction.

Parameters:
  `cache` - Cache.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `clo` - Closure.
Throws:
  `IgniteCheckedException` - If failed.

#### inTx

    public static <K,V> void inTx(Ignite ignite,
                  IgniteCache<K,V> cache,
                  TransactionConcurrency concurrency,
                  TransactionIsolation isolation,
                  IgniteInClosureX<IgniteCache<K,V>> clo)
                     throws IgniteCheckedException

Execute closure inside cache transaction.

Parameters:
  `cache` - Cache.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `clo` - Closure.
Throws:
  `IgniteCheckedException` - If failed.

#### subjectId

    public static <K,V> UUID subjectId(IgniteInternalTx tx,
                       GridCacheSharedContext<K,V> ctx)

Gets subject ID by transaction.

Parameters:
  `tx` - Transaction.
Returns:
  Subject ID.

#### invalidate

    public static <K,V> void invalidate(IgniteCache<K,V> cache,
                        K key)

Invalidate entry in cache.

Parameters:
  `cache` - Cache.
  `key` - Key.

#### toTtl

    public static long toTtl(javax.cache.expiry.Duration duration)

Parameters:
  `duration` - Duration.
Returns:
  TTL.

#### ttlForLoad

    public static long ttlForLoad(javax.cache.expiry.ExpiryPolicy plc)

Get TTL for load operation.

Parameters:
  `plc` - Expiry policy.
Returns:
  TTL for load operation or `TTL_ZERO` in case of immediate expiration.

#### expireTimeInPast

    public static long expireTimeInPast()

Returns:
  Expire time denoting a point in the past.

#### readEntryFilterArray

    @Nullable
    public static <K,V> CacheEntryPredicate[] readEntryFilterArray(ObjectInput in)
                                                      throws IOException,
                                                             ClassNotFoundException

Reads array from input stream.

Parameters:
  `in` - Input stream.
Returns:
  Deserialized array.
Throws:
  `IOException` - If failed.
  `ClassNotFoundException` - If class not found.

#### cachePrimary

    public static CacheEntryPredicate cachePrimary(Affinity aff,
                                   ClusterNode n)

Parameters:
  `aff` - Affinity.
  `n` - Node.
Returns:
  Predicate that evaluates to `true` if entry is primary for node.

#### convertToCacheException

    @NotNull
    public static RuntimeException convertToCacheException(IgniteCheckedException e)

Parameters:
  `e` - Ignite checked exception.
Returns:
  CacheException runtime exception, never null.

#### value

    @Nullable
    public static <T> T value(@Nullable
                       CacheObject cacheObj,
                       GridCacheContext ctx,
                       boolean cpy)

Parameters:
  `cacheObj` - Cache object.
  `ctx` - Cache context.
  `cpy` - Copy flag.
Returns:
  Cache object value.

#### cachePluginConfiguration

    public static <C extends CachePluginConfiguration> C cachePluginConfiguration(CacheConfiguration cfg,
                                                                  Class<C> cl)

Parameters:
  `cfg` - Cache configuration.
  `cl` - Type of cache plugin configuration.
Returns:
  Cache plugin configuration by type from cache configuration or `null`.

#### cachePluginConfigurations

    public static <T extends CachePluginConfiguration> List<T> cachePluginConfigurations(IgniteConfiguration cfg,
                                                                         Class<T> cls)

Parameters:
  `cfg` - Config.
  `cls` - Class.
Returns:
  Not `null` list.

#### clientNode

    public static boolean clientNode(ClusterNode node)

Parameters:
  `node` - Node.
Returns:
  `True` if given node is client node (has flag `IgniteConfiguration.isClientMode()` set).

#### clientNodeDirect

    public static boolean clientNodeDirect(ClusterNode node)

Parameters:
  `node` - Node.
Returns:
  `True` if given node is client node (has flag `IgniteConfiguration.isClientMode()` set).

#### affinityNode

    public static boolean affinityNode(ClusterNode node,
                       IgnitePredicate<ClusterNode> filter)

Parameters:
  `node` - Node.
  `filter` - Node filter.
Returns:
  `True` if node is not client node and pass given filter.

#### startStoreSessionListeners

    public static Collection<CacheStoreSessionListener> startStoreSessionListeners(GridKernalContext ctx,
                                                                   javax.cache.configuration.Factory<CacheStoreSessionListener>[] factories)
                                                                            throws IgniteCheckedException

Creates and starts store session listeners.

Parameters:
  `ctx` - Kernal context.
  `factories` - Factories.
Returns:
  Listeners.
Throws:
  `IgniteCheckedException` - In case of error.

#### convertInvalidPartitions

    public static Map<Integer,int[]> convertInvalidPartitions(Map<Integer,Set<Integer>> partsMap)

Parameters:
  `partsMap` - Cache ID to partition IDs collection map.
Returns:
  Cache ID to partition ID array map.

#### stopStoreSessionListeners

    public static void stopStoreSessionListeners(GridKernalContext ctx,
                                 Collection<CacheStoreSessionListener> sesLsnrs)
                                          throws IgniteCheckedException

Stops store session listeners.

Parameters:
  `ctx` - Kernal context.
  `sesLsnrs` - Session listeners.
Throws:
  `IgniteCheckedException` - In case of error.

#### retryTopologySafe

    public static <S> Callable<S> retryTopologySafe(Callable<S> c)

Type Parameters:
  `S` - Closure type.
Parameters:
  `c` - Closure to retry.
Returns:
  Wrapped closure.

#### neighbors

    public static Map<UUID,Collection<ClusterNode>> neighbors(Collection<ClusterNode> topSnapshot)

Builds neighborhood map for all nodes in snapshot.

Parameters:
  `topSnapshot` - Topology snapshot.
Returns:
  Neighbors map.

#### neighborsForNodes

    public static Collection<ClusterNode> neighborsForNodes(Map<UUID,Collection<ClusterNode>> neighborhood,
                                            Iterable<ClusterNode> nodes)

Returns neighbors for all `nodes`.

Parameters:
  `neighborhood` - Neighborhood cache.
  `nodes` - Nodes.
Returns:
  All neighbors for given nodes.

#### isSwapEnabled

    public static boolean isSwapEnabled(ClusterNode node)

Checks if swap is enabled on node.

Parameters:
  `node` - Node
Returns:
  `true` if swap is enabled, `false` otherwise.

#### transactionConfiguration

    public static TransactionConfiguration transactionConfiguration(@Nullable
                                                    GridCacheContext sysCacheCtx,
                                                    IgniteConfiguration cfg)

Returns:
  default TX configuration if system cache is used or current grid TX config otherwise.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.6.0
Release Date | : May 18 2016