activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r506415 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/ broker/jmx/ broker/region/ management/
Date Mon, 12 Feb 2007 11:20:08 GMT
Author: jlim
Date: Mon Feb 12 03:20:05 2007
New Revision: 506415

URL: http://svn.apache.org/viewvc?view=rev&rev=506415
Log:
updates for https://issues.apache.org/activemq/browse/AMQ-894 - provided option to disable
statistics gathering

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/CountStatisticImpl.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Mon Feb 12 03:20:05 2007
@@ -103,6 +103,7 @@
     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 @@
             }
 
             getBroker().start();
+
             /*
             if(isUseJmx()){
                 // yes - this is order dependent!
@@ -671,8 +673,20 @@
     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 @@
                 });
             }
         };
+        
+        RegionBroker rBroker = (RegionBroker) regionBroker;
+        rBroker.getDestinationStatistics().setEnabled(enableStatistics);
+        
+        
 
         if (isUseJmx()) {
             ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
@@ -1521,6 +1540,9 @@
         if (isUseJmx()) {
             connector = registerConnectorMBean(connector);
         }        
+        
+       	connector.getStatistics().setEnabled(enableStatistics);
+        
         connector.start();
         
         return connector;

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
Mon Feb 12 03:20:05 2007
@@ -256,6 +256,8 @@
     // -------------------------------------------------------------------------
     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;
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Mon Feb 12 03:20:05 2007
@@ -91,6 +91,19 @@
     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);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
Mon Feb 12 03:20:05 2007
@@ -39,6 +39,10 @@
     
     public void resetStatistics();
     
+    public void enableStatistics();
+    public void disableStatistics();
+    public boolean isStatisticsEnabled();
+    
     public long getTotalEnqueueCount();
     public long getTotalDequeueCount();
     public long getTotalConsumerCount();

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java
Mon Feb 12 03:20:05 2007
@@ -54,6 +54,30 @@
     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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java
Mon Feb 12 03:20:05 2007
@@ -25,6 +25,23 @@
      * 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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
Mon Feb 12 03:20:05 2007
@@ -55,6 +55,12 @@
         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) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
Mon Feb 12 03:20:05 2007
@@ -71,6 +71,15 @@
         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);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java
Mon Feb 12 03:20:05 2007
@@ -79,7 +79,18 @@
         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) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Mon Feb 12 03:20:05 2007
@@ -114,6 +114,8 @@
             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());
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
Mon Feb 12 03:20:05 2007
@@ -82,7 +82,9 @@
         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);
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/CountStatisticImpl.java?view=diff&rev=506415&r1=506414&r2=506415
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
Mon Feb 12 03:20:05 2007
@@ -54,40 +54,50 @@
     }
 
     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;



Mime
View raw message