Class Metric

  • All Implemented Interfaces:
    java.io.Serializable

    public final class Metric
    extends java.lang.Object
    implements java.io.Serializable
    A metric of a given instance. The instance can be master, worker, or client.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String TAG_SEPARATOR  
    • Constructor Summary

      Constructors 
      Constructor Description
      Metric​(MetricsSystem.InstanceType instanceType, java.lang.String source, alluxio.grpc.MetricType metricType, java.lang.String name, java.lang.Double value)
      Constructs a Metric instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTag​(java.lang.String name, java.lang.String value)
      Adds a new tag.
      void addValue​(double delta)
      Add metric value delta to the existing value.
      boolean equals​(java.lang.Object other)  
      static Metric from​(java.lang.String fullName, double value, alluxio.grpc.MetricType metricType)
      Creates the metric from the full name and the value.
      static Metric fromProto​(alluxio.grpc.Metric metric)
      Constructs the metric object from the proto format.
      static java.lang.String getBaseName​(java.lang.String fullName)
      Gets the simple name without the tags.
      java.lang.String getFullMetricName()  
      MetricsSystem.InstanceType getInstanceType()  
      static java.lang.String getMetricNameWithTags​(java.lang.String name, java.lang.String... tags)
      Gets the metric name with the appendix of tags.
      static java.lang.String getMetricNameWithUserTag​(java.lang.String metricName, java.lang.String userName)
      Gets a metric name with a specific user tag.
      alluxio.grpc.MetricType getMetricType()  
      java.lang.String getName()  
      java.lang.String getSource()  
      java.util.Map<java.lang.String,​java.lang.String> getTags()  
      static java.lang.String getTagUfsValueFromFullName​(java.lang.String fullName)
      Gets value of ufs tag from the full metric name.
      double getValue()  
      int hashCode()  
      void setValue​(double value)
      Set the metric value.
      alluxio.grpc.Metric toProto()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Metric

        public Metric​(MetricsSystem.InstanceType instanceType,
                      java.lang.String source,
                      alluxio.grpc.MetricType metricType,
                      java.lang.String name,
                      java.lang.Double value)
        Constructs a Metric instance.
        Parameters:
        instanceType - the instance type
        source - the metric source
        metricType - the type of the metric
        name - the metric name
        value - the value
    • Method Detail

      • addValue

        public void addValue​(double delta)
        Add metric value delta to the existing value. This method should only be used by alluxio.master.metrics.MetricsStore
        Parameters:
        delta - value to add
      • setValue

        public void setValue​(double value)
        Set the metric value. This method should only be used by alluxio.master.metrics.MetricsStore
        Parameters:
        value - value to set
      • getValue

        public double getValue()
        Returns:
        the metric value
      • addTag

        public void addTag​(java.lang.String name,
                           java.lang.String value)
        Adds a new tag. If the tag name already exists, it will be replaced.
        Parameters:
        name - the tag name
        value - the tag value
      • getSource

        public java.lang.String getSource()
        Returns:
        the metric source
      • getMetricType

        public alluxio.grpc.MetricType getMetricType()
        Returns:
        the metric type
      • getName

        public java.lang.String getName()
        Returns:
        the metric name
      • getTags

        public java.util.Map<java.lang.String,​java.lang.String> getTags()
        Returns:
        the tags
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getFullMetricName

        public java.lang.String getFullMetricName()
        Returns:
        the fully qualified metric name, which is of pattern instance.name[.tagName:tagValue]*[.source], where the tags are appended at the end
      • toProto

        public alluxio.grpc.Metric toProto()
        Returns:
        the proto object it converts to. Note the value must be either integer or long
      • getMetricNameWithTags

        public static java.lang.String getMetricNameWithTags​(java.lang.String name,
                                                             java.lang.String... tags)
        Gets the metric name with the appendix of tags. The returned name is of the pattern name[.tagName:tagValue]*.
        Parameters:
        name - the metric name
        tags - the tag name and tag value pairs
        Returns:
        the name with the tags appended
      • getMetricNameWithUserTag

        public static java.lang.String getMetricNameWithUserTag​(java.lang.String metricName,
                                                                java.lang.String userName)
        Gets a metric name with a specific user tag.
        Parameters:
        metricName - the name of the metric
        userName - the user
        Returns:
        a metric name with the user tagged
      • getTagUfsValueFromFullName

        public static java.lang.String getTagUfsValueFromFullName​(java.lang.String fullName)
        Gets value of ufs tag from the full metric name.
        Parameters:
        fullName - the full metric name
        Returns:
        value of ufs tag
      • getBaseName

        public static java.lang.String getBaseName​(java.lang.String fullName)
        Gets the simple name without the tags.
        Parameters:
        fullName - the full metric name
        Returns:
        the base name
      • from

        public static Metric from​(java.lang.String fullName,
                                  double value,
                                  alluxio.grpc.MetricType metricType)
        Creates the metric from the full name and the value.
        Parameters:
        fullName - the full name
        value - the value
        metricType - the type of metric that is being created
        Returns:
        the created metric
      • fromProto

        public static Metric fromProto​(alluxio.grpc.Metric metric)
        Constructs the metric object from the proto format.
        Parameters:
        metric - the metric in proto format
        Returns:
        the constructed metric
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object