You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2018/04/27 23:20:47 UTC

[1/4] mesos git commit: Introduced a push-based gauge metric.

Repository: mesos
Updated Branches:
  refs/heads/master 617d55e24 -> ed830653a


Introduced a push-based gauge metric.

A push-based gauge differs from a pull-based gauge in that the
client is responsible for pushing the latest value into the gauge
whenever it changes. This can be challenging in some cases as it
requires the client to have a good handle on when the gauge value
changes (rather than just computing the current value when asked).

It is highly recommended to use push-based gauges if possible as
they provide significant performance benefits over pull-based
gauges. Pull-based gauge suffer from delays getting processed on
the event queue of a `Process`, as well as incur computation cost
on the `Process` each time the metrics are collected. Push-based
gauges, on the other hand, incur no cost to the owning `Process`
when metrics are collected, and instead incur a trivial cost when
the `Process` pushes new values in.

Review: https://reviews.apache.org/r/66828/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6707d39d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6707d39d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6707d39d

Branch: refs/heads/master
Commit: 6707d39d2ee2e1ccb62e4998ef57d4db8cda5c96
Parents: 617d55e
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Apr 27 16:06:53 2018 -0700
Committer: Gilbert Song <so...@gmail.com>
Committed: Fri Apr 27 16:06:53 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/Makefile.am         |   1 +
 .../include/process/metrics/push_gauge.hpp      | 100 +++++++++++++++++++
 2 files changed, 101 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6707d39d/3rdparty/libprocess/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/Makefile.am b/3rdparty/libprocess/include/Makefile.am
index cd2c3bc..25520c2 100644
--- a/3rdparty/libprocess/include/Makefile.am
+++ b/3rdparty/libprocess/include/Makefile.am
@@ -47,6 +47,7 @@ nobase_include_HEADERS =		\
   process/mutex.hpp			\
   process/metrics/counter.hpp		\
   process/metrics/gauge.hpp		\
+  process/metrics/push_gauge.hpp	\
   process/metrics/metric.hpp		\
   process/metrics/metrics.hpp		\
   process/metrics/timer.hpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/6707d39d/3rdparty/libprocess/include/process/metrics/push_gauge.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/metrics/push_gauge.hpp b/3rdparty/libprocess/include/process/metrics/push_gauge.hpp
new file mode 100644
index 0000000..5c39846
--- /dev/null
+++ b/3rdparty/libprocess/include/process/metrics/push_gauge.hpp
@@ -0,0 +1,100 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+#ifndef __PROCESS_METRICS_PUSH_GAUGE_HPP__
+#define __PROCESS_METRICS_PUSH_GAUGE_HPP__
+
+#include <memory>
+#include <string>
+
+#include <process/metrics/metric.hpp>
+
+namespace process {
+namespace metrics {
+
+// A Metric that represents an instantaneous measurement of a value
+// (e.g. number of items in a queue).
+//
+// A push-based gauge differs from a pull-based gauge in that the
+// client is responsible for pushing the latest value into the gauge
+// whenever it changes. This can be challenging in some cases as it
+// requires the client to have a good handle on when the gauge value
+// changes (rather than just computing the current value when asked).
+//
+// NOTE: It is highly recommended to use push-based gauges if
+// possible as they provide significant performance benefits over
+// pull-based gauges. Pull-based gauge suffer from delays getting
+// processed on the event queue of a `Process`, as well as incur
+// computation cost on the `Process` each time the metrics are
+// collected. Push-based gauges, on the other hand, incur no cost
+// to the owning `Process` when metrics are collected, and instead
+// incur a trivial cost when the `Process` pushes new values in.
+class PushGauge : public Metric
+{
+public:
+  // 'name' is the unique name for the instance of Gauge being constructed.
+  // It will be the key exposed in the JSON endpoint.
+  //
+  // 'f' is the function that is called when the Metric value is requested.
+  // The user of `Gauge` must ensure that `f` is safe to execute up until
+  // the removal of the `Gauge` (via `process::metrics::remove(...)`) is
+  // complete.
+  explicit PushGauge(const std::string& name)
+    : Metric(name, None()), data(new Data()) {}
+
+  virtual ~PushGauge() {}
+
+  virtual Future<double> value() const
+  {
+    return static_cast<double>(data->value.load());
+  }
+
+  PushGauge& operator=(int64_t v)
+  {
+    data->value.store(v);
+    push(v);
+    return *this;
+  }
+
+  PushGauge& operator++() { return *this += 1; }
+
+  PushGauge& operator+=(int64_t v)
+  {
+    int64_t prev = data->value.fetch_add(v);
+    push(static_cast<double>(prev + v));
+    return *this;
+  }
+
+  PushGauge& operator--() { return *this -= 1; }
+
+  PushGauge& operator-=(int64_t v)
+  {
+    int64_t prev = data->value.fetch_sub(v);
+    push(static_cast<double>(prev - v));
+    return *this;
+  }
+
+private:
+  struct Data
+  {
+    explicit Data() : value(0) {}
+
+    std::atomic<int64_t> value;
+  };
+
+  std::shared_ptr<Data> data;
+};
+
+} // namespace metrics {
+} // namespace process {
+
+#endif // __PROCESS_METRICS_PUSH_GAUGE_HPP__


[3/4] mesos git commit: Renamed Gauge to PullGauge and documented differences to PushGauge.

Posted by gi...@apache.org.
Renamed Gauge to PullGauge and documented differences to PushGauge.

Given `PushGauge`, it makes sense to explicitly distinguish the two
gauge types and document the the caveats of `PullGauge`.

Review: https://reviews.apache.org/r/66831/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8fad04ef
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8fad04ef
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8fad04ef

Branch: refs/heads/master
Commit: 8fad04ef8e86949cba0de3a0e571dd138d581d68
Parents: 898ff1b
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Apr 27 16:07:01 2018 -0700
Committer: Gilbert Song <so...@gmail.com>
Committed: Fri Apr 27 16:20:10 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/Makefile.am         |  2 +-
 .../include/process/metrics/gauge.hpp           | 58 ---------------
 .../include/process/metrics/metric.hpp          |  2 +-
 .../include/process/metrics/pull_gauge.hpp      | 77 ++++++++++++++++++++
 3rdparty/libprocess/include/process/system.hpp  | 14 ++--
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 51 +++++++------
 3rdparty/libprocess/src/tests/system_tests.cpp  |  2 +-
 7 files changed, 116 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/Makefile.am b/3rdparty/libprocess/include/Makefile.am
index 25520c2..1ddcc2d 100644
--- a/3rdparty/libprocess/include/Makefile.am
+++ b/3rdparty/libprocess/include/Makefile.am
@@ -46,7 +46,7 @@ nobase_include_HEADERS =		\
   process/mime.hpp			\
   process/mutex.hpp			\
   process/metrics/counter.hpp		\
-  process/metrics/gauge.hpp		\
+  process/metrics/pull_gauge.hpp	\
   process/metrics/push_gauge.hpp	\
   process/metrics/metric.hpp		\
   process/metrics/metrics.hpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/include/process/metrics/gauge.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/metrics/gauge.hpp b/3rdparty/libprocess/include/process/metrics/gauge.hpp
deleted file mode 100644
index 474f8e8..0000000
--- a/3rdparty/libprocess/include/process/metrics/gauge.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License
-
-#ifndef __PROCESS_METRICS_GAUGE_HPP__
-#define __PROCESS_METRICS_GAUGE_HPP__
-
-#include <functional>
-#include <memory>
-#include <string>
-
-#include <process/metrics/metric.hpp>
-
-namespace process {
-namespace metrics {
-
-// A Metric that represents an instantaneous value evaluated when
-// 'value' is called.
-class Gauge : public Metric
-{
-public:
-  // 'name' is the unique name for the instance of Gauge being constructed.
-  // It will be the key exposed in the JSON endpoint.
-  //
-  // 'f' is the function that is called when the Metric value is requested.
-  // The user of `Gauge` must ensure that `f` is safe to execute up until
-  // the removal of the `Gauge` (via `process::metrics::remove(...)`) is
-  // complete.
-  Gauge(const std::string& name, const std::function<Future<double>()>& f)
-    : Metric(name, None()), data(new Data(f)) {}
-
-  virtual ~Gauge() {}
-
-  virtual Future<double> value() const { return data->f(); }
-
-private:
-  struct Data
-  {
-    explicit Data(const std::function<Future<double>()>& _f) : f(_f) {}
-
-    const std::function<Future<double>()> f;
-  };
-
-  std::shared_ptr<Data> data;
-};
-
-} // namespace metrics {
-} // namespace process {
-
-#endif // __PROCESS_METRICS_GAUGE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/include/process/metrics/metric.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/metrics/metric.hpp b/3rdparty/libprocess/include/process/metrics/metric.hpp
index 21f162d..2c4a154 100644
--- a/3rdparty/libprocess/include/process/metrics/metric.hpp
+++ b/3rdparty/libprocess/include/process/metrics/metric.hpp
@@ -29,7 +29,7 @@
 namespace process {
 namespace metrics {
 
-// The base class for Metrics such as Counter and Gauge.
+// The base class for Metrics.
 class Metric {
 public:
   virtual ~Metric() {}

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/include/process/metrics/pull_gauge.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/metrics/pull_gauge.hpp b/3rdparty/libprocess/include/process/metrics/pull_gauge.hpp
new file mode 100644
index 0000000..5c2a227
--- /dev/null
+++ b/3rdparty/libprocess/include/process/metrics/pull_gauge.hpp
@@ -0,0 +1,77 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+#ifndef __PROCESS_METRICS_PULL_GAUGE_HPP__
+#define __PROCESS_METRICS_PULL_GAUGE_HPP__
+
+#include <functional>
+#include <memory>
+#include <string>
+
+#include <process/metrics/metric.hpp>
+
+namespace process {
+namespace metrics {
+
+// A Metric that represents an instantaneous measurement of a value
+// (e.g. number of items in a queue).
+//
+// A pull-based gauge differs from a push-based gauge in that the
+// client does not need to worry about when to compute a new gauge
+// value and instead provides the value function to invoke during
+// metrics collection. This makes the client logic simpler but comes
+// with significant performance disadvantages. If this function
+// dispatches to a `Process`, metrics collection will be exposed to
+// delays while the dispatches work their way through the event
+// queues. Also, gauges can be expensive to compute (e.g. loop over
+// all items while counting how many match a criteria) and therefore
+// can lead to a performance degradation on critial `Process`es
+// during metrics collection.
+//
+// NOTE: Due to the performance disadvantages of pull-based gauges,
+// it is recommended to use push-based gauges where possible.
+// Pull-based gauges should ideally (1) be used on `Process`es that
+// experience very light load, and (2) use functions that do not
+// perform heavyweight computation to compute the value (e.g. looping
+// over a large collection).
+class PullGauge : public Metric
+{
+public:
+  // 'name' is the unique name for the instance of Gauge being constructed.
+  // It will be the key exposed in the JSON endpoint.
+  //
+  // 'f' is the function that is called when the Metric value is requested.
+  // The user of `Gauge` must ensure that `f` is safe to execute up until
+  // the removal of the `Gauge` (via `process::metrics::remove(...)`) is
+  // complete.
+  PullGauge(const std::string& name, const std::function<Future<double>()>& f)
+    : Metric(name, None()), data(new Data(f)) {}
+
+  virtual ~PullGauge() {}
+
+  virtual Future<double> value() const { return data->f(); }
+
+private:
+  struct Data
+  {
+    explicit Data(const std::function<Future<double>()>& _f) : f(_f) {}
+
+    const std::function<Future<double>()> f;
+  };
+
+  std::shared_ptr<Data> data;
+};
+
+} // namespace metrics {
+} // namespace process {
+
+#endif // __PROCESS_METRICS_PULL_GAUGE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/include/process/system.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/system.hpp b/3rdparty/libprocess/include/process/system.hpp
index 6bd815d..81ded8a 100644
--- a/3rdparty/libprocess/include/process/system.hpp
+++ b/3rdparty/libprocess/include/process/system.hpp
@@ -20,7 +20,7 @@
 #include <process/http.hpp>
 #include <process/process.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/os.hpp>
@@ -183,14 +183,14 @@ private:
     return http::OK(object, request.url.query.get("jsonp"));
   }
 
-  metrics::Gauge load_1min;
-  metrics::Gauge load_5min;
-  metrics::Gauge load_15min;
+  metrics::PullGauge load_1min;
+  metrics::PullGauge load_5min;
+  metrics::PullGauge load_15min;
 
-  metrics::Gauge cpus_total;
+  metrics::PullGauge cpus_total;
 
-  metrics::Gauge mem_total_bytes;
-  metrics::Gauge mem_free_bytes;
+  metrics::PullGauge mem_total_bytes;
+  metrics::PullGauge mem_free_bytes;
 };
 
 } // namespace process {

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index 3a68388..a5b41ed 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -30,8 +30,8 @@
 #include <process/time.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
 #include <process/metrics/metrics.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/push_gauge.hpp>
 #include <process/metrics/timer.hpp>
 
@@ -48,7 +48,7 @@ using http::Response;
 using http::Unauthorized;
 
 using metrics::Counter;
-using metrics::Gauge;
+using metrics::PullGauge;
 using metrics::PushGauge;
 using metrics::Timer;
 
@@ -66,7 +66,7 @@ using std::map;
 using std::string;
 using std::vector;
 
