Interface AccountStatsStore


  • public interface AccountStatsStore
    The interface that stores and fetches account stats, aggregated account stats. TODO: Add methods to support partition class stats.
    • Method Detail

      • storeStats

        void storeStats​(StatsWrapper statsWrapper)
                 throws java.lang.Exception
        Store stats in the StatsWrapper. The StatsWrapper's StatsSnapshot should include partition, account and container. This method will be used for individual ambry server to store local stats.
        Parameters:
        statsWrapper - The StatsWrapper that contains stats and other metadata.
        Throws:
        java.lang.Exception
      • storeAggregatedStats

        void storeAggregatedStats​(StatsSnapshot snapshot)
                           throws java.lang.Exception
        Store aggregated stats in the StatsSnapshot. The StatsSnapshot should include account and container. This method will be used for aggregation task to store aggregated stats.
        Parameters:
        snapshot - The StatsSnapshot that contains aggregated container usage.
        Throws:
        java.lang.Exception
      • queryStatsOf

        StatsWrapper queryStatsOf​(java.lang.String clusterName,
                                  java.lang.String hostname)
                           throws java.lang.Exception
        Return individual ambry server's stats for the given clusterName and hostname. This is the stats stored by method storeStats(com.github.ambry.server.StatsWrapper).
        Parameters:
        clusterName - The clusterName.
        hostname - The hostname.
        Returns:
        StatsWrapper of given hostname in the clusterName.
        Throws:
        java.lang.Exception
      • queryAggregatedStats

        java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Long>> queryAggregatedStats​(java.lang.String clusterName)
                                                                                                                 throws java.lang.Exception
        Return the aggregated stats for the given clusterName. This is the stats stored by method storeAggregatedStats(com.github.ambry.server.StatsSnapshot). Since the StatsSnapshot passed to storeAggregatedStats(com.github.ambry.server.StatsSnapshot) only have account and container stats, this method returns a map back to the caller. The key of the outer map is the account id in string format, and the key of the inner map is the container id in string format, the value of the inner map is the storage usage for this container.
           {
             "1001": {
               "1": 10456,
               "2": 75637292
             },
             "1002": {
               "8": 1785385436
             }
           }
         
        Parameters:
        clusterName - The clusterName.
        Returns:
        The map that represents the container storage usage.
        Throws:
        java.lang.Exception
      • queryMonthlyAggregatedStats

        java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Long>> queryMonthlyAggregatedStats​(java.lang.String clusterName)
                                                                                                                        throws java.lang.Exception
        Return the monthly aggregated stats. This method returns a map in the same format as the queryAggregatedStats(java.lang.String). The only difference these two methods have is that this method's returned value only changes in the beginning of each month. For every new month(in local zone offset), an aggregated stats will be written to storage and a snapshot will be created. This method will return current snapshot. This method doesn't require a month value to fetch the snapshot as this new snapshot will be override the old ones.
        Parameters:
        clusterName - The clusterName.
        Returns:
        The map thtat represents the container storage usage.
        Throws:
        java.lang.Exception
      • queryRecordedMonth

        java.lang.String queryRecordedMonth​(java.lang.String clusterName)
                                     throws java.lang.Exception
        Return the month value of the current container storage snapshot.
        Parameters:
        clusterName - The clusterName.
        Returns:
        The month value for current snapshot, like "2020-01". Empty string will be returned if there is no record.
        Throws:
        java.lang.Exception
      • takeSnapshotOfAggregatedStatsAndUpdateMonth

        void takeSnapshotOfAggregatedStatsAndUpdateMonth​(java.lang.String clusterName,
                                                         java.lang.String monthValue)
                                                  throws java.lang.Exception
        Taking a snapshot of current aggregated stats and update the month value.
        Parameters:
        clusterName - The clusterName.
        monthValue - The month in string format, like "2020-01".
        Throws:
        java.lang.Exception