| Modifier and Type | Field and Description |
|---|---|
static boolean |
DHT_ENABLED
Flag to turn off DHT cache for debugging purposes.
|
static String |
DR_SYS_CACHE_PREFIX
DR system cache name prefix.
|
static String |
SECURITY_SYS_CACHE_NAME
Security system cache name.
|
| Modifier | Constructor and Description |
|---|---|
protected |
GridCacheUtils()
Ensure singleton.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
affinityNode(GridCacheContext ctx,
GridNode s)
Checks if given node has specified cache started and the local DHT storage is enabled.
|
static Collection<GridNode> |
affinityNodes(GridCacheContext ctx)
Gets all nodes on which cache with the same name is started and the local DHT storage is enabled.
|
static Collection<GridNode> |
affinityNodes(GridCacheContext ctx,
long topOrder)
Gets DHT affinity nodes.
|
static Collection<GridNode> |
aliveNodes(GridCacheContext ctx,
long topOrder)
Gets alive nodes.
|
static Collection<GridNode> |
aliveRemoteNodes(GridCacheContext ctx,
long topOrder)
Gets alive nodes.
|
static Collection<GridNode> |
allNodes(GridCacheContext ctx)
Gets all nodes on which cache with the same name is started.
|
static Collection<GridNode> |
allNodes(GridCacheContext ctx,
long topOrder)
Gets all nodes on which cache with the same name is started.
|
static boolean |
allowForStartup(Object msg) |
static <K,V> GridPredicate<GridCacheEntry<K,V>>[] |
alwaysFalse() |
static Collection<GridNode> |
backups(Collection<GridNode> nodes) |
static GridReducer<Boolean,Boolean> |
boolReducer() |
static <K,V> GridClosure<K,GridCacheEntry<K,V>> |
cacheKey2Entry(GridCacheContext<K,V> ctx)
Gets closure which returns
GridCacheEntry given cache key. |
static String |
cacheNameForDrSystemCache(String cacheName) |
static String |
cacheNameForSwapSpaceName(String swapSpaceName) |
static boolean |
cacheNode(GridCacheContext ctx,
GridNode node)
Checks if given node contains configured cache with the name
as described by given cache context.
|
static boolean |
cacheNode(GridCacheContext ctx,
GridNodeShadow s)
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 boolean |
cacheNode(String cacheName,
GridNode node)
Checks if given node has specified cache started.
|
static void |
checkAttributeMismatch(GridLogger log,
GridCacheConfiguration locCfg,
GridCacheConfiguration rmtCfg,
GridNode rmt,
T2<String,String> attr,
boolean fail)
Checks that local and remove configurations have the same value of given attribute.
|
static void |
checkAttributeMismatch(GridLogger log,
String cfgName,
GridNode 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> GridReducer<Collection<T>,Collection<T>> |
collectionsReducer()
Gets reducer that aggregates collections.
|
static GridCacheDistributionMode |
distributionMode(GridCacheConfiguration cfg)
Gets default partitioned cache mode.
|
static <K,V> GridPredicate<GridCacheEntry<K,V>>[] |
empty() |
static <K,V> GridClosure<GridCacheEntryEx<K,V>,K> |
entry2Key() |
static GridInClosure<GridFuture<?>> |
errorLogger(GridLogger log,
Class<? extends Exception>... excl) |
static <K,V> GridClosure<Integer,GridPredicate<GridCacheEntry<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 <K,V> GridClosure<GridCacheEntryInfo<K,V>,K> |
info2Key() |
static <K,V> void |
inTx(GridCacheProjection<K,V> cache,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
GridInClosureX<GridCacheProjection<K,V>> clo)
Execute closure inside cache transaction.
|
static <K,V> boolean |
invalidate(GridCacheProjection<K,V> cache,
K key)
Invalidate entry in cache.
|
static boolean |
isAffinityNode(GridCacheConfiguration cfg)
Checks if node is affinity node for given cache configuration.
|
static boolean |
isDrSystemCache(String cacheName) |
static boolean |
isGgfsCache(GridConfiguration cfg,
String cacheName) |
static boolean |
isLockTimeout(Throwable t) |
static boolean |
isLockTimeoutOrCancelled(Throwable t) |
static boolean |
isNearEnabled(GridCacheConfiguration 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 |
isSecuritySystemCache(String cacheName) |
static <K,V> GridPredicate<K> |
keyHasMeta(GridCacheContext<K,V> ctx,
String meta) |
static GridNode |
localOrPrimary(Iterable<GridNode> nodes,
UUID locId) |
static <K> Map<GridNode,Collection<K>> |
mapKeysToNodes(GridCacheContext<K,?> ctx,
Collection<? extends K> keys) |
static <K,V> GridReducer<Map<K,V>,Map<K,V>> |
mapsReducer(int size)
Gets reducer that aggregates maps into one.
|
static byte[] |
marshal(GridCacheContext ctx,
Object obj) |
static String |
mask(String cacheName)
Mask cache name in case it is null.
|
static Comparator<GridNode> |
nodeComparator(boolean asc) |
static <K,V> GridPredicate<GridDhtLocalPartition<K,V>> |
notEvicted() |
static <T> GridReducer<T,Collection<T>> |
objectsReducer()
Gets reducer that aggregates items into collection.
|
static GridNode |
oldest(GridCacheContext cctx)
Gets oldest alive node for specified topology version.
|
static GridNode |
oldest(GridCacheContext cctx,
long topOrder)
Gets oldest alive node 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> GridClosure<GridDhtLocalPartition<K,V>,GridDhtPartitionState> |
part2state() |
static GridCachePeekMode[] |
peekFlags() |
static GridNode |
primary(Iterable<? extends GridNode> nodes) |
static GridNode |
primaryNode(GridCacheContext ctx,
Object key)
Gets primary node on which given key is cached.
|
static <K,V> GridPredicate<GridCacheTxEntry<K,V>> |
reads() |
static GridCacheVersion |
readVersion(ObjectInput in)
Reads
GridCacheVersion from input stream. |
static Collection<GridNode> |
remoteNodes(GridCacheContext ctx)
Gets remote nodes on which cache with the same name is started.
|
static Collection<GridNode> |
remoteNodes(GridCacheContext ctx,
long topOrder)
Gets remote nodes on which cache with the same name is started.
|
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(GridCacheContext ctx) |
static <K,V> UUID |
subjectId(GridCacheTxEx<K,V> tx,
GridCacheContext<K,V> ctx)
Gets subject ID by transaction.
|
static String |
swapSpaceName(GridCacheContext<?,?> ctx) |
static long |
toExpireTime(long ttl)
Convert TTL to expire time.
|
static <K,V> GridPredicate<GridCacheTxEntry<K,V>> |
transferRequired() |
static <K,V> GridClosure<GridCacheTxEntry<K,V>,GridCacheEntryEx<K,V>> |
tx2entry() |
static <K,V> GridClosure<GridCacheTxEntry<K,V>,K> |
tx2key() |
static <K,V> GridClosure<GridCacheTxEntry<K,V>,byte[]> |
tx2keyBytes() |
static GridClosure<GridCacheTx,GridUuid> |
tx2xid() |
static <K,V> GridClosure<GridCacheTxEx<K,V>,GridCacheVersion> |
tx2xidVersion() |
static <K,V> GridClosure<Collection<GridCacheTxEntry<K,V>>,Collection<K>> |
txCol2Key() |
static GridCacheTx |
txStartInternal(GridCacheContext ctx,
GridCacheProjection prj,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation) |
static String |
txString(GridCacheTx tx) |
static <K,V> GridBiPredicate<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 String |
uuid()
Gets per-thread-unique ID for this thread.
|
static void |
validateCacheKey(GridLogger log,
Object key)
Validates that cache key object has overridden equals and hashCode methods and
implements
Externalizable. |
static void |
validateCacheValue(GridLogger log,
Object val)
Validates that cache value object implements
Externalizable. |
static GridClosure<Integer,GridCacheVersion[]> |
versionArrayFactory() |
static byte[] |
versionToBytes(GridCacheVersion ver)
Converts cache version to byte array.
|
static void |
writeMetrics(DataOutput out,
GridCacheMetrics metrics)
Writes
GridCacheMetrics to output stream. |
static <K,V> GridPredicate<GridCacheTxEntry<K,V>> |
writes() |
static void |
writeVersion(ObjectOutput out,
GridCacheVersion ver)
Writes
GridCacheVersion to output stream. |
public static final String DR_SYS_CACHE_PREFIX
public static final String SECURITY_SYS_CACHE_NAME
public static final boolean DHT_ENABLED
public static String uuid()
public static boolean allowForStartup(Object msg)
msg - Message to check.True if preloader message.public static void writeVersion(ObjectOutput out, GridCacheVersion ver) throws IOException
GridCacheVersion to output stream. This method is meant to be used by
implementations of Externalizable interface.out - Output stream.ver - Version to write.IOException - If write failed.@Nullable public static GridCacheVersion readVersion(ObjectInput in) throws IOException
GridCacheVersion from input stream. This method is meant to be used by
implementations of Externalizable interface.in - Input stream.IOException - If read failed.public static void writeMetrics(DataOutput out, GridCacheMetrics metrics) throws IOException
GridCacheMetrics to output stream. This method is meant
to be used by implementations of Externalizable interface.out - Output stream.metrics - Metrics to write.IOException - If write failed.public static <K,V> GridPredicate<K> keyHasMeta(GridCacheContext<K,V> ctx, String meta)
K - Key type.V - Value type.ctx - Cache context.meta - Meta name.@Nullable public static <T> T failed(boolean err) throws GridCacheFilterFailedException
T - Return type.err - If true, then throw GridCacheFilterFailedException,
otherwise return val passed in.null.GridCacheFilterFailedException - If err flag is true.@Nullable public static <T> T failed(boolean err, T val) throws GridCacheFilterFailedException
T - Return type.err - If true, then throw GridCacheFilterFailedException,
otherwise return val passed in.val - Value for which evaluation happened.val passed in or throw exception.GridCacheFilterFailedException - If err flag is true.public static <K,V> GridClosure<Integer,GridPredicate<GridCacheEntry<K,V>>[]> factory()
K - Key type.V - Value type.public static void checkStore(GridCacheContext<?,?> ctx) throws GridException
ctx - Registry.GridException - If cache store is not present.public static String swapSpaceName(GridCacheContext<?,?> ctx)
ctx - Cache registry.public static String cacheNameForSwapSpaceName(String swapSpaceName)
swapSpaceName - Swap space name.public static <K,V> GridClosure<K,GridCacheEntry<K,V>> cacheKey2Entry(GridCacheContext<K,V> ctx)
GridCacheEntry given cache key.
If current cache is DHT and key doesn't belong to current partition,
null is returned.K - Cache key type.V - Cache value type.ctx - Cache context.GridCacheEntry given cache key or null if partition is invalid.public static <K,V> GridClosure<GridDhtLocalPartition<K,V>,GridDhtPartitionState> part2state()
public static <K,V> GridPredicate<GridDhtLocalPartition<K,V>> notEvicted()
public static Collection<GridNode> allNodes(GridCacheContext ctx)
ctx - Cache context.public static Collection<GridNode> allNodes(GridCacheContext ctx, long topOrder)
ctx - Cache context.topOrder - Maximum allowed node order.public static Collection<GridNode> aliveNodes(GridCacheContext ctx, long topOrder)
ctx - Cache context.topOrder - Maximum allowed node order.public static Collection<GridNode> remoteNodes(GridCacheContext ctx)
ctx - Cache context.public static Collection<GridNode> remoteNodes(GridCacheContext ctx, long topOrder)
ctx - Cache context.topOrder - Maximum allowed node order.public static Collection<GridNode> aliveRemoteNodes(GridCacheContext ctx, long topOrder)
ctx - Cache context.topOrder - Maximum allowed node order.public static Collection<GridNode> affinityNodes(GridCacheContext ctx)
ctx - Cache context.public static boolean isAffinityNode(GridCacheConfiguration cfg)
cfg - Configuration to check.True if local node is affinity node (i.e. will store partitions).public static Collection<GridNode> affinityNodes(GridCacheContext ctx, long topOrder)
ctx - Cache context.topOrder - Maximum allowed node order.public static boolean affinityNode(GridCacheContext ctx, GridNode s)
ctx - Cache context.s - Node shadow to check.True if given node has specified cache started.public static boolean cacheNode(GridCacheContext ctx, GridNode node)
ctx - Cache context.node - Node to check.true if node contains required cache.public static boolean isNearEnabled(GridCacheContext ctx)
ctx - Cache context to check.True if near cache is enabled, false otherwise.public static boolean isNearEnabled(GridCacheConfiguration cfg)
cfg - Cache configuration to check.True if near cache is enabled, false otherwise.public static GridCacheDistributionMode distributionMode(GridCacheConfiguration cfg)
cfg - Configuration.public static boolean cacheNode(GridCacheContext ctx, GridNodeShadow s)
ctx - Cache context.s - Node shadow to check.True if given node has specified cache started.public static boolean cacheNode(String cacheName, GridNode node)
cacheName - Cache name.node - Node to check.True if given node has specified cache started.public static boolean cacheNode(String cacheName, GridCacheAttributes[] caches)
cacheName - Cache name.caches - Node cache attributes.True if given node has specified cache started.public static GridNode oldest(GridCacheContext cctx)
cctx - Cache context.public static GridNode oldest(GridCacheContext cctx, long topOrder)
cctx - Cache context.topOrder - Maximum allowed node order.public static <K,V> GridPredicate<GridCacheEntry<K,V>>[] empty()
public static <K,V> GridPredicate<GridCacheEntry<K,V>>[] alwaysFalse()
public static <K,V> GridClosure<GridCacheTxEntry<K,V>,K> tx2key()
public static <K,V> GridClosure<Collection<GridCacheTxEntry<K,V>>,Collection<K>> txCol2Key()
public static <K,V> GridClosure<GridCacheTxEntry<K,V>,byte[]> tx2keyBytes()
public static <K,V> GridClosure<GridCacheTxEntry<K,V>,GridCacheEntryEx<K,V>> tx2entry()
public static <K,V> GridClosure<GridCacheTxEx<K,V>,GridCacheVersion> tx2xidVersion()
public static GridClosure<GridCacheTx,GridUuid> tx2xid()
public static <K,V> GridClosure<GridCacheEntryEx<K,V>,K> entry2Key()
public static <K,V> GridClosure<GridCacheEntryInfo<K,V>,K> info2Key()
public static <K,V> GridPredicate<GridCacheTxEntry<K,V>> reads()
public static <K,V> GridPredicate<GridCacheTxEntry<K,V>> writes()
public static <K,V> GridPredicate<GridCacheTxEntry<K,V>> transferRequired()
public static <K,V> GridBiPredicate<K,V> typeFilter(Class<?> keyType, Class<?> valType)
K - Key type.V - Value type.keyType - Key type.valType - Value type.public static GridReducer<Boolean,Boolean> boolReducer()
public static <K,V> GridReducer<Map<K,V>,Map<K,V>> mapsReducer(int size)
K - Key type.V - Value type.size - Predicted size of the resulting map to avoid resizings.public static <T> GridReducer<Collection<T>,Collection<T>> collectionsReducer()
T - Collection element type.public static <T> GridReducer<T,Collection<T>> objectsReducer()
T - Items type.public static GridNode primary(Iterable<? extends GridNode> nodes)
nodes - Set of nodes.public static GridNode localOrPrimary(Iterable<GridNode> nodes, UUID locId)
nodes - Nodes.locId - Local node ID.public static Collection<GridNode> backups(Collection<GridNode> nodes)
nodes - Nodes.public static <K,V> Collection<V> getOrSet(Map<K,List<V>> mappings, K k)
mappings - Mappings.k - map key.public static <K,V> Collection<V> getOrSet(ConcurrentMap<K,Collection<V>> mappings, K k)
mappings - Mappings.k - map key.public static GridCachePeekMode[] peekFlags()
public static GridInClosure<GridFuture<?>> errorLogger(GridLogger log, Class<? extends Exception>... excl)
log - Logger.excl - Excludes.public static <K> Map<GridNode,Collection<K>> mapKeysToNodes(GridCacheContext<K,?> ctx, Collection<? extends K> keys)
ctx - Context.keys - Keys.public static boolean isLockTimeout(Throwable t)
t - Exception to check.true if caused by lock timeout.public static boolean isLockTimeoutOrCancelled(Throwable t)
t - Exception to check.true if caused by lock timeout or cancellation.public static byte[] marshal(GridCacheContext ctx, Object obj) throws GridException
ctx - Cache context.obj - Object to marshal.GridException - If marshalling failed.public static <T> T outTx(Callable<T> cmd, GridCacheContext ctx) throws GridException
cmd will be executed in another thread.cmd - Callable.ctx - Cache context.GridException - If execution failed.public static GridCacheTx txStartInternal(GridCacheContext ctx, GridCacheProjection prj, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation)
ctx - Context.prj - Projection.concurrency - Concurrency.isolation - Isolation.public static String txString(@Nullable GridCacheTx tx)
tx - Transaction.public static void resetTxContext(GridCacheContext ctx)
ctx - Cache context.public static void unwindEvicts(GridCacheContext ctx)
ctx - Cache context.public static GridNode primaryNode(GridCacheContext ctx, Object key)
ctx - Cache.key - Key to find primary node for.public static Comparator<GridNode> nodeComparator(boolean asc)
asc - True for ascending.public static GridClosure<Integer,GridCacheVersion[]> versionArrayFactory()
public static byte[] versionToBytes(GridCacheVersion ver)
ver - Version.public static String mask(String cacheName)
cacheName - Cache name.<default> in case the name is null.@Nullable public static String unmask(String cacheName)
cacheName - Cache name.<default> then null
will be returned.public static String replicationTopicSend()
public static String replicationTopicReceive(String cacheName)
cacheName - Cache name.public static void checkAttributeMismatch(GridLogger log, GridCacheConfiguration locCfg, GridCacheConfiguration rmtCfg, GridNode rmt, T2<String,String> attr, boolean fail) throws GridException
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 GridException in case of attribute values mismatch, otherwise logs warning.GridException - If attribute values are different and fail flag is true.public static void checkAttributeMismatch(GridLogger log, String cfgName, GridNode rmt, String attrName, String attrMsg, @Nullable Object locVal, @Nullable Object rmtVal, boolean fail) throws GridException
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 GridException in case of attribute values mismatch, otherwise logs warning.GridException - If attribute values are different and fail flag is true.public static void validateCacheValue(GridLogger log, @Nullable Object val)
Externalizable.log - Logger used to log warning message.val - Value.public static void validateCacheKey(GridLogger log, @Nullable Object key)
Externalizable.log - Logger used to log warning message.key - Key.IllegalArgumentException - If equals or hashCode is not implemented.public static String cacheNameForDrSystemCache(String cacheName)
cacheName - Cache name.public static boolean isDrSystemCache(String cacheName)
cacheName - Cache name.True if this is DR system cache.public static boolean isSecuritySystemCache(String cacheName)
cacheName - Cache name.True if this is security system cache.public static boolean isGgfsCache(GridConfiguration cfg, @Nullable String cacheName)
cfg - Grid configuration.cacheName - Cache name.True in this is GGFS data or meta cache.public static long toExpireTime(long ttl)
ttl - TTL.public static <K,V> void inTx(GridCacheProjection<K,V> cache, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, GridInClosureX<GridCacheProjection<K,V>> clo) throws GridException
cache - Cache.concurrency - Concurrency.isolation - Isolation.clo - Closure.GridException - If failed.public static <K,V> UUID subjectId(GridCacheTxEx<K,V> tx, GridCacheContext<K,V> ctx)
tx - Transaction.public static <K,V> boolean invalidate(GridCacheProjection<K,V> cache, K key)
cache - Cache.key - Key.True if entry was invalidated.Copyright © 2014. All rights reserved.