-class GaugeProcess : public Process<GaugeProcess>
+class PullGaugeProcess : public Process<PullGaugeProcess>
 {
 public:
   double get()
@@ -145,14 +145,14 @@ TEST_F(MetricsTest, Counter)
 }
 
 
-TEST_F(MetricsTest, THREADSAFE_Gauge)
+TEST_F(MetricsTest, PullGauge)
 {
-  GaugeProcess process;
-  PID<GaugeProcess> pid = spawn(&process);
+  PullGaugeProcess process;
+  PID<PullGaugeProcess> pid = spawn(&process);
   ASSERT_TRUE(pid);
 
-  // Gauge with a value.
-  Gauge gauge("test/gauge", defer(pid, &GaugeProcess::get));
+  // PullGauge with a value.
+  PullGauge gauge("test/gauge", defer(pid, &PullGaugeProcess::get));
 
   AWAIT_READY(metrics::add(gauge));
 
@@ -161,7 +161,7 @@ TEST_F(MetricsTest, THREADSAFE_Gauge)
   AWAIT_READY(metrics::remove(gauge));
 
   // Failing gauge.
-  gauge = Gauge("test/failedgauge", defer(pid, &GaugeProcess::fail));
+  gauge = PullGauge("test/failedgauge", defer(pid, &PullGaugeProcess::fail));
 
   AWAIT_READY(metrics::add(gauge));
 
@@ -244,14 +244,14 @@ TEST_F(MetricsTest, THREADSAFE_Snapshot)
 
   Clock::pause();
 
-  // Add a gauge and a counter.
-  GaugeProcess process;
-  PID<GaugeProcess> pid = spawn(&process);
+  // Add a pull-gauge and a counter.
+  PullGaugeProcess process;
+  PID<PullGaugeProcess> pid = spawn(&process);
   ASSERT_TRUE(pid);
 
-  Gauge gauge("test/gauge", defer(pid, &GaugeProcess::get));
-  Gauge gaugeFail("test/gauge_fail", defer(pid, &GaugeProcess::fail));
-  Gauge gaugeConst("test/gauge_const", []() { return 99.0; });
+  PullGauge gauge("test/gauge", defer(pid, &PullGaugeProcess::get));
+  PullGauge gaugeFail("test/gauge_fail", defer(pid, &PullGaugeProcess::fail));
+  PullGauge gaugeConst("test/gauge_const", []() { return 99.0; });
   Counter counter("test/counter");
 
   AWAIT_READY(metrics::add(gauge));
@@ -382,15 +382,22 @@ TEST_F(MetricsTest, THREADSAFE_SnapshotTimeout)
   // Advance the clock to avoid rate limit.
   Clock::advance(Seconds(1));
 
-  // Add gauges and a counter.
-  GaugeProcess process;
-  PID<GaugeProcess> pid = spawn(&process);
+  // Add pull-gauges and a counter.
+  PullGaugeProcess process;
+  PID<PullGaugeProcess> pid = spawn(&process);
   ASSERT_TRUE(pid);
 
-  Gauge gauge("test/gauge", defer(pid, &GaugeProcess::get));
-  Gauge gaugeFail("test/gauge_fail", defer(pid, &GaugeProcess::fail));
-  Gauge gaugeTimeout("test/gauge_timeout", defer(pid, &GaugeProcess::pending));
-  Counter counter("test/counter");
+  PullGauge gauge(
+      "test/gauge",
+      defer(pid, &PullGaugeProcess::get));
+  PullGauge gaugeFail(
+      "test/gauge_fail",
+      defer(pid, &PullGaugeProcess::fail));
+  PullGauge gaugeTimeout(
+      "test/gauge_timeout",
+      defer(pid, &PullGaugeProcess::pending));
+  Counter counter(
+      "test/counter");
 
   AWAIT_READY(metrics::add(gauge));
   AWAIT_READY(metrics::add(gaugeFail));

http://git-wip-us.apache.org/repos/asf/mesos/blob/8fad04ef/3rdparty/libprocess/src/tests/system_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/system_tests.cpp b/3rdparty/libprocess/src/tests/system_tests.cpp
index 17f2881..237523f 100644
--- a/3rdparty/libprocess/src/tests/system_tests.cpp
+++ b/3rdparty/libprocess/src/tests/system_tests.cpp
@@ -30,7 +30,7 @@ namespace http = process::http;
 using process::Future;
 
 // MESOS-1433
-// This test is disabled as the Gauges that are used for these metrics
+// This test is disabled as the pull-gauges that are used for these metrics
 // may return Failures. In this case we do not put the metric into the
 // endpoint. This has been observed specifically for the memory
 // metrics. If in the future we put the error message from the Failure


[4/4] mesos git commit: Updated mesos source for Gauge -> PullGauge renaming.

Posted by gi...@apache.org.
Updated mesos source for Gauge -> PullGauge renaming.

Review: https://reviews.apache.org/r/66832/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ed830653
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ed830653
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ed830653

Branch: refs/heads/master
Commit: ed830653ac4c997c98ca359730f8a402962a05d6
Parents: 8fad04e
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Apr 27 16:07:05 2018 -0700
Committer: Gilbert Song <so...@gmail.com>
Committed: Fri Apr 27 16:20:16 2018 -0700

----------------------------------------------------------------------
 src/examples/balloon_framework.cpp              |  8 +--
 src/examples/disk_full_framework.cpp            |  8 +--
 src/examples/long_lived_framework.cpp           |  8 +--
 src/log/log.hpp                                 |  2 +-
 src/log/metrics.hpp                             |  6 +--
 src/master/allocator/mesos/metrics.cpp          | 32 ++++++------
 src/master/allocator/mesos/metrics.hpp          | 26 +++++-----
 src/master/allocator/sorter/drf/metrics.cpp     |  6 +--
 src/master/allocator/sorter/drf/metrics.hpp     |  4 +-
 src/master/master.hpp                           |  2 +-
 src/master/metrics.cpp                          | 28 +++++-----
 src/master/metrics.hpp                          | 54 ++++++++++----------
 src/master/registrar.cpp                        | 10 ++--
 src/resource_provider/manager.cpp               |  6 +--
 src/sched/sched.cpp                             |  6 +--
 src/scheduler/scheduler.cpp                     |  6 +--
 src/slave/containerizer/fetcher_process.hpp     |  6 +--
 .../mesos/isolators/filesystem/linux.hpp        |  4 +-
 src/slave/gc_process.hpp                        |  4 +-
 src/slave/metrics.cpp                           | 30 +++++------
 src/slave/metrics.hpp                           | 38 +++++++-------
 src/slave/slave.hpp                             |  2 +-
 22 files changed, 148 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/examples/balloon_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_framework.cpp b/src/examples/balloon_framework.cpp
index f25324d..cbc25e4 100644
--- a/src/examples/balloon_framework.cpp
+++ b/src/examples/balloon_framework.cpp
@@ -32,7 +32,7 @@
 #include <process/time.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/bytes.hpp>
@@ -61,7 +61,7 @@ using google::protobuf::RepeatedPtrField;
 using process::Clock;
 using process::defer;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 using process::metrics::Counter;
 
 const double CPUS_PER_TASK = 0.1;
@@ -357,8 +357,8 @@ private:
       process::metrics::remove(abnormal_terminations);
     }
 
