Loading cmds/statsd/src/condition/CombinationConditionTracker.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -39,11 +39,11 @@ CombinationConditionTracker::~CombinationConditionTracker() { VLOG("~CombinationConditionTracker() %s", mName.c_str()); } bool CombinationConditionTracker::init(const vector<Condition>& allConditionConfig, bool CombinationConditionTracker::init(const vector<Predicate>& allConditionConfig, const vector<sp<ConditionTracker>>& allConditionTrackers, const unordered_map<string, int>& conditionNameIndexMap, vector<bool>& stack) { VLOG("Combiniation condition init() %s", mName.c_str()); VLOG("Combination predicate init() %s", mName.c_str()); if (mInitialized) { return true; } Loading @@ -51,22 +51,22 @@ bool CombinationConditionTracker::init(const vector<Condition>& allConditionConf // mark this node as visited in the recursion stack. stack[mIndex] = true; Condition_Combination combinationCondition = allConditionConfig[mIndex].combination(); Predicate_Combination combinationCondition = allConditionConfig[mIndex].combination(); if (!combinationCondition.has_operation()) { return false; } mLogicalOperation = combinationCondition.operation(); if (mLogicalOperation == LogicalOperation::NOT && combinationCondition.condition_size() != 1) { if (mLogicalOperation == LogicalOperation::NOT && combinationCondition.predicate_size() != 1) { return false; } for (string child : combinationCondition.condition()) { for (string child : combinationCondition.predicate()) { auto it = conditionNameIndexMap.find(child); if (it == conditionNameIndexMap.end()) { ALOGW("Condition %s not found in the config", child.c_str()); ALOGW("Predicate %s not found in the config", child.c_str()); return false; } Loading Loading @@ -154,7 +154,7 @@ void CombinationConditionTracker::evaluateCondition( } } nonSlicedConditionCache[mIndex] = ConditionState::kUnknown; ALOGD("CombinationCondition %s sliced may changed? %d", mName.c_str(), ALOGD("CombinationPredicate %s sliced may changed? %d", mName.c_str(), conditionChangedCache[mIndex] == true); } } Loading cmds/statsd/src/condition/CombinationConditionTracker.h +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ public: ~CombinationConditionTracker(); bool init(const std::vector<Condition>& allConditionConfig, bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) override; Loading @@ -47,7 +47,7 @@ public: private: LogicalOperation mLogicalOperation; // Store index of the children Conditions. // Store index of the children Predicates. // We don't store string name of the Children, because we want to get rid of the hash map to // map the name to object. We don't want to store smart pointers to children, because it // increases the risk of circular dependency and memory leak. Loading cmds/statsd/src/condition/ConditionTracker.h +2 −3 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ public: // Initialize this ConditionTracker. This initialization is done recursively (DFS). It can also // be done in the constructor, but we do it separately because (1) easy to return a bool to // indicate whether the initialization is successful. (2) makes unit test easier. // allConditionConfig: the list of all Condition config from statsd_config. // allConditionConfig: the list of all Predicate config from statsd_config. // allConditionTrackers: the list of all ConditionTrackers (this is needed because we may also // need to call init() on children conditions) // conditionNameIndexMap: the mapping from condition name to its index. // stack: a bit map to keep track which nodes have been visited on the stack in the recursion. virtual bool init(const std::vector<Condition>& allConditionConfig, virtual bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) = 0; Loading Loading @@ -118,4 +118,3 @@ protected: } // namespace statsd } // namespace os } // namespace android cmds/statsd/src/condition/SimpleConditionTracker.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -34,16 +34,16 @@ using std::vector; SimpleConditionTracker::SimpleConditionTracker( const ConfigKey& key, const string& name, const int index, const SimpleCondition& simpleCondition, const SimplePredicate& simplePredicate, const unordered_map<string, int>& trackerNameIndexMap) : ConditionTracker(name, index), mConfigKey(key) { VLOG("creating SimpleConditionTracker %s", mName.c_str()); mCountNesting = simpleCondition.count_nesting(); mCountNesting = simplePredicate.count_nesting(); if (simpleCondition.has_start()) { auto pair = trackerNameIndexMap.find(simpleCondition.start()); if (simplePredicate.has_start()) { auto pair = trackerNameIndexMap.find(simplePredicate.start()); if (pair == trackerNameIndexMap.end()) { ALOGW("Start matcher %s not found in the config", simpleCondition.start().c_str()); ALOGW("Start matcher %s not found in the config", simplePredicate.start().c_str()); return; } mStartLogMatcherIndex = pair->second; Loading @@ -52,10 +52,10 @@ SimpleConditionTracker::SimpleConditionTracker( mStartLogMatcherIndex = -1; } if (simpleCondition.has_stop()) { auto pair = trackerNameIndexMap.find(simpleCondition.stop()); if (simplePredicate.has_stop()) { auto pair = trackerNameIndexMap.find(simplePredicate.stop()); if (pair == trackerNameIndexMap.end()) { ALOGW("Stop matcher %s not found in the config", simpleCondition.stop().c_str()); ALOGW("Stop matcher %s not found in the config", simplePredicate.stop().c_str()); return; } mStopLogMatcherIndex = pair->second; Loading @@ -64,10 +64,10 @@ SimpleConditionTracker::SimpleConditionTracker( mStopLogMatcherIndex = -1; } if (simpleCondition.has_stop_all()) { auto pair = trackerNameIndexMap.find(simpleCondition.stop_all()); if (simplePredicate.has_stop_all()) { auto pair = trackerNameIndexMap.find(simplePredicate.stop_all()); if (pair == trackerNameIndexMap.end()) { ALOGW("Stop all matcher %s not found in the config", simpleCondition.stop().c_str()); ALOGW("Stop all matcher %s not found in the config", simplePredicate.stop().c_str()); return; } mStopAllLogMatcherIndex = pair->second; Loading @@ -76,14 +76,14 @@ SimpleConditionTracker::SimpleConditionTracker( mStopAllLogMatcherIndex = -1; } mOutputDimension.insert(mOutputDimension.begin(), simpleCondition.dimension().begin(), simpleCondition.dimension().end()); mOutputDimension.insert(mOutputDimension.begin(), simplePredicate.dimension().begin(), simplePredicate.dimension().end()); if (mOutputDimension.size() > 0) { mSliced = true; } if (simpleCondition.initial_value() == SimpleCondition_InitialValue_FALSE) { if (simplePredicate.initial_value() == SimplePredicate_InitialValue_FALSE) { mInitialValue = ConditionState::kFalse; } else { mInitialValue = ConditionState::kUnknown; Loading @@ -98,7 +98,7 @@ SimpleConditionTracker::~SimpleConditionTracker() { VLOG("~SimpleConditionTracker()"); } bool SimpleConditionTracker::init(const vector<Condition>& allConditionConfig, bool SimpleConditionTracker::init(const vector<Predicate>& allConditionConfig, const vector<sp<ConditionTracker>>& allConditionTrackers, const unordered_map<string, int>& conditionNameIndexMap, vector<bool>& stack) { Loading Loading @@ -139,7 +139,7 @@ bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { StatsdStats::getInstance().noteConditionDimensionSize(mConfigKey, mName, newTupleCount); // 2. Don't add more tuples, we are above the allowed threshold. Drop the data. if (newTupleCount > StatsdStats::kDimensionKeySizeHardLimit) { ALOGE("Condition %s dropping data for dimension key %s", mName.c_str(), newKey.c_str()); ALOGE("Predicate %s dropping data for dimension key %s", mName.c_str(), newKey.c_str()); return true; } } Loading Loading @@ -221,7 +221,7 @@ void SimpleConditionTracker::handleConditionEvent(const HashableDimensionKey& ou conditionChangedCache[mIndex] = changed; conditionCache[mIndex] = newCondition; VLOG("SimpleCondition %s nonSlicedChange? %d", mName.c_str(), VLOG("SimplePredicate %s nonSlicedChange? %d", mName.c_str(), conditionChangedCache[mIndex] == true); } Loading Loading @@ -292,13 +292,13 @@ void SimpleConditionTracker::isConditionMet( (pair == conditionParameters.end()) ? DEFAULT_DIMENSION_KEY : pair->second; if (pair == conditionParameters.end() && mOutputDimension.size() > 0) { ALOGE("Condition %s output has dimension, but it's not specified in the query!", ALOGE("Predicate %s output has dimension, but it's not specified in the query!", mName.c_str()); conditionCache[mIndex] = mInitialValue; return; } VLOG("simpleCondition %s query key: %s", mName.c_str(), key.c_str()); VLOG("simplePredicate %s query key: %s", mName.c_str(), key.c_str()); auto startedCountIt = mSlicedConditionState.find(key); if (startedCountIt == mSlicedConditionState.end()) { Loading @@ -308,7 +308,7 @@ void SimpleConditionTracker::isConditionMet( startedCountIt->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; } VLOG("Condition %s return %d", mName.c_str(), conditionCache[mIndex]); VLOG("Predicate %s return %d", mName.c_str(), conditionCache[mIndex]); } } // namespace statsd Loading cmds/statsd/src/condition/SimpleConditionTracker.h +2 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,12 @@ namespace statsd { class SimpleConditionTracker : public virtual ConditionTracker { public: SimpleConditionTracker(const ConfigKey& key, const std::string& name, const int index, const SimpleCondition& simpleCondition, const SimplePredicate& simplePredicate, const std::unordered_map<std::string, int>& trackerNameIndexMap); ~SimpleConditionTracker(); bool init(const std::vector<Condition>& allConditionConfig, bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) override; Loading Loading
cmds/statsd/src/condition/CombinationConditionTracker.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -39,11 +39,11 @@ CombinationConditionTracker::~CombinationConditionTracker() { VLOG("~CombinationConditionTracker() %s", mName.c_str()); } bool CombinationConditionTracker::init(const vector<Condition>& allConditionConfig, bool CombinationConditionTracker::init(const vector<Predicate>& allConditionConfig, const vector<sp<ConditionTracker>>& allConditionTrackers, const unordered_map<string, int>& conditionNameIndexMap, vector<bool>& stack) { VLOG("Combiniation condition init() %s", mName.c_str()); VLOG("Combination predicate init() %s", mName.c_str()); if (mInitialized) { return true; } Loading @@ -51,22 +51,22 @@ bool CombinationConditionTracker::init(const vector<Condition>& allConditionConf // mark this node as visited in the recursion stack. stack[mIndex] = true; Condition_Combination combinationCondition = allConditionConfig[mIndex].combination(); Predicate_Combination combinationCondition = allConditionConfig[mIndex].combination(); if (!combinationCondition.has_operation()) { return false; } mLogicalOperation = combinationCondition.operation(); if (mLogicalOperation == LogicalOperation::NOT && combinationCondition.condition_size() != 1) { if (mLogicalOperation == LogicalOperation::NOT && combinationCondition.predicate_size() != 1) { return false; } for (string child : combinationCondition.condition()) { for (string child : combinationCondition.predicate()) { auto it = conditionNameIndexMap.find(child); if (it == conditionNameIndexMap.end()) { ALOGW("Condition %s not found in the config", child.c_str()); ALOGW("Predicate %s not found in the config", child.c_str()); return false; } Loading Loading @@ -154,7 +154,7 @@ void CombinationConditionTracker::evaluateCondition( } } nonSlicedConditionCache[mIndex] = ConditionState::kUnknown; ALOGD("CombinationCondition %s sliced may changed? %d", mName.c_str(), ALOGD("CombinationPredicate %s sliced may changed? %d", mName.c_str(), conditionChangedCache[mIndex] == true); } } Loading
cmds/statsd/src/condition/CombinationConditionTracker.h +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ public: ~CombinationConditionTracker(); bool init(const std::vector<Condition>& allConditionConfig, bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) override; Loading @@ -47,7 +47,7 @@ public: private: LogicalOperation mLogicalOperation; // Store index of the children Conditions. // Store index of the children Predicates. // We don't store string name of the Children, because we want to get rid of the hash map to // map the name to object. We don't want to store smart pointers to children, because it // increases the risk of circular dependency and memory leak. Loading
cmds/statsd/src/condition/ConditionTracker.h +2 −3 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ public: // Initialize this ConditionTracker. This initialization is done recursively (DFS). It can also // be done in the constructor, but we do it separately because (1) easy to return a bool to // indicate whether the initialization is successful. (2) makes unit test easier. // allConditionConfig: the list of all Condition config from statsd_config. // allConditionConfig: the list of all Predicate config from statsd_config. // allConditionTrackers: the list of all ConditionTrackers (this is needed because we may also // need to call init() on children conditions) // conditionNameIndexMap: the mapping from condition name to its index. // stack: a bit map to keep track which nodes have been visited on the stack in the recursion. virtual bool init(const std::vector<Condition>& allConditionConfig, virtual bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) = 0; Loading Loading @@ -118,4 +118,3 @@ protected: } // namespace statsd } // namespace os } // namespace android
cmds/statsd/src/condition/SimpleConditionTracker.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -34,16 +34,16 @@ using std::vector; SimpleConditionTracker::SimpleConditionTracker( const ConfigKey& key, const string& name, const int index, const SimpleCondition& simpleCondition, const SimplePredicate& simplePredicate, const unordered_map<string, int>& trackerNameIndexMap) : ConditionTracker(name, index), mConfigKey(key) { VLOG("creating SimpleConditionTracker %s", mName.c_str()); mCountNesting = simpleCondition.count_nesting(); mCountNesting = simplePredicate.count_nesting(); if (simpleCondition.has_start()) { auto pair = trackerNameIndexMap.find(simpleCondition.start()); if (simplePredicate.has_start()) { auto pair = trackerNameIndexMap.find(simplePredicate.start()); if (pair == trackerNameIndexMap.end()) { ALOGW("Start matcher %s not found in the config", simpleCondition.start().c_str()); ALOGW("Start matcher %s not found in the config", simplePredicate.start().c_str()); return; } mStartLogMatcherIndex = pair->second; Loading @@ -52,10 +52,10 @@ SimpleConditionTracker::SimpleConditionTracker( mStartLogMatcherIndex = -1; } if (simpleCondition.has_stop()) { auto pair = trackerNameIndexMap.find(simpleCondition.stop()); if (simplePredicate.has_stop()) { auto pair = trackerNameIndexMap.find(simplePredicate.stop()); if (pair == trackerNameIndexMap.end()) { ALOGW("Stop matcher %s not found in the config", simpleCondition.stop().c_str()); ALOGW("Stop matcher %s not found in the config", simplePredicate.stop().c_str()); return; } mStopLogMatcherIndex = pair->second; Loading @@ -64,10 +64,10 @@ SimpleConditionTracker::SimpleConditionTracker( mStopLogMatcherIndex = -1; } if (simpleCondition.has_stop_all()) { auto pair = trackerNameIndexMap.find(simpleCondition.stop_all()); if (simplePredicate.has_stop_all()) { auto pair = trackerNameIndexMap.find(simplePredicate.stop_all()); if (pair == trackerNameIndexMap.end()) { ALOGW("Stop all matcher %s not found in the config", simpleCondition.stop().c_str()); ALOGW("Stop all matcher %s not found in the config", simplePredicate.stop().c_str()); return; } mStopAllLogMatcherIndex = pair->second; Loading @@ -76,14 +76,14 @@ SimpleConditionTracker::SimpleConditionTracker( mStopAllLogMatcherIndex = -1; } mOutputDimension.insert(mOutputDimension.begin(), simpleCondition.dimension().begin(), simpleCondition.dimension().end()); mOutputDimension.insert(mOutputDimension.begin(), simplePredicate.dimension().begin(), simplePredicate.dimension().end()); if (mOutputDimension.size() > 0) { mSliced = true; } if (simpleCondition.initial_value() == SimpleCondition_InitialValue_FALSE) { if (simplePredicate.initial_value() == SimplePredicate_InitialValue_FALSE) { mInitialValue = ConditionState::kFalse; } else { mInitialValue = ConditionState::kUnknown; Loading @@ -98,7 +98,7 @@ SimpleConditionTracker::~SimpleConditionTracker() { VLOG("~SimpleConditionTracker()"); } bool SimpleConditionTracker::init(const vector<Condition>& allConditionConfig, bool SimpleConditionTracker::init(const vector<Predicate>& allConditionConfig, const vector<sp<ConditionTracker>>& allConditionTrackers, const unordered_map<string, int>& conditionNameIndexMap, vector<bool>& stack) { Loading Loading @@ -139,7 +139,7 @@ bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { StatsdStats::getInstance().noteConditionDimensionSize(mConfigKey, mName, newTupleCount); // 2. Don't add more tuples, we are above the allowed threshold. Drop the data. if (newTupleCount > StatsdStats::kDimensionKeySizeHardLimit) { ALOGE("Condition %s dropping data for dimension key %s", mName.c_str(), newKey.c_str()); ALOGE("Predicate %s dropping data for dimension key %s", mName.c_str(), newKey.c_str()); return true; } } Loading Loading @@ -221,7 +221,7 @@ void SimpleConditionTracker::handleConditionEvent(const HashableDimensionKey& ou conditionChangedCache[mIndex] = changed; conditionCache[mIndex] = newCondition; VLOG("SimpleCondition %s nonSlicedChange? %d", mName.c_str(), VLOG("SimplePredicate %s nonSlicedChange? %d", mName.c_str(), conditionChangedCache[mIndex] == true); } Loading Loading @@ -292,13 +292,13 @@ void SimpleConditionTracker::isConditionMet( (pair == conditionParameters.end()) ? DEFAULT_DIMENSION_KEY : pair->second; if (pair == conditionParameters.end() && mOutputDimension.size() > 0) { ALOGE("Condition %s output has dimension, but it's not specified in the query!", ALOGE("Predicate %s output has dimension, but it's not specified in the query!", mName.c_str()); conditionCache[mIndex] = mInitialValue; return; } VLOG("simpleCondition %s query key: %s", mName.c_str(), key.c_str()); VLOG("simplePredicate %s query key: %s", mName.c_str(), key.c_str()); auto startedCountIt = mSlicedConditionState.find(key); if (startedCountIt == mSlicedConditionState.end()) { Loading @@ -308,7 +308,7 @@ void SimpleConditionTracker::isConditionMet( startedCountIt->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; } VLOG("Condition %s return %d", mName.c_str(), conditionCache[mIndex]); VLOG("Predicate %s return %d", mName.c_str(), conditionCache[mIndex]); } } // namespace statsd Loading
cmds/statsd/src/condition/SimpleConditionTracker.h +2 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,12 @@ namespace statsd { class SimpleConditionTracker : public virtual ConditionTracker { public: SimpleConditionTracker(const ConfigKey& key, const std::string& name, const int index, const SimpleCondition& simpleCondition, const SimplePredicate& simplePredicate, const std::unordered_map<std::string, int>& trackerNameIndexMap); ~SimpleConditionTracker(); bool init(const std::vector<Condition>& allConditionConfig, bool init(const std::vector<Predicate>& allConditionConfig, const std::vector<sp<ConditionTracker>>& allConditionTrackers, const std::unordered_map<std::string, int>& conditionNameIndexMap, std::vector<bool>& stack) override; Loading