org.jboss.messaging.core.impl.postoffice
Class MessagingPostOffice

java.lang.Object
  extended by org.jboss.messaging.core.impl.JDBCSupport
      extended by org.jboss.messaging.core.impl.postoffice.MessagingPostOffice
All Implemented Interfaces:
MessagingComponent, PostOffice, Replicator

public class MessagingPostOffice
extends JDBCSupport
implements PostOffice, Replicator

Version:
$Revision: 2782 $ $Id: DefaultClusteredPostOffice.java 2782 2007-06-14 12:16:17Z timfox $
Author:
Tim Fox, Ovidiu Feodorov, Clebert Suconic

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.messaging.core.impl.JDBCSupport
JDBCSupport.JDBCTxRunner<T>, JDBCSupport.JDBCTxRunner2<T>, JDBCSupport.TransactionWrapper
 
Field Summary
static java.lang.String FAILOVER_COMPLETED_NOTIFICATION
           
static java.lang.String VIEW_CHANGED_NOTIFICATION
           
 
Fields inherited from class org.jboss.messaging.core.impl.JDBCSupport
ds, sqlProperties
 
Fields inherited from interface org.jboss.messaging.core.contract.Replicator
CF_PREFIX, JVM_ID_KEY
 
Constructor Summary
MessagingPostOffice(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, IDManager channelIDManager, ClusterNotifier clusterNotifier)
           
MessagingPostOffice(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, IDManager channelIDManager, ClusterNotifier clusterNotifier, java.lang.String groupName, ChannelFactory jChannelFactory, long stateTimeout, long castTimeout, boolean supportsFailover, int maxConcurrentReplications)
           
 
Method Summary
 boolean addBinding(Binding binding, boolean allNodes)
          Add a binding to the post office
 void addBindingFromCluster(org.jboss.messaging.core.impl.postoffice.MappingInfo mapping, boolean allNodes)
           
 void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object object)
           
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.
 java.util.Collection getAllBindings()
          Get all the bindings
 java.util.Collection getAllBindingsForQueueName(java.lang.String queueName)
          Get all bindings with the specified queue name (They will be on different nodes)
 Binding getBindingForChannelID(long channelID)
          Get the binding with the specified channel ID
 Binding getBindingForQueueName(java.lang.String queueName)
          Get the binding with the specified queue name
protected  java.util.Map getDefaultDDLStatements()
           
protected  java.util.Map getDefaultDMLStatements()
           
 java.util.Map getFailoverMap()
          Get the failover map
 MessagingComponent getInstance()
           
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
 java.lang.String getOfficeName()
          Get the name of the post office
 java.util.Collection getQueuesForCondition(Condition condition, boolean localOnly)
          Get all queues that match the condition
 java.util.Map getRecoveryArea(java.lang.String queueName)
           
 int getRecoveryMapSize(java.lang.String queueName)
           
 byte[] getState()
           
 void handleAckAllReplicatedDeliveries(int nodeID)
           
 void handleAddAllReplicatedDeliveries(int nodeID, java.util.Map deliveries)
           
 void handleGetReplicatedDeliveries(java.lang.String queueName, Address returnAddress)
           
 void handleNodeJoined(int nodeId, org.jboss.messaging.core.impl.postoffice.PostOfficeAddressInfo info)
           
 void handleNodeLeft(int nodeId)
           
 void handleReplicateAck(int nodeID, java.lang.String queueName, long messageID)
           
 void handleReplicateDelivery(int nodeID, java.lang.String queueName, java.lang.String sessionID, long messageID, long deliveryID, Address replyAddress)
           
 void handleReplicateDeliveryAck(java.lang.String sessionID, long deliveryID)
           
 void injectServerPeer(ServerPeer serverPeer)
           
 boolean isClustered()
          Is this post office clustered?
 boolean isFirstNode()
           
 boolean isSupportsFailover()
           
 java.util.Set nodeIDView()
          Get a set of nodes in the cluster
 void nodeJoined(Address address)
           
 void nodesLeft(java.util.List addresses)
           
 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 remove(java.io.Serializable key)
          Updates the replication maps across the cluster by removing the data corresponding to the give key.
 Binding removeBinding(java.lang.String queueName, boolean allNodes)
          Remove a binding from the post office
 void removeBindingFromCluster(org.jboss.messaging.core.impl.postoffice.MappingInfo mapping, boolean allNodes)
           
 void removeNotificationListener(javax.management.NotificationListener listener)
           
 boolean removeReplicantLocally(int originatorNodeID, java.io.Serializable key)
           
 boolean route(MessageReference ref, Condition condition, Transaction tx)
          Route a reference.
 void routeFromCluster(Message message, java.lang.String routingKeyText, java.util.Set queueNames)
           
 void sendReplicateAckMessage(java.lang.String queueName, long messageID)
           
 void sendReplicateDeliveryMessage(java.lang.String queueName, java.lang.String sessionID, long messageID, long deliveryID, boolean reply, boolean sync)
           
 void setState(byte[] bytes)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.jboss.messaging.core.impl.JDBCSupport
closeConnection, closeResultSet, closeStatement, getSQLStatement, ignoreVerificationOnStartup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VIEW_CHANGED_NOTIFICATION

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

FAILOVER_COMPLETED_NOTIFICATION

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

MessagingPostOffice

public MessagingPostOffice(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,
                           IDManager channelIDManager,
                           ClusterNotifier clusterNotifier)
                    throws java.lang.Exception
Throws:
java.lang.Exception

MessagingPostOffice

public MessagingPostOffice(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,
                           IDManager channelIDManager,
                           ClusterNotifier clusterNotifier,
                           java.lang.String groupName,
                           ChannelFactory jChannelFactory,
                           long stateTimeout,
                           long castTimeout,
                           boolean supportsFailover,
                           int maxConcurrentReplications)
                    throws java.lang.Exception
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

getInstance

public MessagingComponent getInstance()

start

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

stop

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

addNotificationListener

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

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener listener)
                                throws javax.management.ListenerNotFoundException
Throws:
javax.management.ListenerNotFoundException

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()

getOfficeName

public java.lang.String getOfficeName()
Description copied from interface: PostOffice
Get the name of the post office

Specified by:
getOfficeName in interface PostOffice
Returns:
The name of this post office

addBinding

public boolean addBinding(Binding binding,
                          boolean allNodes)
                   throws java.lang.Exception
Description copied from interface: PostOffice
Add a binding to the post office

Specified by:
addBinding in interface PostOffice
Parameters:
binding - The binding to add
allNodes - Add this binding on ALL nodes?
Throws:
java.lang.Exception

removeBinding

public Binding removeBinding(java.lang.String queueName,
                             boolean allNodes)
                      throws java.lang.Throwable
Description copied from interface: PostOffice
Remove a binding from the post office

Specified by:
removeBinding in interface PostOffice
Parameters:
queueName - The queue name that identifies the binding
allNodes - Remove this binding from ALL node?
Throws:
java.lang.Throwable

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
condition - - the message will be routed to queue(s) if the specified condition matches the condition of the bindings.
tx - - the transaction or null if not in the context of a transaction.
Returns:
true if reference was accepted by at least one queue.
Throws:
java.lang.Exception

getQueuesForCondition

public java.util.Collection getQueuesForCondition(Condition condition,
                                                  boolean localOnly)
                                           throws java.lang.Exception
Description copied from interface: PostOffice
Get all queues that match the condition

Specified by:
getQueuesForCondition in interface PostOffice
Parameters:
condition - The condition
localOnly - Only retrieve local queues ?
Returns:
Throws:
java.lang.Exception

getBindingForQueueName

public Binding getBindingForQueueName(java.lang.String queueName)
                               throws java.lang.Exception
Description copied from interface: PostOffice
Get the binding with the specified queue name

Specified by:
getBindingForQueueName in interface PostOffice
Returns:
Throws:
java.lang.Exception

getBindingForChannelID

public Binding getBindingForChannelID(long channelID)
                               throws java.lang.Exception
Description copied from interface: PostOffice
Get the binding with the specified channel ID

Specified by:
getBindingForChannelID in interface PostOffice
Returns:
Throws:
java.lang.Exception

isClustered

public boolean isClustered()
Description copied from interface: PostOffice
Is this post office clustered?

Specified by:
isClustered in interface PostOffice
Returns:
true If the post office is clustered

getFailoverMap

public java.util.Map getFailoverMap()
Description copied from interface: PostOffice
Get the failover map

Specified by:
getFailoverMap in interface PostOffice
Returns:

getAllBindingsForQueueName

public java.util.Collection getAllBindingsForQueueName(java.lang.String queueName)
                                                throws java.lang.Exception
Description copied from interface: PostOffice
Get all bindings with the specified queue name (They will be on different nodes)

Specified by:
getAllBindingsForQueueName in interface PostOffice
Returns:
Throws:
java.lang.Exception

getAllBindings

public java.util.Collection getAllBindings()
                                    throws java.lang.Exception
Description copied from interface: PostOffice
Get all the bindings

Specified by:
getAllBindings in interface PostOffice
Returns:
Throws:
java.lang.Exception

nodeIDView

public java.util.Set nodeIDView()
Description copied from interface: PostOffice
Get a set of nodes in the cluster

Specified by:
nodeIDView in interface PostOffice
Returns:

sendReplicateDeliveryMessage

public void sendReplicateDeliveryMessage(java.lang.String queueName,
                                         java.lang.String sessionID,
                                         long messageID,
                                         long deliveryID,
                                         boolean reply,
                                         boolean sync)
                                  throws java.lang.Exception
Specified by:
sendReplicateDeliveryMessage in interface PostOffice
Throws:
java.lang.Exception

sendReplicateAckMessage

public void sendReplicateAckMessage(java.lang.String queueName,
                                    long messageID)
                             throws java.lang.Exception
Specified by:
sendReplicateAckMessage in interface PostOffice
Throws:
java.lang.Exception

injectServerPeer

public void injectServerPeer(ServerPeer serverPeer)

isFirstNode

public boolean isFirstNode()
Specified by:
isFirstNode in interface PostOffice

getRecoveryArea

public java.util.Map getRecoveryArea(java.lang.String queueName)
Specified by:
getRecoveryArea in interface PostOffice

getRecoveryMapSize

public int getRecoveryMapSize(java.lang.String queueName)
Specified by:
getRecoveryMapSize in interface PostOffice

setState

public void setState(byte[] bytes)
              throws java.lang.Exception
Throws:
java.lang.Exception

getState

public byte[] getState()
                throws java.lang.Exception
Throws:
java.lang.Exception

nodeJoined

public void nodeJoined(Address address)
                throws java.lang.Exception
Throws:
java.lang.Exception

nodesLeft

public void nodesLeft(java.util.List addresses)
               throws java.lang.Throwable
Throws:
java.lang.Throwable

addBindingFromCluster

public void addBindingFromCluster(org.jboss.messaging.core.impl.postoffice.MappingInfo mapping,
                                  boolean allNodes)
                           throws java.lang.Exception
Throws:
java.lang.Exception

removeBindingFromCluster

public void removeBindingFromCluster(org.jboss.messaging.core.impl.postoffice.MappingInfo mapping,
                                     boolean allNodes)
                              throws java.lang.Throwable
Throws:
java.lang.Throwable

handleNodeLeft

public void handleNodeLeft(int nodeId)
                    throws java.lang.Exception
Throws:
java.lang.Exception

handleNodeJoined

public void handleNodeJoined(int nodeId,
                             org.jboss.messaging.core.impl.postoffice.PostOfficeAddressInfo info)
                      throws java.lang.Exception
Throws:
java.lang.Exception

putReplicantLocally

public void putReplicantLocally(int originatorNodeID,
                                java.io.Serializable key,
                                java.io.Serializable replicant)
                         throws java.lang.Exception
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
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.Set queueNames)
                      throws java.lang.Exception
Throws:
java.lang.Exception

handleReplicateDelivery

public void handleReplicateDelivery(int nodeID,
                                    java.lang.String queueName,
                                    java.lang.String sessionID,
                                    long messageID,
                                    long deliveryID,
                                    Address replyAddress)
                             throws java.lang.Exception
Throws:
java.lang.Exception

handleGetReplicatedDeliveries

public void handleGetReplicatedDeliveries(java.lang.String queueName,
                                          Address returnAddress)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

handleReplicateAck

public void handleReplicateAck(int nodeID,
                               java.lang.String queueName,
                               long messageID)
                        throws java.lang.Exception
Throws:
java.lang.Exception

handleReplicateDeliveryAck

public void handleReplicateDeliveryAck(java.lang.String sessionID,
                                       long deliveryID)
                                throws java.lang.Exception
Throws:
java.lang.Exception

handleAckAllReplicatedDeliveries

public void handleAckAllReplicatedDeliveries(int nodeID)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

handleAddAllReplicatedDeliveries

public void handleAddAllReplicatedDeliveries(int nodeID,
                                             java.util.Map deliveries)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

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

getDefaultDMLStatements

protected java.util.Map getDefaultDMLStatements()
Overrides:
getDefaultDMLStatements in class JDBCSupport

getDefaultDDLStatements

protected java.util.Map getDefaultDDLStatements()
Overrides:
getDefaultDDLStatements in class JDBCSupport

isSupportsFailover

public boolean isSupportsFailover()

printBindingInformation

public java.lang.String printBindingInformation()


Copyright © 2006 JBoss Inc. All Rights Reserved.