-    process::metrics::Gauge uptime_secs;
-    process::metrics::Gauge registered;
+    process::metrics::PullGauge uptime_secs;
+    process::metrics::PullGauge registered;
 
     process::metrics::Counter tasks_finished;
     process::metrics::Counter tasks_oomed;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/examples/disk_full_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/disk_full_framework.cpp b/src/examples/disk_full_framework.cpp
index b6029dc..dfbddda 100644
--- a/src/examples/disk_full_framework.cpp
+++ b/src/examples/disk_full_framework.cpp
@@ -30,7 +30,7 @@
 #include <process/time.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/bytes.hpp>
@@ -52,7 +52,7 @@ using std::string;
 using process::Clock;
 using process::defer;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 using process::metrics::Counter;
 
 const double CPUS_PER_TASK = 0.1;
@@ -321,8 +321,8 @@ private:
       process::metrics::remove(abnormal_terminations);
     }
 
-    process::metrics::Gauge uptime_secs;
-    process::metrics::Gauge registered;
+    process::metrics::PullGauge uptime_secs;
+    process::metrics::PullGauge registered;
 
     process::metrics::Counter tasks_finished;
     process::metrics::Counter tasks_disk_full;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/examples/long_lived_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_framework.cpp b/src/examples/long_lived_framework.cpp
index 53e3ec9..0e4e3d0 100644
--- a/src/examples/long_lived_framework.cpp
+++ b/src/examples/long_lived_framework.cpp
@@ -36,7 +36,7 @@
 #include <process/time.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/flags.hpp>
@@ -89,7 +89,7 @@ using process::TLDR;
 
 using process::http::OK;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 using process::metrics::Counter;
 
 // NOTE: Per-task resources are nominal because all of the resources for the
@@ -487,8 +487,8 @@ private:
       process::metrics::remove(abnormal_terminations);
     }
 
-    process::metrics::Gauge uptime_secs;
-    process::metrics::Gauge subscribed;
+    process::metrics::PullGauge uptime_secs;
+    process::metrics::PullGauge subscribed;
 
     process::metrics::Counter offers_received;
     process::metrics::Counter tasks_launched;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/log/log.hpp
----------------------------------------------------------------------
diff --git a/src/log/log.hpp b/src/log/log.hpp
index be038d1..7cba0b1 100644
--- a/src/log/log.hpp
+++ b/src/log/log.hpp
@@ -26,7 +26,7 @@
 #include <process/process.hpp>
 #include <process/shared.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 #include <stout/nothing.hpp>
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/log/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/log/metrics.hpp b/src/log/metrics.hpp
index b537e0a..4a9efce 100644
--- a/src/log/metrics.hpp
+++ b/src/log/metrics.hpp
@@ -19,7 +19,7 @@
 
 #include <string>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 namespace mesos {
 namespace internal {
@@ -36,9 +36,9 @@ struct Metrics
 
   ~Metrics();
 
-  process::metrics::Gauge recovered;
+  process::metrics::PullGauge recovered;
 
-  process::metrics::Gauge ensemble_size;
+  process::metrics::PullGauge ensemble_size;
 };
 
 } // namespace log {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/allocator/mesos/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/metrics.cpp b/src/master/allocator/mesos/metrics.cpp
index 4892dbc..5194f5b 100644
--- a/src/master/allocator/mesos/metrics.cpp
+++ b/src/master/allocator/mesos/metrics.cpp
@@ -20,7 +20,7 @@
 
 #include <mesos/quota/quota.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/hashmap.hpp>
