mirror of https://github.com/apache/activemq.git
added patch with addition of getter for link stealing enabled and a unit test.
This commit is contained in:
parent
9e139017e4
commit
d223ea979f
|
@ -66,4 +66,10 @@ public interface Connector extends Service {
|
|||
* @return true/false if link stealing is enabled
|
||||
*/
|
||||
boolean isAllowLinkStealing();
|
||||
|
||||
/**
|
||||
* @return The comma separated string of regex patterns to match
|
||||
* broker names for cluster client updates
|
||||
*/
|
||||
String getUpdateClusterFilter();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
this.connector = connector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
connector.start();
|
||||
}
|
||||
|
@ -35,6 +36,7 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
return getBrokerInfo().getBrokerName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
connector.stop();
|
||||
}
|
||||
|
@ -50,6 +52,7 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
/**
|
||||
* Resets the statistics
|
||||
*/
|
||||
@Override
|
||||
public void resetStatistics() {
|
||||
connector.getStatistics().reset();
|
||||
}
|
||||
|
@ -57,6 +60,7 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
/**
|
||||
* enable statistics gathering
|
||||
*/
|
||||
@Override
|
||||
public void enableStatistics() {
|
||||
connector.getStatistics().setEnabled(true);
|
||||
}
|
||||
|
@ -64,15 +68,17 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
/**
|
||||
* disable statistics gathering
|
||||
*/
|
||||
@Override
|
||||
public void disableStatistics() {
|
||||
connector.getStatistics().setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if statistics is enabled
|
||||
*
|
||||
*
|
||||
* @return true if statistics is enabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatisticsEnabled() {
|
||||
return connector.getStatistics().isEnabled();
|
||||
}
|
||||
|
@ -80,8 +86,54 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
/**
|
||||
* Returns the number of current connections
|
||||
*/
|
||||
@Override
|
||||
public int connectionCount() {
|
||||
return connector.connectionCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if updating cluster client URL is enabled
|
||||
*
|
||||
* @return true if update cluster client URL is enabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isUpdateClusterClients() {
|
||||
return this.connector.isUpdateClusterClientsOnRemove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if rebalancing cluster clients is enabled
|
||||
*
|
||||
* @return true if rebalance cluster clients is enabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isRebalanceClusterClients() {
|
||||
return this.connector.isRebalanceClusterClients();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if updating cluster client URL when brokers are removed is
|
||||
* enabled
|
||||
*
|
||||
* @return true if update cluster client URL when brokers are removed is
|
||||
* enabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isUpdateClusterClientsOnRemove() {
|
||||
return this.connector.isUpdateClusterClientsOnRemove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The comma separated string of regex patterns to match broker
|
||||
* names for cluster client updates
|
||||
*/
|
||||
@Override
|
||||
public String getUpdateClusterFilter() {
|
||||
return this.connector.getUpdateClusterFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowLinkStealingEnabled() {
|
||||
return this.connector.isAllowLinkStealing();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ public interface ConnectorViewMBean extends Service {
|
|||
|
||||
@MBeanInfo("Connection count")
|
||||
int connectionCount();
|
||||
|
||||
|
||||
/**
|
||||
* Resets the statistics
|
||||
*/
|
||||
@MBeanInfo("Resets the statistics")
|
||||
void resetStatistics();
|
||||
|
||||
|
||||
/**
|
||||
* enable statistics gathering
|
||||
*/
|
||||
|
@ -37,16 +37,51 @@ public interface ConnectorViewMBean extends Service {
|
|||
|
||||
/**
|
||||
* disable statistics gathering
|
||||
*/
|
||||
*/
|
||||
@MBeanInfo("Disables statistics gathering")
|
||||
void disableStatistics();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if statistics is enabled
|
||||
*
|
||||
*
|
||||
* @return true if statistics is enabled
|
||||
*/
|
||||
*/
|
||||
@MBeanInfo("Statistics gathering enabled")
|
||||
boolean isStatisticsEnabled();
|
||||
|
||||
/**
|
||||
* Returns true if link stealing is enabled on this Connector
|
||||
*
|
||||
* @returns true if link stealing is enabled.
|
||||
*/
|
||||
@MBeanInfo("Link Stealing enabled")
|
||||
boolean isAllowLinkStealingEnabled();
|
||||
|
||||
/**
|
||||
* @return true if update client connections when brokers leave/join a cluster
|
||||
*/
|
||||
@MBeanInfo("Update client URL's when brokers leave/join a custer enabled")
|
||||
boolean isUpdateClusterClients();
|
||||
|
||||
/**
|
||||
* @return true if clients should be re-balanced across the cluster
|
||||
*/
|
||||
@MBeanInfo("Rebalance clients across the broker cluster enabled")
|
||||
boolean isRebalanceClusterClients();
|
||||
|
||||
/**
|
||||
* @return true if clients should be updated when
|
||||
* a broker is removed from a broker
|
||||
*/
|
||||
@MBeanInfo("Update clients when a broker is removed from a network enabled.")
|
||||
boolean isUpdateClusterClientsOnRemove();
|
||||
|
||||
/**
|
||||
* @return The comma separated string of regex patterns to match
|
||||
* broker names for cluster client updates
|
||||
*/
|
||||
@MBeanInfo("Comma separated list of regex patterns to match broker names for cluster client updates.")
|
||||
String getUpdateClusterFilter();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1361,6 +1361,31 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
|||
session.close();
|
||||
}
|
||||
|
||||
public void testConnectorView() throws Exception {
|
||||
ConnectorViewMBean connector = getProxyToConnectionView("tcp");
|
||||
assertNotNull(connector);
|
||||
|
||||
assertFalse(connector.isRebalanceClusterClients());
|
||||
assertFalse(connector.isUpdateClusterClientsOnRemove());
|
||||
assertFalse(connector.isUpdateClusterClients());
|
||||
assertFalse(connector.isAllowLinkStealingEnabled());
|
||||
}
|
||||
|
||||
protected ConnectorViewMBean getProxyToConnectionView(String connectionType) throws Exception {
|
||||
ObjectName connectorQuery = new ObjectName(
|
||||
"org.apache.activemq:type=Broker,brokerName=localhost,connector=clientConnectors,connectorName="+connectionType+"_//*");
|
||||
|
||||
Set<ObjectName> results = broker.getManagementContext().queryNames(connectorQuery, null);
|
||||
|
||||
if (results == null || results.isEmpty() || results.size() > 1) {
|
||||
throw new Exception("Unable to find the exact Connector instance.");
|
||||
}
|
||||
|
||||
ConnectorViewMBean proxy = (ConnectorViewMBean) broker.getManagementContext()
|
||||
.newProxyInstance(results.iterator().next(), ConnectorViewMBean.class, true);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void testDynamicProducers() throws Exception {
|
||||
connection = connectionFactory.createConnection();
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
|
Loading…
Reference in New Issue