Class ClusterAwareHitMissMetricsHolder

java.lang.Object
com.mysql.cj.jdbc.ha.ca.ClusterAwareHitMissMetricsHolder

public class ClusterAwareHitMissMetricsHolder
extends java.lang.Object
A simple implementation of hit-miss metric. It collects a total number of events been reported as well as number of "hit" events.

Example of hit-miss metric: loaded or not loaded data, data found in cache or not found.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String metricName  
    protected int numberOfHits  
    protected int numberOfReports  
  • Constructor Summary

    Constructors 
    Constructor Description
    ClusterAwareHitMissMetricsHolder​(java.lang.String metricName)
    Initialize a metric holder with a metric name.
  • Method Summary

    Modifier and Type Method Description
    void register​(boolean isHit)
    Register (notify) a metric holder about event.
    void reportMetrics​(Log log)
    Report collected metric to a provided logger.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ClusterAwareHitMissMetricsHolder

      public ClusterAwareHitMissMetricsHolder​(java.lang.String metricName)
      Initialize a metric holder with a metric name.
      Parameters:
      metricName - Metric name
  • Method Details

    • register

      public void register​(boolean isHit)
      Register (notify) a metric holder about event.
      Parameters:
      isHit - True if event is a "hit" event.
    • reportMetrics

      public void reportMetrics​(Log log)
      Report collected metric to a provided logger.
      Parameters:
      log - A logger to report collected metric.