Author: jlmonteiro Date: Tue Oct 15 19:39:39 2013 New Revision: 1532500 URL: http://svn.apache.org/r1532500 Log: Fixing bad scheduling and Graphite test accordingly.
Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/BatchCounterDataStore.java commons/sandbox/monitoring/trunk/graphite/src/test/java/org/apache/commons/monitoring/graphite/GraphiteTest.java Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/BatchCounterDataStore.java URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/BatchCounterDataStore.java?rev=1532500&r1=1532499&r2=1532500&view=diff ============================================================================== --- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/BatchCounterDataStore.java (original) +++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/BatchCounterDataStore.java Tue Oct 15 19:39:39 2013 @@ -35,8 +35,7 @@ public abstract class BatchCounterDataSt final long period = Configuration.getInteger(Configuration.COMMONS_MONITORING_PREFIX + name + ".period", 60000); final ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory(name + "-schedule-")); - final ScheduledFuture<?> future = ses.schedule(new BatchPushCountersTask(), period, TimeUnit.MILLISECONDS); - ses.shutdown(); // don't add anything more now + final ScheduledFuture<?> future = ses.scheduleAtFixedRate(new BatchPushCountersTask(), period, period, TimeUnit.MILLISECONDS); scheduledTask = new BatchFuture(ses, future); } @@ -70,6 +69,7 @@ public abstract class BatchCounterDataSt public void done() { try { + executor.shutdown(); // don't add anything more now task.cancel(false); executor.awaitTermination(1, TimeUnit.MINUTES); if (!task.isDone()) { Modified: commons/sandbox/monitoring/trunk/graphite/src/test/java/org/apache/commons/monitoring/graphite/GraphiteTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/graphite/src/test/java/org/apache/commons/monitoring/graphite/GraphiteTest.java?rev=1532500&r1=1532499&r2=1532500&view=diff ============================================================================== --- commons/sandbox/monitoring/trunk/graphite/src/test/java/org/apache/commons/monitoring/graphite/GraphiteTest.java (original) +++ commons/sandbox/monitoring/trunk/graphite/src/test/java/org/apache/commons/monitoring/graphite/GraphiteTest.java Tue Oct 15 19:39:39 2013 @@ -22,6 +22,7 @@ import org.apache.commons.monitoring.rep import org.junit.Test; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import static org.junit.Assert.assertEquals; @@ -53,7 +54,7 @@ public class GraphiteTest extends Graphi } { // counters - assertEquals(13, counters.size()); + assertEquals(39, counters.size()); assertTrue(counters.contains("counter-performances-test-Hits 2.00")); assertTrue(counters.contains("counter-performances-test-Max 1.60")); assertTrue(counters.contains("counter-performances-test-Mean 1.50"));