@@ -29,7 +29,7 @@
 
 using std::string;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 
 namespace mesos {
 namespace internal {
@@ -67,13 +67,13 @@ Metrics::Metrics(const HierarchicalAllocatorProcess& _allocator)
   string resources[] = {"cpus", "mem", "disk"};
 
   foreach (const string& resource, resources) {
-    Gauge total(
+    PullGauge total(
         "allocator/mesos/resources/" + resource + "/total",
         defer(allocator,
               &HierarchicalAllocatorProcess::_resources_total,
               resource));
 
-    Gauge offered_or_allocated(
+    PullGauge offered_or_allocated(
         "allocator/mesos/resources/" + resource + "/offered_or_allocated",
         defer(allocator,
               &HierarchicalAllocatorProcess::_resources_offered_or_allocated,
@@ -96,27 +96,27 @@ Metrics::~Metrics()
   process::metrics::remove(allocation_run);
   process::metrics::remove(allocation_run_latency);
 
-  foreach (const Gauge& gauge, resources_total) {
+  foreach (const PullGauge& gauge, resources_total) {
     process::metrics::remove(gauge);
   }
 
-  foreach (const Gauge& gauge, resources_offered_or_allocated) {
+  foreach (const PullGauge& gauge, resources_offered_or_allocated) {
     process::metrics::remove(gauge);
   }
 
   foreachkey (const string& role, quota_allocated) {
-    foreachvalue (const Gauge& gauge, quota_allocated[role]) {
+    foreachvalue (const PullGauge& gauge, quota_allocated[role]) {
       process::metrics::remove(gauge);
     }
   }
 
   foreachkey (const string& role, quota_guarantee) {
-    foreachvalue (const Gauge& gauge, quota_guarantee[role]) {
+    foreachvalue (const PullGauge& gauge, quota_guarantee[role]) {
       process::metrics::remove(gauge);
     }
   }
 
-  foreachvalue (const Gauge& gauge, offer_filters_active) {
+  foreachvalue (const PullGauge& gauge, offer_filters_active) {
     process::metrics::remove(gauge);
   }
 }
@@ -126,21 +126,21 @@ void Metrics::setQuota(const string& role, const Quota& quota)
 {
   CHECK(!quota_allocated.contains(role));
 
-  hashmap<string, Gauge> allocated;
-  hashmap<string, Gauge> guarantees;
+  hashmap<string, PullGauge> allocated;
+  hashmap<string, PullGauge> guarantees;
 
   foreach (const Resource& resource, quota.info.guarantee()) {
     CHECK_EQ(Value::SCALAR, resource.type());
     double value = resource.scalar().value();
 
-    Gauge guarantee = Gauge(
+    PullGauge guarantee = PullGauge(
         "allocator/mesos/quota"
         "/roles/" + role +
         "/resources/" + resource.name() +
         "/guarantee",
         process::defer([value]() { return value; }));
 
-    Gauge offered_or_allocated(
+    PullGauge offered_or_allocated(
         "allocator/mesos/quota"
         "/roles/" + role +
         "/resources/" + resource.name() +
@@ -166,7 +166,7 @@ void Metrics::removeQuota(const string& role)
 {
   CHECK(quota_allocated.contains(role));
 
-  foreachvalue (const Gauge& gauge, quota_allocated[role]) {
+  foreachvalue (const PullGauge& gauge, quota_allocated[role]) {
     process::metrics::remove(gauge);
   }
 
@@ -178,7 +178,7 @@ void Metrics::addRole(const string& role)
 {
   CHECK(!offer_filters_active.contains(role));
 
-  Gauge gauge(
+  PullGauge gauge(
       "allocator/mesos/offer_filters/roles/" + role + "/active",
       defer(allocator,
             &HierarchicalAllocatorProcess::_offer_filters_active,
@@ -192,7 +192,7 @@ void Metrics::addRole(const string& role)
 
 void Metrics::removeRole(const string& role)
 {
-  Option<Gauge> gauge = offer_filters_active.get(role);
+  Option<PullGauge> gauge = offer_filters_active.get(role);
 
   CHECK_SOME(gauge);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/allocator/mesos/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/metrics.hpp b/src/master/allocator/mesos/metrics.hpp
index d56a10b..6d38622 100644
--- a/src/master/allocator/mesos/metrics.hpp
+++ b/src/master/allocator/mesos/metrics.hpp
@@ -23,7 +23,7 @@
 #include <mesos/quota/quota.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/timer.hpp>
 
 #include <process/pid.hpp>
@@ -56,12 +56,12 @@ struct Metrics
   const process::PID<HierarchicalAllocatorProcess> allocator;
 
   // Number of dispatch events currently waiting in the allocator process.
-  process::metrics::Gauge event_queue_dispatches;
+  process::metrics::PullGauge event_queue_dispatches;
 
   // TODO(bbannier) This metric is identical to `event_queue_dispatches`, but
   // uses a name deprecated in 1.0. This metric should be removed after the
   // deprecation cycle.
-  process::metrics::Gauge event_queue_dispatches_;
+  process::metrics::PullGauge event_queue_dispatches_;
 
   // Number of times the allocation algorithm has run.
   process::metrics::Counter allocation_runs;
@@ -72,22 +72,22 @@ struct Metrics
   // The latency of allocation runs due to the batching of allocation requests.
   process::metrics::Timer<Milliseconds> allocation_run_latency;
 
-  // Gauges for the total amount of each resource in the cluster.
-  std::vector<process::metrics::Gauge> resources_total;
+  // PullGauges for the total amount of each resource in the cluster.
+  std::vector<process::metrics::PullGauge> resources_total;
 
-  // Gauges for the allocated amount of each resource in the cluster.
-  std::vector<process::metrics::Gauge> resources_offered_or_allocated;
+  // PullGauges for the allocated amount of each resource in the cluster.
+  std::vector<process::metrics::PullGauge> resources_offered_or_allocated;
 
-  // Gauges for the per-role quota allocation for each resource.
-  hashmap<std::string, hashmap<std::string, process::metrics::Gauge>>
+  // PullGauges for the per-role quota allocation for each resource.
+  hashmap<std::string, hashmap<std::string, process::metrics::PullGauge>>
     quota_allocated;
 
-  // Gauges for the per-role quota guarantee for each resource.
-  hashmap<std::string, hashmap<std::string, process::metrics::Gauge>>
+  // PullGauges for the per-role quota guarantee for each resource.
+  hashmap<std::string, hashmap<std::string, process::metrics::PullGauge>>
     quota_guarantee;
 
-  // Gauges for the per-role count of active offer filters.
-  hashmap<std::string, process::metrics::Gauge> offer_filters_active;
+  // PullGauges for the per-role count of active offer filters.
+  hashmap<std::string, process::metrics::PullGauge> offer_filters_active;
 };
 
 } // namespace internal {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/allocator/sorter/drf/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/metrics.cpp b/src/master/allocator/sorter/drf/metrics.cpp
index ff63fba..ece151c 100644
--- a/src/master/allocator/sorter/drf/metrics.cpp
+++ b/src/master/allocator/sorter/drf/metrics.cpp
@@ -30,7 +30,7 @@ using std::string;
 using process::UPID;
 using process::defer;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 
 namespace mesos {
 namespace internal {
@@ -48,7 +48,7 @@ Metrics::Metrics(
 
 Metrics::~Metrics()
 {
-  foreachvalue (const Gauge& gauge, dominantShares) {
+  foreachvalue (const PullGauge& gauge, dominantShares) {
     process::metrics::remove(gauge);
   }
 }
@@ -58,7 +58,7 @@ void Metrics::add(const string& client)
 {
   CHECK(!dominantShares.contains(client));
 
-  Gauge gauge(
+  PullGauge gauge(
       path::join(prefix, client, "/shares/", "/dominant"),
       defer(context, [this, client]() {
         // The client may have been removed if the dispatch

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/allocator/sorter/drf/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/metrics.hpp b/src/master/allocator/sorter/drf/metrics.hpp
index 61568cb..1ff7489 100644
--- a/src/master/allocator/sorter/drf/metrics.hpp
+++ b/src/master/allocator/sorter/drf/metrics.hpp
@@ -21,7 +21,7 @@
 
 #include <process/pid.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 #include <stout/hashmap.hpp>
 
@@ -51,7 +51,7 @@ struct Metrics
   const std::string prefix;
 
   // Dominant share of each client.
-  hashmap<std::string, process::metrics::Gauge> dominantShares;
+  hashmap<std::string, process::metrics::PullGauge> dominantShares;
 };
 
 } // namespace allocator {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index a7cadd9..c30cf08 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -2095,7 +2095,7 @@ private:
   // copyable metric types only.
   std::shared_ptr<Metrics> metrics;
 
-  // Gauge handlers.
+  // PullGauge handlers.
   double _uptime_secs()
   {
     return (process::Clock::now() - startTime).secs();

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index 4cc96a1..e46ead7 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -17,7 +17,7 @@
 #include <string>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/foreach.hpp>
@@ -26,7 +26,7 @@
 #include "master/metrics.hpp"
 
 using process::metrics::Counter;
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 
 using std::string;
 
@@ -313,15 +313,15 @@ Metrics::Metrics(const Master& master)
   const string resources[] = {"cpus", "gpus", "mem", "disk"};
 
   foreach (const string& resource, resources) {
-    Gauge total(
+    PullGauge total(
         "master/" + resource + "_total",
         defer(master, &Master::_resources_total, resource));
 
-    Gauge used(
+    PullGauge used(
         "master/" + resource + "_used",
         defer(master, &Master::_resources_used, resource));
 
-    Gauge percent(
+    PullGauge percent(
         "master/" + resource + "_percent",
         defer(master, &Master::_resources_percent, resource));
 
@@ -335,15 +335,15 @@ Metrics::Metrics(const Master& master)
   }
 
   foreach (const string& resource, resources) {
-    Gauge total(
+    PullGauge total(
         "master/" + resource + "_revocable_total",
         defer(master, &Master::_resources_revocable_total, resource));
 
-    Gauge used(
+    PullGauge used(
         "master/" + resource + "_revocable_used",
         defer(master, &Master::_resources_revocable_used, resource));
 
-    Gauge percent(
+    PullGauge percent(
         "master/" + resource + "_revocable_percent",
         defer(master, &Master::_resources_revocable_percent, resource));
 
@@ -458,32 +458,32 @@ Metrics::~Metrics()
   process::metrics::remove(slave_unreachable_completed);
   process::metrics::remove(slave_unreachable_canceled);
 
-  foreach (const Gauge& gauge, resources_total) {
+  foreach (const PullGauge& gauge, resources_total) {
     process::metrics::remove(gauge);
   }
   resources_total.clear();
 
-  foreach (const Gauge& gauge, resources_used) {
+  foreach (const PullGauge& gauge, resources_used) {
     process::metrics::remove(gauge);
   }
   resources_used.clear();
 
-  foreach (const Gauge& gauge, resources_percent) {
+  foreach (const PullGauge& gauge, resources_percent) {
     process::metrics::remove(gauge);
   }
   resources_percent.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_total) {
+  foreach (const PullGauge& gauge, resources_revocable_total) {
     process::metrics::remove(gauge);
   }
   resources_revocable_total.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_used) {
+  foreach (const PullGauge& gauge, resources_revocable_used) {
     process::metrics::remove(gauge);
   }
   resources_revocable_used.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_percent) {
+  foreach (const PullGauge& gauge, resources_revocable_percent) {
     process::metrics::remove(gauge);
   }
   resources_revocable_percent.clear();

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index 5414c47..ec76dbc 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -21,7 +21,7 @@
 #include <vector>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/hashmap.hpp>
@@ -41,28 +41,28 @@ struct Metrics
 
   ~Metrics();
 
-  process::metrics::Gauge uptime_secs;
-  process::metrics::Gauge elected;
+  process::metrics::PullGauge uptime_secs;
+  process::metrics::PullGauge elected;
 
-  process::metrics::Gauge slaves_connected;
-  process::metrics::Gauge slaves_disconnected;
-  process::metrics::Gauge slaves_active;
-  process::metrics::Gauge slaves_inactive;
-  process::metrics::Gauge slaves_unreachable;
+  process::metrics::PullGauge slaves_connected;
+  process::metrics::PullGauge slaves_disconnected;
+  process::metrics::PullGauge slaves_active;
+  process::metrics::PullGauge slaves_inactive;
+  process::metrics::PullGauge slaves_unreachable;
 
-  process::metrics::Gauge frameworks_connected;
-  process::metrics::Gauge frameworks_disconnected;
-  process::metrics::Gauge frameworks_active;
-  process::metrics::Gauge frameworks_inactive;
+  process::metrics::PullGauge frameworks_connected;
+  process::metrics::PullGauge frameworks_disconnected;
+  process::metrics::PullGauge frameworks_active;
+  process::metrics::PullGauge frameworks_inactive;
 
-  process::metrics::Gauge outstanding_offers;
+  process::metrics::PullGauge outstanding_offers;
 
   // Task state metrics.
-  process::metrics::Gauge tasks_staging;
-  process::metrics::Gauge tasks_starting;
-  process::metrics::Gauge tasks_running;
-  process::metrics::Gauge tasks_unreachable;
-  process::metrics::Gauge tasks_killing;
+  process::metrics::PullGauge tasks_staging;
+  process::metrics::PullGauge tasks_starting;
+  process::metrics::PullGauge tasks_running;
+  process::metrics::PullGauge tasks_unreachable;
+  process::metrics::PullGauge tasks_killing;
   process::metrics::Counter tasks_finished;
   process::metrics::Counter tasks_failed;
   process::metrics::Counter tasks_killed;
@@ -172,9 +172,9 @@ struct Metrics
   process::metrics::Counter recovery_slave_removals;
 
   // Process metrics.
-  process::metrics::Gauge event_queue_messages;
-  process::metrics::Gauge event_queue_dispatches;
-  process::metrics::Gauge event_queue_http_requests;
+  process::metrics::PullGauge event_queue_messages;
+  process::metrics::PullGauge event_queue_dispatches;
+  process::metrics::PullGauge event_queue_http_requests;
 
   // Successful registry operations.
   process::metrics::Counter slave_registrations;
@@ -197,14 +197,14 @@ struct Metrics
   process::metrics::Counter slave_unreachable_canceled;
 
   // Non-revocable resources.
-  std::vector<process::metrics::Gauge> resources_total;
-  std::vector<process::metrics::Gauge> resources_used;
-  std::vector<process::metrics::Gauge> resources_percent;
+  std::vector<process::metrics::PullGauge> resources_total;
+  std::vector<process::metrics::PullGauge> resources_used;
+  std::vector<process::metrics::PullGauge> resources_percent;
 
   // Revocable resources.
-  std::vector<process::metrics::Gauge> resources_revocable_total;
-  std::vector<process::metrics::Gauge> resources_revocable_used;
-  std::vector<process::metrics::Gauge> resources_revocable_percent;
+  std::vector<process::metrics::PullGauge> resources_revocable_total;
+  std::vector<process::metrics::PullGauge> resources_revocable_used;
+  std::vector<process::metrics::PullGauge> resources_revocable_percent;
 
   void incrementInvalidSchedulerCalls(const scheduler::Call& call);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/master/registrar.cpp
----------------------------------------------------------------------
diff --git a/src/master/registrar.cpp b/src/master/registrar.cpp
index b0c2817..cc19126 100644
--- a/src/master/registrar.cpp
+++ b/src/master/registrar.cpp
@@ -30,7 +30,7 @@
 #include <process/owned.hpp>
 #include <process/process.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 #include <process/metrics/timer.hpp>
 
@@ -67,7 +67,7 @@ using process::http::OK;
 
 using process::http::authentication::Principal;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 using process::metrics::Timer;
 
 using std::deque;
@@ -166,14 +166,14 @@ private:
       process::metrics::remove(state_store);
     }
 
-    Gauge queued_operations;
-    Gauge registry_size_bytes;
+    PullGauge queued_operations;
+    PullGauge registry_size_bytes;
 
     Timer<Milliseconds> state_fetch;
     Timer<Milliseconds> state_store;
   } metrics;
 
-  // Gauge handlers.
+  // PullGauge handlers.
   double _queued_operations()
   {
     return static_cast<double>(operations.size());

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/resource_provider/manager.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp
index 68e1866..4128808 100644
--- a/src/resource_provider/manager.cpp
+++ b/src/resource_provider/manager.cpp
@@ -32,7 +32,7 @@
 #include <process/id.hpp>
 #include <process/process.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/hashmap.hpp>
@@ -84,7 +84,7 @@ using process::http::UnsupportedMediaType;
 
 using process::http::authentication::Principal;
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 
 namespace mesos {
 namespace internal {
@@ -205,7 +205,7 @@ private:
     explicit Metrics(const ResourceProviderManagerProcess& manager);
     ~Metrics();
 
-    Gauge subscribed;
+    PullGauge subscribed;
   };
 
   Metrics metrics;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index b682d1b..620a3b2 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -61,7 +61,7 @@
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/abort.hpp>
@@ -1611,8 +1611,8 @@ private:
     }
 
     // Process metrics.
-    process::metrics::Gauge event_queue_messages;
-    process::metrics::Gauge event_queue_dispatches;
+    process::metrics::PullGauge event_queue_messages;
+    process::metrics::PullGauge event_queue_dispatches;
   } metrics;
 
   double _event_queue_messages()

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/scheduler/scheduler.cpp
----------------------------------------------------------------------
diff --git a/src/scheduler/scheduler.cpp b/src/scheduler/scheduler.cpp
index c0dff53..238f869 100644
--- a/src/scheduler/scheduler.cpp
+++ b/src/scheduler/scheduler.cpp
@@ -56,7 +56,7 @@
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <process/ssl/flags.hpp>
@@ -920,8 +920,8 @@ private:
     }
 
     // Process metrics.
-    process::metrics::Gauge event_queue_messages;
-    process::metrics::Gauge event_queue_dispatches;
+    process::metrics::PullGauge event_queue_messages;
+    process::metrics::PullGauge event_queue_dispatches;
   } metrics;
 
   double _event_queue_messages()

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/containerizer/fetcher_process.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher_process.hpp b/src/slave/containerizer/fetcher_process.hpp
index 034fe34..56fecf2 100644
--- a/src/slave/containerizer/fetcher_process.hpp
+++ b/src/slave/containerizer/fetcher_process.hpp
@@ -28,7 +28,7 @@
 #include <process/process.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 #include <stout/hashmap.hpp>
 
@@ -258,8 +258,8 @@ private:
     process::metrics::Counter task_fetches_succeeded;
     process::metrics::Counter task_fetches_failed;
 
-    process::metrics::Gauge cache_size_total_bytes;
-    process::metrics::Gauge cache_size_used_bytes;
+    process::metrics::PullGauge cache_size_total_bytes;
+    process::metrics::PullGauge cache_size_used_bytes;
   } metrics;
 
   const Flags flags;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/containerizer/mesos/isolators/filesystem/linux.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.hpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.hpp
index d933af4..99a6f0d 100644
--- a/src/slave/containerizer/mesos/isolators/filesystem/linux.hpp
+++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.hpp
@@ -23,7 +23,7 @@
 #include <process/owned.hpp>
 #include <process/pid.hpp>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 #include <stout/hashmap.hpp>
 
@@ -94,7 +94,7 @@ private:
         const process::PID<LinuxFilesystemIsolatorProcess>& isolator);
     ~Metrics();
 
-    process::metrics::Gauge containers_new_rootfs;
+    process::metrics::PullGauge containers_new_rootfs;
   } metrics;
 
   double _containers_new_rootfs();

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/gc_process.hpp
----------------------------------------------------------------------
diff --git a/src/slave/gc_process.hpp b/src/slave/gc_process.hpp
index 433b0e0..20374ad 100644
--- a/src/slave/gc_process.hpp
+++ b/src/slave/gc_process.hpp
@@ -29,7 +29,7 @@
 #include <process/timer.hpp>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 #include <stout/duration.hpp>
 #include <stout/hashmap.hpp>
@@ -94,7 +94,7 @@ private:
 
     process::metrics::Counter path_removals_succeeded;
     process::metrics::Counter path_removals_failed;
-    process::metrics::Gauge path_removals_pending;
+    process::metrics::PullGauge path_removals_pending;
   } metrics;
 
   // Store all the timeouts and corresponding paths to delete.

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/slave/metrics.cpp b/src/slave/metrics.cpp
index 44294af..a1d01ed 100644
--- a/src/slave/metrics.cpp
+++ b/src/slave/metrics.cpp
@@ -16,7 +16,7 @@
 
 #include <string>
 
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/foreach.hpp>
@@ -30,7 +30,7 @@ namespace mesos {
 namespace internal {
 namespace slave {
 
-using process::metrics::Gauge;
+using process::metrics::PullGauge;
 
 Metrics::Metrics(const Slave& slave)
   : uptime_secs(
@@ -133,15 +133,15 @@ Metrics::Metrics(const Slave& slave)
   const string resources[] = {"cpus", "gpus", "mem", "disk"};
 
   foreach (const string& resource, resources) {
-    Gauge total(
+    PullGauge total(
         "slave/" + resource + "_total",
         defer(slave, &Slave::_resources_total, resource));
 
-    Gauge used(
+    PullGauge used(
         "slave/" + resource + "_used",
         defer(slave, &Slave::_resources_used, resource));
 
-    Gauge percent(
+    PullGauge percent(
         "slave/" + resource + "_percent",
         defer(slave, &Slave::_resources_percent, resource));
 
@@ -155,15 +155,15 @@ Metrics::Metrics(const Slave& slave)
   }
 
   foreach (const string& resource, resources) {
-    Gauge total(
+    PullGauge total(
         "slave/" + resource + "_revocable_total",
         defer(slave, &Slave::_resources_revocable_total, resource));
 
-    Gauge used(
+    PullGauge used(
         "slave/" + resource + "_revocable_used",
         defer(slave, &Slave::_resources_revocable_used, resource));
 
-    Gauge percent(
+    PullGauge percent(
         "slave/" + resource + "_revocable_percent",
         defer(slave, &Slave::_resources_revocable_percent, resource));
 
@@ -214,32 +214,32 @@ Metrics::~Metrics()
 
   process::metrics::remove(container_launch_errors);
 
-  foreach (const Gauge& gauge, resources_total) {
+  foreach (const PullGauge& gauge, resources_total) {
     process::metrics::remove(gauge);
   }
   resources_total.clear();
 
-  foreach (const Gauge& gauge, resources_used) {
+  foreach (const PullGauge& gauge, resources_used) {
     process::metrics::remove(gauge);
   }
   resources_used.clear();
 
-  foreach (const Gauge& gauge, resources_percent) {
+  foreach (const PullGauge& gauge, resources_percent) {
     process::metrics::remove(gauge);
   }
   resources_percent.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_total) {
+  foreach (const PullGauge& gauge, resources_revocable_total) {
     process::metrics::remove(gauge);
   }
   resources_revocable_total.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_used) {
+  foreach (const PullGauge& gauge, resources_revocable_used) {
     process::metrics::remove(gauge);
   }
   resources_revocable_used.clear();
 
-  foreach (const Gauge& gauge, resources_revocable_percent) {
+  foreach (const PullGauge& gauge, resources_revocable_percent) {
     process::metrics::remove(gauge);
   }
   resources_revocable_percent.clear();
@@ -256,7 +256,7 @@ void Metrics::setRecoveryTime(const Duration& duration)
 
   const double recovery_seconds = duration.secs();
 
-  recovery_time_secs = process::metrics::Gauge(
+  recovery_time_secs = process::metrics::PullGauge(
         "slave/recovery_time_secs",
         [recovery_seconds]() { return recovery_seconds;});
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/slave/metrics.hpp b/src/slave/metrics.hpp
index b771c4b..80b4722 100644
--- a/src/slave/metrics.hpp
+++ b/src/slave/metrics.hpp
@@ -20,7 +20,7 @@
 #include <vector>
 
 #include <process/metrics/counter.hpp>
-#include <process/metrics/gauge.hpp>
+#include <process/metrics/pull_gauge.hpp>
 
 
 namespace mesos {
@@ -37,27 +37,27 @@ struct Metrics
 
   void setRecoveryTime(const Duration& duration);
 
-  process::metrics::Gauge uptime_secs;
-  process::metrics::Gauge registered;
+  process::metrics::PullGauge uptime_secs;
+  process::metrics::PullGauge registered;
 
   process::metrics::Counter recovery_errors;
-  Option<process::metrics::Gauge> recovery_time_secs;
+  Option<process::metrics::PullGauge> recovery_time_secs;
 
-  process::metrics::Gauge frameworks_active;
+  process::metrics::PullGauge frameworks_active;
 
-  process::metrics::Gauge tasks_staging;
-  process::metrics::Gauge tasks_starting;
-  process::metrics::Gauge tasks_running;
-  process::metrics::Gauge tasks_killing;
+  process::metrics::PullGauge tasks_staging;
+  process::metrics::PullGauge tasks_starting;
+  process::metrics::PullGauge tasks_running;
+  process::metrics::PullGauge tasks_killing;
   process::metrics::Counter tasks_finished;
   process::metrics::Counter tasks_failed;
   process::metrics::Counter tasks_killed;
   process::metrics::Counter tasks_lost;
   process::metrics::Counter tasks_gone;
 
-  process::metrics::Gauge executors_registering;
-  process::metrics::Gauge executors_running;
-  process::metrics::Gauge executors_terminating;
+  process::metrics::PullGauge executors_registering;
+  process::metrics::PullGauge executors_running;
+  process::metrics::PullGauge executors_terminating;
   process::metrics::Counter executors_terminated;
   process::metrics::Counter executors_preempted;
 
@@ -67,19 +67,19 @@ struct Metrics
   process::metrics::Counter valid_framework_messages;
   process::metrics::Counter invalid_framework_messages;
 
-  process::metrics::Gauge executor_directory_max_allowed_age_secs;
+  process::metrics::PullGauge executor_directory_max_allowed_age_secs;
 
   process::metrics::Counter container_launch_errors;
 
   // Non-revocable resources.
-  std::vector<process::metrics::Gauge> resources_total;
-  std::vector<process::metrics::Gauge> resources_used;
-  std::vector<process::metrics::Gauge> resources_percent;
+  std::vector<process::metrics::PullGauge> resources_total;
+  std::vector<process::metrics::PullGauge> resources_used;
+  std::vector<process::metrics::PullGauge> resources_percent;
 
   // Revocable resources.
-  std::vector<process::metrics::Gauge> resources_revocable_total;
-  std::vector<process::metrics::Gauge> resources_revocable_used;
-  std::vector<process::metrics::Gauge> resources_revocable_percent;
+  std::vector<process::metrics::PullGauge> resources_revocable_total;
+  std::vector<process::metrics::PullGauge> resources_revocable_used;
+  std::vector<process::metrics::PullGauge> resources_revocable_percent;
 };
 
 } // namespace slave {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed830653/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index c35996b..fb911ef 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -669,7 +669,7 @@ private:
   process::Future<Nothing> publishResources(
       const Option<Resources>& additionalResources = None());
 
-  // Gauge methods.
+  // PullGauge methods.
   double _frameworks_active()
   {
     return static_cast<double>(frameworks.size());


[2/4] mesos git commit: Added a test for PushGauge.

Posted by gi...@apache.org.
Added a test for PushGauge.

Review: https://reviews.apache.org/r/66830/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/898ff1b2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/898ff1b2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/898ff1b2

Branch: refs/heads/master
Commit: 898ff1b20293f5d55f2c7b65d231cc52bebf9d85
Parents: 6707d39
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Apr 27 16:06:58 2018 -0700
Committer: Gilbert Song <so...@gmail.com>
Committed: Fri Apr 27 16:06:58 2018 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/898ff1b2/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index f2bd99b..3a68388 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -32,6 +32,7 @@
 #include <process/metrics/counter.hpp>
 #include <process/metrics/gauge.hpp>
 #include <process/metrics/metrics.hpp>
+#include <process/metrics/push_gauge.hpp>
 #include <process/metrics/timer.hpp>
 
 namespace authentication = process::http::authentication;
@@ -48,6 +49,7 @@ using http::Unauthorized;
 
 using metrics::Counter;
 using metrics::Gauge;
+using metrics::PushGauge;
 using metrics::Timer;
 
 using process::Clock;
@@ -172,6 +174,36 @@ TEST_F(MetricsTest, THREADSAFE_Gauge)
 }
 
 
+TEST_F(MetricsTest, PushGauge)
+{
+  // Gauge with a value.
+  PushGauge gauge("test/gauge");
+
+  AWAIT_READY(metrics::add(gauge));
+
+  AWAIT_EXPECT_EQ(0.0, gauge.value());
+
+  ++gauge;
+  AWAIT_EXPECT_EQ(1.0, gauge.value());
+
+  gauge += 42;
+  AWAIT_EXPECT_EQ(43.0, gauge.value());
+
+  --gauge;
+  AWAIT_EXPECT_EQ(42.0, gauge.value());
+
+  gauge -= 42;
+  AWAIT_EXPECT_EQ(0.0, gauge.value());
+
+  gauge = 42;
+  AWAIT_EXPECT_EQ(42.0, gauge.value());
+
+  EXPECT_NONE(gauge.statistics());
+
+  AWAIT_READY(metrics::remove(gauge));
+}
+
+
 TEST_F(MetricsTest, Statistics)
 {
   Counter counter("test/counter", process::TIME_SERIES_WINDOW);