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.

### Nested Class Summary

Nested Classes
`static interface` `GridCacheUtils.BackupPostProcessingClosure`

### Field Summary

Fields
`static String` `ATOMIC_MSG_LOG_CATEGORY`
`static String` `CACHE_MSG_LOG_CATEGORY`
`static int` `cheatCacheId` Cheat cache ID for debugging and benchmarking purposes.
`static String` `CONTINUOUS_QRY_LOG_CATEGORY`
`static long` `EXPIRE_TIME_CALCULATE` Expire time: must be calculated based on TTL value.
`static long` `EXPIRE_TIME_ETERNAL` Expire time: eternal.
`static IgnitePredicate` `FILTER_NEAR_CACHE_ENTRY` Write filter.
`static IgnitePredicate<GridDistributedTxMapping>` `FILTER_QUERY_MAPPING` Query mapped filter.
`static IgnitePredicate` `READ_FILTER` Read filter.
`static IgnitePredicate` `READ_FILTER_COLOCATED` Read filter.
`static IgnitePredicate` `READ_FILTER_NEAR` Read filter.
`static String[]` `RESERVED_NAMES` Reserved cache names
`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` `TX_MSG_FINISH_LOG_CATEGORY`
`static String` `TX_MSG_LOCK_LOG_CATEGORY`
`static String` `TX_MSG_LOG_CATEGORY`
`static String` `TX_MSG_PREPARE_LOG_CATEGORY`
`static String` `TX_MSG_RECOVERY_LOG_CATEGORY`
`static int` `UNDEFINED_CACHE_ID`
`static String` `UTILITY_CACHE_NAME` System cache name.
`static IgnitePredicate` `WRITE_FILTER` Write filter.
`static IgnitePredicate` `WRITE_FILTER_COLOCATED` Write filter.
`static IgnitePredicate` `WRITE_FILTER_NEAR` Write filter.

