Package com.github.ambry.server
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>>
queryAggregatedStats(java.lang.String clusterName)
Return the aggregated stats for the givenclusterName
.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>>
queryMonthlyAggregatedStats(java.lang.String clusterName)
Return the monthly aggregated stats.java.lang.String
queryRecordedMonth(java.lang.String clusterName)
Return the month value of the current container storage snapshot.StatsWrapper
queryStatsOf(java.lang.String clusterName, java.lang.String hostname)
Return individual ambry server's stats for the givenclusterName
andhostname
.void
storeAggregatedStats(StatsSnapshot snapshot)
Store aggregated stats in theStatsSnapshot
.void
storeStats(StatsWrapper statsWrapper)
Store stats in theStatsWrapper
.void
takeSnapshotOfAggregatedStatsAndUpdateMonth(java.lang.String clusterName, java.lang.String monthValue)
Taking a snapshot of current aggregated stats and update the month value.
-
-
-
Method Detail
-
storeStats
void storeStats(StatsWrapper statsWrapper) throws java.lang.Exception
Store stats in theStatsWrapper
. The StatsWrapper'sStatsSnapshot
should include partition, account and container. This method will be used for individual ambry server to store local stats.- Parameters:
statsWrapper
- TheStatsWrapper
that contains stats and other metadata.- Throws:
java.lang.Exception
-
storeAggregatedStats
void storeAggregatedStats(StatsSnapshot snapshot) throws java.lang.Exception
Store aggregated stats in theStatsSnapshot
. The StatsSnapshot should include account and container. This method will be used for aggregation task to store aggregated stats.- Parameters:
snapshot
- TheStatsSnapshot
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 givenclusterName
andhostname
. This is the stats stored by methodstoreStats(com.github.ambry.server.StatsWrapper)
.- Parameters:
clusterName
- The clusterName.hostname
- The hostname.- Returns:
StatsWrapper
of givenhostname
in theclusterName
.- 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 givenclusterName
. This is the stats stored by methodstoreAggregatedStats(com.github.ambry.server.StatsSnapshot)
. Since theStatsSnapshot
passed tostoreAggregatedStats(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 thequeryAggregatedStats(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
-
-