Author: olamy Date: Tue Sep 3 04:40:25 2013 New Revision: 1519555 URL: http://svn.apache.org/r1519555 Log: use a bean rather than parameters to ease futur extensions
Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java (with props) Modified: 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/store/DataStore.java commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java 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=1519555&r1=1519554&r2=1519555&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 Tue Sep 3 04:40:25 2013 @@ -24,6 +24,7 @@ import org.apache.commons.monitoring.gau import org.apache.commons.monitoring.stopwatches.CounterStopWatch; import org.apache.commons.monitoring.stopwatches.StopWatch; import org.apache.commons.monitoring.store.DataStore; +import org.apache.commons.monitoring.store.GaugeValuesRequest; import java.util.Iterator; import java.util.Map; @@ -64,7 +65,7 @@ public class DefaultRepository implement @Override public Map<Long, Double> getGaugeValues(final long start, final long end, final Role role) { - return dataStore.getGaugeValues(start, end, role); + return dataStore.getGaugeValues(new GaugeValuesRequest(start, end, role)); } @Override Modified: 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=1519555&r1=1519554&r2=1519555&view=diff ============================================================================== --- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java (original) +++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DataStore.java Tue Sep 3 04:40:25 2013 @@ -29,7 +29,7 @@ public interface DataStore { 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); + Map<Long,Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest); void createOrNoopGauge(Role role); void addToGauge(Gauge gauge, long time, double value); } Modified: 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=1519555&r1=1519554&r2=1519555&view=diff ============================================================================== --- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java (original) +++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/DefaultDataStore.java Tue Sep 3 04:40:25 2013 @@ -75,19 +75,18 @@ public class DefaultDataStore implements } @Override - public Map<Long, Double> getGaugeValues(final long start, final long end, final Role role) { - final Map<Long, Double> map = gauges.get(role); + public Map<Long, Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest) { + final Map<Long, Double> map = gauges.get(gaugeValuesRequest.getRole()); if (map == null) { return Collections.emptyMap(); } - final Map<Long, Double> copy = new TreeMap<Long, Double>(); - copy.putAll(map); + final Map<Long, Double> copy = new TreeMap<Long, Double>( map ); final Map<Long, Double> out = new TreeMap<Long, Double>(); for (final Map.Entry<Long, Double> entry : copy.entrySet()) { final long time = entry.getKey(); - if (time >= start && time <= end) { + if (time >= gaugeValuesRequest.getStart() && time <= gaugeValuesRequest.getEnd()) { out.put(time, entry.getValue()); } } Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java?rev=1519555&view=auto ============================================================================== --- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java (added) +++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java Tue Sep 3 04:40:25 2013 @@ -0,0 +1,74 @@ +/* + * 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; + +/** + * @author Olivier Lamy + */ +public class GaugeValuesRequest +{ + + private long start; + + private long end; + + private Role role; + + public GaugeValuesRequest() + { + // no op + } + + public GaugeValuesRequest( long start, long end, Role role ) + { + this.start = start; + this.end = end; + this.role = role; + } + + public long getStart() + { + return start; + } + + public void setStart( long start ) + { + this.start = start; + } + + public long getEnd() + { + return end; + } + + public void setEnd( long end ) + { + this.end = end; + } + + public Role getRole() + { + return role; + } + + public void setRole( Role role ) + { + this.role = role; + } +} Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/store/GaugeValuesRequest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision