Commit bb05b9a0 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Added statistics manager

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3825 b35dd754-fafc-0310-a699-88a17e54d16e
parent 70d275c6
/**
* $RCSfile $
* $Revision $
* $Date $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.stats;
/**
* A statistic being tracked by the server
*/
public interface Statistic {
/**
* The key uniquiely identifies a statistic in the system.
*
* @return Returns the key uniquiely identifies a statistic in the system.
*/
public String getKey();
/**
* Returns the name of a stat.
*
* @return Returns the name of a stat.
*/
public String getName();
/**
* Returns the type of a stat.
*
* @return Returns the type of a stat.
*/
public Type getStatType();
/**
* Returns a description of the stat.
*
* @return Returns a description of the stat.
*/
public String getDescription();
/**
* Returns the units that relate to the stat.
*
* @return Returns the units that relate to the stat.
*/
public String getUnits();
/**
* @param timePeriod The time in seconds since the last sample occured.
* @return Returns the sample of data for the timeperiod
*/
public double sample(long timePeriod);
public enum Type {
/**
* Specifies a rate over time.
* For example, the averave of kb/s in file transfers.
*/
RATE,
/**
* Specifies a count over a specific time period. An example would be
* the average of how many users were in MultiUserChat rooms over the last 60 seconds.
*/
COUNT
}
}
/**
* $RCSfile $
* $Revision $
* $Date $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.stats;
import java.util.Collection;
import java.util.Map;
import java.util.HashMap;
/**
* Stores statistics being tracked by the server.
*/
public class StatisticsManager {
private static StatisticsManager instance = new StatisticsManager();
public static StatisticsManager getInstance() {
return instance;
}
private final Map<String, Statistic> statistics = new HashMap<String, Statistic>();
private StatisticsManager() {}
/**
* Adds a stat to be tracked to the StatManager.
*
* @param definition The statistic to be tracked.
*/
public void addStatistic(Statistic definition) {
statistics.put(definition.getKey(), definition);
}
/**
* Returns a statistic being tracked by the StatManager.
*
* @param statKey The key of the definition.
* @return Returns the related stat.
*/
public Statistic getStatistic(String statKey) {
return statistics.get(statKey);
}
/**
* Returns all statistics that the StatManager is tracking.
* @return Returns all statistics that the StatManager is tracking.
*/
public Collection<Statistic> getAllStatistics() {
return statistics.values();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment