Loading cmds/statsd/src/matchers/AtomMatchingTracker.h +10 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,15 @@ public: const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack) = 0; // Update appropriate state on config updates. Primarily, all indices need to be updated. // This matcher and all of its children are guaranteed to be preserved across the update. // matcher: the AtomMatcher proto from the config. // index: the index of this matcher in mAllAtomMatchingTrackers. // atomMatchingTrackerMap: map from matcher id to index in mAllAtomMatchingTrackers virtual bool onConfigUpdated( const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) = 0; // Called when a log event comes. // event: the log event. // allAtomMatchingTrackers: the list of all AtomMatchingTrackers. This is needed because the log Loading Loading @@ -83,7 +92,7 @@ protected: const int64_t mId; // Index of this AtomMatchingTracker in MetricsManager's container. const int mIndex; int mIndex; // Whether this AtomMatchingTracker has been properly initialized. bool mInitialized; Loading cmds/statsd/src/matchers/CombinationAtomMatchingTracker.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,23 @@ bool CombinationAtomMatchingTracker::init( return true; } bool CombinationAtomMatchingTracker::onConfigUpdated( const AtomMatcher& matcher, const int index, const unordered_map<int64_t, int>& atomMatchingTrackerMap) { mIndex = index; mChildren.clear(); AtomMatcher_Combination combinationMatcher = matcher.combination(); for (const int64_t child : combinationMatcher.matcher()) { const auto& pair = atomMatchingTrackerMap.find(child); if (pair == atomMatchingTrackerMap.end()) { ALOGW("Matcher %lld not found in the config", (long long)child); return false; } mChildren.push_back(pair->second); } return true; } void CombinationAtomMatchingTracker::onLogEvent( const LogEvent& event, const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, vector<MatchingState>& matcherResults) { Loading cmds/statsd/src/matchers/CombinationAtomMatchingTracker.h +6 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ namespace os { namespace statsd { // Represents a AtomMatcher_Combination in the StatsdConfig. class CombinationAtomMatchingTracker : public virtual AtomMatchingTracker { class CombinationAtomMatchingTracker : public AtomMatchingTracker { public: CombinationAtomMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash); Loading @@ -35,6 +35,9 @@ public: const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack); bool onConfigUpdated(const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) override; ~CombinationAtomMatchingTracker(); void onLogEvent(const LogEvent& event, Loading @@ -45,6 +48,8 @@ private: LogicalOperation mLogicalOperation; std::vector<int> mChildren; FRIEND_TEST(ConfigUpdateTest, TestUpdateMatchers); }; } // namespace statsd Loading cmds/statsd/src/matchers/SimpleAtomMatchingTracker.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,14 @@ bool SimpleAtomMatchingTracker::init(const vector<AtomMatcher>& allAtomMatchers, return mInitialized; } bool SimpleAtomMatchingTracker::onConfigUpdated( const AtomMatcher& matcher, const int index, const unordered_map<int64_t, int>& atomMatchingTrackerMap) { mIndex = index; // Do not need to update mMatcher since the matcher must be identical across the update. return mInitialized; } void SimpleAtomMatchingTracker::onLogEvent( const LogEvent& event, const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, vector<MatchingState>& matcherResults) { Loading cmds/statsd/src/matchers/SimpleAtomMatchingTracker.h +4 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ namespace android { namespace os { namespace statsd { class SimpleAtomMatchingTracker : public virtual AtomMatchingTracker { class SimpleAtomMatchingTracker : public AtomMatchingTracker { public: SimpleAtomMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash, const SimpleAtomMatcher& matcher, const sp<UidMap>& uidMap); Loading @@ -40,6 +40,9 @@ public: const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack) override; bool onConfigUpdated(const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) override; void onLogEvent(const LogEvent& event, const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, std::vector<MatchingState>& matcherResults) override; Loading Loading
cmds/statsd/src/matchers/AtomMatchingTracker.h +10 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,15 @@ public: const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack) = 0; // Update appropriate state on config updates. Primarily, all indices need to be updated. // This matcher and all of its children are guaranteed to be preserved across the update. // matcher: the AtomMatcher proto from the config. // index: the index of this matcher in mAllAtomMatchingTrackers. // atomMatchingTrackerMap: map from matcher id to index in mAllAtomMatchingTrackers virtual bool onConfigUpdated( const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) = 0; // Called when a log event comes. // event: the log event. // allAtomMatchingTrackers: the list of all AtomMatchingTrackers. This is needed because the log Loading Loading @@ -83,7 +92,7 @@ protected: const int64_t mId; // Index of this AtomMatchingTracker in MetricsManager's container. const int mIndex; int mIndex; // Whether this AtomMatchingTracker has been properly initialized. bool mInitialized; Loading
cmds/statsd/src/matchers/CombinationAtomMatchingTracker.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,23 @@ bool CombinationAtomMatchingTracker::init( return true; } bool CombinationAtomMatchingTracker::onConfigUpdated( const AtomMatcher& matcher, const int index, const unordered_map<int64_t, int>& atomMatchingTrackerMap) { mIndex = index; mChildren.clear(); AtomMatcher_Combination combinationMatcher = matcher.combination(); for (const int64_t child : combinationMatcher.matcher()) { const auto& pair = atomMatchingTrackerMap.find(child); if (pair == atomMatchingTrackerMap.end()) { ALOGW("Matcher %lld not found in the config", (long long)child); return false; } mChildren.push_back(pair->second); } return true; } void CombinationAtomMatchingTracker::onLogEvent( const LogEvent& event, const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, vector<MatchingState>& matcherResults) { Loading
cmds/statsd/src/matchers/CombinationAtomMatchingTracker.h +6 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ namespace os { namespace statsd { // Represents a AtomMatcher_Combination in the StatsdConfig. class CombinationAtomMatchingTracker : public virtual AtomMatchingTracker { class CombinationAtomMatchingTracker : public AtomMatchingTracker { public: CombinationAtomMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash); Loading @@ -35,6 +35,9 @@ public: const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack); bool onConfigUpdated(const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) override; ~CombinationAtomMatchingTracker(); void onLogEvent(const LogEvent& event, Loading @@ -45,6 +48,8 @@ private: LogicalOperation mLogicalOperation; std::vector<int> mChildren; FRIEND_TEST(ConfigUpdateTest, TestUpdateMatchers); }; } // namespace statsd Loading
cmds/statsd/src/matchers/SimpleAtomMatchingTracker.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,14 @@ bool SimpleAtomMatchingTracker::init(const vector<AtomMatcher>& allAtomMatchers, return mInitialized; } bool SimpleAtomMatchingTracker::onConfigUpdated( const AtomMatcher& matcher, const int index, const unordered_map<int64_t, int>& atomMatchingTrackerMap) { mIndex = index; // Do not need to update mMatcher since the matcher must be identical across the update. return mInitialized; } void SimpleAtomMatchingTracker::onLogEvent( const LogEvent& event, const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, vector<MatchingState>& matcherResults) { Loading
cmds/statsd/src/matchers/SimpleAtomMatchingTracker.h +4 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ namespace android { namespace os { namespace statsd { class SimpleAtomMatchingTracker : public virtual AtomMatchingTracker { class SimpleAtomMatchingTracker : public AtomMatchingTracker { public: SimpleAtomMatchingTracker(const int64_t& id, const int index, const uint64_t protoHash, const SimpleAtomMatcher& matcher, const sp<UidMap>& uidMap); Loading @@ -40,6 +40,9 @@ public: const std::unordered_map<int64_t, int>& matcherMap, std::vector<bool>& stack) override; bool onConfigUpdated(const AtomMatcher& matcher, const int index, const std::unordered_map<int64_t, int>& atomMatchingTrackerMap) override; void onLogEvent(const LogEvent& event, const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers, std::vector<MatchingState>& matcherResults) override; Loading