activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r470387 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq: ./ management/
Date Thu, 02 Nov 2006 15:33:26 GMT
Author: rajdavies
Date: Thu Nov  2 07:33:25 2006
New Revision: 470387

URL: http://svn.apache.org/viewvc?view=rev&rev=470387
Log:
make enabling statistics configurable

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/StatisticImpl.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
Thu Nov  2 07:33:25 2006
@@ -863,6 +863,21 @@
     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

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Thu Nov  2 07:33:25 2006
@@ -85,7 +85,6 @@
     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 @@
         props.setProperty("closeTimeout", Integer.toString(getCloseTimeout()));
         props.setProperty("alwaysSessionAsync", Boolean.toString(isAlwaysSessionAsync()));
         props.setProperty("optimizeAcknowledge", Boolean.toString(isOptimizeAcknowledge()));
+        props.setProperty("statsEnabled",Boolean.toString(isStatsEnabled()));
 
     }
 
@@ -661,5 +661,21 @@
 
     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);
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
Thu Nov  2 07:33:25 2006
@@ -54,6 +54,18 @@
             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() {

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
Thu Nov  2 07:33:25 2006
@@ -128,10 +128,12 @@
     }
 
     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) {

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
Thu Nov  2 07:33:25 2006
@@ -95,6 +95,22 @@
             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;

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSStatsImpl.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
Thu Nov  2 07:33:25 2006
@@ -68,4 +68,16 @@
         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);
+        }
+        
+    }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/StatisticImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/StatisticImpl.java?view=diff&rev=470387&r1=470386&r2=470387
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/StatisticImpl.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/StatisticImpl.java
Thu Nov  2 07:33:25 2006
@@ -29,6 +29,7 @@
     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 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 @@
         buffer.append(" description: ");
         buffer.append(description);
     }
+
+    
+   
 }



Mime
View raw message