Statistic.java 3.8 KB
Newer Older
Alex Wenckus's avatar
Alex Wenckus committed
1 2 3 4 5
/**
 * $RCSfile  $
 * $Revision  $
 * $Date  $
 *
6
 * Copyright (C) 1999-2008 Jive Software. All rights reserved.
Alex Wenckus's avatar
Alex Wenckus committed
7 8
 *
 * This software is published under the terms of the GNU Public License (GPL),
9 10
 * a copy of which is included in this distribution, or a commercial license
 * agreement with Jive.
Alex Wenckus's avatar
Alex Wenckus committed
11
 */
12

13
package org.jivesoftware.openfire.stats;
Alex Wenckus's avatar
Alex Wenckus committed
14 15

/**
16 17 18
 * A statistic being tracked by the server.
 *
 * @see StatisticsManager
Alex Wenckus's avatar
Alex Wenckus committed
19 20 21 22 23 24
 */
public interface Statistic {

    /**
     * Returns the name of a stat.
     *
25
     * @return the name of a stat.
Alex Wenckus's avatar
Alex Wenckus committed
26 27 28 29 30 31
     */
    public String getName();

    /**
     * Returns the type of a stat.
     *
32
     * @return the type of a stat.
Alex Wenckus's avatar
Alex Wenckus committed
33 34 35 36 37 38
     */
    public Type getStatType();

    /**
     * Returns a description of the stat.
     *
39
     * @return a description of the stat.
Alex Wenckus's avatar
Alex Wenckus committed
40 41 42 43 44 45
     */
    public String getDescription();

    /**
     * Returns the units that relate to the stat.
     *
46
     * @return the name of the units that relate to the stat.
Alex Wenckus's avatar
Alex Wenckus committed
47 48 49 50
     */
    public String getUnits();

    /**
51 52 53
     * Returns the current sample of data.
     *
     * @return a sample of the data.
Alex Wenckus's avatar
Alex Wenckus committed
54
     */
55
    public double sample();
Alex Wenckus's avatar
Alex Wenckus committed
56

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    /**
     * Returns true if the sample value represents only the value of the cluster node
     * or otherwise it represents the value of the entire cluster. Statistics that keep
     * only a sample of the local node will need to get added up with the value of the
     * other cluster nodes. On the other hand, statistics that hold the value of the
     * entire cluster can be sampled in any cluster node and they don't need to get
     * added up.<p>
     *
     * An example of a partial sample statistic would be network traffic. Each node keeps
     * track of its own network traffic information. Whilst an example of a total sample
     * statistic would be user sessions since every cluster node knows the total number of
     * connected users across the cluster. 
     *
     * @return true if the sample value represents only the value of the cluster node
     * or otherwise it represents the value of the entire cluster. 
     */
    public boolean isPartialSample();

75 76 77
    /**
     * The type of statistic.
     */
78
    @SuppressWarnings({"UnnecessarySemicolon"})  // Support for QDox Parser
Alex Wenckus's avatar
Alex Wenckus committed
79 80 81
    public enum Type {

        /**
82 83 84
         * The average rate over time. For example, the averave kb/s in bandwidth used for
         * file transfers. Each time the {@link Statistic#sample()} method is invoked, it should
         * return the "amount" of data recorded since the last invocation.
Alex Wenckus's avatar
Alex Wenckus committed
85
         */
Alex Wenckus's avatar
Alex Wenckus committed
86
        rate,
87 88 89 90 91 92 93

        /**
         * The total rate over time. For example, the number of users created. Each time the
         * {@link Statistic#sample()} method is invoked, it should return the "amount" of data
         * recorded since the last invocation. The values will be totalled over the relevant
         * time interval (by minute, hourly, daily, etc.).
         */
Matt Tucker's avatar
Matt Tucker committed
94
        // TODO: rate_total,
95

96
        /*
97 98 99 100 101
         * The average count over a time period. An example would be the
         * number of users in multi-user chats. Each time the {@link Statistic#sample()}
         * method is invoked, it should return the current measurement of the data, irrelevant of
         * previous reads of the data.   
         */
102
        count;
103

Alex Wenckus's avatar
Alex Wenckus committed
104
        /**
105 106 107 108 109
         * The max count over a time period. An example would be the maximum number of users
         * connected to the server. Each time the {@link Statistic#sample()}
         * method is invoked, it should return the current measurement of the data, irrelevant of
         * previous reads of the data. The max value read will be stored for each time interval
         * (by minute, hourly, daily, etc.).
Alex Wenckus's avatar
Alex Wenckus committed
110
         */
Matt Tucker's avatar
Matt Tucker committed
111
        // TODO: count_max
Alex Wenckus's avatar
Alex Wenckus committed
112 113
    }
}