org.jboss.ha.hasessionstate.server
Class HASessionStateImpl

java.lang.Object
  extended by org.jboss.ha.hasessionstate.server.HASessionStateImpl
All Implemented Interfaces:
org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer, HASessionState

public class HASessionStateImpl
extends Object
implements HASessionState, org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer

Default implementation of HASessionState

Version:
$Revision: 81001 $

Revisions:

2002/01/09: billb

  1. ripped out sub partitioning stuff. It really belongs as a subclass of HAPartition
Author:
sacha.labourey@cogito-info.ch, Bill Burke, Paul Ferraro
See Also:
HASessionState

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.ha.hasessionstate.interfaces.HASessionState
HASessionState.HASessionStateListener
 
Field Summary
protected  ConcurrentMap<String,Set<HASessionState.HASessionStateListener>> appListenerMap
           
protected  Map<String,ConcurrentMap<Object,PackagedSession>> appSessionMap
           
 
Constructor Summary
HASessionStateImpl(String sessionStateName, org.jboss.ha.framework.interfaces.HAPartition partition, long beanCleaningDelay)
           
 
Method Summary
 PackagedSession _createSession(String appName, Object keyId)
           
 void _removeSession(String appName, Object keyId)
           
 Boolean _setOwnership(String appName, Object keyId, String newOwner, Long remoteVersion)
           
 void _setState(String appName, PackagedSession session)
           
protected  void bind(String jndiName, Object who, Class<?> classType, Context ctx)
           
 void createSession(String appName, Object keyId)
          Share a new session state in the sub-partition of this cluster
protected  byte[] deflate(Object object)
           
 void destroy()
           
protected  ConcurrentMap<Object,PackagedSession> getAppMap(String appName)
           
 org.jboss.ha.framework.interfaces.HAPartition getCurrentHAPartition()
           
 Serializable getCurrentState()
           
 String getNodeName()
          Return the name of this node as used in the computations
 PackagedSession getState(String appName, Object keyId)
          Get a particular state
 PackagedSession getStateWithOwnership(String appName, Object keyId)
          Get a state and, if it is not already the case, takes its ownership (a state is always owned by a node)
