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
|
@ -864,6 +864,21 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,18 @@ public class JMSConnectionStatsImpl extends StatsImpl {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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() {
|
||||
return transactional;
|
||||
|
|
|
@ -128,11 +128,13 @@ public class JMSEndpointStatsImpl extends StatsImpl {
|
|||
}
|
||||
|
||||
public void onMessage() {
|
||||
if (enabled) {
|
||||
long start = messageCount.getLastSampleTime();
|
||||
messageCount.increment();
|
||||
long end = messageCount.getLastSampleTime();
|
||||
messageRateTime.addTime(end - start);
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(IndentPrinter out) {
|
||||
out.printIndent();
|
||||
|
|
|
@ -96,6 +96,22 @@ public class JMSSessionStatsImpl extends StatsImpl {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
@ -76,6 +77,20 @@ public class StatisticImpl implements Statistic, Resettable {
|
|||
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: ");
|
||||
buffer.append(unit);
|
||||
|
@ -88,4 +103,7 @@ public class StatisticImpl implements Statistic, Resettable {
|
|||
buffer.append(" description: ");
|
||||
buffer.append(description);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue