VMware GemFire Java API Reference
Interface StatisticsFactory
-
- All Superinterfaces:
StatisticsTypeFactory
- All Known Implementing Classes:
DistributedSystem
public interface StatisticsFactory extends StatisticsTypeFactory
Instances of this interface provide methods that create instances ofStatistics. It can also be used to create instances ofStatisticDescriptorandStatisticsTypebecause it implementsStatisticsTypeFactory.DistributedSystemis the only instance of this interface.A
StatisticsFactorycan create astatisticof two numeric types:long, anddouble. 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.The following code is an example of how to create a type using the api. In this example the type has two stats whose values always increase:
StatisticsFactory f = ...; StatisticsType t = f.createType( "StatSampler", "Stats on the statistic sampler.", new StatisticDescriptor[] { f.createLongCounter("sampleCount", "Total number of samples taken by this sampler.", "samples"), f.createLongCounter("sampleTime", "Total amount of time spent taking samples.", "milliseconds"), } ); this.samplerStats = f.createStatistics(t, "statSampler"); this.sampleCountId = this.samplerStats.nameToId("sampleCount"); this.sampleTimeId = this.samplerStats.nameToId("sampleTime");Later on the stat ids can be used to increment the stats:this.samplerStats.incLong(this.sampleCountId, 1); this.samplerStats.incLong(this.sampleTimeId, nanosSpentWorking / 1000000);
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="long" 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:StatisticsFactory f = ...; Reader r = new InputStreamReader("fileContainingXmlData")); StatisticsType type = f.createTypesFromXml(r)[0];- Since:
- GemFire 3.0
- See Also:
- Package introduction
-
-
Field Summary
-
Fields inherited from interface org.apache.geode.StatisticsTypeFactory
MAX_DESCRIPTORS_PER_TYPE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StatisticscreateAtomicStatistics(StatisticsType type)Creates and returns aStatisticsinstance of the giventypewith default ids.StatisticscreateAtomicStatistics(StatisticsType type, java.lang.String textId)StatisticscreateAtomicStatistics(StatisticsType type, java.lang.String textId, long numericId)StatisticscreateStatistics(StatisticsType type)Creates and returns aStatisticsinstance of the giventypewith default ids.StatisticscreateStatistics(StatisticsType type, java.lang.String textId)StatisticscreateStatistics(StatisticsType type, java.lang.String textId, long numericId)Statistics[]findStatisticsByNumericId(long numericId)Returns an array of all the existing statistics with the given numericId.Statistics[]findStatisticsByTextId(java.lang.String textId)Returns an array of all the existing statistics with the given textId.Statistics[]findStatisticsByType(StatisticsType type)Returns an array of all the existing statistics of the given type.-
Methods inherited from interface org.apache.geode.StatisticsTypeFactory
createDoubleCounter, createDoubleCounter, createDoubleGauge, createDoubleGauge, createIntCounter, createIntCounter, createIntGauge, createIntGauge, createLongCounter, createLongCounter, createLongGauge, createLongGauge, createType, createTypesFromXml, findType
-
-
-
-
Method Detail
-
createStatistics
Statistics createStatistics(StatisticsType type)
Creates and returns aStatisticsinstance of the giventypewith default ids.The created instance may not be
atomic.- Parameters:
type- thetypeofStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
createStatistics
Statistics createStatistics(StatisticsType type, java.lang.String textId)
Creates and returns aStatisticsinstance of the giventype,textId, and with a default numeric id.The created instance may not be
atomic.- Parameters:
type- thetypeofStatisticsinstancetextId- thetextIdof theStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
createStatistics
Statistics createStatistics(StatisticsType type, java.lang.String textId, long numericId)
Creates and returns aStatisticsinstance of the giventype,textId, andnumericId.The created instance may not be
atomic.- Parameters:
type- thetypeofStatisticsinstancetextId- thetextIdof theStatisticsinstancenumericId- thenumericIdof theStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
createAtomicStatistics
Statistics createAtomicStatistics(StatisticsType type)
Creates and returns aStatisticsinstance of the giventypewith default ids.The created instance will be
atomic.- Parameters:
type- thetypeofStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
createAtomicStatistics
Statistics createAtomicStatistics(StatisticsType type, java.lang.String textId)
Creates and returns aStatisticsinstance of the giventype,textId, and with a default numeric id.The created instance will be
atomic.- Parameters:
type- thetypeofStatisticsinstancetextId- thetextIdof theStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
createAtomicStatistics
Statistics createAtomicStatistics(StatisticsType type, java.lang.String textId, long numericId)
Creates and returns aStatisticsinstance of the giventype,textId, andnumericId.The created instance will be
atomic.- Parameters:
type- thetypeofStatisticsinstancetextId- thetextIdof theStatisticsinstancenumericId- thenumericIdof theStatisticsinstance- Returns:
- a newly created
Statisticsinstance
-
findStatisticsByType
Statistics[] findStatisticsByType(StatisticsType type)
Returns an array of all the existing statistics of the given type.- Parameters:
type- thetypeof statistics to find- Returns:
- an array of all the existing statistics of the given type
-
findStatisticsByTextId
Statistics[] findStatisticsByTextId(java.lang.String textId)
Returns an array of all the existing statistics with the given textId.- Parameters:
textId- the textId of statistics to find- Returns:
- an array of all the existing statistics with the given textId
-
findStatisticsByNumericId
Statistics[] findStatisticsByNumericId(long numericId)
Returns an array of all the existing statistics with the given numericId.- Parameters:
numericId- the numericId of statistics to find- Returns:
- an array of all the existing statistics with the given numericId
-
-