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

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


org.jboss.ha.framework.server
Class HAPartitionImpl

java.lang.Object
  extended byorg.jgroups.blocks.MessageDispatcher
      extended byorg.jgroups.blocks.RpcDispatcher
          extended byorg.jboss.ha.framework.server.HAPartitionImpl
All Implemented Interfaces:
org.jgroups.ChannelListener, HAPartition, org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.blocks.RequestHandler

public class HAPartitionImpl
extends org.jgroups.blocks.RpcDispatcher
implements org.jgroups.MessageListener, org.jgroups.MembershipListener, HAPartition

This class is an abstraction class for a JGroups RPCDispatch and JChannel. It is a default implementation of HAPartition for the JGroups framework

Version:
$Revision: 1.43 $
Author:
Sacha Labourey., Bill Burke., Scott.Stark@jboss.org

Nested Class Summary
 
Nested classes inherited from class org.jgroups.blocks.RpcDispatcher
org.jgroups.blocks.RpcDispatcher.Marshaller
 
Nested classes inherited from class org.jboss.ha.framework.interfaces.HAPartition
HAPartition.AsynchHAMembershipExtendedListener, HAPartition.AsynchHAMembershipListener, HAPartition.HAMembershipExtendedListener, HAPartition.HAMembershipListener, HAPartition.HAPartitionStateTransfer
 
Field Summary
protected  ArrayList asynchListeners
          The asynch HAMembershipListener and HAMembershipExtendedListeners
protected  Thread asynchNotifyThread
          The Thread used to send membership change notifications asynchronously
protected  EDU.oswego.cs.dl.util.concurrent.LinkedQueue asynchViewChanges
          The LinkedQueue of changes to notify asynch listeners of
protected  org.jgroups.JChannel channel
          The JGroups partition channel
protected  org.jboss.logging.Logger clusterLifeCycleLog
           
protected  long currentViewId
          The current cluster view id
protected  DistributedStateImpl dsManager
          The cluster state manager
 Vector history
           
protected  Vector jgmembers
           
protected  Vector jgotherMembers
           
protected  ArrayList listeners
          The HAMembershipListener and HAMembershipExtendedListeners
protected  org.jgroups.stack.IpAddress localJGAddress
          the local JG IP Address
protected  org.jboss.logging.Logger log
          The cluster instance log category
protected  ClusterNode me
          me as a ClusterNode
protected  Vector members
          The current cluster partition members
protected  String nodeName
          The cluster transport protocol address string
protected  Vector otherMembers
          The partition members other than this node
protected  String partitionName
          The JChannel name
protected  DistributedReplicantManagerImpl replicantManager
          The cluster replicant manager
protected  HashMap rpcHandlers
           
protected  javax.management.MBeanServer server
          The JMX MBeanServer to use for registrations
protected  long state_transfer_timeout
          Number of ms to wait for state
protected  HashMap stateHandlers
           
protected  long timeout
          The timeout for cluster RPC calls
 
Fields inherited from class org.jgroups.blocks.RpcDispatcher
marshaller, server_obj
 
Fields inherited from class org.jgroups.blocks.MessageDispatcher
adapter, concurrent_processing, corr, deadlock_detection, id, local_addr, membership_listener, msg_listener, prot_adapter, req_handler, transport_adapter
 
Constructor Summary
HAPartitionImpl(String partitionName, org.jgroups.JChannel channel, boolean deadlock_detection)
           
HAPartitionImpl(String partitionName, org.jgroups.JChannel channel, boolean deadlock_detection, javax.management.MBeanServer server)
           
 
Method Summary
protected  void bind(String jndiName, Object who, Class classType, Context ctx)
          Helper method that binds the partition in the JNDI tree.
 void block()
           
 void callAsynchMethodOnCluster(String objName, String methodName, Object[] args, boolean excludeSelf)
          Deprecated. Use callAsynchMethodOnCluster(String, String, Object[], Class[], boolean) instead
 void callAsynchMethodOnCluster(String objName, String methodName, Object[] args, Class[] types, boolean excludeSelf)
          This function is an abstraction of RpcDispatcher for asynchronous messages
 ArrayList callMethodOnCluster(String objName, String methodName, Object[] args, boolean excludeSelf)
          Deprecated. Use callMethodOnCluster(String,String,Object[],Class[], boolean) instead
 ArrayList callMethodOnCluster(String objName, String methodName, Object[] args, Class[] types, boolean excludeSelf)
          This function is an abstraction of RpcDispatcher.
 ArrayList callMethodOnCluster(String objName, String methodName, Object[] args, Class[] types, boolean excludeSelf, long methodTimeout)
           
 void closePartition()
           
 ClusterNode[] getClusterNodes()
          Return the member nodes that built the current view i.e.
 Vector getCurrentView()
          Return the list of member nodes that built the current view i.e.
 long getCurrentViewId()
          Each time the partition topology changes, a new view is computed.
