com.gemstone.gbjstats

## Class GbjCacheStats

- java.lang.Object
- - com.gemstone.gbjgci.GbjGciCacheStats
  - - com.gemstone.gbjstats.GbjCacheStats

-     public class GbjCacheStats
      extends GbjGciCacheStats

  GbjCacheStats provides an application-friendly level of access to shared page cache statistics. The class represents a batch of cache stats associated with a particular GS process, and extends the low-level GbjGciCacheStats class, which provides the basic fields for representing the stat info, including:

  " "
  • | name | The name of the process generating these stats
  • | pid | The process ID
  • | sid | The session ID
  • | type | An integer representing the type of GS process
  • | stats32 | An int[] array for holding the 32-bit stats
  • | stats64 | A long[] array for holding the 64-bit stats

  Useful behavior defined in GbjCacheStats includes:

  " "
  • | attach | Attach to a particular shared page cache
  • | sample | Take a sample of all cache stats for all processes associated with this shared page cache
  • | fetch | Fetch the batch of stats associated with a particular GS process that were taken during a prior sample()
  • | get | Get the single stat value associated with the given name
  • | detach | Detach from the shared page cache

  The following is a code snippet demonstrating a typical calling sequence for using these functions:

              // Initialize Pid tracking lists
              List<Long> newPids  = new ArrayList<Long>(maxProcs);
              List<Long> oldPids  = new ArrayList<Long>(maxProcs);
              List<Long> deadPids = new ArrayList<Long>(maxProcs);

              // Attach cache
              int maxProcs = GbjCacheStats.attach("StoneName");

              // Take first sample
              GbjCacheStats.sample(newPids, oldPids, deadPids);

              // Get stat from a process of interest
              GbjCacheStats myStats = GbjCacheStats.fetch(PidOfInterest);
              long stat = myStats.get("StatOfInterest");

              // Loop over time and update stat
              do {
                  // sleep for some time interval..
                  Thread.currentThread().sleep(SleepTimeInMilliseconds);

                  // Take next sample
                  GbjCacheStats.sample(newPids, oldPids, deadPids);

                  // Update our stat info from new sample
                  myStats.update();
                  stat = myStats.get("StatOfInterest");

              } while (true);

              // when done, detach the cache
              GbjCacheStats.detach();

  Version:
    3.1

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GbjCacheStats.CacheType` A representation for various types of GS processes

  - ### Field Summary

    - ### Fields inherited from class com.gemstone.gbjgci.GbjGciCacheStats

      `name, pid, sid, stats32, stats64, type, TYPE_APP, TYPE_GEM, TYPE_PGSVR, TYPE_SPCMONITOR, TYPE_STATMON, TYPE_STONE, TYPE_SYSTEM, TYPE_UNASSIGNED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GbjCacheStats(long p)` Establish a set of cache stats associated with this process ID

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `attach(java.lang.String stnName)` Attach to a particular shared page cache
    `java.lang.String` | `cacheTypeString()` Return the type of cache stat: spcmon, stone, pgsvr, gem
    `static void` | `detach()` Detach from this shared page cache
    `static GbjCacheStats` | `fetch(long pid)` Return the GbjCacheStats associated with this process ID taken during a prior sample( ).
    `long` | `get(java.lang.String name)` Return the value of the stat with this given name
    `static void` | `sample(java.util.List<java.lang.Long> newPids, java.util.List<java.lang.Long> oldPids, java.util.List<java.lang.Long> deadPids)` Sample all the cache statistics associated with this stone/shared page cache.
    `java.lang.String[]` | `statNames()` Return the list of stat names associated with this stat
    `void` | `update()` Update (refresh) the information for this cache stat with the data taken from the last sample()

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GbjCacheStats

          public GbjCacheStats(long p)

      Establish a set of cache stats associated with this process ID
      Parameters:
        `p` - long process ID

  - ### Method Detail

    - #### cacheTypeString

          public java.lang.String cacheTypeString()

      Return the type of cache stat: spcmon, stone, pgsvr, gem
      Returns:
        String representing type of cache stat

    - #### attach

          public static int attach(java.lang.String stnName)

      Attach to a particular shared page cache
      Parameters:
        `stnName` - String name of stone
      Returns:
        the maximum number of processes that can use this shared page cache

    - #### detach

          public static void detach()

      Detach from this shared page cache

    - #### sample

          public static void sample(java.util.List<java.lang.Long> newPids,
                                    java.util.List<java.lang.Long> oldPids,
                                    java.util.List<java.lang.Long> deadPids)

      Sample all the cache statistics associated with this stone/shared page cache. The arguments are lists used to return process ID information as follows:

      newPids - processes that have appeared since the last sample
      oldPids - processes which existed during the last sample
      deadPids - processes which have disappeared since the last sample

      These lists should be initialized using:

      new ArrayList<Long>(maxProcs)

      Where maxProcs is the maximum number of processes returned by the GbjGciStats.attach() call.

      Note that the first time this method is called, *all* processes will be returned as newPids with oldPids and deadPids empty.

      Parameters:
        `newPids` - List of long process ID's that just appeared
        `oldPids` - List of long process ID's that were in last sample
        `deadPids` - List of long process ID's that have disappeard

    - #### update

          public void update()

      Update (refresh) the information for this cache stat with the data taken from the last sample()

    - #### fetch

          public static GbjCacheStats fetch(long pid)

      Return the GbjCacheStats associated with this process ID taken during a prior sample( ).
      Parameters:
        `pid` - long process ID
      Returns:
        GbjCacheStats result

    - #### get

          public long get(java.lang.String name)
                   throws java.lang.IllegalArgumentException

      Return the value of the stat with this given name
      Parameters:
        `name` - String name of stat
      Returns:
        long value of stat
      Throws:
        `java.lang.IllegalArgumentException` - thrown if stat name doesn't exist

    - #### statNames

          public java.lang.String[] statNames()

      Return the list of stat names associated with this stat
      Returns:
        array of strings containing names of stats