mirror of https://github.com/apache/activemq.git
Support naming all the connectors so that JMX object names are easier to view.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@383972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c977f7ddfc
commit
b2ad8fa833
|
@ -775,7 +775,8 @@ public class BrokerService implements Service {
|
|||
ObjectName objectName = new ObjectName(
|
||||
managementContext.getJmxDomainName()+":"+
|
||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
||||
"Type=NetworkConnector"
|
||||
"Type=NetworkConnector,"+
|
||||
"NetworkConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
||||
);
|
||||
mbeanServer.registerMBean(view, objectName);
|
||||
registeredMBeanNames.add(objectName);
|
||||
|
@ -792,7 +793,8 @@ public class BrokerService implements Service {
|
|||
ObjectName objectName = new ObjectName(
|
||||
managementContext.getJmxDomainName()+":"+
|
||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
||||
"Type=ProxyConnector"
|
||||
"Type=ProxyConnector,"+
|
||||
"ProxyConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
||||
);
|
||||
mbeanServer.registerMBean(view, objectName);
|
||||
registeredMBeanNames.add(objectName);
|
||||
|
@ -826,7 +828,8 @@ public class BrokerService implements Service {
|
|||
ObjectName objectName = new ObjectName(
|
||||
managementContext.getJmxDomainName()+":"+
|
||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
||||
"Type=JmsConnector"
|
||||
"Type=JmsConnector,"+
|
||||
"JmsConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
||||
);
|
||||
mbeanServer.registerMBean(view, objectName);
|
||||
registeredMBeanNames.add(objectName);
|
||||
|
|
|
@ -63,6 +63,7 @@ public class TransportConnector implements Connector {
|
|||
private ConnectorStatistics statistics = new ConnectorStatistics();
|
||||
private URI discoveryUri;
|
||||
private URI connectUri;
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -86,12 +87,13 @@ public class TransportConnector implements Connector {
|
|||
* Factory method to create a JMX managed version of this transport connector
|
||||
*/
|
||||
public ManagedTransportConnector asManagedConnector(MBeanServer mbeanServer, ObjectName connectorName) throws IOException, URISyntaxException {
|
||||
ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer,connectorName, getBroker(), getServer());
|
||||
ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer, connectorName, getBroker(), getServer());
|
||||
rc.setTaskRunnerFactory(getTaskRunnerFactory());
|
||||
rc.setUri(uri);
|
||||
rc.setConnectUri(connectUri);
|
||||
rc.setDiscoveryAgent(discoveryAgent);
|
||||
rc.setDiscoveryUri(discoveryUri);
|
||||
rc.setName(name);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -110,10 +112,6 @@ public class TransportConnector implements Connector {
|
|||
return server;
|
||||
}
|
||||
|
||||
public String getName() throws IOException, URISyntaxException {
|
||||
return getServer().getConnectURI().toString();
|
||||
}
|
||||
|
||||
public Broker getBroker() {
|
||||
return broker;
|
||||
}
|
||||
|
@ -195,15 +193,13 @@ public class TransportConnector implements Connector {
|
|||
|
||||
public void start() throws Exception {
|
||||
getServer().start();
|
||||
log.info("Accepting connection on: "+getServer().getConnectURI());
|
||||
|
||||
DiscoveryAgent da = getDiscoveryAgent();
|
||||
if( da!=null ) {
|
||||
da.registerService(getConnectUri().toString());
|
||||
da.start();
|
||||
}
|
||||
|
||||
this.statusDector.start();
|
||||
log.info("Connector "+getName()+" Started");
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
|
@ -220,6 +216,7 @@ public class TransportConnector implements Connector {
|
|||
ss.stop(c);
|
||||
}
|
||||
ss.throwFirstException();
|
||||
log.info("Connector "+getName()+" Stopped");
|
||||
}
|
||||
|
||||
// Implementation methods
|
||||
|
@ -288,4 +285,14 @@ public class TransportConnector implements Connector {
|
|||
connections.remove(connection);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if( name == null ) {
|
||||
name = server.getConnectURI().toString();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class MasterConnector implements Service{
|
|||
private TransportConnector connector;
|
||||
private AtomicBoolean masterActive=new AtomicBoolean(false);
|
||||
private AtomicBoolean started=new AtomicBoolean(false);
|
||||
IdGenerator idGenerator=new IdGenerator();
|
||||
private final IdGenerator idGenerator=new IdGenerator();
|
||||
|
||||
ConnectionInfo connectionInfo;
|
||||
SessionInfo sessionInfo;
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
package org.apache.activemq.network;
|
||||
|
||||
import java.util.Set;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
||||
import org.apache.activemq.command.ConsumerId;
|
||||
import org.apache.activemq.command.ConsumerInfo;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet;
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents a network bridge interface
|
||||
*
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.apache.activemq.command.SessionInfo;
|
|||
import org.apache.activemq.command.ShutdownInfo;
|
||||
import org.apache.activemq.transport.DefaultTransportListener;
|
||||
import org.apache.activemq.transport.Transport;
|
||||
import org.apache.activemq.transport.TransportListener;
|
||||
import org.apache.activemq.util.IdGenerator;
|
||||
import org.apache.activemq.util.ServiceStopper;
|
||||
import org.apache.activemq.util.ServiceSupport;
|
||||
|
|
|
@ -81,6 +81,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
throw new IllegalStateException("You must configure the 'localURI' property");
|
||||
}
|
||||
this.discoveryAgent.start();
|
||||
log.info("Network Connector "+getName()+" Started");
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
|
@ -89,6 +90,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
Bridge bridge = (Bridge)i.next();
|
||||
bridge.stop();
|
||||
}
|
||||
log.info("Network Connector "+getName()+" Stopped");
|
||||
}
|
||||
|
||||
public void onServiceAdd(DiscoveryEvent event) {
|
||||
|
@ -228,6 +230,9 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
* @return Returns the name.
|
||||
*/
|
||||
public String getName(){
|
||||
if( name == null ) {
|
||||
name = discoveryAgent.toString();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -373,7 +378,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
if (conduitSubscriptions){
|
||||
if (dynamicOnly){
|
||||
result = new ConduitBridge(localTransport, remoteTransport) {
|
||||
protected void serviceRemoteException(IOException error) {
|
||||
protected void serviceRemoteException(Exception error) {
|
||||
super.serviceRemoteException(error);
|
||||
try {
|
||||
// Notify the discovery agent that the remote broker failed.
|
||||
|
@ -384,7 +389,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
};
|
||||
}else {
|
||||
result = new DurableConduitBridge(localTransport, remoteTransport) {
|
||||
protected void serviceRemoteException(IOException error) {
|
||||
protected void serviceRemoteException(Exception error) {
|
||||
super.serviceRemoteException(error);
|
||||
try {
|
||||
// Notify the discovery agent that the remote broker failed.
|
||||
|
@ -396,7 +401,7 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
}
|
||||
}else {
|
||||
result = new DemandForwardingBridge(localTransport, remoteTransport) {
|
||||
protected void serviceRemoteException(IOException error) {
|
||||
protected void serviceRemoteException(Exception error) {
|
||||
super.serviceRemoteException(error);
|
||||
try {
|
||||
// Notify the discovery agent that the remote broker failed.
|
||||
|
|
|
@ -19,10 +19,9 @@ package org.apache.activemq.network.jms;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.Service;
|
||||
|
@ -31,6 +30,7 @@ import org.apache.activemq.util.LRUCache;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.jndi.JndiTemplate;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
@ -41,6 +41,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
|||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public abstract class JmsConnector implements Service{
|
||||
|
||||
private static final Log log=LogFactory.getLog(JmsConnector.class);
|
||||
protected JndiTemplate jndiLocalTemplate;
|
||||
protected JndiTemplate jndiOutboundTemplate;
|
||||
|
@ -52,11 +53,18 @@ public abstract class JmsConnector implements Service{
|
|||
protected AtomicBoolean started = new AtomicBoolean(false);
|
||||
protected ActiveMQConnectionFactory embeddedConnectionFactory;
|
||||
protected int replyToDestinationCacheSize=10000;
|
||||
protected String outboundUsername;
|
||||
protected String outboundUsername;
|
||||
protected String outboundPassword;
|
||||
protected String localUsername;
|
||||
protected String localPassword;
|
||||
protected String localPassword;
|
||||
private String name;
|
||||
|
||||
protected LRUCache replyToBridges=new LRUCache(){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7446792754185879286L;
|
||||
|
||||
protected boolean removeEldestEntry(Map.Entry enty){
|
||||
if(size()>maxCacheSize){
|
||||
Iterator iter=entrySet().iterator();
|
||||
|
@ -97,14 +105,15 @@ public abstract class JmsConnector implements Service{
|
|||
public void start() throws Exception{
|
||||
init();
|
||||
if (started.compareAndSet(false, true)){
|
||||
for(int i=0;i<inboundBridges.size();i++){
|
||||
DestinationBridge bridge=(DestinationBridge) inboundBridges.get(i);
|
||||
bridge.start();
|
||||
}
|
||||
for(int i=0;i<outboundBridges.size();i++){
|
||||
DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
|
||||
bridge.start();
|
||||
}
|
||||
for(int i=0;i<inboundBridges.size();i++){
|
||||
DestinationBridge bridge=(DestinationBridge) inboundBridges.get(i);
|
||||
bridge.start();
|
||||
}
|
||||
for(int i=0;i<outboundBridges.size();i++){
|
||||
DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
|
||||
bridge.start();
|
||||
}
|
||||
log.info("JMS Connector "+getName()+" Started");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +127,7 @@ public abstract class JmsConnector implements Service{
|
|||
DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
|
||||
bridge.stop();
|
||||
}
|
||||
log.info("JMS Connector "+getName()+" Stopped");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,4 +286,20 @@ public abstract class JmsConnector implements Service{
|
|||
protected void removeOutboundBridge(DestinationBridge bridge){
|
||||
outboundBridges.add(bridge);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if( name == null ) {
|
||||
name = "Connector:"+getNextId();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
static int nextId;
|
||||
static private synchronized int getNextId() {
|
||||
return nextId;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ public class ProxyConnector implements Service {
|
|||
private URI bind;
|
||||
private URI remote;
|
||||
private URI localUri;
|
||||
private String name;
|
||||
|
||||
CopyOnWriteArrayList connections = new CopyOnWriteArrayList();
|
||||
|
||||
|
@ -69,6 +70,7 @@ public class ProxyConnector implements Service {
|
|||
}
|
||||
});
|
||||
getServer().start();
|
||||
log.info("Proxy Connector "+getName()+" Started");
|
||||
|
||||
}
|
||||
|
||||
|
@ -82,6 +84,7 @@ public class ProxyConnector implements Service {
|
|||
ss.stop((Service) iter.next());
|
||||
}
|
||||
ss.throwFirstException();
|
||||
log.info("Proxy Connector "+getName()+" Stopped");
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
@ -147,4 +150,15 @@ public class ProxyConnector implements Service {
|
|||
return transport;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if( name == null ) {
|
||||
name = server.getConnectURI().toString();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue