mirror of https://github.com/apache/activemq.git
make enabling statistics configurable
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@470387 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12fff78943
commit
526cb5bae8
|
@ -863,6 +863,21 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
public void setSessionTaskRunner(TaskRunnerFactory sessionTaskRunner) {
|
||||
this.sessionTaskRunner = sessionTaskRunner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the statsEnabled
|
||||
*/
|
||||
public boolean isStatsEnabled(){
|
||||
return this.stats.isEnabled();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param statsEnabled the statsEnabled to set
|
||||
*/
|
||||
public void setStatsEnabled(boolean statsEnabled){
|
||||
this.stats.setEnabled(statsEnabled);
|
||||
}
|
||||
|
||||
|
||||
// Implementation methods
|
||||
|
|
|
@ -85,7 +85,6 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
|||
private int closeTimeout = 15000;
|
||||
private boolean useRetroactiveConsumer;
|
||||
private boolean nestedMapAndListEnabled = true;
|
||||
|
||||
JMSStatsImpl factoryStats = new JMSStatsImpl();
|
||||
|
||||
static protected final Executor DEFAULT_CONNECTION_EXECUTOR = new ScheduledThreadPoolExecutor(5, new ThreadFactory() {
|
||||
|
@ -519,6 +518,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
|||
props.setProperty("closeTimeout", Integer.toString(getCloseTimeout()));
|
||||
props.setProperty("alwaysSessionAsync", Boolean.toString(isAlwaysSessionAsync()));
|
||||
props.setProperty("optimizeAcknowledge", Boolean.toString(isOptimizeAcknowledge()));
|
||||
props.setProperty("statsEnabled",Boolean.toString(isStatsEnabled()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -662,4 +662,20 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
|||
protected void setClientIdGenerator(IdGenerator clientIdGenerator) {
|
||||
this.clientIdGenerator = clientIdGenerator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the statsEnabled
|
||||
*/
|
||||
public boolean isStatsEnabled(){
|
||||
return this.factoryStats.isEnabled();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param statsEnabled the statsEnabled to set
|
||||
*/
|
||||
public void setStatsEnabled(boolean statsEnabled){
|
||||
this.factoryStats.setEnabled(statsEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,18 @@ public class JMSConnectionStatsImpl extends StatsImpl {
|
|||
stats[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public void setEnabled(boolean enabled){
|
||||
super.setEnabled(enabled);
|
||||
JMSSessionStatsImpl[] stats = getSessions();
|
||||
for (int i = 0, size = stats.length; i < size; i++) {
|
||||
stats[i].setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isTransactional() {
|
||||
|
|
|
@ -128,10 +128,12 @@ public class JMSEndpointStatsImpl extends StatsImpl {
|
|||
}
|
||||
|
||||
public void onMessage() {
|
||||
long start = messageCount.getLastSampleTime();
|
||||
messageCount.increment();
|
||||
long end = messageCount.getLastSampleTime();
|
||||
messageRateTime.addTime(end - start);
|
||||
if (enabled) {
|
||||
long start = messageCount.getLastSampleTime();
|
||||
messageCount.increment();
|
||||
long end = messageCount.getLastSampleTime();
|
||||
messageRateTime.addTime(end - start);
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(IndentPrinter out) {
|
||||
|
|
|
@ -95,6 +95,22 @@ public class JMSSessionStatsImpl extends StatsImpl {
|
|||
pstats[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public void setEnabled(boolean enabled){
|
||||
super.setEnabled(enabled);
|
||||
JMSConsumerStatsImpl[] cstats = getConsumers();
|
||||
for (int i = 0, size = cstats.length; i < size; i++) {
|
||||
cstats[i].setEnabled(enabled);
|
||||
}
|
||||
JMSProducerStatsImpl[] pstats = getProducers();
|
||||
for (int i = 0, size = pstats.length; i < size; i++) {
|
||||
pstats[i].setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CountStatisticImpl getMessageCount() {
|
||||
return messageCount;
|
||||
|
|
|
@ -68,4 +68,16 @@ public class JMSStatsImpl extends StatsImpl {
|
|||
out.println("}");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public void setEnabled(boolean enabled){
|
||||
super.setEnabled(enabled);
|
||||
JMSConnectionStatsImpl[] stats = getConnections();
|
||||
for (int i = 0, size = stats.length; i < size; i++) {
|
||||
stats[i].setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class StatisticImpl implements Statistic, Resettable {
|
|||
private String description;
|
||||
private long startTime;
|
||||
private long lastSampleTime;
|
||||
protected boolean enabled= true;
|
||||
|
||||
public StatisticImpl(String name, String unit, String description) {
|
||||
this.name = name;
|
||||
|
@ -75,6 +76,20 @@ public class StatisticImpl implements Statistic, Resettable {
|
|||
public synchronized long getLastSampleTime() {
|
||||
return lastSampleTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the enabled
|
||||
*/
|
||||
public boolean isEnabled(){
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public void setEnabled(boolean enabled){
|
||||
this.enabled=enabled;
|
||||
}
|
||||
|
||||
protected synchronized void appendFieldDescription(StringBuffer buffer) {
|
||||
buffer.append(" unit: ");
|
||||
|
@ -88,4 +103,7 @@ public class StatisticImpl implements Statistic, Resettable {
|
|||
buffer.append(" description: ");
|
||||
buffer.append(description);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue