Package com.github.ambry.server
Class StatsSnapshot
- java.lang.Object
-
- com.github.ambry.server.StatsSnapshot
-
public class StatsSnapshot extends java.lang.Object
A model object to encapsulate stats in the form of a directory or tree. A example use case would be quota related stats which will be two levels deep. The first level's value will be the total valid data size for all accounts and the subMap field will contain a mapping of accountIds toStatsSnapshot
. Each mappedStatsSnapshot
's value will be the total valid data size for all containers that belong to the account that is mapped with. The mappedStatsSnapshot
's subMap will contain all the containers in the account that is mapped with. At the leaf levelStatsSnapshot
's subMap will be null.
-
-
Constructor Summary
Constructors Constructor Description StatsSnapshot()
StatsSnapshot(StatsSnapshot original)
A copy constructor.StatsSnapshot(java.lang.Long value, java.util.Map<java.lang.String,StatsSnapshot> subMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String str, StatsSnapshot statsSnapshot)
static void
aggregate(StatsSnapshot baseSnapshot, StatsSnapshot newSnapshot)
Performs recursive aggregation of twoStatsSnapshot
and stores the result in the first one.boolean
equals(java.lang.Object o)
java.util.Map<java.lang.String,StatsSnapshot>
getSubMap()
long
getValue()
int
hashCode()
void
removeZeroValueSnapshots()
Remove all 0-value snapshots in the sub map.void
setSubMap(java.util.Map<java.lang.String,StatsSnapshot> subMap)
void
setValue(long value)
void
updateValue()
Update the value in this snapshot by summing up all the subMap's StatsSnapshot's values.
-
-
-
Constructor Detail
-
StatsSnapshot
public StatsSnapshot(java.lang.Long value, java.util.Map<java.lang.String,StatsSnapshot> subMap)
-
StatsSnapshot
public StatsSnapshot()
-
StatsSnapshot
public StatsSnapshot(StatsSnapshot original)
A copy constructor.- Parameters:
original
- The original copy.
-
-
Method Detail
-
aggregate
public static void aggregate(StatsSnapshot baseSnapshot, StatsSnapshot newSnapshot)
Performs recursive aggregation of twoStatsSnapshot
and stores the result in the first one.- Parameters:
baseSnapshot
- one of the addends and where the result will benewSnapshot
- the other addend to be added into the firstStatsSnapshot
-
getValue
public long getValue()
-
getSubMap
public java.util.Map<java.lang.String,StatsSnapshot> getSubMap()
-
setValue
public void setValue(long value)
-
setSubMap
public void setSubMap(java.util.Map<java.lang.String,StatsSnapshot> subMap)
-
add
public void add(java.lang.String str, StatsSnapshot statsSnapshot)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
updateValue
public void updateValue()
Update the value in this snapshot by summing up all the subMap's StatsSnapshot's values.
-
removeZeroValueSnapshots
public void removeZeroValueSnapshots()
Remove all 0-value snapshots in the sub map.
-
-