### Constructor Summary

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

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static boolean` `affinityNode(ClusterNode node, IgnitePredicate<ClusterNode> filter)`
`static Collection<ClusterNode>` `affinityNodes(GridCacheContext ctx, AffinityTopologyVersion topVer)` Gets DHT affinity nodes.
`static CacheEntryPredicate[]` `alwaysFalse0Arr()`
`static Collection<ClusterNode>` `backups(Collection<ClusterNode> nodes)`
`static boolean` `baselineNode(ClusterNode node, DiscoveryDataClusterState discoveryDataClusterState)`
`static IgniteReducer<Boolean,Boolean>` `boolReducer()`
`static int` `cacheGroupId(String cacheName, String grpName)`
`static int` `cacheId(String cacheName)`
`static <C extends CachePluginConfiguration> C` `cachePluginConfiguration(CacheConfiguration cfg, Class<C> cl)`
`static <T extends CachePluginConfiguration> List<T>` `cachePluginConfigurations(IgniteConfiguration cfg, Class<T> cls)`
`static boolean` `cheatCache(int id)` Deprecated.
`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 <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 GridCacheUtils.BackupPostProcessingClosure` `createBackupPostProcessingClosure(AffinityTopologyVersion topVer, IgniteLogger log, GridCacheContext cctx, KeyCacheObject key, IgniteCacheExpiryPolicy expiryPlc, boolean readThrough, boolean skipVals)` Creates closure that saves initial value to backup partition.
`static <K,V> IgnitePredicate<javax.cache.Cache.Entry<K,V>>[]` `empty()`
`static CacheEntryPredicate[]` `empty0()`
`static int` `encryptedPageSize(int pageSize, EncryptionSpi encSpi)`
`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 GridCacheContext<?,?>` `firstPartitioned(GridCacheSharedContext<?,?> sctx, int[] cacheIds)`
`static GridCacheContext<?,?>` `firstPartitioned(GridCacheSharedContext<?,?> sctx, Iterable<Integer> cacheIds)`
`static CacheConfiguration` `hadoopSystemCache()` Create system cache used by Hadoop component.
`static <K,V> IgniteClosure<GridCacheEntryInfo,K>` `info2Key()`
`static void` `initializeConfigDefaults(IgniteLogger log, CacheConfiguration cfg, CacheObjectContext cacheObjCtx)`
`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` `isCacheTemplateName(String cacheName)`
`static boolean` `isHadoopSystemCache(String cacheName)`
`static boolean` `isIgfsCache(IgniteConfiguration cfg, String cacheName)`
`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` `isPersistenceEnabled(DataStorageConfiguration cfg)`
`static boolean` `isPersistenceEnabled(IgniteConfiguration cfg)`
`static boolean` `isPersistentCache(CacheConfiguration ccfg, DataStorageConfiguration dsCfg)` Checks if cache configuration belongs to persistent cache.
`static boolean` `isReservedCacheName(String name)`
`static boolean` `isSystemCache(String cacheName)`
`static boolean` `isUtilityCache(String cacheName)`
`static IgniteReducer<Long,Long>` `longReducer()`
`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 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` `primary(Iterable<? extends ClusterNode> nodes)`
`static IgnitePredicate<IgniteTxEntry>` `reads()`
`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> 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 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 IgniteClosure<IgniteInternalTx,GridCacheVersion>` `tx2xidVersion()`
`static GridNearTxLocal` `txStartInternal(GridCacheContext ctx, IgniteInternalCache prj, TransactionConcurrency concurrency, TransactionIsolation isolation)`
`static String` `txString(IgniteInternalTx tx)`
`static String` `unmask(String cacheName)` Unmask cache name.
`static void` `unwindEvicts(GridCacheContext ctx)`
`static <K,V> void` `unwindEvicts(GridCacheSharedContext<K,V> ctx)`
`static void` `validateCacheGroupsAttributesMismatch(IgniteLogger log, CacheConfiguration cfg1, CacheConfiguration cfg2, String attrName, String attrMsg, Object val1, Object val2, boolean fail)`
`static void` `validateCacheKey(Object key)` Validates that cache key object has overridden equals and hashCode methods.
`static void` `validateCacheName(String name)`
`static void` `validateCacheNames(Collection<String> cacheNames)`
`static void` `validateConfigurationCacheNames(Collection<CacheConfiguration> ccfgs)`
`static void` `validateNewCacheName(String name)`
`static <T> T` `value(CacheObject cacheObj, GridCacheContext ctx, boolean cpy)`
`static IgnitePredicate<IgniteTxEntry>` `writes()`

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

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

### Field Detail

#### cheatCacheId

    public static final int cheatCacheId

Cheat cache ID for debugging and benchmarking purposes.

#### UNDEFINED_CACHE_ID

    public static final int UNDEFINED_CACHE_ID

See Also:
  Constant Field Values

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

#### RESERVED_NAMES

    public static final String[] RESERVED_NAMES

Reserved cache names

#### CONTINUOUS_QRY_LOG_CATEGORY

    public static final String CONTINUOUS_QRY_LOG_CATEGORY

See Also:
  Constant Field Values

#### CACHE_MSG_LOG_CATEGORY

    public static final String CACHE_MSG_LOG_CATEGORY

See Also:
  Constant Field Values

#### ATOMIC_MSG_LOG_CATEGORY

    public static final String ATOMIC_MSG_LOG_CATEGORY

See Also:
  Constant Field Values

#### TX_MSG_LOG_CATEGORY

    public static final String TX_MSG_LOG_CATEGORY

See Also:
  Constant Field Values

#### TX_MSG_PREPARE_LOG_CATEGORY

    public static final String TX_MSG_PREPARE_LOG_CATEGORY

See Also:
  Constant Field Values

#### TX_MSG_FINISH_LOG_CATEGORY

    public static final String TX_MSG_FINISH_LOG_CATEGORY

See Also:
  Constant Field Values

#### TX_MSG_LOCK_LOG_CATEGORY

    public static final String TX_MSG_LOCK_LOG_CATEGORY

See Also:
  Constant Field Values

#### TX_MSG_RECOVERY_LOG_CATEGORY

    public static final String TX_MSG_RECOVERY_LOG_CATEGORY

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

#### READ_FILTER

    public static final IgnitePredicate READ_FILTER

Read filter.

#### READ_FILTER_NEAR

    public static final IgnitePredicate READ_FILTER_NEAR

Read filter.

#### READ_FILTER_COLOCATED

    public static final IgnitePredicate READ_FILTER_COLOCATED

Read filter.

#### WRITE_FILTER

    public static final IgnitePredicate WRITE_FILTER

Write filter.

#### WRITE_FILTER_NEAR

    public static final IgnitePredicate WRITE_FILTER_NEAR

Write filter.

#### WRITE_FILTER_COLOCATED

    public static final IgnitePredicate WRITE_FILTER_COLOCATED

Write filter.

#### FILTER_NEAR_CACHE_ENTRY

    public static final IgnitePredicate FILTER_NEAR_CACHE_ENTRY

Write filter.

#### FILTER_QUERY_MAPPING

    public static final IgnitePredicate<GridDistributedTxMapping> FILTER_QUERY_MAPPING

Query mapped filter.

### Constructor Detail

#### GridCacheUtils

    protected GridCacheUtils()

Ensure singleton.

### Method Detail

#### cheatCache

    @Deprecated
    public static boolean cheatCache(int id)

Deprecated.
Quickly checks if passed in cache ID is a "cheat cache ID" set by -DCHEAT_CACHE=user_cache_name and resolved in static block above. FOR DEBUGGING AND TESTING PURPOSES!

Parameters:
  `id` - Cache ID to check.
Returns:
  `True` if this is cheat cache ID.

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

#### affinityNodes

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

Gets DHT affinity nodes.

Parameters:
  `ctx` - Cache context.
  `topVer` - Topology version.
Returns:
  Cache affinity nodes for given topology version.

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

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

#### alwaysFalse0Arr

    public static CacheEntryPredicate[] alwaysFalse0Arr()

Returns:
  Always false filter.

#### tx2xidVersion

    public static 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 IgnitePredicate<IgniteTxEntry> reads()

Returns:
  Filter for transaction reads.

#### writes

    public static IgnitePredicate<IgniteTxEntry> writes()

Returns:
  Filter for transaction writes.

#### boolReducer

    public static IgniteReducer<Boolean,Boolean> boolReducer()

Returns:
  Boolean reducer.

#### longReducer

    public static IgniteReducer<Long,Long> longReducer()

Returns:
  Long 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.

#### skipValue

    public static Object skipValue(Object val,
                                   boolean skip)

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

#### txStartInternal

    public static GridNearTxLocal 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.

#### nodeComparator

    public static Comparator<ClusterNode> nodeComparator(boolean asc)

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

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

#### validateCacheGroupsAttributesMismatch

    public static void validateCacheGroupsAttributesMismatch(IgniteLogger log,
                                                             CacheConfiguration cfg1,
                                                             CacheConfiguration cfg2,
                                                             String attrName,
                                                             String attrMsg,
                                                             Object val1,
                                                             Object val2,
                                                             boolean fail)
                                                      throws IgniteCheckedException

Parameters:
  `cfg1` - Existing configuration.
  `cfg2` - Cache configuration to start.
  `attrName` - Short attribute name for error message.
  `attrMsg` - Full attribute name for error message.
  `val1` - Attribute value in existing configuration.
  `val2` - Attribute value in starting configuration.
  `fail` - If true throws IgniteCheckedException in case of attribute values mismatch, otherwise logs warning.
Throws:
  `IgniteCheckedException` - If validation failed.

#### validateCacheKey

    public static void validateCacheKey(@Nullable
                                        Object key)

Validates that cache key object has overridden equals and hashCode methods. Will also check that a BinaryObject has a hash code set.

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.

#### isUtilityCache

    public static boolean isUtilityCache(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if this is utility 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.

#### cacheGroupId

    public static int cacheGroupId(String cacheName,
                                   @Nullable
                                   String grpName)

Parameters:
  `cacheName` - Cache name.
  `grpName` - Group name.
Returns:
  Group 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.

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

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

#### baselineNode

    public static boolean baselineNode(ClusterNode node,
                                       DiscoveryDataClusterState discoveryDataClusterState)

Parameters:
  `node` - Node.
  `discoveryDataClusterState` - Discovery data cluster state.
Returns:
  `True` if node is included in BaselineTopology.

#### 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> S retryTopologySafe(Callable<S> c)
                                   throws IgniteCheckedException

Parameters:
  `c` - Closure to retry.
Returns:
  Closure result.
Throws:
  `IgniteCheckedException` - If failed.

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

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

#### validateCacheName

    public static void validateCacheName(String name)
                                  throws IllegalArgumentException

Parameters:
  `name` - Cache name.
Throws:
  `IllegalArgumentException` - In case the name is not valid.

#### validateNewCacheName

    public static void validateNewCacheName(String name)
                                     throws IllegalArgumentException

Parameters:
  `name` - Cache name.
Throws:
  `IllegalArgumentException` - In case the name is not valid.

#### validateCacheNames

    public static void validateCacheNames(Collection<String> cacheNames)
                                   throws IllegalArgumentException

Parameters:
  `cacheNames` - Cache names to validate.
Throws:
  `IllegalArgumentException` - In case the name is not valid.

#### validateConfigurationCacheNames

    public static void validateConfigurationCacheNames(Collection<CacheConfiguration> ccfgs)
                                                throws IllegalArgumentException

Parameters:
  `ccfgs` - Configurations to validate.
Throws:
  `IllegalArgumentException` - In case the name is not valid.

#### isReservedCacheName

    public static boolean isReservedCacheName(String name)

Parameters:
  `name` - Cache name.
Returns:
  `True` if it is a reserved cache name.

#### initializeConfigDefaults

    public static void initializeConfigDefaults(IgniteLogger log,
                                                CacheConfiguration cfg,
                                                CacheObjectContext cacheObjCtx)
                                         throws IgniteCheckedException

Parameters:
  `cfg` - Initializes cache configuration with proper defaults.
  `cacheObjCtx` - Cache object context.
Throws:
  `IgniteCheckedException` - If configuration is not valid.

#### createBackupPostProcessingClosure

    @Nullable
    public static GridCacheUtils.BackupPostProcessingClosure createBackupPostProcessingClosure(AffinityTopologyVersion topVer,
                                                                                                         IgniteLogger log,
                                                                                                         GridCacheContext cctx,
                                                                                                         @Nullable
                                                                                                         KeyCacheObject key,
                                                                                                         @Nullable
                                                                                                         IgniteCacheExpiryPolicy expiryPlc,
                                                                                                         boolean readThrough,
                                                                                                         boolean skipVals)

Creates closure that saves initial value to backup partition.

Useful only when store with readThrough is used. In situation when get() on backup node returns successful result, it's expected that localPeek() will be successful as well. But it isn't true when primary node loaded value from local store, in this case backups will remain non-initialized.
To meet that requirement the value requested from primary should be saved on backup during get().

Parameters:
  `topVer` - Topology version.
  `log` - Logger.
  `cctx` - Cache context.
  `key` - Key.
  `expiryPlc` - Expiry policy.
  `readThrough` - Read through.
  `skipVals` - Skip values.

#### isPersistentCache

    public static boolean isPersistentCache(CacheConfiguration ccfg,
                                            DataStorageConfiguration dsCfg)

Checks if cache configuration belongs to persistent cache.

Parameters:
  `ccfg` - Cache configuration.
  `dsCfg` - Data storage config.

#### isPersistenceEnabled

    public static boolean isPersistenceEnabled(IgniteConfiguration cfg)

Returns:
  `true` if persistence is enabled for at least one data region, `false` if not.

#### isPersistenceEnabled

    public static boolean isPersistenceEnabled(DataStorageConfiguration cfg)

Returns:
  `true` if persistence is enabled for at least one data region, `false` if not.

#### encryptedPageSize

    public static int encryptedPageSize(int pageSize,
                                        EncryptionSpi encSpi)

Parameters:
  `pageSize` - Page size.
  `encSpi` - Encryption spi.
Returns:
  Page size without encryption overhead.

#### firstPartitioned

    public static GridCacheContext<?,?> firstPartitioned(GridCacheSharedContext<?,?> sctx,
                                                         int[] cacheIds)

Parameters:
  `sctx` - Shared context.
  `cacheIds` - Cache ids.
Returns:
  First partitioned cache or `null` in case no partitioned cache ids are in list.

#### firstPartitioned

    public static GridCacheContext<?,?> firstPartitioned(GridCacheSharedContext<?,?> sctx,
                                                         Iterable<Integer> cacheIds)

Parameters:
  `sctx` - Shared context.
  `cacheIds` - Cache ids.
Returns:
  First partitioned cache or `null` in case no partitioned cache ids are in list.

#### isCacheTemplateName

    public static boolean isCacheTemplateName(String cacheName)

Parameters:
  `cacheName` - Name of cache or cache template.
Returns:
  `true` if cache name ends with asterisk (*), and therefire is a template name.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.0
Release Date | : November 30 2018