/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* ident "%Z%%M% %I% %E% SMI"
*/
/**
* Contains information about statistics. An instance must only
* contain Statistics of the same type.
*/
{
/**
* The name of the statistic.
*/
/**
* The maximum number of samples to be stored.
*/
private final int maxSize;
/**
* The list of StatisticListeners.
*/
/**
* Statistically assess utilization.
*/
/**
* Constructor.
*/
public StatisticList()
{
this("default", 10);
}
/**
* Constructor. Statistics will not be held for this set.
*
* @param name is the name of the contained statistics
* @param size is the maximum number of statistics to hold
*/
{
}
/**
* Constructor.
*
* @param name is the name of the contained statistics
* @param size is the maximum number of statistics to hold
* @param doStats indicates whether or not statistics should
* be calculated for the data.
*/
throws IllegalArgumentException
{
super();
if (size < 1)
throw new IllegalArgumentException("Size must be > 0");
listeners = new LinkedList();
if (doStats) {
statisticOperations = new StatisticOperations(this);
}
}
/**
* Return the name of the Statistics being sampled.
*/
{
return (name);
}
/**
* Return a "snapshot" which is the aggregation of all
* statistic records.
*
* @throws NoSuchElementException if there is an error
* accessing a list member.
*/
throws NoSuchElementException
{
}
/**
* Return a "snapshot" of the data using the supplied
* iterator.
*
* @param it An iterator over the contained elements to be
* used as the basis for the snapshot.
* @throws NoSuchElementException if there is an error
* accessing a list member.
*/
throws NoSuchElementException
{
}
/**
* Returns the aggregated value for the StatisticList only
* including samples which satisfy the start and end criteria.
*
* @param start start time or null if unspecified.
* @param end end time or null if unspecified.
* @throws NoSuchElementException if there is an error
* accessing a list member.
*/
{
}
/**
* Returns the aggregated value for the StatisticList only
* including samples which satisfy the start and end criteria.
*
* @param it An iterator over the contained elements to be
* used as the basis for the snapshot.
* @param start start time or null if unspecified.
* @param end end time or null if unspecified.
* @throws NoSuchElementException if there is an error
* accessing a list member.
*/
{
}
/**
* Add the supplied object to the list. If the list is full,
* remove the first entry before adding the new entry.
*
* @param o Object to add to the list.
*/
{
boolean ret;
removeFirst();
if (ret)
return (ret);
}
/**
* Remove the supplied object from the list.
*
* @param o Object to remove from the list.
*/
{
boolean ret;
if (ret)
return (ret);
}
/**
* Removes and returns the first element from this list.
*
* @return the first element from this list.
* @throws NoSuchElementException if this list is empty.
*/
return (first);
}
/**
* Add a listener for StatisticEvents.
*
* @param l Listener to add.
*/
}
/**
* Remove a listener for StatisticEvents.
*
* @param l Listener to remove.
*/
}
/**
* Notify all StatisticEvent listeners of a new Add event.
*
* @param s Event payload.
*/
{
StatisticEvent e = new StatisticEvent(this,
StatisticEvent.ADD, s);
l.onStatisticAdd(e);
}
}
/**
* Notify all StatisticEvent listeners of a new Remove event.
*
* @param s Event payload.
*/
{
StatisticEvent e = new StatisticEvent(this,
StatisticEvent.REMOVE, s);
l.onStatisticRemove(e);
}
}
/**
* Return true if the contents of the instance are
* statistically valid.
*/
boolean isValid()
{
return (statisticOperations.isValid());
}
/**
* Return the zone of control to which the supplied val
* belongs based on the target details in the supplied
* objective expression.
*
* @param kve Objective expression used to determine zone
* details.
* @param val The value to be assessed.
*/
{
}
/**
* Return the zone of control to which the supplied val
* belongs based on the mean of the sampled data.
*
* @param val The value to be assessed.
*/
{
}
/**
* Return the difference (gap) between the target utilization
* expressed in the supplied objective expression and the
* supplied value.
*
* @param kve Objective expression used to determine target
* utilization details.
* @param val The value to be assessed.
*/
{
}
/**
* Clear all the data from the StatisticList and reset all the
* statistic counters.
*/
public void clear()
{
if (statisticOperations != null) {
statisticOperations = new StatisticOperations(this);
}
super.clear();
}
/**
* Return a string which describes the zones for this set of
* data.
*
* @param kve The expression containing objectives.
* @param val The value to be assessed against objectives.
*/
{
}
}
/**
* Event class which describes modifications (Add, Remove) to a
* StatisticList instance.
*/
{
/**
* Identifier for an ADD event.
*/
/**
* Identifier for a REMOVE event.
*/
/**
* The target of the event.
*/
/**
* The identifier of this event.
*/
private final int id;
/**
* Constructor.
*
* @param source The source of the event.
* @param id The type of the event.
* @param target The target of the event.
*/
{
super(source);
}
/**
* Return the target of the event.
*/
{
return (target);
}
/**
* Return the ID (type) of the event.
*/
public int getID()
{
return (id);
}
/**
* Return the source of the event. This is a typesafe
* alternative to using getSource().
*/
{
return ((StatisticList) source);
}
}
/**
* The listener interface for receiving statistic events. The class
* that is interested in processing a statistic event implements this
* interface, and the object created with that class is registered
* with a component, using the component's addStatisticListener
* method. When the statistic event occurs, the relevant method in the
* listener object is invoked, and the StatisticEvent is passed to it.
*/
{
/**
* Invoked when a statistic is added to the source
* StatisticList.
*
* @param e The event.
*/
/**
* Invoked when a statistic is removed from the source
* StatisticList.
*
* @param e The event.
*/
}
/**
* This class performs statistical calculations on a source
* StatisticList. Zones are regions in a set of samples which are set
* to be at 1, 2 and 3 standard deviations from the mean. ZONEC is
* closest to the center, with ZONEZ representing the region beyond
* ZONEA.
*/
{
/**
* Control zone C.
*/
/**
* Control zone B.
*/
/**
* Control zone A.
*/
/**
* Control zone Z.
*/
/**
* Direction from mean (used to test ZONELT and ZONEGT).
*/
/**
* Less than the mean.
*/
/**
* Greater than the mean.
*/
/**
* The raw statistical data.
*/
/**
* The mean of the samples.
*/
private double mean;
/**
* The standard deviation of the samples.
*/
private double sd;
/**
* The total of the samples.
*/
/**
* Constructs a new StatisticOperations object for working on
* the given statistic, whose values are in the given
* (modifiable) data set.
*
* @param statistics The statistics to operate on.
*/
{
this.statistics = statistics;
}
/**
* Calculate the standard deviation for the data held in the
* associated StatisticsList.
*/
private void calc_sd()
{
sd = 0;
}
}
/**
* Return a string which describes the zones for this set of
* data.
*
* @param kve The expression containing objectives.
* @param val The value to be assessed against objectives.
*/
{
if (isValid()) {
}
} else {
return ("Still sampling...");
}
}
/**
* Return a string which describes this instance.
*/
{
if (isValid()) {
"\n\tZones:" +
} else {
return ("Still sampling...");
}
}
/**
* Return true if the data is normally distributed. This
* method currently just returns true if the sample size is >=
* 5. It could be extended to use a test of normality, for
* instance "Pearson's Chi-Squared Test" or "Shapiro-Wilks W
* Test".
*/
public boolean isValid()
{
return (true);
return (false);
}
/**
* Calculate the statistical values for the associated
* samples. This method should be called when the sample
* population changes.
*/
private final void process()
{
calc_sd();
}
/**
* Return the control zone for the supplied value using the
* information derived from the monitored statistics and the
* objective expressed in the supplied objective expression.
*
* @param kve The target utilization expression.
* @param val The value to be evaluated.
*/
{
if (!isValid())
return (StatisticOperations.ZONEC);
}
}
/**
* Return the control zone for the supplied value using the
* information derived from the monitored statistics.
*
* @param val The value to be evaluated.
*/
{
if (!isValid())
return (StatisticOperations.ZONEC);
}
/**
* Return the control zone for the supplied value using the
* information derived from the supplied target.
*
* @param val The value to be evaluated.
*/
{
if (!isValid())
return (StatisticOperations.ZONEC);
}
/**
* Return the difference (gap) between the target utilization
* expressed in the supplied objective expression and the
* supplied value.
*
* @param kve Objective expression used to determine target
* utilization details.
* @param val The value to be assessed.
*/
{
if (!isValid())
return (0.0);
}
return (-100);
return (100);
else
}
/**
* Event handler for added statistics.
*
* @param e The event.
*/
{
process();
}
/**
* Event handler for removed statistics.
*
* @param e The event.
*/
{
process();
}
}