Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8333721a authored by Olivier Gaillard's avatar Olivier Gaillard Committed by Android (Google) Code Review
Browse files

Merge changes I300ab05c,I0910b7db

* changes:
  Adds the concept of invalid bucket.
  Reset the base when pull fails.
parents e8c4958b 9a5d3598
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -28,7 +28,13 @@ namespace statsd {
class PullDataReceiver : virtual public RefBase{
 public:
  virtual ~PullDataReceiver() {}
  virtual void onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& data) = 0;
  /**
   * @param data The pulled data.
   * @param pullSuccess Whether the pull succeeded. If the pull does not succeed, the data for the
   * bucket should be invalidated.
   */
  virtual void onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& data, 
                            bool pullSuccess) = 0;
};

}  // namespace statsd
+7 −6
Original line number Diff line number Diff line
@@ -358,12 +358,13 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {

    for (const auto& pullInfo : needToPull) {
        vector<shared_ptr<LogEvent>> data;
        if (!Pull(pullInfo.first, &data)) {
        bool pullSuccess = Pull(pullInfo.first, &data);
        if (pullSuccess) {
            StatsdStats::getInstance().notePullDelay(
                    pullInfo.first, getElapsedRealtimeNs() - elapsedTimeNs);
        } else {
            VLOG("pull failed at %lld, will try again later", (long long)elapsedTimeNs);
            continue;
        }
        StatsdStats::getInstance().notePullDelay(pullInfo.first,
                                                 getElapsedRealtimeNs() - elapsedTimeNs);

        // Convention is to mark pull atom timestamp at request time.
        // If we pull at t0, puller starts at t1, finishes at t2, and send back
@@ -380,8 +381,8 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
        for (const auto& receiverInfo : pullInfo.second) {
            sp<PullDataReceiver> receiverPtr = receiverInfo->receiver.promote();
            if (receiverPtr != nullptr) {
                receiverPtr->onDataPulled(data);
                // we may have just come out of a coma, compute next pull time
                receiverPtr->onDataPulled(data, pullSuccess);
                // We may have just come out of a coma, compute next pull time.
                int numBucketsAhead =
                        (elapsedTimeNs - receiverInfo->nextPullTimeNs) / receiverInfo->intervalNs;
                receiverInfo->nextPullTimeNs += (numBucketsAhead + 1) * receiverInfo->intervalNs;
+5 −0
Original line number Diff line number Diff line
@@ -448,6 +448,11 @@ void StatsdStats::noteConditionChangeInNextBucket(int metricId) {
    getAtomMetricStats(metricId).conditionChangeInNextBucket++;
}

void StatsdStats::noteInvalidatedBucket(int metricId) {
    lock_guard<std::mutex> lock(mLock);
    getAtomMetricStats(metricId).invalidatedBucket++;
}

StatsdStats::AtomMetricStats& StatsdStats::getAtomMetricStats(int metricId) {
    auto atomMetricStatsIter = mAtomMetricStats.find(metricId);
    if (atomMetricStatsIter != mAtomMetricStats.end()) {
+6 −0
Original line number Diff line number Diff line
@@ -364,6 +364,11 @@ public:
     */
    void noteConditionChangeInNextBucket(int atomId);

    /**
     * A bucket has been tagged as invalid.
     */
    void noteInvalidatedBucket(int metricId);

    /**
     * Reset the historical stats. Including all stats in icebox, and the tracked stats about
     * metrics, matchers, and atoms. The active configs will be kept and StatsdStats will continue
@@ -408,6 +413,7 @@ public:
        long skippedForwardBuckets = 0;
        long badValueType = 0;
        long conditionChangeInNextBucket = 0;
        long invalidatedBucket = 0;
    } AtomMetricStats;

private:
+3 −2
Original line number Diff line number Diff line
@@ -406,9 +406,10 @@ std::shared_ptr<vector<FieldValue>> GaugeMetricProducer::getGaugeFields(const Lo
    return gaugeFields;
}

void GaugeMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& allData) {
void GaugeMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& allData,
                                       bool pullSuccess) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (allData.size() == 0) {
    if (!pullSuccess || allData.size() == 0) {
        return;
    }
    for (const auto& data : allData) {
Loading