class LocalAggregateStorage
Defined at line 27 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
LocalAggregateStorage is the generic interface for storing MetricAggregates.
Different systems perform better with different implementations of this class, so it is up to
the embedder to chose which StorageStrategy is best.
Public Methods
void LocalAggregateStorage (int64_t per_project_reserved_bytes)
Defined at line 97 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
void LocalAggregateStorage (const LocalAggregateStorage & )
Disable copy and assignment
Defined at line 101 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
std::unique_ptr<LocalAggregateStorage> New (StorageStrategy strategy, std::string base_directory, util::FileSystem & fs, const logger::ProjectContextFactory & global_project_context_factory, system_data::SystemDataInterface & system_data, int64_t per_project_reserved_bytes)
New is the expected way to construct LocalAggregateStorage objects. Depending on which
StorageStrategy is supplied, a different implementation of LocalAggregateStorage will be
used.
bool MigrateStoredData (const std::string & customer_name, const std::string & project_name, MetricAggregate & metric, const MetricDefinition & metric_definition, const system_data::SystemDataInterface & system_data)
MigrateStoredData updates the existing data in the metric to reflect changes that have
occurred. Changes that are migrated include:
- data that is using deprecated fields, is migrated to use the new fields
- data is migrated to reflect registry changes that change the way data is stored
Returns true if the data was changed.
lib::statusor::StatusOr<MetricAggregateRef> GetMetricAggregate (lib::MetricIdentifier metric)
GetMetricAggregate returns a pointer to the live, mutable MetricAggregate that was requested.
If no such aggregate exists, nullptr will be returned.
Note: After modifying the MetricAggregate returned by this function, the user is expected to
call 'SaveMetricAggregate' so that the modified values can be persisted to disk.
Status GarbageCollection ()
GarbageCollection is called periodically to allow the storage to garbage collect any unneeded
data.
LocalAggregateStorage & operator= (const LocalAggregateStorage & )
Defined at line 102 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
int64_t AmountStored ()
Returns the amount of data stored in the whole LocalAggregateStorage
Defined at line 134 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
int64_t AmountStored (lib::ProjectIdentifier project)
Returns the amount of data stored for the given project
Defined at line 137 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
void DeleteData ()
When DeleteData is called, all aggregated data should be deleted and written to disk
immediately.
void ResetInternalMetrics (logger::InternalMetrics * internal_metrics)
void ShutDown ()
Trigger the shut down procedures for the local_aggregate_storage instance.
int64_t SlushUsed ()
Returns the amount of data used by projects that exceed their guaranteed per-project data cap.
Data in Slush is on a first come first served basis.
Defined at line 147 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
void ~LocalAggregateStorage ()
Defined at line 158 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
Protected Methods
void StoreFilteredSystemProfile (uint64_t system_profile_hash, const SystemProfile & filtered_system_profile)
StoreFilteredSystemProfile ensures that a filtered SystemProfile is present in the aggregate
storage data.
This must be called after modifying the MetricAggregate returned by GetMetricAggregate, to add
the use of the system_profile_hash, and before calling SaveMetricAggregate. It must be called
while a MetricAggregateRef continues to hold the mutex for the LocalAggregateStorage it came
from. It can also be called during the call to MigrateStoredData.
LocalAggregateStorage implementations should implement periodic garbage collection of unused
SystemProfiles from the store. When there are no outstanding MetricAggregateRef locks, any
system_profile_hash values that don't appear in any MetricAggregates can be removed.
lib::statusor::StatusOr<SystemProfile> RetrieveFilteredSystemProfile (uint64_t system_profile_hash)
RetrieveFilteredSystemProfile loads a filtered SystemProfile that is present in the aggregates
from the storage data.
This must be called while a MetricAggregateRef continues to hold the mutex for the
LocalAggregateStorage it came from.
Status SaveMetricAggregate (lib::MetricIdentifier metric)
SaveMetricAggregate writes the current state of the MetricAggregate for the given
(customer, project, metric) tuple to disk.
Note: This should be called after modifying the MetricAggregate returned by
GetMetricAggregate.
void UpdateProjectSizeBy (lib::ProjectIdentifier proj, int64_t size_increase)
UpdateProjectSizeBy is called whenever the amount of data stored for a project changes. It
handles the bookkeeping to keep track of how much data is stored per project, and how much is
stored overall.
Enumerations
enum StorageStrategy
| Name | Value |
|---|---|
| Immediate | 0 |
| Delayed | 1 |
Defined at line 29 of file ../../third_party/cobalt/src/local_aggregation/local_aggregate_storage/local_aggregate_storage.h
Records
Friends
class LocalAggregateStorageTest_HandlesBookkeepingAsExpected_Test