Statistic.java 4.18 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 9 10 11 12 13 14 15 16 17 18
 * Licensed 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.
Alex Wenckus's avatar
Alex Wenckus committed
19
 */
20

21
package org.jivesoftware.openfire.stats;
Alex Wenckus's avatar
Alex Wenckus committed
22 23

/**
24 25 26
 * A statistic being tracked by the server.
 *
 * @see StatisticsManager
Alex Wenckus's avatar
Alex Wenckus committed
27 28 29 30 31 32
 */
public interface Statistic {

    /**
     * Returns the name of a stat.
     *
33
     * @return the name of a stat.
Alex Wenckus's avatar
Alex Wenckus committed
34 35 36 37 38 39
     */
    public String getName();

    /**
     * Returns the type of a stat.
     *
40
     * @return the type of a stat.
Alex Wenckus's avatar
Alex Wenckus committed
41 42 43 44 45 46
     */
    public Type getStatType();

    /**
     * Returns a description of the stat.
     *
47
     * @return a description of the stat.
Alex Wenckus's avatar
Alex Wenckus committed
48 49 50 51 52 53
     */
    public String getDescription();

    /**
     * Returns the units that relate to the stat.
     *
54
     * @return the name of the units that relate to the stat.
Alex Wenckus's avatar
Alex Wenckus committed
55 56 57 58
     */
    public String getUnits();

    /**
59 60 61
     * Returns the current sample of data.
     *
     * @return a sample of the data.
Alex Wenckus's avatar
Alex Wenckus committed
62
     */
63
    public double sample();
Alex Wenckus's avatar
Alex Wenckus committed
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    /**
     * 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();

83 84 85
    /**
     * The type of statistic.
     */
86
    @SuppressWarnings({"UnnecessarySemicolon"})  // Support for QDox Parser
Alex Wenckus's avatar
Alex Wenckus committed
87 88 89
    public enum Type {

        /**
90 91 92
         * 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
93
         */
Alex Wenckus's avatar
Alex Wenckus committed
94
        rate,
95 96 97 98 99 100 101

        /**
         * 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
102
        // TODO: rate_total,
103

104
        /*
105 106 107 108 109
         * 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.   
         */
110
        count;
111

Alex Wenckus's avatar
Alex Wenckus committed
112
        /**
113 114 115 116 117
         * 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
118
         */
Matt Tucker's avatar
Matt Tucker committed
119
        // TODO: count_max
Alex Wenckus's avatar
Alex Wenckus committed
120 121
    }
}