mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3438 - keep both mbean names, by remoteaddress and by clientid - as navigation between subs and connections uses the clientid but remote connection info based on address has real value to opts. https://issues.apache.org/jira/browse/AMQ-4237 - partition both address types using connectionViewType=remoteAddress|clientId and add clientId to connetionView - now easier to see connections under a clientConnector
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1431369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99682093d9
commit
aaa81deb40
|
@ -151,16 +151,10 @@ public class BrokerMBeanSuppurt {
|
||||||
return objectName;
|
return objectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectName createConnectionViewByAddressName(ObjectName connectorName, String type, String address) throws MalformedObjectNameException {
|
public static ObjectName createConnectionViewByType(ObjectName connectorName, String type, String name) throws MalformedObjectNameException {
|
||||||
String objectNameStr = connectorName.toString();
|
String objectNameStr = connectorName.toString();
|
||||||
objectNameStr += ",connectionViewType=" + JMXSupport.encodeObjectNamePart(type);
|
objectNameStr += ",connectionViewType=" + JMXSupport.encodeObjectNamePart(type);
|
||||||
objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(address);
|
objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(name);
|
||||||
return new ObjectName(objectNameStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ObjectName createConnectionViewByClientIdName(ObjectName connectorName, String clientId) throws MalformedObjectNameException {
|
|
||||||
String objectNameStr = connectorName.toString();
|
|
||||||
objectNameStr += ",connectionName="+JMXSupport.encodeObjectNamePart(clientId);
|
|
||||||
return new ObjectName(objectNameStr);
|
return new ObjectName(objectNameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,11 +210,11 @@ public class BrokerMBeanSuppurt {
|
||||||
|
|
||||||
// MBean Query Creation
|
// MBean Query Creation
|
||||||
|
|
||||||
public static ObjectName createConnectionQuery(String jmxDomainName, String brokerName, String clientId) throws MalformedObjectNameException {
|
public static ObjectName createConnectionQuery(String jmxDomainName, String brokerName, String name) throws MalformedObjectNameException {
|
||||||
return new ObjectName(jmxDomainName + ":type=Broker,brokerName="
|
return new ObjectName(jmxDomainName + ":type=Broker,brokerName="
|
||||||
+ JMXSupport.encodeObjectNamePart(brokerName) + ","
|
+ JMXSupport.encodeObjectNamePart(brokerName) + ","
|
||||||
+ "connector=*," + "connectorName=*,"
|
+ "connector=*," + "connectorName=*," + "connectionViewType=*,"
|
||||||
+ "connectionName=" + JMXSupport.encodeObjectNamePart(clientId));
|
+ "connectionName=" + JMXSupport.encodeObjectNamePart(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectName createConsumerQueury(String jmxDomainName, String clientId) throws MalformedObjectNameException {
|
public static ObjectName createConsumerQueury(String jmxDomainName, String clientId) throws MalformedObjectNameException {
|
||||||
|
|
|
@ -99,6 +99,11 @@ public class ConnectionView implements ConnectionViewMBean {
|
||||||
return connection.getRemoteAddress();
|
return connection.getRemoteAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getClientId() {
|
||||||
|
return connection.getConnectionId();
|
||||||
|
}
|
||||||
|
|
||||||
public String getConnectionId() {
|
public String getConnectionId() {
|
||||||
return connection.getConnectionId();
|
return connection.getConnectionId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,17 @@ public interface ConnectionViewMBean extends Service {
|
||||||
*
|
*
|
||||||
* @return the source address for this connection
|
* @return the source address for this connection
|
||||||
*/
|
*/
|
||||||
@MBeanInfo("Source address for this connection")
|
@MBeanInfo("source address for this connection")
|
||||||
String getRemoteAddress();
|
String getRemoteAddress();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the client identifier for this connection
|
||||||
|
*
|
||||||
|
* @return the the client identifier for this connection
|
||||||
|
*/
|
||||||
|
@MBeanInfo("client id for this connection")
|
||||||
|
String getClientId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of messages to be dispatched to this connection
|
* Returns the number of messages to be dispatched to this connection
|
||||||
* @return the number of messages pending dispatch
|
* @return the number of messages pending dispatch
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ManagedTransportConnection extends TransportConnection {
|
||||||
this.mbean = new ConnectionView(this, managementContext);
|
this.mbean = new ConnectionView(this, managementContext);
|
||||||
this.populateUserName = broker.getBrokerService().isPopulateUserNameInMBeans();
|
this.populateUserName = broker.getBrokerService().isPopulateUserNameInMBeans();
|
||||||
if (managementContext.isAllowRemoteAddressInMBeanNames()) {
|
if (managementContext.isAllowRemoteAddressInMBeanNames()) {
|
||||||
byAddressName = createByAddressObjectName("address", transport.getRemoteAddress());
|
byAddressName = createObjectName("remoteAddress", transport.getRemoteAddress());
|
||||||
registerMBean(byAddressName);
|
registerMBean(byAddressName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,12 @@ public class ManagedTransportConnection extends TransportConnection {
|
||||||
if (populateUserName) {
|
if (populateUserName) {
|
||||||
((ConnectionView) mbean).setUserName(info.getUserName());
|
((ConnectionView) mbean).setUserName(info.getUserName());
|
||||||
}
|
}
|
||||||
if (!managementContext.isAllowRemoteAddressInMBeanNames()) {
|
|
||||||
if (clientId != null) {
|
if (clientId != null) {
|
||||||
if (byClientIdName == null) {
|
if (byClientIdName == null) {
|
||||||
byClientIdName = createByClientIdObjectName(clientId);
|
byClientIdName = createObjectName("clientId", clientId);
|
||||||
registerMBean(byClientIdName);
|
registerMBean(byClientIdName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,19 +114,12 @@ public class ManagedTransportConnection extends TransportConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectName createByAddressObjectName(String type, String value) throws IOException {
|
protected ObjectName createObjectName(String type, String value) throws IOException {
|
||||||
try {
|
try {
|
||||||
return BrokerMBeanSuppurt.createConnectionViewByAddressName(connectorName, type, value);
|
return BrokerMBeanSuppurt.createConnectionViewByType(connectorName, type, value);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw IOExceptionSupport.create(e);
|
throw IOExceptionSupport.create(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectName createByClientIdObjectName(String value) throws IOException {
|
|
||||||
try {
|
|
||||||
return BrokerMBeanSuppurt.createConnectionViewByClientIdName(connectorName, value);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw IOExceptionSupport.create(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -678,7 +678,8 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
bindAddress = "tcp://localhost:0";
|
bindAddress = "tcp://localhost:0";
|
||||||
useTopic = false;
|
useTopic = false;
|
||||||
super.setUp();
|
super.setUp();
|
||||||
mbeanServer = broker.getManagementContext().getMBeanServer();
|
ManagementContext managementContext = broker.getManagementContext();
|
||||||
|
mbeanServer = managementContext.getMBeanServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
@ -953,6 +954,8 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
// Our consumer plus one advisory consumer.
|
// Our consumer plus one advisory consumer.
|
||||||
assertEquals(2, connectionView.getConsumers().length);
|
assertEquals(2, connectionView.getConsumers().length);
|
||||||
|
|
||||||
|
assertEquals("client id match", "MBeanTest", connectionView.getClientId());
|
||||||
|
|
||||||
// Check that the subscription view we found earlier is in this list.
|
// Check that the subscription view we found earlier is in this list.
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ObjectName name : connectionView.getConsumers()) {
|
for (ObjectName name : connectionView.getConsumers()) {
|
||||||
|
@ -1077,7 +1080,8 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertNull(subscriberView.getUserName());
|
assertNull(subscriberView.getUserName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObjectName query = new ObjectName(domain + ":type=Broker,brokerName=localhost,connector=*," + "connectorName=*,connectionName=MBeanTest");
|
ObjectName query = //new ObjectName(domain + ":type=Broker,brokerName=localhost,connector=*," + "connectorName=*,connectionName=MBeanTest");
|
||||||
|
BrokerMBeanSuppurt.createConnectionQuery(domain, "localhost", connection.getClientID());
|
||||||
|
|
||||||
Set<ObjectName> names = mbeanServer.queryNames(query, null);
|
Set<ObjectName> names = mbeanServer.queryNames(query, null);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TransportConnectorMBeanTest {
|
||||||
createBroker(allowRemoteAddress);
|
createBroker(allowRemoteAddress);
|
||||||
ActiveMQConnection connection = createConnection();
|
ActiveMQConnection connection = createConnection();
|
||||||
Set<ObjectName> registeredMbeans = getRegisteredMbeans();
|
Set<ObjectName> registeredMbeans = getRegisteredMbeans();
|
||||||
assertEquals("presence of mbean with clientId", !allowRemoteAddress, match(connection.getClientID(), registeredMbeans));
|
assertEquals("presence of mbean with clientId", true, match(connection.getClientID(), registeredMbeans));
|
||||||
assertEquals("presence of mbean with local port", allowRemoteAddress, match(extractLocalPort(connection), registeredMbeans));
|
assertEquals("presence of mbean with local port", allowRemoteAddress, match(extractLocalPort(connection), registeredMbeans));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue