Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 290857B76 for ; Wed, 12 Oct 2011 16:29:35 +0000 (UTC) Received: (qmail 41106 invoked by uid 500); 12 Oct 2011 16:29:35 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 41062 invoked by uid 500); 12 Oct 2011 16:29:35 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 41055 invoked by uid 99); 12 Oct 2011 16:29:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2011 16:29:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2011 16:29:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3716E2388847; Wed, 12 Oct 2011 16:29:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1182466 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jmx/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/ja... Date: Wed, 12 Oct 2011 16:29:07 -0000 To: commits@jackrabbit.apache.org From: alexparvulescu@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111012162908.3716E2388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: alexparvulescu Date: Wed Oct 12 16:29:07 2011 New Revision: 1182466 URL: http://svn.apache.org/viewvc?rev=1182466&view=rev Log: JCR-3040 JMX Stats for the Session - integration work Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java (with props) jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java (with props) jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java - copied, changed from r1182291, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatistics.java Removed: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jmx/CoreStatManagerMBean.java jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/CoreStat.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jmx/CoreStatManager.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/CoreStatImpl.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatistics.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeries.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java?rev=1182466&view=auto ============================================================================== --- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java (added) +++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java Wed Oct 12 16:29:07 2011 @@ -0,0 +1,46 @@ +/* + * 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.jackrabbit.api.stats; + + +/** + * Statistics on core repository operations + * + */ +public interface RepositoryStatistics { + + enum Type { + SESSION_READ_COUNTER(true), + SESSION_READ_DURATION(true), + SESSION_WRITE_COUNTER(true), + SESSION_WRITE_DURATION(true), + SESSION_LOGIN_COUNTER(true), + SESSION_COUNT(false); + + private final boolean resetValueEachSecond; + + Type(final boolean resetValueEachSecond) { + this.resetValueEachSecond = resetValueEachSecond; + } + + public boolean isResetValueEachSecond() { + return resetValueEachSecond; + } + } + + TimeSeries getTimeSeries(Type type); +} Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java?rev=1182466&view=auto ============================================================================== --- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java (added) +++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java Wed Oct 12 16:29:07 2011 @@ -0,0 +1,57 @@ +/* + * 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.jackrabbit.api.stats; + +/** + * Interface for a time series of the measured values per + * second, minute, hour and day. The type of the value is arbitrary; it + * could be cache hits or misses, disk reads or writes, created sessions, + * completed transactions, or pretty much anything of interest. + * + * @since Apache Jackrabbit 2.3.2 + */ +public interface TimeSeries { + + /** + * Returns the measured value per second over the last minute. + * + * @return measured value per second, in chronological order + */ + long[] getValuePerSecond(); + + /** + * Returns the measured value per minute over the last hour. + * + * @return measured value per minute, in chronological order + */ + long[] getValuePerMinute(); + + /** + * Returns the measured value per hour over the last week. + * + * @return measured value per hour, in chronological order + */ + long[] getValuePerHour(); + + /** + * Returns the measured value per week over the last three years. + * + * @return measured value per week, in chronological order + */ + long[] getValuePerWeek(); + +} Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java ------------------------------------------------------------------------------ svn:executable = * Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/TimeSeries.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=1182466&r1=1182465&r2=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java Wed Oct 12 16:29:07 2011 @@ -83,6 +83,17 @@ public class JackrabbitRepositoryStub ex })); } + public static RepositoryContext getCurrentRepositoryContext() { + synchronized (REPOSITORY_INSTANCES) { + for (Repository repo : REPOSITORY_INSTANCES.values()) { + if (repo instanceof RepositoryImpl) { + return ((RepositoryImpl) repo).context; + } + } + } + return null; + } + private static Properties getStaticProperties() { Properties properties = new Properties(); try { Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java?rev=1182466&r1=1182465&r2=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java Wed Oct 12 16:29:07 2011 @@ -32,7 +32,7 @@ import org.apache.jackrabbit.core.nodety import org.apache.jackrabbit.core.security.JackrabbitSecurityManager; import org.apache.jackrabbit.core.security.authorization.PrivilegeRegistry; import org.apache.jackrabbit.core.state.ItemStateCacheFactory; -import org.apache.jackrabbit.core.stats.RepositoryStatistics; +import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl; import org.apache.jackrabbit.core.version.InternalVersionManagerImpl; /** @@ -115,7 +115,7 @@ public class RepositoryContext { /** * Repository statistics collector. */ - private final RepositoryStatistics statistics; + private final RepositoryStatisticsImpl statistics; /** * Creates a component context for the given repository. @@ -125,7 +125,7 @@ public class RepositoryContext { RepositoryContext(RepositoryImpl repository) { assert repository != null; this.repository = repository; - this.statistics = new RepositoryStatistics(executor); + this.statistics = new RepositoryStatisticsImpl(executor); } /** @@ -411,7 +411,7 @@ public class RepositoryContext { * * @return repository statistics collector */ - public RepositoryStatistics getRepositoryStatistics() { + public RepositoryStatisticsImpl getRepositoryStatistics() { return statistics; } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java?rev=1182466&r1=1182465&r2=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java Wed Oct 12 16:29:07 2011 @@ -16,6 +16,8 @@ */ package org.apache.jackrabbit.core.session; +import static org.apache.jackrabbit.api.stats.RepositoryStatistics.Type; + import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -25,7 +27,7 @@ import javax.jcr.Session; import org.apache.jackrabbit.core.WorkspaceManager; import org.apache.jackrabbit.core.observation.ObservationDispatcher; -import org.apache.jackrabbit.core.stats.RepositoryStatistics; +import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,6 +78,11 @@ public class SessionState { * Duration of write operations. */ private final AtomicLong writeDuration; + + /** + * Number of open sessions. + */ + private final AtomicLong sessionCount; /** * The lock used to guarantee synchronized execution of repository @@ -108,13 +115,15 @@ public class SessionState { public SessionState(SessionContext context) { this.context = context; - RepositoryStatistics statistics = + RepositoryStatisticsImpl statistics = context.getRepositoryContext().getRepositoryStatistics(); - statistics.getCounter("login").incrementAndGet(); - this.readCounter = statistics.getCounter("read"); - this.writeCounter = statistics.getCounter("write"); - this.readDuration = statistics.getCounter("read.duration"); - this.writeDuration = statistics.getCounter("write.duration"); + this.readCounter = statistics.getCounter(Type.SESSION_READ_COUNTER); + this.writeCounter = statistics.getCounter(Type.SESSION_WRITE_COUNTER); + this.readDuration = statistics.getCounter(Type.SESSION_READ_DURATION); + this.writeDuration = statistics.getCounter(Type.SESSION_WRITE_DURATION); + this.sessionCount = statistics.getCounter(Type.SESSION_COUNT); + statistics.getCounter(Type.SESSION_LOGIN_COUNTER).incrementAndGet(); + sessionCount.incrementAndGet(); } /** @@ -262,6 +271,7 @@ public class SessionState { } try { if (isAlive()) { + sessionCount.decrementAndGet(); closed = new Exception( "Stack trace of where " + session + " was originally closed"); Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java (from r1182291, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatistics.java) URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatistics.java&r1=1182291&r2=1182466&rev=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatistics.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java Wed Oct 12 16:29:07 2011 @@ -25,39 +25,50 @@ import java.util.concurrent.ScheduledExe import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -public class RepositoryStatistics - implements Iterable> { +import org.apache.jackrabbit.api.stats.RepositoryStatistics; +import org.apache.jackrabbit.api.stats.RepositoryStatistics.Type; +import org.apache.jackrabbit.api.stats.TimeSeries; - private final Map recorders = - new HashMap(); +public class RepositoryStatisticsImpl implements + Iterable>, RepositoryStatistics { - public RepositoryStatistics(ScheduledExecutorService executor) { + private final Map recorders = + new HashMap(); + + public RepositoryStatisticsImpl(ScheduledExecutorService executor) { executor.scheduleAtFixedRate(new Runnable() { public void run() { recordOneSecond(); } }, 1, 1, TimeUnit.SECONDS); + + getOrCreateRecorder(Type.SESSION_COUNT); + getOrCreateRecorder(Type.SESSION_LOGIN_COUNTER); + getOrCreateRecorder(Type.SESSION_READ_COUNTER); + getOrCreateRecorder(Type.SESSION_READ_DURATION); + getOrCreateRecorder(Type.SESSION_WRITE_COUNTER); + getOrCreateRecorder(Type.SESSION_WRITE_DURATION); } - public synchronized Iterator> iterator() { - Map map = new TreeMap(); + public synchronized Iterator> iterator() { + Map map = new TreeMap(); map.putAll(recorders); return map.entrySet().iterator(); } - public AtomicLong getCounter(String name) { - return getOrCreateRecorder(name).getCounter(); + public AtomicLong getCounter(Type type) { + return getOrCreateRecorder(type).getCounter(); } - public TimeSeries getTimeSeries(String name) { - return getOrCreateRecorder(name); + public TimeSeries getTimeSeries(Type type) { + return getOrCreateRecorder(type); } - private synchronized TimeSeriesRecorder getOrCreateRecorder(String name) { - TimeSeriesRecorder recorder = recorders.get(name); + private synchronized TimeSeriesRecorder getOrCreateRecorder(Type type) { + TimeSeriesRecorder recorder = recorders.get(type); if (recorder == null) { - recorder = new TimeSeriesRecorder(); - recorders.put(name, recorder); + recorder = new TimeSeriesRecorder(type); + recorders.put(type, recorder); } return recorder; } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java?rev=1182466&r1=1182465&r2=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java Wed Oct 12 16:29:07 2011 @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.core.stats; -import org.apache.jackrabbit.api.stats.CoreStat; import org.apache.jackrabbit.api.stats.QueryStat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,13 +32,10 @@ public class StatManager { /* STATS */ private final QueryStat queryStat = new QueryStatImpl(); - private final CoreStat coreStat = new CoreStatImpl(); - public StatManager() { } public void init() { - coreStat.setEnabled(false); queryStat.setEnabled(false); log.debug("Started StatManager"); } @@ -48,10 +44,6 @@ public class StatManager { } - public CoreStat getCoreStat() { - return coreStat; - } - public QueryStat getQueryStat() { return queryStat; } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java?rev=1182466&r1=1182465&r2=1182466&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorder.java Wed Oct 12 16:29:07 2011 @@ -18,6 +18,9 @@ package org.apache.jackrabbit.core.stats import java.util.concurrent.atomic.AtomicLong; +import org.apache.jackrabbit.api.stats.TimeSeries; +import org.apache.jackrabbit.api.stats.RepositoryStatistics.Type; + /** * Recorder of a time series. An instance of this class records (and clears) * the state of a given {@link AtomicLong} counter once every second and @@ -26,83 +29,94 @@ import java.util.concurrent.atomic.Atomi */ class TimeSeriesRecorder implements TimeSeries { - /** Event counter */ + /** Type */ + private final Type type; + + /** Value */ private final AtomicLong counter = new AtomicLong(); - /** Number of events per second over the last minute. */ - private final long[] eventsPerSecond = new long[60]; + /** Measured value per second over the last minute. */ + private final long[] valuePerSecond = new long[60]; - /** Number of events per minute over the last hour. */ - private final long[] eventsPerMinute = new long[60]; + /** Measured value per minute over the last hour. */ + private final long[] valuePerMinute = new long[60]; - /** Number of events per hour over the last week. */ - private final long[] eventsPerHour = new long[7 * 24]; + /** Measured value per hour over the last week. */ + private final long[] valuePerHour = new long[7 * 24]; - /** Number of events per week over the last three years. */ - private final long[] eventsPerWeek = new long[3 * 52]; + /** Measured value per week over the last three years. */ + private final long[] valuePerWeek = new long[3 * 52]; - /** Current second (index in {@link #eventsPerSecond}) */ + /** Current second (index in {@link #valuePerSecond}) */ private int seconds = 0; - /** Current minute (index in {@link #eventsPerMinute}) */ + /** Current minute (index in {@link #valuePerMinute}) */ private int minutes = 0; - /** Current hour (index in {@link #eventsPerHour}) */ + /** Current hour (index in {@link #valuePerHour}) */ private int hours = 0; - /** Current week (index in {@link #eventsPerWeek}) */ + /** Current week (index in {@link #valuePerWeek}) */ private int weeks = 0; + public TimeSeriesRecorder(Type type) { + this.type = type; + } + /** - * Returns the {@link AtomicLong} instance used to count events for + * Returns the {@link AtomicLong} instance used to measure the value for * the time series. * - * @return event counter + * @return value */ public AtomicLong getCounter() { return counter; } /** - * Records the number of counted events over the past second and resets + * Records the number of measured values over the past second and resets * the counter. This method should be scheduled to be called once per * second. */ public synchronized void recordOneSecond() { - eventsPerSecond[seconds++] = counter.getAndSet(0); - if (seconds == eventsPerSecond.length) { + if (type.isResetValueEachSecond()) { + valuePerSecond[seconds++] = counter.getAndSet(0); + } else { + valuePerSecond[seconds++] = counter.get(); + } + if (seconds == valuePerSecond.length) { seconds = 0; - eventsPerMinute[minutes++] = sum(eventsPerSecond); + valuePerMinute[minutes++] = aggregate(valuePerSecond); } - if (minutes == eventsPerMinute.length) { + if (minutes == valuePerMinute.length) { minutes = 0; - eventsPerHour[hours++] = sum(eventsPerMinute); + valuePerHour[hours++] = aggregate(valuePerMinute); } - if (hours == eventsPerHour.length) { + if (hours == valuePerHour.length) { hours = 0; - eventsPerWeek[weeks++] = sum(eventsPerHour); + valuePerWeek[weeks++] = aggregate(valuePerHour); } - if (weeks == eventsPerWeek.length) { + if (weeks == valuePerWeek.length) { weeks = 0; } } //----------------------------------------------------------< TimeSeries > - public synchronized long[] getEventsPerSecond() { - return cyclicCopyFrom(eventsPerSecond, seconds); + public synchronized long[] getValuePerSecond() { + return cyclicCopyFrom(valuePerSecond, seconds); } - public synchronized long[] getEventsPerMinute() { - return cyclicCopyFrom(eventsPerMinute, minutes); + public synchronized long[] getValuePerMinute() { + return cyclicCopyFrom(valuePerMinute, minutes); } - public synchronized long[] getEventsPerHour() { - return cyclicCopyFrom(eventsPerHour, hours); + public synchronized long[] getValuePerHour() { + return cyclicCopyFrom(valuePerHour, hours); } - public synchronized long[] getEventsPerWeek() { - return cyclicCopyFrom(eventsPerWeek, weeks); + public synchronized long[] getValuePerWeek() { + return cyclicCopyFrom(valuePerWeek, weeks); } //-------------------------------------------------------------< private > @@ -113,12 +127,16 @@ class TimeSeriesRecorder implements Time * @param array array to be summed * @return sum of entries */ - private static long sum(long[] array) { + private long aggregate(long[] array) { long sum = 0; for (int i = 0; i < array.length; i++) { + sum += array[i]; } - return sum; + if (type.isResetValueEachSecond()) { + return sum; + } + return sum / array.length; } /**