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!
|
||||
|
@ -671,7 +673,19 @@ public class BrokerService implements Service, Serializable {
|
|||
public boolean isUseJmx() {
|
||||
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.
|
||||
|
@ -1224,6 +1238,11 @@ public class BrokerService implements Service, Serializable {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
RegionBroker rBroker = (RegionBroker) regionBroker;
|
||||
rBroker.getDestinationStatistics().setEnabled(enableStatistics);
|
||||
|
||||
|
||||
|
||||
if (isUseJmx()) {
|
||||
ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,19 @@ public class BrokerView implements BrokerViewMBean {
|
|||
public void resetStatistics() {
|
||||
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();
|
||||
|
|
|
@ -54,6 +54,30 @@ public class ConnectorView implements ConnectorViewMBean {
|
|||
public void resetStatistics() {
|
||||
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
|
||||
|
|
|
@ -25,6 +25,23 @@ public interface ConnectorViewMBean extends Service {
|
|||
* Resets the statistics
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -55,6 +55,12 @@ public class ConnectionStatistics extends StatsImpl {
|
|||
enqueues.reset();
|
||||
dequeues.reset();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
enqueues.setEnabled(enabled);
|
||||
dequeues.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setParent(ConnectorStatistics parent) {
|
||||
if (parent != null) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -79,7 +79,18 @@ public class DestinationStatistics extends StatsImpl {
|
|||
enqueues.reset();
|
||||
dequeues.reset();
|
||||
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) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ public class Topic implements Destination {
|
|||
if( store!=null ) {
|
||||
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) {
|
||||
counter.set(count);
|
||||
if(isEnabled()) {
|
||||
counter.set(count);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(long amount) {
|
||||
counter.addAndGet(amount);
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.add(amount);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
counter.addAndGet(amount);
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.add(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
counter.incrementAndGet();
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.increment();
|
||||
}
|
||||
}
|
||||
if (isEnabled()) {
|
||||
counter.incrementAndGet();
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.increment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void subtract(long amount) {
|
||||
counter.addAndGet(-amount);
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.subtract(amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void decrement() {
|
||||
counter.decrementAndGet();
|
||||
updateSampleTime();
|
||||
if (parent != null) {
|
||||
parent.decrement();
|
||||
}
|
||||
}
|
||||
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