org.jboss.ha.framework.server
Class DistributedStateImpl

java.lang.Object
  extended byorg.jboss.ha.framework.server.DistributedStateImpl
All Implemented Interfaces:
DistributedState (src) , DistributedStateImplMBean (src) , HAPartition.HAPartitionStateTransfer (src)

public class DistributedStateImpl
extends java.lang.Object
implements DistributedStateImplMBean (src) , HAPartition.HAPartitionStateTransfer (src)

This class manages distributed state across the cluster.


Nested Class Summary
 
Nested classes inherited from class org.jboss.ha.framework.interfaces.DistributedState (src)
DistributedState.DSListener (src) , DistributedState.DSListenerEx (src)
 
Field Summary
protected  java.util.HashMap categories
          HashMap.
protected  java.util.HashMap keyListeners
           
protected  Logger (src) log
           
protected  MBeanServer (src) mbeanServer
           
protected  java.lang.String name
           
protected  HAPartition (src) partition
           
protected static java.lang.Class[] remove_types
           
protected static java.lang.String SERVICE_NAME
           
protected static java.lang.Class[] set_types
           
 
Constructor Summary
DistributedStateImpl()
           
DistributedStateImpl(HAPartition (src)  partition, MBeanServer (src)  server)
           
 
Method Summary
 void _remove(java.lang.String category, java.io.Serializable key)
           
 void _remove(java.lang.String category, java.lang.String key)
           
 java.io.Serializable _removeInternal(java.lang.String category, java.io.Serializable key)
           
 void _set(java.lang.String category, java.io.Serializable key, java.io.Serializable value)
           
 void _set(java.lang.String category, java.lang.String key, java.io.Serializable value)
           
 void _setInternal(java.lang.String category, java.io.Serializable key, java.io.Serializable value)
           
protected  void cleanupKeyListeners()
           
 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.
 java.io.Serializable getCurrentState()
          Called when a new node need to be initialized.
 void init()
           
 java.lang.String listContent()
           
 java.lang.String listXmlContent()
           
protected  void notifyKeyListeners(java.lang.String category, java.io.Serializable key, java.io.Serializable value, boolean locallyModified)
           
protected  void notifyKeyListenersOfRemove(java.lang.String category, java.io.Serializable key, java.io.Serializable oldContent, boolean locallyModified)
           
 void registerDSListener(java.lang.String category, DistributedState.DSListener (src)  subscriber)
          Subscribes to receive DistributedState.DSListener events
 void registerDSListenerEx(java.lang.String category, DistributedState.DSListenerEx (src)  subscriber)
          Subscribes to receive DistributedState.DSListenerEx events
protected  void registerListener(java.lang.String category, java.lang.Object subscriber)
           
 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 setCurrentState(java.io.Serializable newState)
          This callback method is called when a new service starts on a new node: the state that it should hold is transfered to it through this callback
 void start()
           
 void stop()
           
 void unregisterDSListener(java.lang.String category, DistributedState.DSListener (src)  subscriber)
          Subscribes from DistributedState.DSListener events
 void unregisterDSListenerEx(java.lang.String category, DistributedState.DSListenerEx (src)  subscriber)
          Subscribes from DistributedState.DSListenerEx events
protected  void unregisterListener(java.lang.String category, java.lang.Object subscriber)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE_NAME

protected static final java.lang.String SERVICE_NAME
See Also:
Constant Field Values (src)

set_types

protected static final java.lang.Class[] set_types

remove_types

protected static final java.lang.Class[] remove_types

categories

protected java.util.HashMap categories
HashMap. Keys= category, value = HashMap


keyListeners

protected java.util.HashMap keyListeners

partition

protected HAPartition (src)  partition

log

protected Logger (src)  log

mbeanServer

protected MBeanServer (src)  mbeanServer

name

protected java.lang.String name
Constructor Detail

DistributedStateImpl

public DistributedStateImpl()

DistributedStateImpl

public DistributedStateImpl(HAPartition (src)  partition,
                            MBeanServer (src)  server)
Method Detail

init

public void init()
          throws java.lang.Exception
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Throws:
java.lang.Exception

listContent

public java.lang.String listContent()
                             throws java.lang.Exception
Specified by:
listContent in interface DistributedStateImplMBean (src)
Throws:
java.lang.Exception

listXmlContent

public java.lang.String listXmlContent()
                                throws java.lang.Exception
Specified by:
listXmlContent in interface DistributedStateImplMBean (src)
Throws:
java.lang.Exception

set

public void set(java.lang.String category,
                java.io.Serializable key,
                java.io.Serializable value)
         throws java.lang.Exception
Description copied from interface: DistributedState (src)
Associates a value to a key in a specific category

