org.jboss.messaging.core.plugin.postoffice.cluster
Class DefaultClusteredPostOffice

java.lang.Object
  extended byorg.jboss.messaging.core.plugin.JDBCSupport
      extended byorg.jboss.messaging.core.plugin.postoffice.DefaultPostOffice
          extended byorg.jboss.messaging.core.plugin.postoffice.cluster.DefaultClusteredPostOffice
All Implemented Interfaces:
ClusteredPostOffice, MessagingComponent, Peer, PostOffice, org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal, Replicator

public class DefaultClusteredPostOffice
extends DefaultPostOffice
implements ClusteredPostOffice, org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal, Replicator

Version:
$Revision: 2670 $ $Id: DefaultClusteredPostOffice.java 2670 2007-05-12 14:43:53Z timfox $
Author:
Tim Fox, Ovidiu Feodorov, Clebert Suconic

Nested Class Summary
 
Nested classes inherited from class org.jboss.messaging.core.plugin.JDBCSupport
JDBCSupport.TransactionWrapper
 
Field Summary
static java.lang.String ADDRESS_INFO_KEY
           
static java.lang.String FAILED_OVER_FOR_KEY
           
 
Fields inherited from class org.jboss.messaging.core.plugin.postoffice.DefaultPostOffice
conditionFactory, conditionMap, currentNodeId, filterFactory, lock, ms, nameMaps, pm, tr
 
Fields inherited from class org.jboss.messaging.core.plugin.JDBCSupport
ds, sqlProperties
 
Fields inherited from interface org.jboss.messaging.core.plugin.contract.ClusteredPostOffice
FAILOVER_COMPLETED_NOTIFICATION, VIEW_CHANGED_NOTIFICATION
 
Constructor Summary
DefaultClusteredPostOffice(javax.sql.DataSource ds, TransactionManager tm, java.util.Properties sqlProperties, boolean createTablesOnStartup, int nodeId, java.lang.String officeName, MessageStore ms, PersistenceManager pm, TransactionRepository tr, FilterFactory filterFactory, ConditionFactory conditionFactory, java.lang.String groupName, JChannelFactory JChannelFactory, long stateTimeout, long castTimeout, MessagePullPolicy redistributionPolicy, ClusterRouterFactory rf, FailoverMapper failoverMapper, long statsSendPeriod, int poolSize)
           
 
Method Summary
 void addBindingFromCluster(int nodeId, java.lang.String queueName, java.lang.String conditionText, java.lang.String filterString, long channelID, boolean durable)
           
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object object)
           
protected  void addToConditionMap(Binding binding)
           
 void asyncSendRequest(org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRequest request)
           
 void asyncSendRequest(org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRequest request, int nodeId)
           
 Binding bindClusteredQueue(Condition condition, LocalClusteredQueue queue)
          Bind a queue to the post office under a specific condition such that it is available across the cluster.
 void checkTransactions(java.lang.Integer nodeId)
          Check for any transactions that need to be committed or rolled back
 void commitTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id)
           
protected  Binding createBinding(int nodeID, Condition condition, java.lang.String queueName, long channelId, Filter filter, boolean durable, boolean isClustered)
           
protected  Binding createBinding(int nodeId, Condition condition, java.lang.String queueName, long channelId, java.lang.String filterString, boolean durable, boolean isClustered)
           
static java.lang.String dumpClusterMap(java.util.Map map)
           
static java.lang.String dumpFailoverMap(java.util.Map map)
           
 java.util.Map get(java.io.Serializable key)
          Return a node-mapped replicated data.
 FailoverMapper getFailoverMapper()
          TODO - this method doesn't belong here...
 java.util.Collection getHoldingTransactions()
          MUST ONLY be used for testing!
 int getNodeId()
           
 java.util.Set getNodeIDView()
          Returns a set of nodeIDs (integers) representing the IDs of cluster's nodes.
 MBeanNotificationInfo[] getNotificationInfo()
           
 PooledExecutor getPooledExecutor()
           
 void handleMessagePullResult(int remoteNodeId, long holdingTxId, java.lang.String queueName, Message message)
           
 void handleNodeLeft(int nodeId)
           
 void holdTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id, org.jboss.messaging.core.plugin.postoffice.cluster.ClusterTransaction tx)
           
 boolean isLocal()
           
 java.util.Collection listAllBindingsForCondition(Condition condition)
           
protected  void loadBindings(boolean nonClusteredOnly)
           
 java.lang.String printBindingInformation()
           
 void put(java.io.Serializable key, java.io.Serializable replicant)
          Broadcast data across the cluster, updating replication maps on all nodes, including the local node.
 void putReplicantLocally(int originatorNodeID, java.io.Serializable key, java.io.Serializable replicant)
           
 boolean referenceExistsInStorage(long channelID, long messageID)
           
 void registerListener(ReplicationListener listener)
           
 boolean remove(java.io.Serializable key)
          Updates the replication maps across the cluster by removing the data corresponding to the give key.
 void removeBindingFromCluster(int nodeId, java.lang.String queueName)
           
protected  void removeFromConditionMap(Binding binding)
           
 void removeNotificationListener(NotificationListener listener)
           
 boolean removeReplicantLocally(int originatorNodeID, java.io.Serializable key)
           
 void rollbackTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id)
           
 boolean route(MessageReference ref, Condition condition, Transaction tx)
          Route a reference.
 void routeFromCluster(Message message, java.lang.String routingKeyText, java.util.Map queueNameNodeIdMap)
           
 void sendQueueStats()
           
 void setFail(boolean beforeCommit, boolean afterCommit, boolean handleResult)
          MUST ONLY be used for testing!
 void start()
           
 void stop(boolean sendNotification)
           
 java.lang.String toString()
           
 Binding unbindClusteredQueue(java.lang.String queueName)
          Unbind a clustered queue from the post office.
 void unregisterListener(ReplicationListener listener)
           
 void updateQueueStats(int nodeId, java.util.List statsList)
           
 
Methods inherited from class org.jboss.messaging.core.plugin.postoffice.DefaultPostOffice
addBinding, addToNameMap, bindQueue, deleteBinding, getBindingforChannelId, getBindingForQueueName, getBindingsForCondition, getDefaultDDLStatements, getDefaultDMLStatements, getOfficeName, insertBinding, internalGetBindingForQueueName, listBindingsForConditionInternal, removeBinding, removeFromNameMap, stop, unbindQueue
 
Methods inherited from class org.jboss.messaging.core.plugin.JDBCSupport
closeConnection, closeResultSet, closeStatement, getSQLStatement, ignoreVerificationOnStartup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.messaging.core.plugin.contract.PostOffice
bindQueue, getBindingforChannelId, getBindingForQueueName, getBindingsForCondition, getOfficeName, unbindQueue
 
Methods inherited from interface org.jboss.messaging.core.plugin.contract.MessagingComponent
stop
 

Field Detail

ADDRESS_INFO_KEY

public static final java.lang.String ADDRESS_INFO_KEY
See Also:
Constant Field Values

FAILED_OVER_FOR_KEY

public static final java.lang.String FAILED_OVER_FOR_KEY
See Also:
Constant Field Values
Constructor Detail

DefaultClusteredPostOffice

public DefaultClusteredPostOffice(javax.sql.DataSource ds,
                                  TransactionManager tm,
                                  java.util.Properties sqlProperties,
                                  boolean createTablesOnStartup,
                                  int nodeId,
                                  java.lang.String officeName,
                                  MessageStore ms,
                                  PersistenceManager pm,
                                  TransactionRepository tr,
                                  FilterFactory filterFactory,
                                  ConditionFactory conditionFactory,
                                  java.lang.String groupName,
                                  JChannelFactory JChannelFactory,
                                  long stateTimeout,
                                  long castTimeout,
                                  MessagePullPolicy redistributionPolicy,
                                  ClusterRouterFactory rf,
                                  FailoverMapper failoverMapper,
                                  long statsSendPeriod,
                                  int poolSize)
                           throws java.lang.Exception
Method Detail

dumpFailoverMap

public static java.lang.String dumpFailoverMap(java.util.Map map)
Parameters:
map - - Map

dumpClusterMap

public static java.lang.String dumpClusterMap(java.util.Map map)
Parameters:
map - - Map

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface MessagingComponent
Overrides:
start in class DefaultPostOffice
Throws:
java.lang.Exception

stop

public void stop(boolean sendNotification)
          throws java.lang.Exception
