org.jboss.ha.framework.server
Class DistributedReplicantManagerImpl

java.lang.Object
  extended by org.jboss.ha.framework.server.DistributedReplicantManagerImpl
All Implemented Interfaces:
org.jboss.ha.framework.interfaces.DistributedReplicantManager, org.jboss.ha.framework.interfaces.HAPartition.HAMembershipExtendedListener, org.jboss.ha.framework.interfaces.HAPartition.HAMembershipListener, org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer, AsynchEventHandler.AsynchEventProcessor, DistributedReplicantManagerImplMBean

public class DistributedReplicantManagerImpl
extends Object
implements DistributedReplicantManagerImplMBean, org.jboss.ha.framework.interfaces.HAPartition.HAMembershipExtendedListener, org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer, AsynchEventHandler.AsynchEventProcessor

This class manages replicated objects.

Version:
$Revision: 89190 $
Author:
Bill Burke., Sacha Labourey., Scott.stark@jboss.org, Galder Zamarreno, Paul Ferraro

Nested Class Summary
protected  class DistributedReplicantManagerImpl.MembersPublisher
           
protected  class DistributedReplicantManagerImpl.MergeMembers
           
 
Nested classes/interfaces inherited from interface org.jboss.ha.framework.interfaces.DistributedReplicantManager
org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener
 
Constructor Summary
DistributedReplicantManagerImpl(org.jboss.ha.framework.interfaces.HAPartition partition)
           
 
Method Summary
 void _add(String key, String nodeName, Serializable replicant)
          Cluster callback called when a new replicant is added on another node
 void _remove(String key, String nodeName)
          Cluster callback called when a replicant is removed by another node
 void add(String key, Serializable replicant)
           
protected  boolean addReplicant(String key, String nodeName, Serializable replicant)
          Add a replicant to the replicants map.
protected  int calculateReplicantsHash(List<org.jboss.ha.framework.interfaces.ClusterNode> members)
           
protected  void cleanupKeyListeners()
           
 void createService()
           
 void destroyService()
           
 Collection<String> getAllServices()
           
 Serializable getCurrentState()
           
 String getPartitionName()
          Get the name of the underlying partition used by this service.
 int getReplicantsViewId(String key)
           
 boolean isMasterReplica(String key)
           
 String listContent()
           
 String listXmlContent()
           
 Serializable lookupLocalReplicant(String key)
           
 Object[] lookupLocalReplicants()
          Cluster callback called when a node wants to know our complete list of local replicants
 List<Serializable> lookupReplicants(String key)
           
 List<String> lookupReplicantsNodeNames(String key)
          Deprecated. 
 List<org.jboss.ha.framework.interfaces.ClusterNode> lookupReplicantsNodes(String key)
           
 void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers)
           
 void membershipChangedDuringMerge(Vector deadMembers, Vector newMembers, Vector allMembers, Vector originatingGroups)
           
protected  void mergeMembers()
           
protected  void notifyKeyListeners(String key, List<Serializable> newReplicants, boolean merge)
          Notifies, through a callback, the listeners for a given replicant that the set of replicants has changed
 void processEvent(Object event)
           
protected  void purgeDeadMembers(Vector<org.jboss.ha.framework.interfaces.ClusterNode> deadMembers, boolean merge)
          Get rid of dead members from replicant list.
 void registerListener(String key, org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener subscriber)
           
 void registerWithJmx(MBeanServer server)
           
 void remove(String key)
           
protected  boolean removeReplicant(String key, String nodeName)
           
protected  void republishLocalReplicants()
           
 void setCurrentState(Serializable newState)
           
 void startService()
           
 void stopService()
           
 void unregisterListener(String key, org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener subscriber)
           
 void unregisterWithJmx(MBeanServer server)
           