Specified by:
set in interface DistributedState (src)
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
Description copied from interface: DistributedState (src)
Same as set(String, String) but caller can choose if the call is made synchronously or asynchronously. By default, calls are asynchronous.

Specified by:
set in interface DistributedState (src)
Throws:
java.lang.Exception

remove

public java.io.Serializable remove(java.lang.String category,
                                   java.io.Serializable key)
                            throws java.lang.Exception
Description copied from interface: DistributedState (src)
Remove the key from the ReplicationService in the given category

Specified by:
remove in interface DistributedState (src)
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
Description copied from interface: DistributedState (src)
Same as remove(String, String) but caller can choose if the call is made synchronously or asynchronously. By default, calls are asynchronous.

Specified by:
remove in interface DistributedState (src)
Throws:
java.lang.Exception

get

public java.io.Serializable get(java.lang.String category,
                                java.io.Serializable key)
Description copied from interface: DistributedState (src)
Read in a value associated to a key in the given category. Read is performed locally.

Specified by:
get in interface DistributedState (src)
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()
Description copied from interface: DistributedState (src)
Return a list of all categories. Call managed locally: no network access.

Specified by:
getAllCategories in interface DistributedState (src)
Returns:
A collection of String representing the existing categories in the DS service.

getAllKeys

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

Specified by:
getAllKeys in interface DistributedState (src)
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)
Description copied from interface: DistributedState (src)
Return a list of all values in a category. Call managed locally: no network access.

Specified by:
getAllValues in interface DistributedState (src)
Parameters:
category - The category name under which to look for values
Returns:
A collection of all values in the give category

registerDSListenerEx

public void registerDSListenerEx(java.lang.String category,
                                 DistributedState.DSListenerEx (src)  subscriber)
Description copied from interface: DistributedState (src)
Subscribes to receive DistributedState.DSListenerEx (src) events

Specified by:
registerDSListenerEx in interface DistributedState (src)
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)
Description copied from interface: DistributedState (src)
Subscribes from DistributedState.DSListenerEx (src) events

Specified by:
unregisterDSListenerEx in interface DistributedState (src)
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)
Description copied from interface: DistributedState (src)
Subscribes to receive DistributedState.DSListener (src) events

Specified by:
registerDSListener in interface DistributedState (src)
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)
Description copied from interface: DistributedState (src)
Subscribes from DistributedState.DSListener (src) events

Specified by:
unregisterDSListener in interface DistributedState (src)
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.lang.String key,
                 java.io.Serializable value)
          throws java.lang.Exception
Throws:
java.lang.Exception

_set

public void _set(java.lang.String category,
                 java.io.Serializable key,
                 java.io.Serializable value)
          throws java.lang.Exception
Throws:
java.lang.Exception

_setInternal

public void _setInternal(java.lang.String category,
                         java.io.Serializable key,
                         java.io.Serializable value)
                  throws java.lang.Exception
Throws:
java.lang.Exception

_remove

public void _remove(java.lang.String category,
                    java.lang.String key)
             throws java.lang.Exception
Throws:
java.lang.Exception

_remove

public void _remove(java.lang.String category,
                    java.io.Serializable key)
             throws java.lang.Exception
Throws:
java.lang.Exception

_removeInternal

public java.io.Serializable _removeInternal(java.lang.String category,
                                            java.io.Serializable key)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getCurrentState

public java.io.Serializable getCurrentState()
Description copied from interface: HAPartition.HAPartitionStateTransfer (src)
Called when a new node need to be initialized. This is called on any existing node to determine a current state for this service.

Specified by:
getCurrentState in interface HAPartition.HAPartitionStateTransfer (src)
Returns:
A serializable representation of the state

setCurrentState

public void setCurrentState(java.io.Serializable newState)
Description copied from interface: HAPartition.HAPartitionStateTransfer (src)
This callback method is called when a new service starts on a new node: the state that it should hold is transfered to it through this callback

Specified by:
setCurrentState in interface HAPartition.HAPartitionStateTransfer (src)
Parameters:
newState - The serialized representation of the state of the new service.

registerListener

protected void registerListener(java.lang.String category,
                                java.lang.Object subscriber)

unregisterListener

protected void unregisterListener(java.lang.String category,
                                  java.lang.Object subscriber)

notifyKeyListeners

protected void notifyKeyListeners(java.lang.String category,
                                  java.io.Serializable key,
                                  java.io.Serializable value,
                                  boolean locallyModified)

notifyKeyListenersOfRemove

protected void notifyKeyListenersOfRemove(java.lang.String category,
                                          java.io.Serializable key,
                                          java.io.Serializable oldContent,
                                          boolean locallyModified)

cleanupKeyListeners

protected void cleanupKeyListeners()