com.gemstone.gemfire.StatisticsTypeFactory Maven / Gradle / Ivy
Show all versions of gemfire-core Show documentation
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* 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. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire;
//import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.StatArchiveFormat;
import java.io.IOException;
import java.io.Reader;
/**
* Instances of this interface provide methods that create instances
* of {@link StatisticDescriptor} and {@link StatisticsType}.
* Every {@link StatisticsFactory} is also a type factory.
*
*
*
* A StatisticsTypeFactory
can create a {@link
* StatisticDescriptor statistic} of three numeric types:
* int
, long
, and double
. A
* statistic (StatisticDescriptor
) can either be a
* gauge meaning that its value can increase and decrease or a
* counter meaning that its value is strictly increasing.
* Marking a statistic as a counter allows statistic display tools
* to properly display a statistics whose value "wraps around" (that
* is, exceeds its maximum value).
*
*
The following code is an example of how to create a type using XML.
* In this example the type has two stats whose values always increase:
*
StatisticsTypeFactory f = ...;
StatisticsType t = f.createType(
"StatSampler",
"Stats on the statistic sampler.",
new StatisticDescriptor[] {
f.createIntCounter("sampleCount",
"Total number of samples taken by this sampler.",
"samples"),
f.createLongCounter("sampleTime",
"Total amount of time spent taking samples.",
"milliseconds"),
}
);
*
* The following is an example of how to create the same type using XML.
* The XML data:
*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE statistics PUBLIC
"-//GemStone Systems, Inc.//GemFire Statistics Type//EN"
"http://www.gemstone.com/dtd/statisticsType.dtd">
<statistics>
<type name="StatSampler">
<description>Stats on the statistic sampler.</description>
<stat name="sampleCount" storage="int" counter="true">
<description>Total number of samples taken by this sampler.</description>
<unit>samples</unit>
</stat>
<stat name="sampleTime" storage="long" counter="true">
<description>Total amount of time spent taking samples.</description>
<unit>milliseconds</unit>
</stat>
</type>
</statistics>
*
* The code to create the type:
*
StatisticsTypeFactory f = ...;
Reader r = new InputStreamReader("fileContainingXmlData"));
StatisticsType type = f.createTypesFromXml(r)[0];
*
*
* @see Package introduction
*
* @author Darrel Schneider
*
* @since 3.0
*/
public interface StatisticsTypeFactory {
/**
* Creates and returns an int counter {@link StatisticDescriptor} with the given name
, description
, units
,
* and with larger values indicating better performance.
*/
public StatisticDescriptor createIntCounter(String name, String description,
String units);
/**
* Creates and returns a long counter {@link StatisticDescriptor} with the given name
, description
, units
,
* and with larger values indicating better performance.
*/
public StatisticDescriptor createLongCounter(String name, String description,
String units);
/**
* Creates and returns a double counter {@link StatisticDescriptor} with the given name
, description
, units
,
* and with larger values indicating better performance.
*/
public StatisticDescriptor createDoubleCounter(String name, String description,
String units);
/**
* Creates and returns an int gauge {@link StatisticDescriptor} with the given name
, description
, units
,
* and with smaller values indicating better performance.
*/
public StatisticDescriptor createIntGauge(String name, String description,
String units);
/**
* Creates and returns a long gauge {@link StatisticDescriptor} with the given name
, description
, units
,
* and with smaller values indicating better performance.
*/
public StatisticDescriptor createLongGauge(String name, String description,
String units);
/**
* Creates and returns a double gauge {@link StatisticDescriptor} with the given name
, description
, units
,
* and with smaller values indicating better performance.
*/
public StatisticDescriptor createDoubleGauge(String name, String description,
String units);
/**
* Creates and returns an int counter {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createIntCounter(String name, String description,
String units, boolean largerBetter);
/**
* Creates and returns a long counter {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createLongCounter(String name, String description,
String units, boolean largerBetter);
/**
* Creates and returns a double counter {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createDoubleCounter(String name, String description,
String units, boolean largerBetter);
/**
* Creates and returns an int gauge {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createIntGauge(String name, String description,
String units, boolean largerBetter);
/**
* Creates and returns a long gauge {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createLongGauge(String name, String description,
String units, boolean largerBetter);
/**
* Creates and returns a double gauge {@link StatisticDescriptor} with the given name
, description
, largerBetter
, and units
.
*/
public StatisticDescriptor createDoubleGauge(String name, String description,
String units, boolean largerBetter);
/**
* The maximum number of descriptors a single statistics type can have.
*
Current value is: 254
*/
public final int MAX_DESCRIPTORS_PER_TYPE = StatArchiveFormat.ILLEGAL_STAT_OFFSET-1;
/**
* Creates or finds and returns a {@link StatisticsType} with the given name
, description
, and {@link StatisticDescriptor statistic descriptions}.
* @throws IllegalArgumentException if a type with the given name
already exists and it differs from the given parameters.
*/
public StatisticsType createType(String name, String description,
StatisticDescriptor[] stats);
/**
* Finds and returns an already created {@link StatisticsType} with the given name
. Returns null
if the type does not exist.
*/
public StatisticsType findType(String name);
/**
* Creates one or more {@link StatisticsType} from the contents of the
* given reader
. The created types can be found by calling
* {@link #findType}.
*
* @param reader
* The source of the XML data which must comply with the
* statisticsType.dtd
.
*
* @throws IllegalArgumentException if a type defined in the reader
* already exists
* @throws IOException
* Something went wrong while reading from
* reader
*/
public StatisticsType[] createTypesFromXml(Reader reader)
throws IOException;
}