Openfire 3.4.1 Javadoc

org.jivesoftware.util.cache
Class CacheFactory

java.lang.Object
  extended by org.jivesoftware.util.cache.CacheFactory

public class CacheFactory
extends Object

Creates Cache objects. The returned caches will either be local or clustered depending on the clustering enabled setting and a user's license.

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


Field Summary
static String CLUSTERED_CACHE_PROPERTY_NAME
           
static String LOCAL_CACHE_PROPERTY_NAME
           
 
Method Summary
static void clearCaches()
           
static
<T extends Cache>
T
createCache(String name)
          Returns the named cache, creating it as necessary.
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 Collection<Object> doSynchronousClusterTask(ClusterTask 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 Object doSynchronousClusterTask(ClusterTask 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 byte[] getClusterMemberID()
          Returns a byte[] that uniquely identifies this member within the cluster or null when not in a cluster.
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 int getMaxClusterNodes()
          Returns the maximum number of cluster members allowed.
static byte[] getSeniorClusterMemberID()
          Returns a byte[] that uniquely identifies this senior cluster member or null when not in a cluster.
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 lockKey(Object key, long timeout)
           
static void startClustering()
           
static void stopClustering()
           
static void unlockKey(Object key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_CACHE_PROPERTY_NAME

public static String LOCAL_CACHE_PROPERTY_NAME

CLUSTERED_CACHE_PROPERTY_NAME

public static String CLUSTERED_CACHE_PROPERTY_NAME
Method Detail

getAllCaches

public static Cache[] getAllCaches()
Returns an array of all caches in the system.

Returns:
an array of all caches in the system.

createCache

public static <T extends Cache> T createCache(String name)
Returns the named cache, creating it as necessary.

Parameters:
name - the name of the cache to create.
Returns:
the named cache, creating it as necessary.

lockKey

public static void lockKey(Object key,
                           long timeout)

unlockKey

public static void unlockKey(Object key)

isClusteringAvailable

public static boolean isClusteringAvailable()
Returns true if clustering is installed and can be used by this JVM to join a cluster. A false value could mean that either clustering support is not available or the license does not allow to have more than 1 cluster node.

Returns:
true if clustering is installed and can be used by this JVM to join a cluster.

isClusteringStarting

public static boolean isClusteringStarting()
Returns true is clustering is currently being started. Once the cluster is started or failed to be started this value will be false.

Returns:
true is clustering is currently being started.

isClusteringStarted

public static boolean isClusteringStarted()
Returns true if this node is currently a member of a cluster. The last step of application initialization is to join a cluster, so this method returns false during most of application startup.

Returns:
true if this node is currently a member of a cluster.

getClusterMemberID

public static byte[] getClusterMemberID()
Returns a byte[] that uniquely identifies this member within the cluster or null when not in a cluster.

Returns:
a byte[] that uniquely identifies this member within the cluster or null when not in a cluster.

clearCaches

public static void clearCaches()

getSeniorClusterMemberID

public static byte[] getSeniorClusterMemberID()
Returns a byte[] that uniquely identifies this senior cluster member or null when not in a cluster.

Returns:
a byte[] that uniquely identifies this senior cluster member or null when not in a cluster.

isSeniorClusterMember

public static boolean isSeniorClusterMember()
Returns true if this member is the senior member in the cluster. If clustering is not enabled, this method will also return true. This test is useful for tasks that should only be run on a single member in a cluster.

Returns:
true if this cluster member is the senior or if clustering is not enabled.

getClusterNodesInfo

public static Collection<ClusterNodeInfo> getClusterNodesInfo()
Returns basic information about the current members of the cluster or an empty collection if not running in a cluster.

Returns:
information about the current members of the cluster or an empty collection if not running in a cluster.

getMaxClusterNodes

public static int getMaxClusterNodes()
Returns the maximum number of cluster members allowed. A value of 0 or 1 will be returned when clustering is not allowed.

Returns:
the maximum number of cluster members allowed or 0 or 1 if clustering is not allowed.

doClusterTask

public static void doClusterTask(ClusterTask task)
Invokes a task on other cluster members in an asynchronous fashion. The task will not be executed on the local cluster member. If clustering is not enabled, this method will do nothing.

Parameters:
task - the task to be invoked on all other cluster members.

doClusterTask

public static void doClusterTask(ClusterTask task,
                                 byte[] nodeID)
Invokes a task on a given cluster member in an asynchronous fashion. If clustering is not enabled, this method will do nothing.

Parameters:
task - the task to be invoked on the specified cluster member.
nodeID - the byte array that identifies the target cluster member.
Throws:
IllegalStateException - if requested node was not found or not running in a cluster.

doSynchronousClusterTask

public static Collection<Object> doSynchronousClusterTask(ClusterTask 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). The task will not be executed on the local cluster member. If clustering is not enabled, this method will return an empty collection.

Parameters:
task - the ClusterTask object to be invoked on all other cluster members.
includeLocalMember - true to run the task on the local member, false otherwise
Returns:
collection with the result of the execution.

doSynchronousClusterTask

public static Object doSynchronousClusterTask(ClusterTask task,
                                              byte[] nodeID)
Invokes a task on a given cluster member synchronously and returns the result of the remote operation. If clustering is not enabled, this method will return null.

Parameters:
task - the ClusterTask object to be invoked on a given cluster member.
nodeID - the byte array that identifies the target cluster member.
Returns:
result of remote operation or null if operation failed or operation returned null.
Throws:
IllegalStateException - if requested node was not found or not running in a cluster.

initialize

public static void initialize()
                       throws InitializationException
Throws:
InitializationException

startClustering

public static void startClustering()

stopClustering

public static void stopClustering()

joinedCluster

public static void joinedCluster()
Notification message indicating that this JVM has joined a cluster.


leftCluster

public static void leftCluster()
Notification message indicating that this JVM has left the cluster.


Openfire 3.4.1 Javadoc

Copyright © 2003-2007 Jive Software.