mirror of https://github.com/apache/activemq.git
updates for https://issues.apache.org/activemq/browse/AMQ-894 - provided option to disable statistics gathering
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@506415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef073d1ae9
commit
ccf3f3c60d
|
@ -103,6 +103,7 @@ public class BrokerService implements Service, Serializable {
|
|||
public static final String LOCAL_HOST_NAME;
|
||||
|
||||
private boolean useJmx = true;
|
||||
private boolean enableStatistics = true;
|
||||
private boolean persistent = true;
|
||||
private boolean populateJMSXUserID = false;
|
||||
private boolean useShutdownHook = true;
|
||||
|
@ -402,6 +403,7 @@ public class BrokerService implements Service, Serializable {
|
|||
}
|
||||
|
||||
getBroker().start();
|
||||
|
||||
/*
|
||||
if(isUseJmx()){
|
||||
// yes - this is order dependent!
|
||||
|
@ -672,6 +674,18 @@ public class BrokerService implements Service, Serializable {
|
|||
return useJmx;
|
||||
}
|
||||
|
||||
public boolean isEnableStatistics() {
|
||||
return enableStatistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the Broker's services enable statistics or
|
||||
* not.
|
||||
*/
|
||||
public void setEnableStatistics(boolean enableStatistics) {
|
||||
this.enableStatistics = enableStatistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the Broker's services should be exposed into JMX or
|
||||
* not.
|
||||
|
@ -1225,6 +1239,11 @@ public class BrokerService implements Service, Serializable {
|
|||
}
|
||||
};
|
||||
|
||||
RegionBroker rBroker = (RegionBroker) regionBroker;
|
||||
rBroker.getDestinationStatistics().setEnabled(enableStatistics);
|
||||
|
||||
|
||||
|
||||
if (isUseJmx()) {
|
||||
ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
|
||||
managedBroker.setContextBroker(broker);
|
||||
|
@ -1521,6 +1540,9 @@ public class BrokerService implements Service, Serializable {
|
|||
if (isUseJmx()) {
|
||||
connector = registerConnectorMBean(connector);
|
||||
}
|
||||
|
||||
connector.getStatistics().setEnabled(enableStatistics);
|
||||
|
||||
connector.start();
|
||||
|
||||
return connector;
|
||||
|
|
|
@ -256,6 +256,8 @@ public class TransportConnector implements Connector {
|
|||
// -------------------------------------------------------------------------
|
||||
protected Connection createConnection(Transport transport) throws IOException {
|
||||
TransportConnection answer = new TransportConnection(this, transport, broker, disableAsyncDispatch ? null : taskRunnerFactory);
|
||||
boolean statEnabled = this.getStatistics().isEnabled();
|
||||
answer.getStatistics().setEnabled(statEnabled);
|
||||
answer.setMessageAuthorizationPolicy(messageAuthorizationPolicy);
|
||||
return answer;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,19 @@ public class BrokerView implements BrokerViewMBean {
|
|||
broker.getDestinationStatistics().reset();
|
||||
}
|
||||
|
||||
public void enableStatistics() {
|
||||
broker.getDestinationStatistics().setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableStatistics() {
|
||||
broker.getDestinationStatistics().setEnabled(false);
|
||||
}
|
||||
|
||||
public boolean isStatisticsEnabled() {
|
||||
return broker.getDestinationStatistics().isEnabled();
|
||||
}
|
||||
|
||||
|
||||
public void terminateJVM(int exitCode) {
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ public interface BrokerViewMBean extends Service {
|
|||
|
||||
public void resetStatistics();
|
||||
|
||||
public void enableStatistics();
|
||||
public void disableStatistics();
|
||||
public boolean isStatisticsEnabled();
|
||||
|
||||
public long getTotalEnqueueCount();
|
||||
public long getTotalDequeueCount();
|
||||
public long getTotalConsumerCount();
|
||||
|
|
|
@ -55,6 +55,30 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
connector.getStatistics().reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* enable statistics gathering
|
||||
*/
|
||||
public void enableStatistics() {
|
||||
connector.getStatistics().setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* disable statistics gathering
|
||||
*/
|
||||
public void disableStatistics() {
|
||||
connector.getStatistics().setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if statistics is enabled
|
||||
*
|
||||
* @return true if statistics is enabled
|
||||
*/
|
||||
public boolean isStatisticsEnabled() {
|
||||
return connector.getStatistics().isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of messages enqueued on this connector
|
||||
*
|
||||
|
|
|
@ -26,6 +26,23 @@ public interface ConnectorViewMBean extends Service {
|
|||
*/
|
||||
public void resetStatistics();
|
||||
|
||||
/**
|
||||
* enable statistics gathering
|
||||
*/
|
||||
public void enableStatistics();
|
||||
|
||||
/**
|
||||
* disable statistics gathering
|
||||
*/
|
||||
public void disableStatistics();
|
||||
|
||||
/**
|
||||
* Returns true if statistics is enabled
|
||||
*
|
||||
* @return true if statistics is enabled
|
||||
*/
|
||||
public boolean isStatisticsEnabled();
|
||||
|
||||
/**
|
||||
* Returns the number of messages enqueued on this connector
|
||||
*
|
||||
|
|
|
@ -56,6 +56,12 @@ public class ConnectionStatistics extends StatsImpl {
|
|||
dequeues.reset();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
enqueues.setEnabled(enabled);
|
||||
dequeues.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setParent(ConnectorStatistics parent) {
|
||||
if (parent != null) {
|
||||
enqueues.setParent(parent.getEnqueues());
|
||||
|
|
|
@ -71,6 +71,15 @@ public class ConnectorStatistics extends StatsImpl {
|
|||
dequeues.reset();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
enqueues.setEnabled(enabled);
|
||||
dequeues.setEnabled(enabled);
|
||||
consumers.setEnabled(enabled);
|
||||
messages.setEnabled(enabled);
|
||||
messagesCached.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setParent(ConnectorStatistics parent) {
|
||||
if( parent!=null ) {
|
||||
enqueues.setParent(parent.enqueues);
|
||||
|
|
|
@ -81,6 +81,17 @@ public class DestinationStatistics extends StatsImpl {
|
|||
dispatched.reset();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
enqueues.setEnabled(enabled);
|
||||
dispatched.setEnabled(enabled);
|
||||
dequeues.setEnabled(enabled);
|
||||
consumers.setEnabled(enabled);
|
||||
messages.setEnabled(enabled);
|
||||
messagesCached.setEnabled(enabled);
|
||||
|
||||
}
|
||||
|
||||
public void setParent(DestinationStatistics parent) {
|
||||
if (parent != null) {
|
||||
enqueues.setParent(parent.enqueues);
|
||||
|
|
|
@ -114,6 +114,8 @@ public class Queue implements Destination, Task {
|
|||
store.setUsageManager(usageManager);
|
||||
}
|
||||
|
||||
//let's copy the enabled property from the parent DestinationStatistics
|
||||
this.destinationStatistics.setEnabled(parentStats.isEnabled());
|
||||
destinationStatistics.setParent(parentStats);
|
||||
this.log = LogFactory.getLog(getClass().getName() + "." + destination.getPhysicalName());
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ public class Topic implements Destination {
|
|||
store.setUsageManager(usageManager);
|
||||
}
|
||||
|
||||
//let's copy the enabled property from the parent DestinationStatistics
|
||||
this.destinationStatistics.setEnabled(parentStats.isEnabled());
|
||||
this.destinationStatistics.setParent(parentStats);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,40 +54,50 @@ public class CountStatisticImpl extends StatisticImpl implements CountStatistic
|
|||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
if(isEnabled()) {
|
||||
counter.set(count);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(long amount) {
|
||||
if (isEnabled()) {
|
||||
counter.addAndGet(amount);
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.add(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
if (isEnabled()) {
|
||||
counter.incrementAndGet();
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.increment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void subtract(long amount) {
|
||||
if (isEnabled()) {
|
||||
counter.addAndGet(-amount);
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.subtract(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decrement() {
|
||||
if (isEnabled()) {
|
||||
counter.decrementAndGet();
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.decrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CountStatisticImpl getParent() {
|
||||
return parent;
|
||||
|
|
Loading…
Reference in New Issue