Package alluxio.metrics
Class Metric
- java.lang.Object
-
- alluxio.metrics.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 aMetric
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()
-
-
-
Field Detail
-
TAG_SEPARATOR
public static final java.lang.String TAG_SEPARATOR
- See Also:
- Constant Field Values
-
-
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 aMetric
instance.- Parameters:
instanceType
- the instance typesource
- the metric sourcemetricType
- the type of the metricname
- the metric namevalue
- the value
-
-
Method Detail
-
addValue
public void addValue(double delta)
Add metric value delta to the existing value. This method should only be used byalluxio.master.metrics.MetricsStore
- Parameters:
delta
- value to add
-
setValue
public void setValue(double value)
Set the metric value. This method should only be used byalluxio.master.metrics.MetricsStore
- Parameters:
value
- value to set
-
getValue
public double getValue()
- Returns:
- the metric value
-
getInstanceType
public MetricsSystem.InstanceType getInstanceType()
- Returns:
- the instance type
-
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 namevalue
- 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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.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 nametags
- 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 metricuserName
- 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 namevalue
- the valuemetricType
- 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 classjava.lang.Object
-
-