commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1510241 - in /commons/sandbox/monitoring/trunk: core/src/main/java/org/apache/commons/monitoring/counters/ core/src/main/java/org/apache/commons/monitoring/counters/queuemanager/ core/src/main/java/org/apache/commons/monitoring/gauges/ cor...
Date Sun, 04 Aug 2013 16:35:51 GMT
Author: rmannibucau
Date: Sun Aug  4 16:35:50 2013
New Revision: 1510241

URL: http://svn.apache.org/r1510241
Log:
adding DataStore interface

Added:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java
Removed:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/queuemanager/
Modified:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/DefaultCounter.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeManager.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/stopwatches/CounterStopWatch.java
    commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/counters/CounterBench.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/jvm/JVMHandler.java

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/DefaultCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/DefaultCounter.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/DefaultCounter.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counters/DefaultCounter.java
Sun Aug  4 16:35:50 2013
@@ -17,25 +17,24 @@
 package org.apache.commons.monitoring.counters;
 
 import org.apache.commons.math.stat.descriptive.SummaryStatistics;
-import org.apache.commons.monitoring.configuration.Configuration;
-import org.apache.commons.monitoring.counters.queuemanager.MetricQueueManager;
+import org.apache.commons.monitoring.store.DataStore;
 
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 public class DefaultCounter implements Counter {
-    private static final MetricQueueManager QUEUE_MANAGER = Configuration.newInstance(MetricQueueManager.class);
-
     private final AtomicInteger concurrency = new AtomicInteger(0);
     private final Key key;
+    private final DataStore dataStore;
     private volatile int maxConcurrency = 0;
     protected SummaryStatistics statistics;
     protected Lock lock = new ReentrantLock();
 
-    public DefaultCounter(final Key key) {
+    public DefaultCounter(final Key key, final DataStore store) {
         this.key = key;
         this.statistics = new SummaryStatistics();
+        this.dataStore = store;
     }
 
     public void addInternal(final double delta) { // should be called from a thread safe
environment
@@ -70,8 +69,8 @@ public class DefaultCounter implements C
     }
 
     @Override
-    public void add(final double delta) { // sensitive method which need to be thread safe,
default implementation relies on disruptor
-        QUEUE_MANAGER.add(this, delta);
+    public void add(final double delta) {
+        dataStore.addToCounter(this, delta);
     }
 
     @Override

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
Sun Aug  4 16:35:50 2013
@@ -17,9 +17,8 @@
 package org.apache.commons.monitoring.gauges;
 
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.configuration.Configuration;
+import org.apache.commons.monitoring.store.DataStore;
 
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Timer;
@@ -27,19 +26,15 @@ import java.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
 
 public final class DefaultGaugeManager implements GaugeManager {
-    private static final int MAX_SIZE = Configuration.getInteger(Configuration.COMMONS_MONITORING_PREFIX
+ "gauge.max-size", 10);
-
     private final Map<Role, Timer> timers = new ConcurrentHashMap<Role, Timer>();
-    private final Map<Role, FixedSizedMap> values = new ConcurrentHashMap<Role,
FixedSizedMap>();
+    private final DataStore store;
 
-    @Override
-    public void start(final Map<Role, Map<Long, Double>> initialData) {
-        if (initialData != null) {
-            for (final Map.Entry<Role, Map<Long, Double>> entry : initialData.entrySet())
{
-                values.put(entry.getKey(), new FixedSizedMap(entry.getValue()));
-            }
-        }
+    public DefaultGaugeManager(final DataStore dataStore) {
+        store = dataStore;
+    }
 
+    @Override
+    public void start() {
         startFoundGaugeTimers();
     }
 
@@ -51,21 +46,15 @@ public final class DefaultGaugeManager i
         timers.clear();
     }
 
-    @Override
-    public Map<Long, Double> getValues(final Role role) {
-        return values.get(role).copy();
-    }
-
     protected void startFoundGaugeTimers() {
         for (final Gauge gauge : findGauges()) {
             final Role role = gauge.role();
 
-            final FixedSizedMap gaugeValues = new FixedSizedMap();
-            this.values.put(role, gaugeValues);
+            this.store.createOrNoopGauge(role);
 
             final Timer timer = new Timer("gauge-" + role.getName() + "-timer", true);
             timers.put(role, timer);
-            timer.scheduleAtFixedRate(new GaugeTask(gauge, gaugeValues), 0, gauge.period());
+            timer.scheduleAtFixedRate(new GaugeTask(store, gauge), 0, gauge.period());
         }
     }
 
@@ -84,40 +73,16 @@ public final class DefaultGaugeManager i
 
     private static class GaugeTask extends TimerTask {
         private final Gauge gauge;
-        private final FixedSizedMap values;
+        private final DataStore store;
 
-        public GaugeTask(final Gauge gauge, FixedSizedMap values) {
+        public GaugeTask(final DataStore store, final Gauge gauge) {
+            this.store = store;
             this.gauge = gauge;
-            this.values = values;
         }
 
         @Override
         public void run() {
-            values.add(gauge.value());
-        }
-    }
-
-    // no perf issues here normally since add is called not that often
-    protected static class FixedSizedMap extends LinkedHashMap<Long, Double> {
-        protected FixedSizedMap() {
-            super(MAX_SIZE);
-        }
-
-        protected FixedSizedMap(final Map<Long, Double> value) {
-            super(value);
-        }
-
-        public synchronized void add(final double value) {
-            put(System.currentTimeMillis(), value);
-        }
-
-        @Override
-        protected boolean removeEldestEntry(final Map.Entry<Long, Double> eldest) {
-            return size() > MAX_SIZE;
-        }
-
-        public synchronized Map<Long, Double> copy() {
-            return Map.class.cast(super.clone());
+            store.addToGauge(gauge, System.currentTimeMillis(), gauge.value());
         }
     }
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeManager.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeManager.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeManager.java
Sun Aug  4 16:35:50 2013
@@ -18,14 +18,10 @@ package org.apache.commons.monitoring.ga
 
 import org.apache.commons.monitoring.Role;
 
-import java.util.Map;
-
 public interface GaugeManager {
-    void start(Map<Role, Map<Long, Double>> initialData);
+    void start();
 
     void stop();
 
-    Map<Long, Double> getValues(Role role);
-
     void stopGauge(Role role);
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
Sun Aug  4 16:35:50 2013
@@ -14,52 +14,46 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.monitoring.repositories;
 
 import org.apache.commons.monitoring.Role;
 import org.apache.commons.monitoring.configuration.Configuration;
 import org.apache.commons.monitoring.counters.Counter;
-import org.apache.commons.monitoring.counters.DefaultCounter;
 import org.apache.commons.monitoring.gauges.DefaultGaugeManager;
 import org.apache.commons.monitoring.stopwatches.CounterStopWatch;
 import org.apache.commons.monitoring.stopwatches.StopWatch;
+import org.apache.commons.monitoring.store.DataStore;
 
 import java.util.Iterator;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 public class DefaultRepository implements Repository {
-    private final DefaultGaugeManager gaugeRepository = new DefaultGaugeManager();
-    private final ConcurrentMap<Counter.Key, Counter> counters = new ConcurrentHashMap<Counter.Key,
Counter>(50);
+    private final DataStore dataStore;
+    private final DefaultGaugeManager gaugeManager;
+
+    public DefaultRepository() {
+        this.dataStore = Configuration.newInstance(DataStore.class);
+        this.gaugeManager = new DefaultGaugeManager(dataStore);
+    }
 
     @Configuration.Created
     public void startGaugeTimers() {
-        gaugeRepository.start(null); // no persistence
+        gaugeManager.start(); // no persistence
     }
 
     @Configuration.Destroying
     public void stopGaugeTimers() {
-        gaugeRepository.stop();
+        gaugeManager.stop();
     }
 
     @Override
     public Counter getCounter(final Counter.Key key) {
-        Counter monitor = counters.get(key);
-        if (monitor == null) {
-            monitor = new DefaultCounter(key);
-            final Counter previous = counters.putIfAbsent(key, monitor);
-            if (previous != null) {
-                monitor = previous;
-            }
-        }
-        return monitor;
+        return dataStore.getOrCreateCounter(key);
     }
 
     @Override
     public void clear() {
-        counters.clear();
+        dataStore.clearCounters();
     }
 
     @Override
@@ -69,16 +63,16 @@ public class DefaultRepository implement
 
     @Override
     public Iterator<Counter> iterator() {
-        return counters.values().iterator();
+        return dataStore.getCounters().iterator();
     }
 
     @Override
-    public Map<Long, Double> getGaugeValues(final Role role) {
-        return gaugeRepository.getValues(role);
+    public Map<Long, Double> getGaugeValues(final long start, final long end, final
Role role) {
+        return dataStore.getGaugeValues(start, end, role);
     }
 
     @Override
     public void stopGauge(final Role role) {
-        gaugeRepository.stopGauge(role);
+        gaugeManager.stopGauge(role);
     }
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
Sun Aug  4 16:35:50 2013
@@ -33,7 +33,7 @@ public interface Repository extends Iter
 
     StopWatch start(Counter counter);
 
-    Map<Long, Double> getGaugeValues(Role role);
+    Map<Long, Double> getGaugeValues(long start, long end, Role role);
 
     void stopGauge(Role role);
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/stopwatches/CounterStopWatch.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/stopwatches/CounterStopWatch.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/stopwatches/CounterStopWatch.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/stopwatches/CounterStopWatch.java
Sun Aug  4 16:35:50 2013
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.monitoring.stopwatches;
 
 import org.apache.commons.monitoring.counters.Counter;
@@ -23,11 +22,6 @@ import java.util.concurrent.atomic.Atomi
 
 import static org.apache.commons.monitoring.counters.Unit.Time.NANOSECOND;
 
-/**
- * Simple implementation of StopWatch that estimate monitored element execution time.
- *
- * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
- */
 public class CounterStopWatch implements StopWatch {
     protected final Counter counter;
     protected final long startedAt;

Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java?rev=1510241&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java
(added)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java
Sun Aug  4 16:35:50 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.store;
+
+import org.apache.commons.monitoring.Role;
+import org.apache.commons.monitoring.counters.Counter;
+import org.apache.commons.monitoring.gauges.Gauge;
+
+import java.util.Collection;
+import java.util.Map;
+
+public interface DataStore {
+    Counter getOrCreateCounter(Counter.Key key);
+    void clearCounters();
+    Collection<Counter> getCounters();
+    void addToCounter(Counter defaultCounter, double delta);  // sensitive method which need
to be thread safe
+
+    Map<Long,Double> getGaugeValues(long start, long end, Role role);
+    void createOrNoopGauge(Role role);
+    void addToGauge(Gauge gauge, long time, double value);
+}

Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java?rev=1510241&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java
(added)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java
Sun Aug  4 16:35:50 2013
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.store;
+
+import org.apache.commons.monitoring.Role;
+import org.apache.commons.monitoring.configuration.Configuration;
+import org.apache.commons.monitoring.counters.Counter;
+import org.apache.commons.monitoring.counters.DefaultCounter;
+import org.apache.commons.monitoring.gauges.Gauge;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.locks.Lock;
+
+public class DefaultDataStore implements DataStore {
+    private final ConcurrentMap<Counter.Key, Counter> counters = new ConcurrentHashMap<Counter.Key,
Counter>(50);
+    private final Map<Role, FixedSizedMap> gauges = new ConcurrentHashMap<Role,
FixedSizedMap>();
+
+    @Override
+    public Counter getOrCreateCounter(final Counter.Key key) {
+        Counter counter = counters.get(key);
+        if (counter == null) {
+            counter = new DefaultCounter(key, this);
+            final Counter previous = counters.putIfAbsent(key, counter);
+            if (previous != null) {
+                counter = previous;
+            }
+        }
+        return counter;
+    }
+
+    @Override
+    public void clearCounters() {
+        counters.clear();
+    }
+
+    @Override
+    public Collection<Counter> getCounters() {
+        return counters.values();
+    }
+
+    @Override
+    public void addToCounter(final Counter counter, final double delta) {
+        if (!DefaultCounter.class.isInstance(counter)) {
+            throw new IllegalArgumentException(DefaultDataStore.class.getName() + " only
supports " + DefaultCounter.class.getName());
+        }
+
+        final DefaultCounter defaultCounter = DefaultCounter.class.cast(counter);
+        final Lock lock = defaultCounter.getLock();
+        lock.lock();
+        try {
+            defaultCounter.addInternal(delta);
+        } finally {
+            lock.unlock();
+        }
+    }
+
+    @Override
+    public Map<Long, Double> getGaugeValues(final long start, final long end, final
Role role) {
+        final Map<Long, Double> map = gauges.get(role);
+        if (map == null) {
+            return Collections.emptyMap();
+        }
+
+        final Map<Long, Double> out = new TreeMap<Long, Double>();
+        for (final Map.Entry<Long, Double> entry : map.entrySet()) {
+            final long time = entry.getKey();
+            if (time >= start && time <= end) {
+                out.put(time, entry.getValue());
+            }
+        }
+        return out;
+    }
+
+    @Override
+    public void createOrNoopGauge(final Role role) {
+        gauges.put(role, new FixedSizedMap());
+    }
+
+    @Override
+    public void addToGauge(final Gauge gauge, final long time, final double value) {
+        gauges.get(gauge.role()).put(time, value);
+    }
+
+    // no perf issues here normally since add is called not that often
+    protected static class FixedSizedMap extends LinkedHashMap<Long, Double> {
+        private static final int MAX_SIZE = Configuration.getInteger(Configuration.COMMONS_MONITORING_PREFIX
+ "gauge.max-size", 100);
+
+        protected FixedSizedMap() {
+            super(MAX_SIZE);
+        }
+
+        protected FixedSizedMap(final Map<Long, Double> value) {
+            super(value);
+        }
+
+        @Override
+        protected boolean removeEldestEntry(final Map.Entry<Long, Double> eldest) {
+            return size() > MAX_SIZE;
+        }
+
+        public synchronized Map<Long, Double> copy() {
+            return Map.class.cast(super.clone());
+        }
+    }
+}

Modified: commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/counters/CounterBench.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/counters/CounterBench.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/counters/CounterBench.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/counters/CounterBench.java
Sun Aug  4 16:35:50 2013
@@ -17,6 +17,7 @@
 package org.apache.commons.monitoring.counters;
 
 import org.apache.commons.monitoring.Role;
+import org.apache.commons.monitoring.store.DefaultDataStore;
 import org.junit.Test;
 
 import java.util.concurrent.ExecutorService;
@@ -35,7 +36,7 @@ public class CounterBench implements Run
     @Test
     public void defaultCounter() throws Exception {
         mode = "RentrantLockCounter";
-        counter = new DefaultCounter(new Counter.Key(Role.FAILURES, mode));
+        counter = new DefaultCounter(new Counter.Key(Role.FAILURES, mode), new DefaultDataStore());
         runConcurrent();
     }
 

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/jvm/JVMHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/jvm/JVMHandler.java?rev=1510241&r1=1510240&r2=1510241&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/jvm/JVMHandler.java
(original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/jvm/JVMHandler.java
Sun Aug  4 16:35:50 2013
@@ -32,14 +32,15 @@ public class JVMHandler extends HandlerR
     }
 
     protected Map<String,?> getVariables() {
+        final long now = System.currentTimeMillis();
         final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
         return new MapBuilder<String, Object>()
             .set("architecture", os.getArch())
             .set("name", os.getName())
             .set("version", os.getVersion())
             .set("numberProcessor", os.getAvailableProcessors())
-            .set("cpu", Repository.INSTANCE.getGaugeValues(CPUGauge.CPU))
-            .set("memory", Repository.INSTANCE.getGaugeValues(UsedMemoryGauge.USED_MEMORY))
+            .set("cpu", Repository.INSTANCE.getGaugeValues(0, now, CPUGauge.CPU))
+            .set("memory", Repository.INSTANCE.getGaugeValues(0, now, UsedMemoryGauge.USED_MEMORY))
             .build();
     }
 }



Mime
View raw message