Overrides:
stop in class DefaultPostOffice
Throws:
java.lang.Exception

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    java.lang.Object object)
                             throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Throws:
ListenerNotFoundException

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()

getNodeIDView

public java.util.Set getNodeIDView()
Description copied from interface: Peer
Returns a set of nodeIDs (integers) representing the IDs of cluster's nodes.

Specified by:
getNodeIDView in interface Peer

bindClusteredQueue

public Binding bindClusteredQueue(Condition condition,
                                  LocalClusteredQueue queue)
                           throws java.lang.Exception
Description copied from interface: ClusteredPostOffice
Bind a queue to the post office under a specific condition such that it is available across the cluster.

Specified by:
bindClusteredQueue in interface ClusteredPostOffice
Parameters:
condition - - the condition to be used when routing references.
Throws:
java.lang.Exception

unbindClusteredQueue

public Binding unbindClusteredQueue(java.lang.String queueName)
                             throws java.lang.Throwable
Description copied from interface: ClusteredPostOffice
Unbind a clustered queue from the post office.

Specified by:
unbindClusteredQueue in interface ClusteredPostOffice
Parameters:
queueName - - the unique name of the queue.
Throws:
java.lang.Throwable

listAllBindingsForCondition

public java.util.Collection listAllBindingsForCondition(Condition condition)
                                                 throws java.lang.Exception
Specified by:
listAllBindingsForCondition in interface ClusteredPostOffice
Throws:
java.lang.Exception

addBindingFromCluster

public void addBindingFromCluster(int nodeId,
                                  java.lang.String queueName,
                                  java.lang.String conditionText,
                                  java.lang.String filterString,
                                  long channelID,
                                  boolean durable)
                           throws java.lang.Exception
Specified by:
addBindingFromCluster in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

removeBindingFromCluster

public void removeBindingFromCluster(int nodeId,
                                     java.lang.String queueName)
                              throws java.lang.Exception
Specified by:
removeBindingFromCluster in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

handleNodeLeft

public void handleNodeLeft(int nodeId)
                    throws java.lang.Exception
Specified by:
handleNodeLeft in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

putReplicantLocally

public void putReplicantLocally(int originatorNodeID,
                                java.io.Serializable key,
                                java.io.Serializable replicant)
                         throws java.lang.Exception
Specified by:
putReplicantLocally in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Parameters:
originatorNodeID - - the ID of the node that initiated the modification.
Throws:
java.lang.Exception

removeReplicantLocally

public boolean removeReplicantLocally(int originatorNodeID,
                                      java.io.Serializable key)
                               throws java.lang.Exception
Specified by:
removeReplicantLocally in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Parameters:
originatorNodeID - - the ID of the node that initiated the modification.
Throws:
java.lang.Exception

routeFromCluster

public void routeFromCluster(Message message,
                             java.lang.String routingKeyText,
                             java.util.Map queueNameNodeIdMap)
                      throws java.lang.Exception
Specified by:
routeFromCluster in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

asyncSendRequest

public void asyncSendRequest(org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRequest request)
                      throws java.lang.Exception
Specified by:
asyncSendRequest in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

asyncSendRequest

public void asyncSendRequest(org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRequest request,
                             int nodeId)
                      throws java.lang.Exception
Specified by:
asyncSendRequest in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

holdTransaction

public void holdTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id,
                            org.jboss.messaging.core.plugin.postoffice.cluster.ClusterTransaction tx)
                     throws java.lang.Exception
Specified by:
holdTransaction in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

commitTransaction

public void commitTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id)
                       throws java.lang.Throwable
Specified by:
commitTransaction in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Throwable

rollbackTransaction

public void rollbackTransaction(org.jboss.messaging.core.plugin.postoffice.cluster.TransactionId id)
                         throws java.lang.Throwable
Specified by:
rollbackTransaction in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Throwable

updateQueueStats

public void updateQueueStats(int nodeId,
                             java.util.List statsList)
                      throws java.lang.Exception
Specified by:
updateQueueStats in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

sendQueueStats

public void sendQueueStats()
                    throws java.lang.Exception
Specified by:
sendQueueStats in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

referenceExistsInStorage

public boolean referenceExistsInStorage(long channelID,
                                        long messageID)
                                 throws java.lang.Exception
