pt.digitalis.iss
Class ServiceStatistics

java.lang.Object
  extended by pt.digitalis.iss.ServiceStatistics

public final class ServiceStatistics
extends Object

This class is a small statistics engine that calculates the estimated time for a request service. The method used tries to reduce the number of insertion operations performed on the container and iterations over it's elements. To achieve this, a method that sums groups of samples is used. Every incoming sample is added to a group total. When a certain number of samples is reached, the group total is summed to the absolute total, the group total is stored on the container (which also has it's oldest element removed) and the control variables reset.

Author:
Rodrigo Gonçalves rgoncalves@digitalis.pt

Constructor Summary
ServiceStatistics()
          Constructor
 
Method Summary
 void addSample(long sample)
          Adds a new sample to the statistics engine.
 int getConfigElementsPerGroup()
          Returns the defined number of elements in a group.
 int getConfigNumberOfGroups()
          Returns the current number of groups.
 double getMeanExecutionTime()
          Calculates the mean service time of a request from the available data.
 void reset()
          This method enables that a client explicitly resets the stats engine.
 void setConfigElementsPerGroup(int groupElementNumber)
          Sets the number of elements in a group.
 void setConfigNumberOfGroups(int numberOfGroups)
          Sets the number of groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceStatistics

public ServiceStatistics()
Constructor

Method Detail

addSample

public void addSample(long sample)
Adds a new sample to the statistics engine. If the number of samples counter is equal to the number (max) of elements in a group the group total is added to the absolute total and stored in the container. The container and control variables are properly managed according to the system status. Synchronized to ensure sample consistency (prevent management operations during concurrent access).

Parameters:
sample - the new sample to add

getMeanExecutionTime

public double getMeanExecutionTime()
Calculates the mean service time of a request from the available data. The evaluation considers two main situations: evaluating before and after the first group is processed. After the first group is processed, one must consider the case where the sample container is full or not. Synchronized to ensure result consistency.

Returns:
the mean service time of a request

getConfigElementsPerGroup

public int getConfigElementsPerGroup()
Returns the defined number of elements in a group.

Returns:
the defined number of elements in a group

setConfigElementsPerGroup

public void setConfigElementsPerGroup(int groupElementNumber)
Sets the number of elements in a group.

Parameters:
groupElementNumber - the configElementsPerGroup to set

getConfigNumberOfGroups

public int getConfigNumberOfGroups()
Returns the current number of groups.

Returns:
the configNumberOfGroups value

setConfigNumberOfGroups

public void setConfigNumberOfGroups(int numberOfGroups)
Sets the number of groups.

Parameters:
numberOfGroups - the numberOfGroups to set

reset

public void reset()
This method enables that a client explicitly resets the stats engine. It clears all the sample records, and sets all the execution variables to zero.



Copyright © 2010 Digitalis Informática Lda. All Rights Reserved.