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 String` `SYS_CACHE_HADOOP_MR` Hadoop syste cache name.
`static long` `TTL_NOT_CHANGED`
`static long` `TTL_ZERO`
`static String` `UTILITY_CACHE_NAME` System cache name.

### Constructor Summary

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

### Method Summary

Methods
`static boolean` `affinityNode(GridCacheContext ctx, ClusterNode s)` Checks if given node has specified cache started and the local DHT storage is enabled.
`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, long topOrder)` Gets DHT affinity nodes.
`static Collection<ClusterNode>` `aliveCacheNodes(GridCacheSharedContext ctx, long topOrder)` Gets alive nodes with at least one cache configured.
`static Collection<ClusterNode>` `aliveNodes(GridCacheContext ctx, long topOrder)` Gets alive nodes.
`static Collection<ClusterNode>` `aliveRemoteCacheNodes(GridCacheSharedContext ctx, long topOrder)` Gets alive remote nodes with at least one cache configured.
`static Collection<ClusterNode>` `aliveRemoteNodes(GridCacheContext ctx, long topOrder)` Gets alive nodes.
`static Collection<ClusterNode>` `allNodes(GridCacheContext ctx)` Gets all nodes on which cache with the same name is started.
`static Collection<ClusterNode>` `allNodes(GridCacheContext ctx, long topOrder)` Gets all nodes on which cache with the same name is started.
`static Collection<ClusterNode>` `allNodes(GridCacheSharedContext ctx, long topOrder)` Gets all nodes with at least one cache configured.
`static boolean` `allowForStartup(Object msg)`
`static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]` `alwaysFalse()`
`static Collection<ClusterNode>` `backups(Collection<ClusterNode> nodes)`
`static IgniteReducer<Boolean,Boolean>` `boolReducer()`
`static <K,V> IgniteClosure<K,javax.cache.Cache.Entry<K,V>>` `cacheKey2Entry(GridCacheContext<K,V> ctx)` Gets closure which returns `Entry` given cache key.
`static String` `cacheNameForSwapSpaceName(String swapSpaceName)`
`static boolean` `cacheNode(GridCacheContext ctx, ClusterNode node)` Checks if given node contains configured cache with the name as described by given cache context.
`static boolean` `cacheNode(String cacheName, ClusterNode node)` Checks if given node has specified cache started.
`static boolean` `cacheNode(String cacheName, GridCacheAttributes[] caches)` Checks if given attributes relate the the node which has (or had) specified cache started.
`static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>` `cachePrimary(CacheAffinity<K> aff, ClusterNode n)`
`static void` `checkAttributeMismatch(IgniteLogger log, CacheConfiguration locCfg, CacheConfiguration rmtCfg, ClusterNode rmt, 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, ClusterNode rmt, 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 <T> IgniteReducer<Collection<T>,Collection<T>>` `collectionsReducer()` Gets reducer that aggregates collections.
`static CacheDistributionMode` `distributionMode(CacheConfiguration cfg)` Gets default partitioned cache mode.
`static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]` `empty()`
`static <K,V> IgniteClosure<GridCacheEntryEx<K,V>,K>` `entry2Key()`
`static IgniteInClosure<IgniteInternalFuture<?>>` `errorLogger(IgniteLogger log, Class<? extends Exception>... excl)`
`static <K,V> IgniteClosure<Integer,IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]>` `factory()` Entry predicate factory mostly used for deserialization.
`static <T> T` `failed(boolean err)`
`static <T> T` `failed(boolean err, T val)`
`static <K,V> Collection<V>` `getOrSet(ConcurrentMap<K,Collection<V>> mappings, K k)`
`static <K,V> Collection<V>` `getOrSet(Map<K,List<V>> mappings, K k)`
`static CacheConfiguration` `hadoopSystemCache()` Create system cache used by Hadoop component.
`static <K,V> IgniteClosure<GridCacheEntryInfo<K,V>,K>` `info2Key()`
`static <K,V> void` `inTx(CacheProjection<K,V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<CacheProjection<K,V>> clo)` Execute closure inside cache transaction.
`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> boolean` `invalidate(CacheProjection<K,V> cache, K key)` Invalidate entry in cache.
`static boolean` `isAffinityNode(CacheConfiguration cfg)` Checks if node is affinity node for given cache configuration.
`static boolean` `isAtomicsCache(String cacheName)`
`static boolean` `isHadoopSystemCache(String cacheName)`
`static boolean` `isIgfsCache(IgniteConfiguration cfg, String cacheName)`
`static boolean` `isLockTimeout(Throwable t)`
`static boolean` `isLockTimeoutOrCancelled(Throwable t)`
`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` `isSystemCache(String cacheName)`
`static boolean` `isUtilityCache(String cacheName)`
`static <K,V> IgnitePredicate<K>` `keyHasMeta(GridCacheContext<K,V> ctx, String meta)`
`static ClusterNode` `localOrPrimary(Iterable<ClusterNode> nodes, UUID locId)`
`static <K> Map<ClusterNode,Collection<K>>` `mapKeysToNodes(GridCacheContext<K,?> ctx, Collection<? extends K> keys)`
`static <K,V> IgniteReducer<Map<K,V>,Map<K,V>>` `mapsReducer(int size)` Gets reducer that aggregates maps into one.
`static byte[]` `marshal(GridCacheSharedContext ctx, Object obj)`
`static String` `mask(String cacheName)` Mask cache name in case it is null.
`static Comparator<ClusterNode>` `nodeComparator(boolean asc)`
`static <K,V> IgnitePredicate<GridDhtLocalPartition<K,V>>` `notEvicted()`
`static <T> IgniteReducer<T,Collection<T>>` `objectsReducer()` Gets reducer that aggregates items into collection.
`static ClusterNode` `oldest(GridCacheContext cctx)` Gets oldest alive node for specified topology version.
`static ClusterNode` `oldest(GridCacheContext cctx, long topOrder)` Gets oldest alive node for specified topology version.
`static ClusterNode` `oldest(GridCacheSharedContext ctx)` Gets oldest alive node across nodes with at least one cache configured.
`static ClusterNode` `oldest(GridCacheSharedContext cctx, long topOrder)` Gets oldest alive 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 <K,V> IgniteClosure<GridDhtLocalPartition<K,V>,GridDhtPartitionState>` `part2state()`
`static GridCachePeekMode[]` `peekFlags()`
`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> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]` `readEntryFilterArray(ObjectInput in)` Reads array from input stream.
`static <K,V> IgnitePredicate<IgniteTxEntry<K,V>>` `reads()`
`static GridCacheVersion` `readVersion(ObjectInput in)` Reads `GridCacheVersion` from input stream.
`static Collection<ClusterNode>` `remoteNodes(GridCacheContext ctx)` Gets remote nodes on which cache with the same name is started.
`static Collection<ClusterNode>` `remoteNodes(GridCacheContext ctx, long topOrder)` Gets remote nodes on which cache with the same name is started.
`static Collection<ClusterNode>` `remoteNodes(GridCacheSharedContext ctx)` Gets remote node with at least one cache configured.
`static Collection<ClusterNode>` `remoteNodes(GridCacheSharedContext ctx, long 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 void` `resetTxContext(GridCacheSharedContext ctx)`
`static Object` `skipValue(Object val, boolean skip)`
`static <K,V> UUID` `subjectId(IgniteInternalTx<K,V> 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 <K,V> IgniteClosure<IgniteTxEntry<K,V>,GridCacheEntryEx<K,V>>` `tx2entry()`
`static <K,V> IgniteClosure<IgniteTxEntry<K,V>,K>` `tx2key()`
`static <K,V> IgniteClosure<IgniteTxEntry<K,V>,byte[]>` `tx2keyBytes()`
`static <K,V> IgniteClosure<IgniteInternalTx<K,V>,GridCacheVersion>` `tx2xidVersion()`
`static <K,V> IgniteClosure<Collection<IgniteTxEntry<K,V>>,Collection<K>>` `txCol2Key()`
`static IgniteInternalTx` `txStartInternal(GridCacheContext ctx, CacheProjection 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 String` `unmask(String cacheName)` Unmask cache name.
`static void` `unwindEvicts(GridCacheContext ctx)`
`static <K,V> void` `unwindEvicts(GridCacheSharedContext<K,V> ctx)`
`static int` `utilityCacheId()`
`static String` `uuid()` Gets per-thread-unique ID for this thread.
`static void` `validateCacheKey(IgniteLogger log, Object key)` Validates that cache key object has overridden equals and hashCode methods and implements `Externalizable`.
`static void` `validateCacheValue(IgniteLogger log, Object val)` Validates that cache value object implements `Externalizable`.
`static IgniteClosure<Integer,GridCacheVersion[]>` `versionArrayFactory()`
`static byte[]` `versionToBytes(GridCacheVersion ver)` Converts cache version to byte array.
`static <K,V> IgnitePredicate<IgniteTxEntry<K,V>>` `writes()`
`static void` `writeVersion(ObjectOutput out, GridCacheVersion ver)` Writes `GridCacheVersion` to output stream.

### 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

#### TTL_NOT_CHANGED

    public static final long TTL_NOT_CHANGED

See Also:
  Constant Field Values

#### TTL_ZERO

    public static final long TTL_ZERO

See Also:
  Constant Field Values

### Constructor Detail

#### GridCacheUtils

    protected GridCacheUtils()

Ensure singleton.

### Method Detail

#### uuid

    public static String uuid()

Gets per-thread-unique ID for this thread.

Returns:
  ID for this thread.

#### allowForStartup

    public static boolean allowForStartup(Object msg)

Parameters:
  `msg` - Message to check.
Returns:
  `True` if preloader message.

#### writeVersion

    public static void writeVersion(ObjectOutput out,
                    GridCacheVersion ver)
                             throws IOException

Writes `GridCacheVersion` to output stream. This method is meant to be used by implementations of `Externalizable` interface.

Parameters:
  `out` - Output stream.
  `ver` - Version to write.
Throws:
  `IOException` - If write failed.

#### readVersion

    @Nullable
    public static GridCacheVersion readVersion(ObjectInput in)
                                        throws IOException

Reads `GridCacheVersion` from input stream. This method is meant to be used by implementations of `Externalizable` interface.

Parameters:
  `in` - Input stream.
Returns:
  Read version.
Throws:
  `IOException` - If read failed.