protected  Object inflate(byte[] compressedContent)
           
 void init()
           
 PackagedSession localTakeOwnership(String appName, Object keyId)
           
 void ownedObjectExternallyModified(String appName, Object key, PackagedSession oldSession, PackagedSession newSession)
           
 void purgeState()
           
 void removeSession(String appName, Object keyId)
          Remove a session from the sub-partition
 void setCurrentState(Serializable newState)
           
 void setState(String appName, Object keyId, byte[] state)
          Modifies a state already shared
 void start()
           
 void stop()
           
 void subscribe(String appName, HASessionState.HASessionStateListener listener)
          Subscribe to receive notifications when objects gets modified on another node.
 void takeOwnership(String appName, Object keyId)
          Take ownership of a state.
 void unsubscribe(String appName, HASessionState.HASessionStateListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appSessionMap

protected Map<String,ConcurrentMap<Object,PackagedSession>> appSessionMap

appListenerMap

protected ConcurrentMap<String,Set<HASessionState.HASessionStateListener>> appListenerMap
Constructor Detail

HASessionStateImpl

public HASessionStateImpl(String sessionStateName,
                          org.jboss.ha.framework.interfaces.HAPartition partition,
                          long beanCleaningDelay)
Method Detail

init

public void init()
          throws Exception
Specified by:
init in interface HASessionState
Throws:
Exception

start

public void start()
           throws Exception
Specified by:
start in interface HASessionState
Throws:
Exception

bind

protected void bind(String jndiName,
                    Object who,
                    Class<?> classType,
                    Context ctx)
             throws Exception
Throws:
Exception

stop

public void stop()

destroy

public void destroy()
             throws Exception
Throws:
Exception

getNodeName

public String getNodeName()
Description copied from interface: HASessionState
Return the name of this node as used in the computations

Specified by:
getNodeName in interface HASessionState

getCurrentState

public Serializable getCurrentState()
Specified by:
getCurrentState in interface org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer

setCurrentState

public void setCurrentState(Serializable newState)
Specified by:
setCurrentState in interface org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer

purgeState

public void purgeState()

deflate

protected byte[] deflate(Object object)
                  throws IOException
Throws:
IOException

inflate

protected Object inflate(byte[] compressedContent)
                  throws IOException
Throws:
IOException

getAppMap

protected ConcurrentMap<Object,PackagedSession> getAppMap(String appName)

createSession

public void createSession(String appName,
                          Object keyId)
Description copied from interface: HASessionState
Share a new session state in the sub-partition of this cluster

Specified by:
createSession in interface HASessionState
Parameters:
appName - Application name for which is state is shared
keyId - Key identifier of the state

_createSession

public PackagedSession _createSession(String appName,
                                      Object keyId)

setState

public void setState(String appName,
                     Object keyId,
                     byte[] state)
              throws RemoteException
Description copied from interface: HASessionState
Modifies a state already shared

Specified by:
setState in interface HASessionState
Parameters:
appName - Application name hosting this state
keyId - Key identifier of the state to modify
state - New state
Throws:
RemoteException

_setState

public void _setState(String appName,
                      PackagedSession session)

getState

public PackagedSession getState(String appName,
                                Object keyId)
Description copied from interface: HASessionState
Get a particular state

Specified by:
getState in interface HASessionState
Parameters:
appName - Application hosting the state
keyId - Key identifier of the state
Returns:
The state value

getStateWithOwnership

public PackagedSession getStateWithOwnership(String appName,
                                             Object keyId)
                                      throws RemoteException
Description copied from interface: HASessionState
Get a state and, if it is not already the case, takes its ownership (a state is always owned by a node)

Specified by:
getStateWithOwnership in interface HASessionState
Parameters:
appName - Application hosting the state
keyId - Key identifier of the state
Returns:
The state value
Throws:
RemoteException - Thrown if an exception occurs while getting the ownership of the state

localTakeOwnership

public PackagedSession localTakeOwnership(String appName,
                                          Object keyId)
                                   throws RemoteException
Throws:
RemoteException

_setOwnership

public Boolean _setOwnership(String appName,
                             Object keyId,
                             String newOwner,
                             Long remoteVersion)

takeOwnership

public void takeOwnership(String appName,
                          Object keyId)
                   throws RemoteException
Description copied from interface: HASessionState
Take ownership of a state. Each state is owned by a node.

Specified by:
takeOwnership in interface HASessionState
Parameters:
appName - Application hosting the state
keyId - Key identifier of the state
Throws:
RemoteException - Trown if a communication exception occurs while asking other node to get the ownership

removeSession

public void removeSession(String appName,
                          Object keyId)
Description copied from interface: HASessionState
Remove a session from the sub-partition

Specified by:
removeSession in interface HASessionState
Parameters:
appName - Application hosting the state
keyId - Key identifier of the state

_removeSession

public void _removeSession(String appName,
                           Object keyId)

subscribe

public void subscribe(String appName,
                      HASessionState.HASessionStateListener listener)
Description copied from interface: HASessionState
Subscribe to receive notifications when objects gets modified on another node.

Specified by:
subscribe in interface HASessionState

unsubscribe

public void unsubscribe(String appName,
                        HASessionState.HASessionStateListener listener)
Specified by:
unsubscribe in interface HASessionState

ownedObjectExternallyModified

public void ownedObjectExternallyModified(String appName,
                                          Object key,
                                          PackagedSession oldSession,
                                          PackagedSession newSession)

getCurrentHAPartition

public org.jboss.ha.framework.interfaces.HAPartition getCurrentHAPartition()
Specified by:
getCurrentHAPartition in interface HASessionState


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.