Package org.apache.hadoop.hdfs.util
Class EnumCounters<E extends Enum<E>>
java.lang.Object
org.apache.hadoop.hdfs.util.EnumCounters<E>
- Type Parameters:
E- the enum type
- Direct Known Subclasses:
ConstEnumCounters,NumberReplicas,Quota.Counts
Counters for an enum type.
For example, suppose there is an enum type
enum Fruit { APPLE, ORANGE, GRAPE }
An EnumCounters object can be created for counting the numbers of
APPLE, ORANGE and GRAPE.-
Constructor Summary
ConstructorsConstructorDescriptionEnumCounters(Class<E> enumClass) Construct counters for the given enum constants.EnumCounters(Class<E> enumClass, long defaultVal) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the given value to counter e.voidadd(EnumCounters<E> that) Add that counters to this counters.booleanallLessOrEqual(long val) booleananyGreaterOrEqual(long val) long[]asArray()Return a deep copy of EnumCounter.booleanfinal longinthashCode()voidnegation()Negate all counters.voidreset()Reset all counters to zero.voidreset(long val) voidSet counter e to the given value.voidset(EnumCounters<E> that) Set this counters to that counters.voidSubtract the given value from counter e.voidsubtract(EnumCounters<E> that) Subtract this counters from that counters.longsum()toString()
-
Constructor Details
-
EnumCounters
Construct counters for the given enum constants.- Parameters:
enumClass- the enum class of the counters.
-
EnumCounters
-
-
Method Details
-
get
- Returns:
- the value of counter e.
-
asArray
public long[] asArray()- Returns:
- the values of counter as a shadow copy of array
-
negation
public void negation()Negate all counters. -
set
Set counter e to the given value. -
set
Set this counters to that counters. -
reset
public void reset()Reset all counters to zero. -
add
Add the given value to counter e. -
add
Add that counters to this counters. -
subtract
Subtract the given value from counter e. -
subtract
Subtract this counters from that counters. -
sum
public long sum()- Returns:
- the sum of all counters.
-
equals
-
deepCopyEnumCounter
Return a deep copy of EnumCounter. -
hashCode
public int hashCode() -
toString
-
reset
public void reset(long val) -
allLessOrEqual
public boolean allLessOrEqual(long val) -
anyGreaterOrEqual
public boolean anyGreaterOrEqual(long val)
-