class LocalAggregation

Defined at line 25 of file ../../third_party/cobalt/src/local_aggregation/local_aggregation.h

LocalAggregation is the top-level object responsible for scheduling and managing the current

aggregated observations.

Public Methods

void LocalAggregation (const CobaltConfig & cfg, const logger::ProjectContextFactory & global_project_context_factory, system_data::SystemDataInterface & system_data, util::FileSystem & fs, const logger::ObservationWriter & observation_writer, util::CivilTimeConverterInterface & civil_time_converter, logger::InternalMetrics * internal_metrics)

Constructor for LocalAggregation

|cfg|: A reference to the CobaltConfig used to construct the CobaltService.

|global_project_context_factory|: The current global registry.

|system_data|: Used by the ObservationGenerator to get the current SystemProfile.

|fs|: An instance of util::FileSystem

|observation_writer|: An implementation of the ObservationWriter interface.

|civil_time_converter|: Converts a `time_point` to a civil time for a given time zone.

|internal_metrics|: A possibly null pointer to an InternalMetrics instance.

void Start (util::SystemClockInterface * clock)

Start should be called when the system is ready to start the background process for generating

observations based on the aggregated events.

|clock|: An implementation of the SystemClockInterface. The caller should make sure that this

clock is an accurate representation of the current system time before calling Start.

void ShutDown ()

ShutDown stops all background process and waits until they end.

Status GenerateAggregatedObservations (std::chrono::system_clock::time_point system_time)

GenerateAggregatedObservations forces the observation generator to run a single observation

generation pass. This should not be called if Start() has been called previously. The

observation generator creates observations for aggregation periods which have ended by

`system_time` and for which observations have not already been generated.

Status AddEvent (const logger::EventRecord & event_record, const std::chrono::system_clock::time_point & event_timestamp)

AddEvent adds an EventRecord to local aggregation. The |event_timestamp| is used as the

time the event occurred at.

void Disable (bool is_disabled)

Disable allows enabling/disabling LocalAggregation. When aggregation is disabled, AddEvent()

will return kOk, but the event will not be stored.

bool CanStore (lib::ProjectIdentifier project)

CanStore will return true if either:

1. The project is currently storing less than per_project_reserved_bytes

2. The project is over per_project_reserved_bytes, but there is room in the "Slush" storage.

void ~LocalAggregation ()

Defined at line 43 of file ../../third_party/cobalt/src/local_aggregation/local_aggregation.h

bool IsDisabled ()

IsDisabled returns true if LocalAggregation is disabled and should ignore incoming events

by returning kOk and not storing the data.

Defined at line 72 of file ../../third_party/cobalt/src/local_aggregation/local_aggregation.h

void DeleteData ()

Defined at line 74 of file ../../third_party/cobalt/src/local_aggregation/local_aggregation.h

bool IsUnderQuota (lib::ProjectIdentifier project)
void ResetInternalMetrics (logger::InternalMetrics * internal_metrics)

Defined at line 76 of file ../../third_party/cobalt/src/local_aggregation/local_aggregation.h

int64_t SlushSize ()

Returns the size of the "Slush" storage. This should be the total_capacity_bytes minus (number

of projects * per_project_reserved_bytes).

int64_t SlushUsed ()

Returns the amount of data used that exceeds each projects' per_project_reserved_bytes.