All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gemstone.gemfire.StatisticsFactory Maven / Gradle / Ivy

There is a newer version: 2.0-BETA
Show newest version
/*
 * 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 Statistics}.
 * It can also be used to create instances of {@link StatisticDescriptor}
 * and {@link StatisticsType} because it implements {@link StatisticsTypeFactory}.
 * {@link
 * com.gemstone.gemfire.distributed.DistributedSystem} is the only
 * instance of this interface.
 *
 * 

* * A StatisticsFactory 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 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.createIntCounter("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.incInt(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="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: *
      StatisticsFactory f = ...;
      Reader r = new InputStreamReader("fileContainingXmlData"));
      StatisticsType type = f.createTypesFromXml(r)[0];
 * 
*

* @see Package introduction * * @author Darrel Schneider * * @since 3.0 */ public interface StatisticsFactory extends StatisticsTypeFactory { /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type} with default ids. *

* The created instance may not be {@link Statistics#isAtomic atomic}. */ public Statistics createStatistics(StatisticsType type); /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type}, textId, and with a default numeric id. *

* The created instance may not be {@link Statistics#isAtomic atomic}. */ public Statistics createStatistics(StatisticsType type, String textId); /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type}, textId, and numericId. *

* The created instance may not be {@link Statistics#isAtomic atomic}. */ public Statistics createStatistics(StatisticsType type, String textId, long numericId); /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type} with default ids. *

* The created instance will be {@link Statistics#isAtomic atomic}. */ public Statistics createAtomicStatistics(StatisticsType type); /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type}, textId, and with a default numeric id. *

* The created instance will be {@link Statistics#isAtomic atomic}. */ public Statistics createAtomicStatistics(StatisticsType type, String textId); /** * Creates and returns a {@link Statistics} instance of the given {@link StatisticsType type}, textId, and numericId. *

* The created instance will be {@link Statistics#isAtomic atomic}. */ public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId); /** * Creates and returns a {@link Statistics} instance of the given * {@link StatisticsType type}, textId, numericId * and uniqueId. *

* The created instance will be {@link Statistics#isAtomic atomic}. */ public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId, long uniqueId); /** * Returns an array of all the existing statistics of the given type. */ public Statistics[] findStatisticsByType(StatisticsType type); /** * Returns an array of all the existing statistics with the given textId. */ public Statistics[] findStatisticsByTextId(String textId); /** * Returns an array of all the existing statistics with the given numericId. */ public Statistics[] findStatisticsByNumericId(long numericId); public Statistics findStatisticsByUniqueId(long uniqueId); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy