commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1509182 - in /commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager: DefaultMetricQueueManager.java MetricQueueManager.java
Date Thu, 01 Aug 2013 11:55:15 GMT
Author: rmannibucau
Date: Thu Aug  1 11:55:15 2013
New Revision: 1509182

URL: http://svn.apache.org/r1509182
Log:
using Counter in MetricQueueManager API

Modified:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/DefaultMetricQueueManager.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/MetricQueueManager.java

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/DefaultMetricQueueManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/DefaultMetricQueueManager.java?rev=1509182&r1=1509181&r2=1509182&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/DefaultMetricQueueManager.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/DefaultMetricQueueManager.java
Thu Aug  1 11:55:15 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.monitoring.counter.queuemanager;
 
+import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.counter.DefaultCounter;
 
 import java.util.concurrent.locks.Lock;
@@ -162,11 +163,16 @@ public class DisruptorMetricQueueManager
 */
 public class DefaultMetricQueueManager implements MetricQueueManager {
     @Override
-    public void add(final DefaultCounter baseMetrics, final double delta) {
-        final Lock lock = baseMetrics.getLock();
+    public void add(final Counter counter, final double delta) {
+        if (!DefaultCounter.class.isInstance(counter)) {
+            throw new IllegalArgumentException(DefaultMetricQueueManager.class.getName()
+ " only supports " + DefaultCounter.class.getName());
+        }
+
+        final DefaultCounter defaultCounter = DefaultCounter.class.cast(counter);
+        final Lock lock = defaultCounter.getLock();
         lock.lock();
         try {
-            baseMetrics.addInternal(delta);
+            defaultCounter.addInternal(delta);
         } finally {
             lock.unlock();
         }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/MetricQueueManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/MetricQueueManager.java?rev=1509182&r1=1509181&r2=1509182&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/MetricQueueManager.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/queuemanager/MetricQueueManager.java
Thu Aug  1 11:55:15 2013
@@ -16,8 +16,8 @@
  */
 package org.apache.commons.monitoring.counter.queuemanager;
 
-import org.apache.commons.monitoring.counter.DefaultCounter;
+import org.apache.commons.monitoring.counter.Counter;
 
 public interface MetricQueueManager {
-    void add(DefaultCounter baseMetrics, double delta);
+    void add(Counter baseMetrics, double delta);
 }



Mime
View raw message