protected  Vector getDeadMembers(Vector oldMembers, Vector newMembers)
          Helper method that returns a vector of dead members from two input vectors: new and old vectors of two views.
 DistributedReplicantManager getDistributedReplicantManager()
          Accessor to the DRM that is linked to this partition.
 DistributedState getDistributedStateService()
          Accessor the the DistributedState (DS) that is linked to this partition.
 long getMethodCallTimeout()
           
protected  Vector getNewMembers(Vector oldMembers, Vector allMembers)
          Helper method that returns a vector of new members from two input vectors: new and old vectors of two views.
 String getNodeName()
          Return the name of the current name in the current partition.
 String getPartitionName()
          The name of the partition.
 byte[] getState()
           
 long getStateTransferTimeout()
           
 Object handle(org.jgroups.Message req)
          Message contains MethodCall.
 void init()
           
 boolean isCurrentNodeCoordinator()
           
 void logHistory(String message)
           
protected  void notifyListeners(ArrayList theListeners, long viewID, Vector allMembers, Vector deadMembers, Vector newMembers, Vector originatingGroups)
           
static Object objectFromByteBuffer(byte[] buffer)
          Creates an object from a byte buffer
static byte[] objectToByteBuffer(Object obj)
          Serializes an object into a byte buffer.
 void receive(org.jgroups.Message msg)
           
 void registerMembershipListener(HAPartition.HAMembershipListener listener)
          Subscribes to receive HAMembershipListener events.
 void registerRPCHandler(String objName, Object subscriber)
          The partition receives RPC calls from other nodes in the cluster and demultiplex them, according to a service name, to a particular service.
 void setMethodCallTimeout(long timeout)
           
 void setState(byte[] obj)
           
 void setStateTransferTimeout(long state_transfer_timeout)
           
 void startPartition()
           
 void subscribeToStateTransferEvents(String objectName, HAPartition.HAPartitionStateTransfer subscriber)
          Register a service that will participate in state transfer protocol and receive callbacks
 void suspect(org.jgroups.Address suspected_mbr)
           
protected  Vector translateAddresses(Vector jgAddresses)
           
 void unregisterMembershipListener(HAPartition.HAMembershipListener listener)
          Unsubscribes from receiving HAMembershipListener events.
 void unregisterRPCHandler(String objName, Object subscriber)
          Unregister the service from the partition
 void unsubscribeFromStateTransferEvents(String objectName, HAPartition.HAPartitionStateTransfer subscriber)
          Unregister a service from state transfer callbacks.
protected  void verifyNodeIsUnique(Vector javaGroupIpAddresses)
           
 void viewAccepted(org.jgroups.View newView)
          Notification of a cluster view change.
 
Methods inherited from class org.jgroups.blocks.RpcDispatcher
callRemoteMethod, callRemoteMethod, callRemoteMethod, callRemoteMethods, callRemoteMethods, callRemoteMethods, castMessage, channelClosed, channelConnected, channelDisconnected, channelReconnected, channelShunned, getMarshaller, getName, getServerObject, sendMessage, setMarshaller
 
Methods inherited from class org.jgroups.blocks.MessageDispatcher
castMessage, done, send, setConcurrentProcessing, setDeadlockDetection, setMembershipListener, setMessageListener, setRequestHandler, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rpcHandlers

protected HashMap rpcHandlers

stateHandlers

protected HashMap stateHandlers

listeners

protected ArrayList listeners
The HAMembershipListener and HAMembershipExtendedListeners


asynchListeners

protected ArrayList asynchListeners
The asynch HAMembershipListener and HAMembershipExtendedListeners


asynchViewChanges

protected EDU.oswego.cs.dl.util.concurrent.LinkedQueue asynchViewChanges
The LinkedQueue of changes to notify asynch listeners of


asynchNotifyThread

protected Thread asynchNotifyThread
The Thread used to send membership change notifications asynchronously


members

protected Vector members
The current cluster partition members


jgmembers

protected Vector jgmembers

history

public Vector history

otherMembers

protected Vector otherMembers
The partition members other than this node


jgotherMembers

protected Vector jgotherMembers

partitionName

protected String partitionName
The JChannel name


localJGAddress

protected org.jgroups.stack.IpAddress localJGAddress
the local JG IP Address


nodeName

protected String nodeName
The cluster transport protocol address string


me

protected ClusterNode me
me as a ClusterNode


timeout

protected long timeout
The timeout for cluster RPC calls


channel

protected org.jgroups.JChannel channel
The JGroups partition channel


replicantManager

protected DistributedReplicantManagerImpl replicantManager
The cluster replicant manager


dsManager

protected DistributedStateImpl dsManager
The cluster state manager


log

protected org.jboss.logging.Logger log
The cluster instance log category


clusterLifeCycleLog

protected org.jboss.logging.Logger clusterLifeCycleLog

currentViewId

protected long currentViewId
The current cluster view id


server

protected javax.management.MBeanServer server
The JMX MBeanServer to use for registrations


state_transfer_timeout

protected long state_transfer_timeout
Number of ms to wait for state

Constructor Detail

HAPartitionImpl

public HAPartitionImpl(String partitionName,
                       org.jgroups.JChannel channel,
                       boolean deadlock_detection,
                       javax.management.MBeanServer server)
                throws Exception

HAPartitionImpl

public HAPartitionImpl(String partitionName,
                       org.jgroups.JChannel channel,
                       boolean deadlock_detection)
                throws Exception
Method Detail

objectFromByteBuffer

public static Object objectFromByteBuffer(byte[] buffer)
                                   throws Exception
Creates an object from a byte buffer

Throws:
Exception

objectToByteBuffer

public static byte[] objectToByteBuffer(Object obj)
                                 throws Exception
Serializes an object into a byte buffer. The object has to implement interface Serializable or Externalizable

Throws:
Exception

getStateTransferTimeout

public long getStateTransferTimeout()

setStateTransferTimeout

public void setStateTransferTimeout(long state_transfer_timeout)

getMethodCallTimeout

public long getMethodCallTimeout()

setMethodCallTimeout

public void setMethodCallTimeout(long timeout)

init

public void init()
          throws Exception
Throws:
Exception

startPartition

public void startPartition()
                    throws Exception
Throws:
Exception

closePartition

public void closePartition()
                    throws Exception
Throws:
Exception

getState

public byte[] getState()
Specified by:
getState in interface org.jgroups.MessageListener

setState

public void setState(byte[] obj)
Specified by:
setState in interface org.jgroups.MessageListener

receive

public void receive(org.jgroups.Message msg)
Specified by:
receive in interface org.jgroups.MessageListener

suspect

public void suspect(org.jgroups.Address suspected_mbr)
Specified by:
suspect in interface org.jgroups.MembershipListener

block

public void block()
Specified by:
block in interface org.jgroups.MembershipListener

viewAccepted

public void viewAccepted(org.jgroups.View newView)
Notification of a cluster view change. This is done from the JG protocol handlder thread and we must be careful to not unduly block this thread. Because of this there are two types of listeners, synchronous and asynchronous. The synchronous listeners are messaged with the view change event using the calling thread while the asynchronous listeners are messaged using a seperate thread.

Specified by:
viewAccepted in interface org.jgroups.MembershipListener
Parameters:
newView -

getNodeName

public String getNodeName()
Description copied from interface: HAPartition
Return the name of the current name in the current partition. The name is dynamically determined by the partition.

Specified by:
getNodeName in interface HAPartition
Returns:
The partition name

getPartitionName

public String getPartitionName()
Description copied from interface: HAPartition
The name of the partition. Either set when creating the partition (MBEAN definition) or uses the default name

Specified by:
getPartitionName in interface HAPartition
Returns:
Name of the current partition

getDistributedReplicantManager

public DistributedReplicantManager getDistributedReplicantManager()
Description copied from interface: HAPartition
Accessor to the DRM that is linked to this partition.

Specified by:
getDistributedReplicantManager in interface HAPartition
Returns:
the DRM linked to this partition

getDistributedStateService

public DistributedState getDistributedStateService()
Description copied from interface: HAPartition
Accessor the the DistributedState (DS) that is linked to this partition.

Specified by:
getDistributedStateService in interface HAPartition
Returns:
the DistributedState service

getCurrentViewId

public long getCurrentViewId()
Description copied from interface: HAPartition
Each time the partition topology changes, a new view is computed. A view is a list of members, the first member being the coordinator of the view. Each view also has a distinct identifier.

Specified by:
getCurrentViewId in interface HAPartition
Returns:
The identifier of the current view

getCurrentView

public Vector getCurrentView()
Description copied from interface: HAPartition
Return the list of member nodes that built the current view i.e. the current partition.

Specified by:
getCurrentView in interface HAPartition
Returns:
An array of Strings containing the node names

getClusterNodes

public ClusterNode[] getClusterNodes()
Description copied from interface: HAPartition
Return the member nodes that built the current view i.e. the current partition.

Specified by:
getClusterNodes in interface HAPartition
Returns:
An array of ClusterNode containing the node names

isCurrentNodeCoordinator

public boolean isCurrentNodeCoordinator()

registerRPCHandler

public void registerRPCHandler(String objName,
                               Object subscriber)
Description copied from interface: HAPartition
The partition receives RPC calls from other nodes in the cluster and demultiplex them, according to a service name, to a particular service. Consequently, each service must first subscribe with a particular service name in the partition. The subscriber does not need to implement any specific interface: the call is handled dynamically through reflection.

Specified by:
registerRPCHandler in interface HAPartition
Parameters:
objName - Name of the subscribing service (demultiplexing key)
subscriber - object to be called when receiving a RPC for its key.

unregisterRPCHandler

public void unregisterRPCHandler(String objName,
                                 Object subscriber)
Description copied from interface: HAPartition
Unregister the service from the partition

Specified by:
unregisterRPCHandler in interface HAPartition
Parameters:
objName - Name of the service key (on which the demultiplexing occurs)
subscriber - The target object that unsubscribes

callMethodOnCluster

public ArrayList callMethodOnCluster(String objName,
                                     String methodName,
                                     Object[] args,
                                     boolean excludeSelf)
                              throws Exception
Deprecated. Use callMethodOnCluster(String,String,Object[],Class[], boolean) instead

Specified by:
callMethodOnCluster in interface HAPartition
Parameters:
objName -
methodName -
args -
excludeSelf -
Returns:
Throws:
Exception

callMethodOnCluster

public ArrayList callMethodOnCluster(String objName,
                                     String methodName,
                                     Object[] args,
                                     Class[] types,
                                     boolean excludeSelf)
                              throws Exception
This function is an abstraction of RpcDispatcher.

Specified by:
callMethodOnCluster in interface HAPartition
Parameters:
objName - Name of the target service name on which calls are de-multiplexed
methodName - name of the Java method to be called on remote services
args - array of Java Object representing the set of parameters to be given to the remote method
types - The types of the parameters
excludeSelf - indicates if the RPC must also be made on the current node of the partition or only on remote nodes
Returns:
an array of answers from remote nodes
Throws:
Exception - Throws if a communication exception occurs

callMethodOnCluster

public ArrayList callMethodOnCluster(String objName,
                                     String methodName,
                                     Object[] args,
                                     Class[] types,
                                     boolean excludeSelf,
                                     long methodTimeout)
                              throws Exception
Throws:
Exception

callAsynchMethodOnCluster

public void callAsynchMethodOnCluster(String objName,
                                      String methodName,
                                      Object[] args,
                                      boolean excludeSelf)
                               throws Exception
Deprecated. Use callAsynchMethodOnCluster(String, String, Object[], Class[], boolean) instead

Specified by:
callAsynchMethodOnCluster in interface HAPartition
Parameters:
objName -
methodName -
args -
excludeSelf -
Throws:
Exception

callAsynchMethodOnCluster

public void callAsynchMethodOnCluster(String objName,
                                      String methodName,
                                      Object[] args,
                                      Class[] types,
                                      boolean excludeSelf)
                               throws Exception
This function is an abstraction of RpcDispatcher for asynchronous messages

Specified by:
callAsynchMethodOnCluster in interface HAPartition
Parameters:
objName - Name of the target service name on which calls are de-multiplexed
methodName - name of the Java method to be called on remote services
args - array of Java Object representing the set of parameters to be given to the remote method
types - The types of the parameters
excludeSelf - indicates if the RPC must also be made on the current node of the partition or only on remote nodes
Throws:
Exception - Throws if a communication exception occurs

subscribeToStateTransferEvents

public void subscribeToStateTransferEvents(String objectName,
                                           HAPartition.HAPartitionStateTransfer subscriber)
Description copied from interface: HAPartition
Register a service that will participate in state transfer protocol and receive callbacks

Specified by:
subscribeToStateTransferEvents in interface HAPartition
Parameters:
objectName - Name of the service that subscribes for state stransfer events. This name must be identical for all identical services in the cluster.
subscriber - Object implementing HAPartition.HAPartitionStateTransfer and providing or receiving state transfer callbacks

unsubscribeFromStateTransferEvents

public void unsubscribeFromStateTransferEvents(String objectName,
                                               HAPartition.HAPartitionStateTransfer subscriber)
Description copied from interface: HAPartition
Unregister a service from state transfer callbacks.

Specified by:
unsubscribeFromStateTransferEvents in interface HAPartition
Parameters:
objectName - Name of the service that participates in the state transfer protocol
subscriber - Service implementing the state transfer callback methods

registerMembershipListener

public void registerMembershipListener(HAPartition.HAMembershipListener listener)
Description copied from interface: HAPartition
Subscribes to receive HAPartition.HAMembershipListener events.

Specified by:
registerMembershipListener in interface HAPartition
Parameters:
listener - The membership listener object

unregisterMembershipListener

public void unregisterMembershipListener(HAPartition.HAMembershipListener listener)
Description copied from interface: HAPartition
Unsubscribes from receiving HAPartition.HAMembershipListener events.

Specified by:
unregisterMembershipListener in interface HAPartition
Parameters:
listener - The listener wishing to unsubscribe

handle

public Object handle(org.jgroups.Message req)
Message contains MethodCall. Execute it against *this* object and return result. Use MethodCall.Invoke() to do this. Return result. This overrides RpcDispatcher.Handle so that we can dispatch to many different objects.

Specified by:
handle in interface org.jgroups.blocks.RequestHandler
Parameters:
req - The org.jgroups. representation of the method invocation
Returns:
The serializable return value from the invocation

verifyNodeIsUnique

protected void verifyNodeIsUnique(Vector javaGroupIpAddresses)
                           throws Exception
Throws:
Exception

bind

protected void bind(String jndiName,
                    Object who,
                    Class classType,
                    Context ctx)
             throws Exception
Helper method that binds the partition in the JNDI tree.

Parameters:
jndiName - Name under which the object must be bound
who - Object to bind in JNDI
classType - Class type under which should appear the bound object
ctx - Naming context under which we bind the object
Throws:
Exception - Thrown if a naming exception occurs during binding

getDeadMembers

protected Vector getDeadMembers(Vector oldMembers,
                                Vector newMembers)
Helper method that returns a vector of dead members from two input vectors: new and old vectors of two views. Dead members are old - new members.

Parameters:
oldMembers - Vector of old members
newMembers - Vector of new members
Returns:
Vector of members that have died between the two views, can be empty.

getNewMembers

protected Vector getNewMembers(Vector oldMembers,
                               Vector allMembers)
Helper method that returns a vector of new members from two input vectors: new and old vectors of two views.

Parameters:
oldMembers - Vector of old members
allMembers - Vector of new members
Returns:
Vector of members that have joined the partition between the two views

notifyListeners

protected void notifyListeners(ArrayList theListeners,
                               long viewID,
                               Vector allMembers,
                               Vector deadMembers,
                               Vector newMembers,
                               Vector originatingGroups)

translateAddresses

protected Vector translateAddresses(Vector jgAddresses)

logHistory

public void logHistory(String message)


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