Class MetricImpl<T>
- java.lang.Object
-
- org.apache.solr.cluster.placement.impl.MetricImpl<T>
-
- All Implemented Interfaces:
Metric<T>
- Direct Known Subclasses:
NodeMetricImpl
,ReplicaMetricImpl
public abstract class MetricImpl<T> extends Object implements Metric<T>
Base class forMetric
implementations.
-
-
Field Summary
Fields Modifier and Type Field Description static Function<Object,Double>
BYTES_TO_GB_CONVERTER
Bytes to gigabytes converter.protected Function<Object,T>
converter
static double
GB
Function<Object,T>
IDENTITY_CONVERTER
Identity converter.protected String
internalName
protected String
name
-
Constructor Summary
Constructors Constructor Description MetricImpl(String name, String internalName)
Create a metric attribute.MetricImpl(String name, String internalName, Function<Object,T> converter)
Create a metric attribute.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
convert(Object value)
Convert raw value.boolean
equals(Object o)
String
getInternalName()
Return the internal name of a Solr metric associated with this attribute.String
getName()
Return the short-hand name that identifies this attribute.int
hashCode()
String
toString()
-
-
-
Field Detail
-
GB
public static final double GB
- See Also:
- Constant Field Values
-
IDENTITY_CONVERTER
public final Function<Object,T> IDENTITY_CONVERTER
Identity converter. It returns the raw value unchanged IFF the value's type can be cast to the generic type of this attribute, otherwise it returns null.
-
BYTES_TO_GB_CONVERTER
public static final Function<Object,Double> BYTES_TO_GB_CONVERTER
Bytes to gigabytes converter. Supports converting number or string representations of raw values expressed in bytes.
-
name
protected final String name
-
internalName
protected final String internalName
-
-
Constructor Detail
-
MetricImpl
public MetricImpl(String name, String internalName)
Create a metric attribute.- Parameters:
name
- short-hand name that identifies this attribute.internalName
- internal name of a Solr metric.
-
MetricImpl
public MetricImpl(String name, String internalName, Function<Object,T> converter)
Create a metric attribute.- Parameters:
name
- short-hand name that identifies this attribute.internalName
- internal name of a Solr metric.converter
- optional raw value converter. If null thenIDENTITY_CONVERTER
will be used.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:Metric
Return the short-hand name that identifies this attribute.
-
getInternalName
public String getInternalName()
Description copied from interface:Metric
Return the internal name of a Solr metric associated with this attribute.- Specified by:
getInternalName
in interfaceMetric<T>
-
convert
public T convert(Object value)
Description copied from interface:Metric
Convert raw value. This may involve changing raw value type or units.
-
-