Specified by:
referenceExistsInStorage in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Exception

handleMessagePullResult

public void handleMessagePullResult(int remoteNodeId,
                                    long holdingTxId,
                                    java.lang.String queueName,
                                    Message message)
                             throws java.lang.Throwable
Specified by:
handleMessagePullResult in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal
Throws:
java.lang.Throwable

getPooledExecutor

public PooledExecutor getPooledExecutor()
Specified by:
getPooledExecutor in interface org.jboss.messaging.core.plugin.postoffice.cluster.PostOfficeInternal

put

public void put(java.io.Serializable key,
                java.io.Serializable replicant)
         throws java.lang.Exception
Description copied from interface: Replicator
Broadcast data across the cluster, updating replication maps on all nodes, including the local node.

Specified by:
put in interface Replicator
Throws:
java.lang.Exception

get

public java.util.Map get(java.io.Serializable key)
                  throws java.lang.Exception
Description copied from interface: Replicator
Return a node-mapped replicated data.

Specified by:
get in interface Replicator
Returns:
a Map. Returns an empty map if no replicants are found for 'key', but never null.
Throws:
java.lang.Exception

remove

public boolean remove(java.io.Serializable key)
               throws java.lang.Exception
Description copied from interface: Replicator
Updates the replication maps across the cluster by removing the data corresponding to the give key. Only the data corresponding to the current node is removed.

Specified by:
remove in interface Replicator
Throws:
java.lang.Exception

registerListener

public void registerListener(ReplicationListener listener)
Specified by:
registerListener in interface Replicator

unregisterListener

public void unregisterListener(ReplicationListener listener)
Specified by:
unregisterListener in interface Replicator

getFailoverMapper

public FailoverMapper getFailoverMapper()
Description copied from interface: Replicator
TODO - this method doesn't belong here... We should have POJOized containers updating dependencies between ConnectionFActoryJNDIMapper and DefaultClusteredPostOffice

Specified by:
getFailoverMapper in interface Replicator

route

public boolean route(MessageReference ref,
                     Condition condition,
                     Transaction tx)
              throws java.lang.Exception
Description copied from interface: PostOffice
Route a reference.

Specified by:
route in interface PostOffice
Overrides:
route in class DefaultPostOffice
Throws:
java.lang.Exception

isLocal

public boolean isLocal()
Specified by:
isLocal in interface PostOffice
Overrides:
isLocal in class DefaultPostOffice

checkTransactions

public void checkTransactions(java.lang.Integer nodeId)
                       throws java.lang.Throwable
Check for any transactions that need to be committed or rolled back

Throws:
java.lang.Throwable

getNodeId

public int getNodeId()

toString

public java.lang.String toString()
Overrides:
toString in class DefaultPostOffice

printBindingInformation

public java.lang.String printBindingInformation()
Overrides:
printBindingInformation in class DefaultPostOffice

setFail

public void setFail(boolean beforeCommit,
                    boolean afterCommit,
                    boolean handleResult)
MUST ONLY be used for testing!


getHoldingTransactions

public java.util.Collection getHoldingTransactions()
MUST ONLY be used for testing!


addToConditionMap

protected void addToConditionMap(Binding binding)
Overrides:
addToConditionMap in class DefaultPostOffice

removeFromConditionMap

protected void removeFromConditionMap(Binding binding)
Overrides:
removeFromConditionMap in class DefaultPostOffice

loadBindings

protected void loadBindings(boolean nonClusteredOnly)
                     throws java.lang.Exception
Overrides:
loadBindings in class DefaultPostOffice
Throws:
java.lang.Exception

createBinding

protected Binding createBinding(int nodeId,
                                Condition condition,
                                java.lang.String queueName,
                                long channelId,
                                java.lang.String filterString,
                                boolean durable,
                                boolean isClustered)
                         throws java.lang.Exception
Overrides:
createBinding in class DefaultPostOffice
Throws:
java.lang.Exception

createBinding

protected Binding createBinding(int nodeID,
                                Condition condition,
                                java.lang.String queueName,
                                long channelId,
                                Filter filter,
                                boolean durable,
                                boolean isClustered)
Overrides:
createBinding in class DefaultPostOffice


Copyright © 2006 JBoss Inc. All Rights Reserved.