public class CacheFactory extends Object
When clustered caching is turned on, cache usage statistics for all caches that have been created are periodically published to the clustered cache named "opt-$cacheStats".
Modifier and Type | Field and Description |
---|---|
static String |
CLUSTERED_CACHE_PROPERTY_NAME |
static long |
DEFAULT_MAX_CACHE_LIFETIME |
static int |
DEFAULT_MAX_CACHE_SIZE |
static String |
LOCAL_CACHE_PROPERTY_NAME |
Modifier and Type | Method and Description |
---|---|
static void |
clearCaches() |
static <T extends Cache> |
createCache(String name)
Returns the named cache, creating it as necessary.
|
static <T extends Cache> |
createLocalCache(String name)
Returns the named local cache, creating it as necessary.
|
static void |
destroyCache(String name)
Destroys the cache for the cache name specified.
|
static void |
doClusterTask(ClusterTask<?> task)
Invokes a task on other cluster members in an asynchronous fashion.
|
static void |
doClusterTask(ClusterTask<?> task,
byte[] nodeID)
Invokes a task on a given cluster member in an asynchronous fashion.
|
static <T> Collection<T> |
doSynchronousClusterTask(ClusterTask<T> task,
boolean includeLocalMember)
Invokes a task on other cluster members synchronously and returns the result as a Collection
(method will not return until the task has been executed on each cluster member).
|
static <T> T |
doSynchronousClusterTask(ClusterTask<T> task,
byte[] nodeID)
Invokes a task on a given cluster member synchronously and returns the result of
the remote operation.
|
static Cache[] |
getAllCaches()
Returns an array of all caches in the system.
|
static String |
getCacheTypeProperty(String cacheName) |
static byte[] |
getClusterMemberID()
Returns a byte[] that uniquely identifies this member within the cluster or
null
when not in a cluster. |
static ClusterNodeInfo |
getClusterNodeInfo(byte[] nodeID)
Returns the node info for the given cluster node
|
static Collection<ClusterNodeInfo> |
getClusterNodesInfo()
Returns basic information about the current members of the cluster or an empty
collection if not running in a cluster.
|
static long |
getClusterTime()
Gets the pseudo-synchronized time from the cluster.
|
static Lock |
getLock(Object key,
Cache cache)
Deprecated.
in favour of
Cache.getLock(K) . Will be removed in Openfire 5.0.0.
Returns an existing The supplied cache may or may not be used depending whether the server is running on cluster mode or not. When not running as part of a cluster then the lock will be unrelated to the cache and will only be visible in this JVM. |
static long |
getMaxCacheLifetime(String cacheName)
If a local property is found for the supplied name which specifies a value for cache entry lifetime, it
is returned.
|
static long |
getMaxCacheSize(String cacheName)
If a local property is found for the supplied name which specifies a value for cache size, it is returned.
|
static int |
getMaxClusterNodes()
Returns the maximum number of cluster members allowed.
|
static long |
getMinCacheSize(String cacheName) |
static String |
getPluginName() |
static byte[] |
getSeniorClusterMemberID()
Returns a byte[] that uniquely identifies this senior cluster member or
null
when not in a cluster. |
static boolean |
hasMaxLifetimeFromProperty(String cacheName) |
static boolean |
hasMaxSizeFromProperty(String cacheName) |
static void |
initialize() |
static boolean |
isClusteringAvailable()
Returns true if clustering is installed and can be used by this JVM
to join a cluster.
|
static boolean |
isClusteringStarted()
Returns true if this node is currently a member of a cluster.
|
static boolean |
isClusteringStarting()
Returns true is clustering is currently being started.
|
static boolean |
isSeniorClusterMember()
Returns true if this member is the senior member in the cluster.
|
static void |
joinedCluster()
Notification message indicating that this JVM has joined a cluster.
|
static void |
leftCluster()
Notification message indicating that this JVM has left the cluster.
|
static void |
setCacheTypeProperty(String cacheName,
String type) |
static void |
setMaxLifetimeProperty(String cacheName,
long lifetime)
Sets a local property which overrides the maximum cache entry lifetime
for the supplied cache name.
|
static void |
setMaxSizeProperty(String cacheName,
long size)
Sets a local property which overrides the maximum cache size for the
supplied cache name.
|
static void |
setMinCacheSize(String cacheName,
long size) |
static void |
startClustering() |
static void |
stopClustering() |
public static String LOCAL_CACHE_PROPERTY_NAME
public static String CLUSTERED_CACHE_PROPERTY_NAME
public static final int DEFAULT_MAX_CACHE_SIZE
public static final long DEFAULT_MAX_CACHE_LIFETIME
public static long getMaxCacheSize(String cacheName)
cacheName
- the name of the cache to look up a corresponding property for.public static void setMaxSizeProperty(String cacheName, long size)
cacheName
- the name of the cache to store a value for.size
- the maximum cache size.public static boolean hasMaxSizeFromProperty(String cacheName)
public static long getMaxCacheLifetime(String cacheName)
cacheName
- the name of the cache to look up a corresponding property for.public static void setMaxLifetimeProperty(String cacheName, long lifetime)
cacheName
- the name of the cache to store a value for.lifetime
- the maximum cache entry lifetime.public static boolean hasMaxLifetimeFromProperty(String cacheName)
public static void setMinCacheSize(String cacheName, long size)
public static long getMinCacheSize(String cacheName)
public static Cache[] getAllCaches()
public static <T extends Cache> T createCache(String name)
T
- the type cache being createdname
- the name of the cache to create.public static <T extends Cache> T createLocalCache(String name)
T
- the type cache being createdname
- the name of the cache to create.public static void destroyCache(String name)
name
- the name of the cache to destroy.@Deprecated public static Lock getLock(Object key, Cache cache)
Cache.getLock(K)
. Will be removed in Openfire 5.0.0.
Returns an existing Lock
on the specified key or creates a new one
if none was found. This operation is thread safe. Successive calls with the same key may or may not
return the same Lock
. However, different threads asking for the
same Lock at the same time will get the same Lock object.
The supplied cache may or may not be used depending whether the server is running on cluster mode or not. When not running as part of a cluster then the lock will be unrelated to the cache and will only be visible in this JVM.
key
- the object that defines the visibility or scope of the lock.cache
- the cache used for holding the lock.public static boolean isClusteringAvailable()
public static boolean isClusteringStarting()
public static boolean isClusteringStarted()
public static byte[] getClusterMemberID()
null
when not in a cluster.public static void clearCaches()
public static byte[] getSeniorClusterMemberID()
null
when not in a cluster.public static boolean isSeniorClusterMember()
public static Collection<ClusterNodeInfo> getClusterNodesInfo()
public static int getMaxClusterNodes()
public static long getClusterTime()
public static void doClusterTask(ClusterTask<?> task)
task
- the task to be invoked on all other cluster members.public static void doClusterTask(ClusterTask<?> task, byte[] nodeID)
task
- the task to be invoked on the specified cluster member.nodeID
- the byte array that identifies the target cluster member.IllegalStateException
- if requested node was not found or not running in a cluster.public static <T> Collection<T> doSynchronousClusterTask(ClusterTask<T> task, boolean includeLocalMember)
T
- the return type of the cluster tasktask
- the ClusterTask object to be invoked on all other cluster members.includeLocalMember
- true to run the task on the local member, false otherwisepublic static <T> T doSynchronousClusterTask(ClusterTask<T> task, byte[] nodeID)
T
- the return type of the cluster tasktask
- the ClusterTask object to be invoked on a given cluster member.nodeID
- the byte array that identifies the target cluster member.IllegalStateException
- if requested node was not found or not running in a cluster.public static ClusterNodeInfo getClusterNodeInfo(byte[] nodeID)
nodeID
- The target cluster nodepublic static String getPluginName()
public static void initialize() throws InitializationException
InitializationException
public static void startClustering()
public static void stopClustering()
public static void joinedCluster()
public static void leftCluster()
Copyright © 2003–2019 Ignite Realtime. All rights reserved.