Loading cmds/statsd/src/StatsLogProcessor.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -75,10 +75,8 @@ StatsLogProcessor::~StatsLogProcessor() { void StatsLogProcessor::onAnomalyAlarmFired( const uint64_t timestampNs, unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet) { for (const auto& anomaly : anomalySet) { for (const auto& itr : mMetricsManagers) { itr.second->onAnomalyAlarmFired(timestampNs, anomaly); } itr.second->onAnomalyAlarmFired(timestampNs, anomalySet); } } Loading cmds/statsd/src/StatsLogProcessor.h +2 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public: size_t GetMetricsSize(const ConfigKey& key) const; void onDumpReport(const ConfigKey& key, vector<uint8_t>* outData); /* Tells MetricsManager that the alarms in anomalySet have fired. Modifies anomalySet. */ void onAnomalyAlarmFired( const uint64_t timestampNs, unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet); Loading cmds/statsd/src/StatsService.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -585,11 +585,10 @@ Status StatsService::informAnomalyAlarmFired() { } if (DEBUG) ALOGD("StatsService::informAnomalyAlarmFired succeeded"); // TODO: check through all counters/timers and see if an anomaly has indeed occurred. uint64_t currentTimeNs = time(nullptr) * NS_PER_SEC; uint64_t currentTimeSec = time(nullptr); std::unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet = mAnomalyMonitor->onAlarmFired(currentTimeNs); mProcessor->onAnomalyAlarmFired(currentTimeNs, anomalySet); mAnomalyMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); mProcessor->onAnomalyAlarmFired(currentTimeSec * NS_PER_SEC, anomalySet); return Status::ok(); } Loading cmds/statsd/src/anomaly/AnomalyMonitor.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ void AnomalyMonitor::remove(sp<const AnomalyAlarm> alarm) { return; } if (DEBUG) ALOGD("Removing alarm with time %u", alarm->timestampSec); mPq.remove(alarm); bool wasPresent = mPq.remove(alarm); if (!wasPresent) return; if (mPq.empty()) { if (DEBUG) ALOGD("Queue is empty. Cancel any alarm."); mRegisteredAlarmTimeSec = 0; Loading Loading @@ -129,11 +130,6 @@ int64_t AnomalyMonitor::secToMs(uint32_t timeSec) { return ((int64_t)timeSec) * 1000; } unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> AnomalyMonitor::onAlarmFired( uint64_t timestampNs) { return popSoonerThan(static_cast<uint32_t>(timestampNs)); } } // namespace statsd } // namespace os } // namespace android cmds/statsd/src/anomaly/AnomalyMonitor.h +0 −12 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #include <vector> Loading Loading @@ -97,15 +96,6 @@ public: unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> popSoonerThan( uint32_t timestampSec); // TODO: Function that uses popSoonerThan to get all alarms that have fired, and then // iterates over all DurationAnomalyTracker, looking for those alarms. When they're found, // have them declareAnomaly on those alarms. This means that DurationAnomalyTracker // must be thread-safe (since this is being called on a different thread). There is no // worry about missing the alarms (due to them being cancelled after this function being called) // because DurationAnomalyTracker guarantees that it checks for anaomlies when it cancels // alarms anyway. // void declareAnomalies(uint32_t timestampSec); /** * Returns the projected alarm timestamp that is registered with * StatsCompanionService. This may not be equal to the soonest alarm, Loading @@ -115,8 +105,6 @@ public: return mRegisteredAlarmTimeSec; } unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> onAlarmFired(uint64_t timestampNs); private: std::mutex mLock; Loading Loading
cmds/statsd/src/StatsLogProcessor.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -75,10 +75,8 @@ StatsLogProcessor::~StatsLogProcessor() { void StatsLogProcessor::onAnomalyAlarmFired( const uint64_t timestampNs, unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet) { for (const auto& anomaly : anomalySet) { for (const auto& itr : mMetricsManagers) { itr.second->onAnomalyAlarmFired(timestampNs, anomaly); } itr.second->onAnomalyAlarmFired(timestampNs, anomalySet); } } Loading
cmds/statsd/src/StatsLogProcessor.h +2 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public: size_t GetMetricsSize(const ConfigKey& key) const; void onDumpReport(const ConfigKey& key, vector<uint8_t>* outData); /* Tells MetricsManager that the alarms in anomalySet have fired. Modifies anomalySet. */ void onAnomalyAlarmFired( const uint64_t timestampNs, unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet); Loading
cmds/statsd/src/StatsService.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -585,11 +585,10 @@ Status StatsService::informAnomalyAlarmFired() { } if (DEBUG) ALOGD("StatsService::informAnomalyAlarmFired succeeded"); // TODO: check through all counters/timers and see if an anomaly has indeed occurred. uint64_t currentTimeNs = time(nullptr) * NS_PER_SEC; uint64_t currentTimeSec = time(nullptr); std::unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet = mAnomalyMonitor->onAlarmFired(currentTimeNs); mProcessor->onAnomalyAlarmFired(currentTimeNs, anomalySet); mAnomalyMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); mProcessor->onAnomalyAlarmFired(currentTimeSec * NS_PER_SEC, anomalySet); return Status::ok(); } Loading
cmds/statsd/src/anomaly/AnomalyMonitor.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ void AnomalyMonitor::remove(sp<const AnomalyAlarm> alarm) { return; } if (DEBUG) ALOGD("Removing alarm with time %u", alarm->timestampSec); mPq.remove(alarm); bool wasPresent = mPq.remove(alarm); if (!wasPresent) return; if (mPq.empty()) { if (DEBUG) ALOGD("Queue is empty. Cancel any alarm."); mRegisteredAlarmTimeSec = 0; Loading Loading @@ -129,11 +130,6 @@ int64_t AnomalyMonitor::secToMs(uint32_t timeSec) { return ((int64_t)timeSec) * 1000; } unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> AnomalyMonitor::onAlarmFired( uint64_t timestampNs) { return popSoonerThan(static_cast<uint32_t>(timestampNs)); } } // namespace statsd } // namespace os } // namespace android
cmds/statsd/src/anomaly/AnomalyMonitor.h +0 −12 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #include <vector> Loading Loading @@ -97,15 +96,6 @@ public: unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> popSoonerThan( uint32_t timestampSec); // TODO: Function that uses popSoonerThan to get all alarms that have fired, and then // iterates over all DurationAnomalyTracker, looking for those alarms. When they're found, // have them declareAnomaly on those alarms. This means that DurationAnomalyTracker // must be thread-safe (since this is being called on a different thread). There is no // worry about missing the alarms (due to them being cancelled after this function being called) // because DurationAnomalyTracker guarantees that it checks for anaomlies when it cancels // alarms anyway. // void declareAnomalies(uint32_t timestampSec); /** * Returns the projected alarm timestamp that is registered with * StatsCompanionService. This may not be equal to the soonest alarm, Loading @@ -115,8 +105,6 @@ public: return mRegisteredAlarmTimeSec; } unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> onAlarmFired(uint64_t timestampNs); private: std::mutex mLock; Loading