protected  int updateReplicantsHashId(String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedReplicantManagerImpl

public DistributedReplicantManagerImpl(org.jboss.ha.framework.interfaces.HAPartition partition)
Method Detail

createService

public void createService()
                   throws Exception
Throws:
Exception

startService

public void startService()
                  throws Exception
Throws:
Exception

stopService

public void stopService()
                 throws Exception
Throws:
Exception

destroyService

public void destroyService()
                    throws Exception
Throws:
Exception

registerWithJmx

public void registerWithJmx(MBeanServer server)
                     throws Exception
Throws:
Exception

unregisterWithJmx

public void unregisterWithJmx(MBeanServer server)
                       throws Exception
Throws:
Exception

getPartitionName

public String getPartitionName()
Description copied from interface: DistributedReplicantManagerImplMBean
Get the name of the underlying partition used by this service.

Specified by:
getPartitionName in interface DistributedReplicantManagerImplMBean
Returns:
the name of the partition

listContent

public String listContent()
                   throws Exception
Specified by:
listContent in interface DistributedReplicantManagerImplMBean
Throws:
Exception

listXmlContent

public String listXmlContent()
                      throws Exception
Specified by:
listXmlContent in interface DistributedReplicantManagerImplMBean
Throws:
Exception

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

getAllServices

public Collection<String> getAllServices()
Specified by:
getAllServices in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

membershipChangedDuringMerge

public void membershipChangedDuringMerge(Vector deadMembers,
                                         Vector newMembers,
                                         Vector allMembers,
                                         Vector originatingGroups)
Specified by:
membershipChangedDuringMerge in interface org.jboss.ha.framework.interfaces.HAPartition.HAMembershipExtendedListener

membershipChanged

public void membershipChanged(Vector deadMembers,
                              Vector newMembers,
                              Vector allMembers)
Specified by:
membershipChanged in interface org.jboss.ha.framework.interfaces.HAPartition.HAMembershipListener

processEvent

public void processEvent(Object event)
Specified by:
processEvent in interface AsynchEventHandler.AsynchEventProcessor

add

public void add(String key,
                Serializable replicant)
         throws Exception
Specified by:
add in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager
Throws:
Exception

remove

public void remove(String key)
            throws Exception
Specified by:
remove in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager
Throws:
Exception

lookupLocalReplicant

public Serializable lookupLocalReplicant(String key)
Specified by:
lookupLocalReplicant in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

lookupReplicants

public List<Serializable> lookupReplicants(String key)
Specified by:
lookupReplicants in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

lookupReplicantsNodeNames

@Deprecated
public List<String> lookupReplicantsNodeNames(String key)
Deprecated. 

Specified by:
lookupReplicantsNodeNames in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

lookupReplicantsNodes

public List<org.jboss.ha.framework.interfaces.ClusterNode> lookupReplicantsNodes(String key)
Specified by:
lookupReplicantsNodes in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

registerListener

public void registerListener(String key,
                             org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener subscriber)
Specified by:
registerListener in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

unregisterListener

public void unregisterListener(String key,
                               org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener subscriber)
Specified by:
unregisterListener in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

getReplicantsViewId

public int getReplicantsViewId(String key)
Specified by:
getReplicantsViewId in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

isMasterReplica

public boolean isMasterReplica(String key)
Specified by:
isMasterReplica in interface org.jboss.ha.framework.interfaces.DistributedReplicantManager

_add

public void _add(String key,
                 String nodeName,
                 Serializable replicant)
Cluster callback called when a new replicant is added on another node

Parameters:
key - Replicant key
nodeName - Node that add the current replicant
replicant - Serialized representation of the replicant

_remove

public void _remove(String key,
                    String nodeName)
Cluster callback called when a replicant is removed by another node

Parameters:
key - Name of the replicant key
nodeName - Node that wants to remove its replicant for the give key

removeReplicant

protected boolean removeReplicant(String key,
                                  String nodeName)

lookupLocalReplicants

public Object[] lookupLocalReplicants()
                               throws Exception
Cluster callback called when a node wants to know our complete list of local replicants

Returns:
A java array of size 2 containing the name of our node in this cluster and the serialized representation of our state
Throws:
Exception - Thrown if a cluster communication exception occurs

calculateReplicantsHash

protected int calculateReplicantsHash(List<org.jboss.ha.framework.interfaces.ClusterNode> members)

updateReplicantsHashId

protected int updateReplicantsHashId(String key)

addReplicant

protected boolean addReplicant(String key,
                               String nodeName,
                               Serializable replicant)
Add a replicant to the replicants map.

Parameters:
key - replicant key name
nodeName - name of the node that adds this replicant
replicant - Serialized representation of the replica
Returns:
true, if this replicant was newly added to the map, false otherwise

notifyKeyListeners

protected void notifyKeyListeners(String key,
                                  List<Serializable> newReplicants,
                                  boolean merge)
Notifies, through a callback, the listeners for a given replicant that the set of replicants has changed

Parameters:
key - The replicant key name
newReplicants - The new list of replicants
merge - is the notification the result of a cluster merge?

republishLocalReplicants

protected void republishLocalReplicants()

mergeMembers

protected void mergeMembers()

purgeDeadMembers

protected void purgeDeadMembers(Vector<org.jboss.ha.framework.interfaces.ClusterNode> deadMembers,
                                boolean merge)
Get rid of dead members from replicant list.

Parameters:
deadMembers - the members that are no longer in the view
merge - whether the membership change occurred during a cluster merge

cleanupKeyListeners

protected void cleanupKeyListeners()


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