Interface CacheStatistics


  • public interface CacheStatistics
    Defines common statistics information for both region and entries. All of these methods may throw a CacheClosedException, RegionDestroyedException or an EntryDestroyedException.
    Since:
    GemFire 2.0
    See Also:
    Region.getStatistics(), Region.Entry.getStatistics()
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long getHitCount()
      Returns the number of hits for this region or entry.
      float getHitRatio()
      Return the hit ratio, a convenience method defined as the ratio of hits to the number of calls to Region.get.
      long getLastAccessedTime()
      For an entry, returns the last time it was accessed via Region.get; for a region, the last time any of its entries or the entries of its subregions were accessed with Region.get.
      long getLastModifiedTime()
      For an entry, returns the time that the entry's value was last modified; for a region, the last time any of the region's entries' values or the values in subregions' entries were modified.
      long getMissCount()
      Returns the number of times that Region.get on the region or the entry was called and there was no value found locally.
      void resetCounts()
      Reset the missCount and hitCount to zero for this entry.
    • Method Detail

      • getLastModifiedTime

        long getLastModifiedTime()
        For an entry, returns the time that the entry's value was last modified; for a region, the last time any of the region's entries' values or the values in subregions' entries were modified. The modification may have been initiated locally or it may have been an update distributed from another cache. It may also have been a new value provided by a loader. The modification time on a region is propagated upward to parent regions, transitively, to the root region.

        The number is expressed as the number of milliseconds since January 1, 1970. The granularity may be as course as 100ms, so the accuracy may be off by up to 50ms.

        Entry and subregion creation will update the modification time on a region, but destroy, destroyRegion, invalidate, and invalidateRegion do not update the modification time.

        Returns:
        the last modification time of the region or the entry; returns 0 if entry is invalid or modification time is uninitialized.
        See Also:
        Region.put(Object, Object), Region.get(Object), Region.create(Object, Object), Region.createSubregion(java.lang.String, org.apache.geode.cache.RegionAttributes<SK, SV>)
      • getLastAccessedTime

        long getLastAccessedTime()
                          throws StatisticsDisabledException
        For an entry, returns the last time it was accessed via Region.get; for a region, the last time any of its entries or the entries of its subregions were accessed with Region.get. Any modifications will also update the lastAccessedTime, so lastAccessedTime is always >= lastModifiedTime. The lastAccessedTime on a region is propagated upward to parent regions, transitively, to the the root region.

        The number is expressed as the number of milliseconds since January 1, 1970. The granularity may be as course as 100ms, so the accuracy may be off by up to 50ms.

        Returns:
        the last access time of the region or the entry's value; returns 0 if entry is invalid or access time is uninitialized.
        Throws:
        StatisticsDisabledException - if statistics are not available
        See Also:
        Region.get(Object), getLastModifiedTime()
      • getMissCount

        long getMissCount()
                   throws StatisticsDisabledException
        Returns the number of times that Region.get on the region or the entry was called and there was no value found locally. Unlike lastAccessedTime, the miss count is not propagated to parent regions. Note that remote operations such as a "net search" do not effect the miss count.
        Returns:
        the number of cache misses on the region or the entry.
        Throws:
        StatisticsDisabledException - if statistics are not available
      • getHitCount

        long getHitCount()
                  throws StatisticsDisabledException
        Returns the number of hits for this region or entry. The number of hits is defined as the number of times when the Region.get finds a value locally. Unlike lastAccessedTime, the hit count is not propagated to parent regions. Note that remote operations such as a "net search" do not effect the hit count.
        Returns:
        the number of hits for this region or entry.
        Throws:
        StatisticsDisabledException - if statistics are not available
      • getHitRatio

        float getHitRatio()
                   throws StatisticsDisabledException
        Return the hit ratio, a convenience method defined as the ratio of hits to the number of calls to Region.get. If there have been zero calls to Region.get, then zero is returned.

        The hit ratio is equivalent to:

         long hitCount = getHitCount();
         long total = hitCount + getMissCount();
         return total == 0L ? 0.0f : ((float) hitCount / total);
         
        Returns:
        the hit ratio as a float
        Throws:
        StatisticsDisabledException - if statistics are not available