Package org.apache.cassandra.metrics
Class CassandraMetricsRegistry.MetricName
- java.lang.Object
-
- org.apache.cassandra.metrics.CassandraMetricsRegistry.MetricName
-
- All Implemented Interfaces:
java.lang.Comparable<CassandraMetricsRegistry.MetricName>
- Enclosing class:
- CassandraMetricsRegistry
public static class CassandraMetricsRegistry.MetricName extends java.lang.Object implements java.lang.Comparable<CassandraMetricsRegistry.MetricName>
A value class encapsulating a metric's owning class and name.
-
-
Constructor Summary
Constructors Constructor Description MetricName(java.lang.Class<?> klass, java.lang.String name)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.MetricName(java.lang.Class<?> klass, java.lang.String name, java.lang.String scope)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.MetricName(java.lang.String group, java.lang.String type, java.lang.String name)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope, java.lang.String mBeanName)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
chooseGroup(java.lang.String group, java.lang.Class<?> klass)
If the group is empty, use the package name of the given class.static java.lang.String
chooseName(java.lang.String name, java.lang.reflect.Method method)
If name is empty, use the name of the given method.static java.lang.String
chooseType(java.lang.String type, java.lang.Class<?> klass)
If the type is empty, use the simple name of the given class.int
compareTo(CassandraMetricsRegistry.MetricName o)
boolean
equals(java.lang.Object o)
java.lang.String
getGroup()
Returns the group to which theMetric
belongs.javax.management.ObjectName
getMBeanName()
Returns the MBean name for theMetric
identified by this metric name.java.lang.String
getMetricName()
java.lang.String
getName()
Returns the name of theMetric
.java.lang.String
getScope()
Returns the scope of theMetric
.java.lang.String
getType()
Returns the type to which theMetric
belongs.int
hashCode()
boolean
hasScope()
Returnstrue
if theMetric
has a scope,false
otherwise.java.lang.String
toString()
-
-
-
Constructor Detail
-
MetricName
public MetricName(java.lang.Class<?> klass, java.lang.String name)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.- Parameters:
klass
- theClass
to which theMetric
belongsname
- the name of theMetric
-
MetricName
public MetricName(java.lang.String group, java.lang.String type, java.lang.String name)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.- Parameters:
group
- the group to which theMetric
belongstype
- the type to which theMetric
belongsname
- the name of theMetric
-
MetricName
public MetricName(java.lang.Class<?> klass, java.lang.String name, java.lang.String scope)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.- Parameters:
klass
- theClass
to which theMetric
belongsname
- the name of theMetric
scope
- the scope of theMetric
-
MetricName
public MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.- Parameters:
group
- the group to which theMetric
belongstype
- the type to which theMetric
belongsname
- the name of theMetric
scope
- the scope of theMetric
-
MetricName
public MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope, java.lang.String mBeanName)
Creates a newCassandraMetricsRegistry.MetricName
without a scope.- Parameters:
group
- the group to which theMetric
belongstype
- the type to which theMetric
belongsname
- the name of theMetric
scope
- the scope of theMetric
mBeanName
- the 'ObjectName', represented as a string, to use when registering the MBean.
-
-
Method Detail
-
getGroup
public java.lang.String getGroup()
Returns the group to which theMetric
belongs. For class-based metrics, this will be the package name of theClass
to which theMetric
belongs.- Returns:
- the group to which the
Metric
belongs
-
getType
public java.lang.String getType()
Returns the type to which theMetric
belongs. For class-based metrics, this will be the simple class name of theClass
to which theMetric
belongs.- Returns:
- the type to which the
Metric
belongs
-
getName
public java.lang.String getName()
Returns the name of theMetric
.- Returns:
- the name of the
Metric
-
getMetricName
public java.lang.String getMetricName()
-
getScope
public java.lang.String getScope()
Returns the scope of theMetric
.- Returns:
- the scope of the
Metric
-
hasScope
public boolean hasScope()
Returnstrue
if theMetric
has a scope,false
otherwise.- Returns:
true
if theMetric
has a scope
-
getMBeanName
public javax.management.ObjectName getMBeanName()
Returns the MBean name for theMetric
identified by this metric name.- Returns:
- the MBean name
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(CassandraMetricsRegistry.MetricName o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<CassandraMetricsRegistry.MetricName>
-
chooseGroup
public static java.lang.String chooseGroup(java.lang.String group, java.lang.Class<?> klass)
If the group is empty, use the package name of the given class. Otherwise use group- Parameters:
group
- The group to use by defaultklass
- The class being tracked- Returns:
- a group for the metric
-
chooseType
public static java.lang.String chooseType(java.lang.String type, java.lang.Class<?> klass)
If the type is empty, use the simple name of the given class. Otherwise use type- Parameters:
type
- The type to use by defaultklass
- The class being tracked- Returns:
- a type for the metric
-
chooseName
public static java.lang.String chooseName(java.lang.String name, java.lang.reflect.Method method)
If name is empty, use the name of the given method. Otherwise use name- Parameters:
name
- The name to use by defaultmethod
- The method being tracked- Returns:
- a name for the metric
-
-