#### keyHasMeta

    public static <K,V> IgnitePredicate<K> keyHasMeta(GridCacheContext<K,V> ctx,
                                      String meta)

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Parameters:
  `ctx` - Cache context.
  `meta` - Meta name.
Returns:
  Filter for entries with meta.

#### failed

    @Nullable
    public static <T> T failed(boolean err)
                    throws GridCacheFilterFailedException

Type Parameters:
  `T` - Return type.
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 <T> T failed(boolean err,
                        T val)
                    throws GridCacheFilterFailedException

Type Parameters:
  `T` - Return type.
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`.

#### 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.

#### cacheKey2Entry

    public static <K,V> IgniteClosure<K,javax.cache.Cache.Entry<K,V>> cacheKey2Entry(GridCacheContext<K,V> ctx)

Gets closure which returns `Entry` given cache key. If current cache is DHT and key doesn't belong to current partition, `null` is returned.

Type Parameters:
  `K` - Cache key type.
  `V` - Cache value type.
Parameters:
  `ctx` - Cache context.
Returns:
  Closure which returns `Entry` given cache key or `null` if partition is invalid.

#### part2state

    public static <K,V> IgniteClosure<GridDhtLocalPartition<K,V>,GridDhtPartitionState> part2state()

Returns:
  Partition to state transformer.

#### notEvicted

    public static <K,V> IgnitePredicate<GridDhtLocalPartition<K,V>> notEvicted()

Returns:
  Not evicted partitions.

#### allNodes

    public static Collection<ClusterNode> allNodes(GridCacheContext ctx)

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

Parameters:
  `ctx` - Cache context.
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(GridCacheContext ctx,
                                   long 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,
                                   long 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).

#### aliveNodes

    public static Collection<ClusterNode> aliveNodes(GridCacheContext ctx,
                                     long topOrder)

Gets alive nodes.

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

#### remoteNodes

    public static Collection<ClusterNode> remoteNodes(GridCacheContext ctx)

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

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

#### remoteNodes

    public static Collection<ClusterNode> remoteNodes(GridCacheSharedContext ctx)

Gets remote node with at least one cache configured.

Parameters:
  `ctx` - Shared cache context.
Returns:
  Collection of nodes with at least one cache configured.

#### remoteNodes

    public static Collection<ClusterNode> remoteNodes(GridCacheContext ctx,
                                      long topOrder)

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

Parameters:
  `ctx` - Cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  Remote nodes on which cache with the same name is started.

#### aliveRemoteNodes

    public static Collection<ClusterNode> aliveRemoteNodes(GridCacheContext ctx,
                                           long topOrder)

Gets alive nodes.

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

#### remoteNodes

    public static Collection<ClusterNode> remoteNodes(GridCacheSharedContext ctx,
                                      long 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.

#### aliveCacheNodes

    public static Collection<ClusterNode> aliveCacheNodes(GridCacheSharedContext ctx,
                                          long topOrder)

Gets alive nodes with at least one cache configured.

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

#### aliveRemoteCacheNodes

    public static Collection<ClusterNode> aliveRemoteCacheNodes(GridCacheSharedContext ctx,
                                                long 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.

#### isAffinityNode

    public static boolean isAffinityNode(CacheConfiguration cfg)

Checks if node is affinity node for given cache configuration.

Parameters:
  `cfg` - Configuration to check.
Returns:
  `True` if local node is affinity node (i.e. will store partitions).

#### affinityNodes

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

Gets DHT affinity nodes.

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

#### affinityNode

    public static boolean affinityNode(GridCacheContext ctx,
                       ClusterNode s)

Checks if given node has specified cache started and the local DHT storage is enabled.

Parameters:
  `ctx` - Cache context.
  `s` - Node shadow to check.
Returns:
  `True` if given node has specified cache started.

#### cacheNode

    public static boolean cacheNode(GridCacheContext ctx,
                    ClusterNode node)

Checks if given node contains configured cache with the name as described by given cache context.

Parameters:
  `ctx` - Cache context.
  `node` - Node to check.
Returns:
  `true` if node contains required cache.

#### 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.

#### distributionMode

    public static CacheDistributionMode distributionMode(CacheConfiguration cfg)

Gets default partitioned cache mode.

Parameters:
  `cfg` - Configuration.
Returns:
  Partitioned cache mode.

#### cacheNode

    public static boolean cacheNode(String cacheName,
                    ClusterNode node)

Checks if given node has specified cache started.

Parameters:
  `cacheName` - Cache name.
  `node` - Node to check.
Returns:
  `True` if given node has specified cache started.

#### cacheNode

    public static boolean cacheNode(String cacheName,
                    GridCacheAttributes[] caches)

Checks if given attributes relate the the node which has (or had) specified cache started.

Parameters:
  `cacheName` - Cache name.
  `caches` - Node cache attributes.
Returns:
  `True` if given node has specified cache started.

#### oldest

    public static ClusterNode oldest(GridCacheContext cctx)

Gets oldest alive node for specified topology version.

Parameters:
  `cctx` - Cache context.
Returns:
  Oldest node for the current topology version.

#### oldest

    public static ClusterNode oldest(GridCacheSharedContext ctx)

Gets oldest alive node across nodes with at least one cache configured.

Parameters:
  `ctx` - Cache context.
Returns:
  Oldest node.

#### oldest

    public static ClusterNode oldest(GridCacheContext cctx,
                     long topOrder)

Gets oldest alive node for specified topology version.

Parameters:
  `cctx` - Cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  Oldest node for the given topology version.

#### oldest

    public static ClusterNode oldest(GridCacheSharedContext cctx,
                     long topOrder)

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

Parameters:
  `cctx` - Shared cache context.
  `topOrder` - Maximum allowed node order.
Returns:
  Oldest node for the given topology version.

#### empty

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

Returns:
  Empty filter.

#### alwaysFalse

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

Returns:
  Always false filter.

#### tx2key

    public static <K,V> IgniteClosure<IgniteTxEntry<K,V>,K> tx2key()

Returns:
  Closure that converts tx entry to key.

#### txCol2Key

    public static <K,V> IgniteClosure<Collection<IgniteTxEntry<K,V>>,Collection<K>> txCol2Key()

Returns:
  Closure that converts tx entry collection to key collection.

#### tx2keyBytes

    public static <K,V> IgniteClosure<IgniteTxEntry<K,V>,byte[]> tx2keyBytes()

Returns:
  Closure that converts tx entry to key.

#### tx2entry

    public static <K,V> IgniteClosure<IgniteTxEntry<K,V>,GridCacheEntryEx<K,V>> tx2entry()

Returns:
  Converts transaction entry to cache entry.

#### tx2xidVersion

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

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

#### entry2Key

    public static <K,V> IgniteClosure<GridCacheEntryEx<K,V>,K> entry2Key()

Returns:
  Closure that converts entry to key.

#### info2Key

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

Returns:
  Closure that converts entry info to key.

#### reads

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

Returns:
  Filter for transaction reads.

#### writes

    public static <K,V> IgnitePredicate<IgniteTxEntry<K,V>> 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.

#### 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()

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.

#### localOrPrimary

    public static ClusterNode localOrPrimary(Iterable<ClusterNode> nodes,
                             UUID locId)

Parameters:
  `nodes` - Nodes.
  `locId` - Local node ID.
Returns:
  Local node if it is in the list of nodes, or primary node.

#### backups

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

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

#### getOrSet

    public static <K,V> Collection<V> getOrSet(Map<K,List<V>> mappings,
                               K k)

Parameters:
  `mappings` - Mappings.
  `k` - map key.
Returns:
  Either current list value or newly created one.

#### getOrSet

    public static <K,V> Collection<V> getOrSet(ConcurrentMap<K,Collection<V>> mappings,
                               K k)

Parameters:
  `mappings` - Mappings.
  `k` - map key.
Returns:
  Either current list value or newly created one.

#### peekFlags

    public static GridCachePeekMode[] peekFlags()

Returns:
  Peek flags.

#### errorLogger

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

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

#### mapKeysToNodes

    public static <K> Map<ClusterNode,Collection<K>> mapKeysToNodes(GridCacheContext<K,?> ctx,
                                                    Collection<? extends K> keys)

Parameters:
  `ctx` - Context.
  `keys` - Keys.
Returns:
  Mapped keys.

#### isLockTimeout

    public static boolean isLockTimeout(Throwable t)

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

#### 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(GridCacheSharedContext 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.

#### 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,
                                   CacheProjection 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.

#### resetTxContext

    public static void resetTxContext(GridCacheSharedContext ctx)

Parameters:
  `ctx` - Cache context.

#### 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

    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.

#### versionArrayFactory

    public static IgniteClosure<Integer,GridCacheVersion[]> versionArrayFactory()

Returns:
  Version array factory.

#### 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,
                              ClusterNode rmt,
                              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.
  `rmt` - 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,
                              ClusterNode rmt,
                              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.
  `rmt` - 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.

#### validateCacheValue

    public static void validateCacheValue(IgniteLogger log,
                          @Nullable
                          Object val)

Validates that cache value object implements `Externalizable`.

Parameters:
  `log` - Logger used to log warning message.
  `val` - Value.

#### validateCacheKey

    public static void validateCacheKey(IgniteLogger log,
                        @Nullable
                        Object key)

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

Parameters:
  `log` - Logger used to log warning message.
  `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.

#### isUtilityCache

    public static boolean isUtilityCache(String cacheName)

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

#### isAtomicsCache

    public static boolean isAtomicsCache(String cacheName)

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

#### isSystemCache

    public static boolean isSystemCache(String cacheName)

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

#### utilityCacheId

    public static int utilityCacheId()

Returns:
  Cache ID for utility cache.

#### 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(CacheProjection<K,V> cache,
                  TransactionConcurrency concurrency,
                  TransactionIsolation isolation,
                  IgniteInClosureX<CacheProjection<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<K,V> tx,
                       GridCacheSharedContext<K,V> ctx)

Gets subject ID by transaction.

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

#### invalidate

    public static <K,V> boolean invalidate(CacheProjection<K,V> cache,
                           K key)

Invalidate entry in cache.

Parameters:
  `cache` - Cache.
  `key` - Key.
Returns:
  `True` if entry was invalidated.

#### toTtl

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

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

#### readEntryFilterArray

    @Nullable
    public static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] 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 <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>> cachePrimary(CacheAffinity<K> aff,
                                                                   ClusterNode n)

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

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015