站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 cluster API Documentation 英文版文档

DistributedReplicantManagerImpl (JBoss Cluster API) - JBoss 4.0.1 sp1 cluster API Documentation 英文版文档


org.jboss.ha.framework.server
Class DistributedReplicantManagerImpl

java.lang.Object
  extended byorg.jboss.ha.framework.server.DistributedReplicantManagerImpl
All Implemented Interfaces:
DistributedReplicantManager, DistributedReplicantManagerImplMBean, HAPartition.HAMembershipExtendedListener, HAPartition.HAMembershipListener, HAPartition.HAPartitionStateTransfer

public class DistributedReplicantManagerImpl
extends Object
implements DistributedReplicantManagerImplMBean, HAPartition.HAMembershipExtendedListener, HAPartition.HAPartitionStateTransfer

This class manages replicated objects.

Version:
$Id: DistributedReplicantManagerImpl.java,v 1.25 2004/08/05 09:35:13 belaban Exp $
Author:
Bill Burke., Sacha Labourey.

Nested Class Summary
protected  class DistributedReplicantManagerImpl.MembersPublisher
           
protected  class DistributedReplicantManagerImpl.MergeMembers
           
 
Nested classes inherited from class org.jboss.ha.framework.interfaces.DistributedReplicantManager
DistributedReplicantManager.ReplicantListener
 
Field Summary
protected  Class[] add_types
           
protected  HashMap intraviewIdCache
           
protected  javax.management.ObjectName jmxName
           
protected  HashMap keyListeners
           
protected  HashMap localReplicants
           
protected  org.jboss.logging.Logger log
           
protected  javax.management.MBeanServer mbeanserver
           
protected  String nodeName
           
protected  HAPartition partition
           
protected  EDU.oswego.cs.dl.util.concurrent.Latch partitionNameKnown
           
protected  Class[] remove_types
           
protected  HashMap replicants
           
protected static String SERVICE_NAME
           
protected static int threadID
           
protected  boolean trace
           
 
Constructor Summary
DistributedReplicantManagerImpl(HAPartition partition, javax.management.MBeanServer server)
          This class manages replicated objects through the given 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)
          Add a replicant, it will be attached to this cluster node
protected  void addReplicant(HashMap map, String key, String nodeName, Serializable replicant)
          Logic for adding replicant to any map.
protected  void addReplicant(String key, String nodeName, Serializable replicant)
          Add a replicant to the replicants map.
protected  int calculateReplicantsHash(List members)
           
protected  void cleanupKeyListeners()
           
 Collection getAllServices()
          Return a list of all services that have a least one replicant.
 Serializable getCurrentState()
          Called when a new node need to be initialized.
protected  Vector getKeysReplicatedByNode(String nodeName)
           
 int getReplicantsViewId(String key)
          Returns an id corresponding to the current view of this set of replicants.
 void init()
           
 boolean isMasterReplica(String key)
          Indicates if the current node is the master replica for this given key.
 String listContent()
           
 String listXmlContent()
           
 Serializable lookupLocalReplicant(String key)
          Lookup the replicant attached to this cluster node
 Object[] lookupLocalReplicants()
          Cluster callback called when a node wants to know our complete list of local replicants
 List lookupReplicants(String key)
          Return a list of all replicants.
 List lookupReplicantsNodeNames(String key)
          Return a list of all replicants node names.
 void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers)
          Called when a new partition topology occurs.
 void membershipChangedDuringMerge(Vector deadMembers, Vector newMembers, Vector allMembers, Vector originatingGroups)
          Extends HAMembershipListener to receive a specific callback when a network-partition merge occurs.
protected  void mergeMembers()
           
protected static int nextThreadID()
           
protected  void notifyKeyListeners(String key, List newReplicants)
          Notifies, through a callback, the listeners for a given replicant that the set of replicants has changed
protected  void purgeDeadMembers(Vector deadMembers)
          get rid of dead members from replicant list return true if anything was purged.
 void registerListener(String key, DistributedReplicantManager.ReplicantListener subscriber)
          Subscribe a new listener ReplicantListener for replicants change
 void remove(String key)
          Remove the entire key from the ReplicationService
protected  boolean removeReplicant(String key, String nodeName)
           
protected  boolean replicantEntryAlreadyExists(HashMap map, String key, String nodeName)
          Indicates if the a replicant already exists for a given key/node pair in the give data structure
protected  boolean replicantEntryAlreadyExists(String key, String nodeName)
          Indicates if the a replicant already exists for a given key/node pair
protected  void republishLocalReplicants()
           
 void setCurrentState(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 unregisterListener(String key, DistributedReplicantManager.ReplicantListener subscriber)
          Unsubscribe a listener ReplicantListener that had subscribed for replicants changes
protected  int updateReplicantsHashId(String key)
           
 
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 String SERVICE_NAME
See Also:
Constant Field Values

threadID

protected static int threadID

localReplicants

protected HashMap localReplicants

replicants

protected HashMap replicants

keyListeners

protected HashMap keyListeners

intraviewIdCache

protected HashMap intraviewIdCache

partition

protected HAPartition partition

log

protected org.jboss.logging.Logger log

mbeanserver

protected javax.management.MBeanServer mbeanserver

jmxName

protected javax.management.ObjectName jmxName

nodeName

protected String nodeName

partitionNameKnown

protected EDU.oswego.cs.dl.util.concurrent.Latch partitionNameKnown

trace

protected boolean trace

add_types

protected Class[] add_types

remove_types

protected Class[] remove_types
Constructor Detail

DistributedReplicantManagerImpl

public DistributedReplicantManagerImpl(HAPartition partition,
                                       javax.management.MBeanServer server)
This class manages replicated objects through the given partition

Parameters:
partition - HAPartition through which replicated objects will be exchanged
Method Detail

init

public void init()
          throws Exception
Throws:
Exception

start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Throws:
Exception

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()
Description copied from interface: HAPartition.HAPartitionStateTransfer
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
Returns:
A serializable representation of the state

setCurrentState

public void setCurrentState(Serializable newState)
Description copied from interface: HAPartition.HAPartitionStateTransfer
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
Parameters:
newState - The serialized representation of the state of the new service.

getAllServices

public Collection getAllServices()
Description copied from interface: DistributedReplicantManager
Return a list of all services that have a least one replicant.

Specified by:
getAllServices in interface DistributedReplicantManager
Returns:
A collection of services names (String)

membershipChangedDuringMerge

public void membershipChangedDuringMerge(Vector deadMembers,
                                         Vector newMembers,
                                         Vector allMembers,
                                         Vector originatingGroups)
Description copied from interface: HAPartition.HAMembershipExtendedListener
Extends HAMembershipListener to receive a specific callback when a network-partition merge occurs. The same restriction on interaction with the JG protocol stack applies.

Specified by:
membershipChangedDuringMerge in interface HAPartition.HAMembershipExtendedListener
Parameters:
deadMembers - A list of nodes that have died since the previous view
newMembers - A list of nodes that have joined the partition since the previous view
allMembers - A list of nodes that built the current view
originatingGroups - A list of list of nodes that were previously partionned and that are now merged

membershipChanged

public void membershipChanged(Vector deadMembers,
                              Vector newMembers,
                              Vector allMembers)
Description copied from interface: HAPartition.HAMembershipListener
Called when a new partition topology occurs. This callback is made using the JG protocol handler thread and so you cannot execute new cluster calls that need this thread. If you need to do that implement the aynchronous version of the listener interface.

Specified by:
membershipChanged in interface HAPartition.HAMembershipListener
Parameters:
deadMembers - A list of nodes that have died since the previous view
newMembers - A list of nodes that have joined the partition since the previous view
allMembers - A list of nodes that built the current view

add

public void add(String key,
                Serializable replicant)
         throws Exception
Description copied from interface: DistributedReplicantManager
Add a replicant, it will be attached to this cluster node

Specified by:
add in interface DistributedReplicantManager
Parameters:
key - Replicant name. All replicas around the cluster must use the same key name.
replicant - Local data of the replicant, that is, any serializable data
Throws:
Exception - Thrown if a cluster communication problem occurs

remove

public void remove(String key)
            throws Exception
Description copied from interface: DistributedReplicantManager
Remove the entire key from the ReplicationService

Specified by:
remove in interface DistributedReplicantManager
Parameters:
key - Name of the replicant
Throws:
Exception - Thrown if a cluster communication problem occurs

lookupLocalReplicant

public Serializable lookupLocalReplicant(String key)
Description copied from interface: DistributedReplicantManager
Lookup the replicant attached to this cluster node

Specified by:
lookupLocalReplicant in interface DistributedReplicantManager
Parameters:
key - The name of the replicant
Returns:
The local replicant for the give key name

lookupReplicants

public List lookupReplicants(String key)
Description copied from interface: DistributedReplicantManager
Return a list of all replicants.

Specified by:
lookupReplicants in interface DistributedReplicantManager
Parameters:
key - The replicant name
Returns:
An array of serialized replicants available around the cluster for the given key

lookupReplicantsNodeNames

public List lookupReplicantsNodeNames(String key)
Description copied from interface: DistributedReplicantManager
Return a list of all replicants node names.

Specified by:
lookupReplicantsNodeNames in interface DistributedReplicantManager
Parameters:
key - The replicant name
Returns:
An array of replicants node names available around the cluster for the given key

registerListener

public void registerListener(String key,
                             DistributedReplicantManager.ReplicantListener subscriber)
Description copied from interface: DistributedReplicantManager
Subscribe a new listener DistributedReplicantManager.ReplicantListener for replicants change

Specified by:
registerListener in interface DistributedReplicantManager
Parameters:
key - Name of the replicant, must be identical cluster-wide for all identical replicants
subscriber - The subsribing DistributedReplicantManager.ReplicantListener

unregisterListener

public void unregisterListener(String key,
                               DistributedReplicantManager.ReplicantListener subscriber)
Description copied from interface: DistributedReplicantManager
Unsubscribe a listener DistributedReplicantManager.ReplicantListener that had subscribed for replicants changes

Specified by:
unregisterListener in interface DistributedReplicantManager
Parameters:
key - Name of the replicant, must be identical cluster-wide for all identical replicants
subscriber - The unsubscribing DistributedReplicantManager.ReplicantListener

getReplicantsViewId

public int getReplicantsViewId(String key)
Description copied from interface: DistributedReplicantManager
Returns an id corresponding to the current view of this set of replicants.

Specified by:
getReplicantsViewId in interface DistributedReplicantManager
Parameters:
key - The replicant name
Returns:
A view id (doesn't grow sequentially)

isMasterReplica

public boolean isMasterReplica(String key)
Description copied from interface: DistributedReplicantManager
Indicates if the current node is the master replica for this given key.

Specified by:
isMasterReplica in interface DistributedReplicantManager
Parameters:
key - The replicant name
Returns:
True if this node is the master

_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)
                           throws Exception
Throws:
Exception

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 members)

updateReplicantsHashId

protected int updateReplicantsHashId(String key)

addReplicant

protected void 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

addReplicant

protected void addReplicant(HashMap map,
                            String key,
                            String nodeName,
                            Serializable replicant)
Logic for adding replicant to any map.

Parameters:
map - structure in which adding the new replicant
key - name of the replicant key
nodeName - name of the node adding the replicant
replicant - serialized representation of the replicant that is added

getKeysReplicatedByNode

protected Vector getKeysReplicatedByNode(String nodeName)

replicantEntryAlreadyExists

protected boolean replicantEntryAlreadyExists(String key,
                                              String nodeName)
Indicates if the a replicant already exists for a given key/node pair

Parameters:
key - replicant key name
nodeName - name of the node
Returns:
a boolean indicating if a replicant for the given node exists for the given key

replicantEntryAlreadyExists

protected boolean replicantEntryAlreadyExists(HashMap map,
                                              String key,
                                              String nodeName)
Indicates if the a replicant already exists for a given key/node pair in the give data structure


notifyKeyListeners

protected void notifyKeyListeners(String key,
                                  List newReplicants)
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

republishLocalReplicants

protected void republishLocalReplicants()

mergeMembers

protected void mergeMembers()

purgeDeadMembers

protected void purgeDeadMembers(Vector deadMembers)
get rid of dead members from replicant list return true if anything was purged.


cleanupKeyListeners

protected void cleanupKeyListeners()

nextThreadID

protected static int nextThreadID()


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.