Class 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 to StatsSnapshot. Each mapped StatsSnapshot's value will be the total valid data size for all containers that belong to the account that is mapped with. The mapped StatsSnapshot's subMap will contain all the containers in the account that is mapped with. At the leaf level StatsSnapshot's subMap will be null.
    • 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 two StatsSnapshot and stores the result in the first one.
        Parameters:
        baseSnapshot - one of the addends and where the result will be
        newSnapshot - the other addend to be added into the first StatsSnapshot
      • 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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.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.