org.jboss.ha.framework.interfaces
Interface DistributedState

All Known Subinterfaces:
DistributedStateImplMBean (src)
All Known Implementing Classes:
DistributedStateImpl (src)

public interface DistributedState

DistributedState is a service on top of HAPartition that provides a cluster-wide distributed state. The DistributedState (DS) service provides a tuple map. Thus, any service, application, container, ... can request its own DS "private space" by working* in its own category (a string name). You work in a category like a Dictionary: you set values by key within a category. Each time a value is added/modified/removed, the modification is made cluster-wide, on all other nodes. Reading values is always made locally (no network access!) Objects can also subscribes to DS events to be notified when some values gets modified/removed/added in a particular category.

See Also:
HAPartition (src)

Nested Class Summary
static interface DistributedState.DSListener (src)
          Deprecated. use the DSListenerEx instead
static interface DistributedState.DSListenerEx (src)
          A generalization of the DSListener that supports the Serializable key type.
 
Method Summary
 java.io.Serializable get(java.lang.String category, java.io.Serializable key)
          Read in a value associated to a key in the given category.
 java.util.Collection getAllCategories()
          Return a list of all categories.
 java.util.Collection getAllKeys(java.lang.String category)
          Return a list of all keys in a category.
 java.util.Collection getAllValues(java.lang.String category)
          Return a list of all values in a category.
 void registerDSListener(java.lang.String category, DistributedState.DSListener (src)  subscriber)
          Subscribes to receive DistributedState.DSListener (src) events
 void registerDSListenerEx(java.lang.String category, DistributedState.DSListenerEx (src)  subscriber)
          Subscribes to receive DistributedState.DSListenerEx (src) events
 java.io.Serializable remove(java.lang.String category, java.io.Serializable key)
          Remove the key from the ReplicationService in the given category
 java.io.Serializable remove(java.lang.String category, java.io.Serializable key, boolean asynchronousCall)
          Same as remove(String, String) but caller can choose if the call is made synchronously or asynchronously.
 void set(java.lang.String category, java.io.Serializable key, java.io.Serializable value)
          Associates a value to a key in a specific category
 void set(java.lang.String category, java.io.Serializable key, java.io.Serializable value, boolean asynchronousCall)
          Same as set(String, String) but caller can choose if the call is made synchronously or asynchronously.
 void unregisterDSListener(java.lang.String category, DistributedState.DSListener (src)  subscriber)
          Subscribes from DistributedState.DSListener (src) events
 void unregisterDSListenerEx(java.lang.String category, DistributedState.DSListenerEx (src)  subscriber)
          Subscribes from DistributedState.DSListenerEx (src) events
 

Method Detail

registerDSListenerEx

public void registerDSListenerEx(java.lang.String category,
                                 DistributedState.DSListenerEx (src)  subscriber)
Subscribes to receive DistributedState.DSListenerEx (src) events

Parameters:
category - Name of the private-space to watch for
subscriber - Object that will receive callbacks. This

unregisterDSListenerEx

public void unregisterDSListenerEx(java.lang.String category,
                                   DistributedState.DSListenerEx (src)  subscriber)
Subscribes from DistributedState.DSListenerEx (src) events

Parameters:
category - Name of the private-space dictionary currently observed
subscriber - object currently observing this category

registerDSListener

public void registerDSListener(java.lang.String category,
                               DistributedState.DSListener (src)  subscriber)
Subscribes to receive DistributedState.DSListener (src) events

Parameters:
category - Name of the private-space to watch for
subscriber - Object that will receive callbacks. This

unregisterDSListener

public void unregisterDSListener(java.lang.String category,
                                 DistributedState.DSListener (src)  subscriber)
Subscribes from DistributedState.DSListener (src) events

Parameters:
category - Name of the private-space dictionary currently observed
subscriber - object currently observing this category

set

public void set(java.lang.String category,
                java.io.Serializable key,
                java.io.Serializable value)
         throws java.lang.Exception
Associates a value to a key in a specific category

Parameters:
category - Name of the private naming-space
key - Name of the data to set
value - Value of the data to set
Throws:
java.lang.Exception - If a network communication occurs

set

public void set(java.lang.String category,
                java.io.Serializable key,
                java.io.Serializable value,
                boolean asynchronousCall)
         throws java.lang.Exception
Same as set(String, String) but caller can choose if the call is made synchronously or asynchronously. By default, calls are asynchronous.

Throws:
java.lang.Exception

get

public java.io.Serializable get(java.lang.String category,
                                java.io.Serializable key)
Read in a value associated to a key in the given category. Read is performed locally.

Parameters:
category - Name of the private naming-space
key - The key of the value to read
Returns:
The value of the key in the given category

getAllCategories

public java.util.Collection getAllCategories()
Return a list of all categories. Call managed locally: no network access.

Returns:
A collection of String representing the existing categories in the DS service.

getAllKeys

public java.util.Collection getAllKeys(java.lang.String category)
Return a list of all keys in a category. Call managed locally: no network access.

Parameters:
category - The category under which to look for keys
Returns:
A collection of all keys in the give category

getAllValues

public java.util.Collection getAllValues(java.lang.String category)
Return a list of all values in a category. Call managed locally: no network access.

Parameters:
category - The category name under which to look for values
Returns:
A collection of all values in the give category

remove

public java.io.Serializable remove(java.lang.String category,
                                   java.io.Serializable key)
                            throws java.lang.Exception
Remove the key from the ReplicationService in the given category

Parameters:
category - Name of the category
key - Key to be removed
Throws:
java.lang.Exception - if a network exception occurs while removing the entry.

remove

public java.io.Serializable remove(java.lang.String category,
                                   java.io.Serializable key,
                                   boolean asynchronousCall)
                            throws java.lang.Exception
Same as remove(String, String) but caller can choose if the call is made synchronously or asynchronously. By default, calls are asynchronous.

Throws:
java.lang.Exception