blob: 625bebdc34fb26bee9c3bd3f279de70fe0867a97 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright 2011, Big Switch Networks, Inc.
3* Originally created by David Erickson, Stanford University
4*
5* Licensed under the Apache License, Version 2.0 (the "License"); you may
6* not use this file except in compliance with the License. You may obtain
7* a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14* License for the specific language governing permissions and limitations
15* under the License.
16**/
17
18/**
19 * Simple interface for a counter whose value can be retrieved in several different
20 * time increments (last x seconds, minutes, hours, days)
21 */
22package net.floodlightcontroller.counter;
23
24import java.util.Date;
25
26/**
27 * @author kyle
28 *
29 */
30public interface ICounter {
31
32 /**
33 * Most commonly used method
34 */
35 public void increment();
36
37 /**
38 * Used primarily for testing - no performance guarantees
39 */
40 public void increment(Date d, long delta);
41
42 /**
43 * Counter value setter
44 */
45 public void setCounter(Date d, CounterValue value);
46
47 /**
48 * Return the most current value
49 */
50 public Date getCounterDate();
51
52 /**
53 * Return the most current value
54 */
55 public CounterValue getCounterValue();
56
57 /**
58 * Reset the value
59 */
60 public void reset(Date d);
61
62 /**
63 * Returns a CountSeries that is a snapshot of the counter's values for the given dateSpan. (Further changes
64 * to this counter won't be reflected in the CountSeries that comes back.)
65 *
66 * @param dateSpan
67 * @return
68 */
69 public CountSeries snapshot(DateSpan dateSpan);
70
71
72 public static enum DateSpan {
73 REALTIME,
74 SECONDS,
75 MINUTES,
76 HOURS,
77 DAYS,
78 WEEKS
79 }
80}