org.apache.activemq.partition
Class PartitionBroker

java.lang.Object
  extended by org.apache.activemq.broker.BrokerFilter
      extended by org.apache.activemq.partition.PartitionBroker
All Implemented Interfaces:
Broker, Region, Service
Direct Known Subclasses:
ZooKeeperPartitionBroker

public class PartitionBroker
extends BrokerFilter

A BrokerFilter which partitions client connections over a cluster of brokers. It can use a client identifier like client id, authenticated user name, source ip address or even destination being used by the connection to figure out which is the best broker in the cluster that the connection should be using and then redirects failover clients to that broker.


Field Summary
protected static Logger LOG
           
protected  ConcurrentHashMap<ConnectionId,org.apache.activemq.partition.PartitionBroker.ConnectionMonitor> monitors
           
protected  PartitionBrokerPlugin plugin
           
protected  boolean reloadConfigOnPoll
           
 
Fields inherited from class org.apache.activemq.broker.BrokerFilter
next
 
Constructor Summary
PartitionBroker(Broker broker, PartitionBrokerPlugin plugin)
           
 
Method Summary
 void addConnection(ConnectionContext context, ConnectionInfo info)
          A client is establishing a connection with the broker.
protected  void checkTarget(org.apache.activemq.partition.PartitionBroker.ConnectionMonitor monitor)
           
protected  Partitioning getConfig()
           
protected  String getConnectionString(HashSet<String> ids)
           
protected  Target getTarget(ActiveMQDestination dest)
           
protected  void monitorWait()
           
protected  void monitorWakeup()
           
protected  void onMonitorStart()
           
protected  void onMonitorStop()
           
protected  Target pickBestBroker(org.apache.activemq.partition.PartitionBroker.ConnectionMonitor monitor)
           
protected  void reloadConfiguration()
           
 void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error)
          A client is disconnecting from the broker.
protected  void runPartitionMonitor()
           
 void send(ProducerBrokerExchange producerExchange, Message messageSend)
          Send a message to the broker to using the specified destination.
 void start()
           
 
Methods inherited from class org.apache.activemq.broker.BrokerFilter
acknowledge, addBroker, addConsumer, addDestination, addDestinationInfo, addProducer, addSession, beginTransaction, brokerServiceStarted, commitTransaction, fastProducer, forgetTransaction, gc, getAdaptor, getAdminConnectionContext, getBrokerId, getBrokerName, getBrokerSequenceId, getBrokerService, getClients, getDestinationMap, getDestinations, getDestinations, getDurableDestinations, getExecutor, getPeerBrokerInfos, getPreparedTransactions, getRoot, getScheduler, getTempDataStore, getVmConnectorURI, isExpired, isFaultTolerantConfiguration, isFull, isStopped, messageConsumed, messageDelivered, messageDiscarded, messageExpired, messagePull, networkBridgeStarted, networkBridgeStopped, nowMasterBroker, postProcessDispatch, prepareTransaction, preProcessDispatch, processConsumerControl, processDispatchNotification, removeBroker, removeConsumer, removeDestination, removeDestinationInfo, removeProducer, removeSession, removeSubscription, rollbackTransaction, sendToDeadLetterQueue, setAdminConnectionContext, slowConsumer, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final Logger LOG

plugin

protected final PartitionBrokerPlugin plugin

reloadConfigOnPoll

protected boolean reloadConfigOnPoll

monitors

protected final ConcurrentHashMap<ConnectionId,org.apache.activemq.partition.PartitionBroker.ConnectionMonitor> monitors
Constructor Detail

PartitionBroker

public PartitionBroker(Broker broker,
                       PartitionBrokerPlugin plugin)
Method Detail

start

public void start()
           throws Exception
Specified by:
start in interface Service
Overrides:
start in class BrokerFilter
Throws:
Exception

onMonitorStart

protected void onMonitorStart()

onMonitorStop

protected void onMonitorStop()

runPartitionMonitor

protected void runPartitionMonitor()

monitorWait

protected void monitorWait()
                    throws InterruptedException
Throws:
InterruptedException

monitorWakeup

protected void monitorWakeup()

reloadConfiguration

protected void reloadConfiguration()
                            throws Exception
Throws:
Exception

checkTarget

protected void checkTarget(org.apache.activemq.partition.PartitionBroker.ConnectionMonitor monitor)

getConnectionString

protected String getConnectionString(HashSet<String> ids)

pickBestBroker

protected Target pickBestBroker(org.apache.activemq.partition.PartitionBroker.ConnectionMonitor monitor)

getTarget

protected Target getTarget(ActiveMQDestination dest)

addConnection

public void addConnection(ConnectionContext context,
                          ConnectionInfo info)
                   throws Exception
Description copied from interface: Broker
A client is establishing a connection with the broker.

Specified by:
addConnection in interface Broker
Overrides:
addConnection in class BrokerFilter
Throws:
Exception - TODO

removeConnection

public void removeConnection(ConnectionContext context,
                             ConnectionInfo info,
                             Throwable error)
                      throws Exception
Description copied from interface: Broker
A client is disconnecting from the broker.

Specified by:
removeConnection in interface Broker
Overrides:
removeConnection in class BrokerFilter
Parameters:
context - the environment the operation is being executed under.
error - null if the client requested the disconnect or the error that caused the client to disconnect.
Throws:
Exception - TODO

send

public void send(ProducerBrokerExchange producerExchange,
                 Message messageSend)
          throws Exception
Description copied from interface: Region
Send a message to the broker to using the specified destination. The destination specified in the message does not need to match the destination the message is sent to. This is handy in case the message is being sent to a dead letter destination.

Specified by:
send in interface Region
Overrides:
send in class BrokerFilter
Parameters:
producerExchange - the environment the operation is being executed under.
Throws:
Exception - TODO

getConfig

protected Partitioning getConfig()


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.