You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/02/25 20:45:06 UTC
svn commit: r1449839 - in /incubator/mesos/trunk: include/mesos/ src/
src/files/ src/slave/ src/tests/ third_party/libprocess/include/process/
third_party/libprocess/src/ third_party/libprocess/src/tests/
Author: vinodkone
Date: Mon Feb 25 19:45:05 2013
New Revision: 1449839
URL: http://svn.apache.org/r1449839
Log:
Resource Monitoring 6: Added ResourceMonitor and
updated the isolation module API.
This is the meat of the resource monitoring design.
-Added a ResourceUsage protobuf.
-Added a ResourceMonitor process that periodically hits
the isolation module for usage information.
-Usage is exported to the Statistics process.
-Usage is available via a JSON endpoint.
From: Ben Mahler <be...@gmail.com>
Review: https://reviews.apache.org/r/9094
Added:
incubator/mesos/trunk/src/slave/monitor.cpp
incubator/mesos/trunk/src/slave/monitor.hpp
Modified:
incubator/mesos/trunk/include/mesos/executor.hpp
incubator/mesos/trunk/include/mesos/mesos.proto
incubator/mesos/trunk/src/Makefile.am
incubator/mesos/trunk/src/files/files.cpp
incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp
incubator/mesos/trunk/src/slave/flags.hpp
incubator/mesos/trunk/src/slave/isolation_module.hpp
incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp
incubator/mesos/trunk/src/slave/lxc_isolation_module.hpp
incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
incubator/mesos/trunk/src/slave/process_based_isolation_module.hpp
incubator/mesos/trunk/src/slave/slave.cpp
incubator/mesos/trunk/src/slave/slave.hpp
incubator/mesos/trunk/src/tests/utils.hpp
incubator/mesos/trunk/third_party/libprocess/include/process/statistics.hpp
incubator/mesos/trunk/third_party/libprocess/src/statistics.cpp
incubator/mesos/trunk/third_party/libprocess/src/tests/statistics_tests.cpp
Modified: incubator/mesos/trunk/include/mesos/executor.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/mesos/executor.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/include/mesos/executor.hpp (original)
+++ incubator/mesos/trunk/include/mesos/executor.hpp Mon Feb 25 19:45:05 2013
@@ -68,6 +68,8 @@ class ExecutorProcess;
* returns). This is intended for convenience so that an executor
* doesn't need to store a pointer to the driver itself.
*/
+// TODO(bmahler): Consider adding a usage() callback here, that provides
+// information to the executor about it's ResourceUsage.
class Executor
{
public:
Modified: incubator/mesos/trunk/include/mesos/mesos.proto
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/mesos/mesos.proto?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/include/mesos/mesos.proto (original)
+++ incubator/mesos/trunk/include/mesos/mesos.proto Mon Feb 25 19:45:05 2013
@@ -247,6 +247,56 @@ message Resource {
}
+/*
+ * A snapshot of resource usage statistics.
+ */
+message ResourceStatistics {
+ required double timestamp = 1; // Snapshot time, in seconds since the Epoch.
+
+ // CPU Usage Information:
+ // A percentage based cpu usage rate since the last snapshot.
+ // This is akin to what the 'top' program shows.
+ optional double cpu_usage = 2;
+ // Total CPU time spent in user mode, and kernel mode.
+ optional double cpu_user_time = 3; // In seconds.
+ optional double cpu_system_time = 4; // In seconds.
+
+ // Memory Usage Information:
+ optional uint64 memory_rss = 5; // Resident Set Size (in bytes).
+
+ // TODO(bmahler): Add disk usage.
+ // TODO(bmahler): Add network usage?
+}
+
+
+/**
+ * Describes a snapshot of the resource usage for an executor.
+ *
+ * TODO(bmahler): Note that we want to be sending this information
+ * to the master, and subsequently to the relevant scheduler. So
+ * this proto is designed to be easy for the scheduler to use, this
+ * is why we provide the slave id, executor info / task info.
+ */
+message ResourceUsage {
+ required SlaveID slave_id = 1;
+ required FrameworkID framework_id = 2;
+
+ // Resource usage is for an executor. For tasks launched with
+ // an explicit executor, the executor id is provided. For tasks
+ // launched without an executor, our internal executor will be
+ // used. In this case, we provide the task id here instead, in
+ // order to make this message easier for schedulers to work with.
+
+ optional ExecutorID executor_id = 3; // If present, this executor was
+ optional string executor_name = 4; // explicitly specified.
+
+ optional TaskID task_id = 5; // If present, the task did not have an executor.
+
+ // If missing, the isolation module cannot provide resource usage.
+ optional ResourceStatistics statistics = 6;
+}
+
+
/**
* Describes a request for resources that can be used by a framework
* to proactively influence the allocator. If 'slave_id' is provided
@@ -300,13 +350,13 @@ message TaskInfo {
* another task).
*/
enum TaskState {
- TASK_STAGING = 6; // Initial state. Framework status updates should not use.
+ TASK_STAGING = 6; // Initial state. Framework status updates should not use.
TASK_STARTING = 0;
TASK_RUNNING = 1;
TASK_FINISHED = 2; // TERMINAL.
- TASK_FAILED = 3; // TERMINAL.
- TASK_KILLED = 4; // TERMINAL.
- TASK_LOST = 5; // TERMINAL.
+ TASK_FAILED = 3; // TERMINAL.
+ TASK_KILLED = 4; // TERMINAL.
+ TASK_LOST = 5; // TERMINAL.
}
Modified: incubator/mesos/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/Makefile.am?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/Makefile.am (original)
+++ incubator/mesos/trunk/src/Makefile.am Mon Feb 25 19:45:05 2013
@@ -161,6 +161,7 @@ libmesos_no_third_party_la_SOURCES =
master/slaves_manager.cpp \
slave/constants.cpp \
slave/gc.cpp \
+ slave/monitor.cpp \
slave/state.cpp \
slave/slave.cpp \
slave/http.cpp \
@@ -223,7 +224,7 @@ libmesos_no_third_party_la_SOURCES += co
master/hierarchical_allocator_process.hpp master/http.hpp \
master/master.hpp master/slaves_manager.hpp master/sorter.hpp \
messages/messages.hpp slave/constants.hpp \
- slave/flags.hpp slave/gc.hpp slave/http.hpp \
+ slave/flags.hpp slave/gc.hpp slave/monitor.hpp slave/http.hpp \
slave/isolation_module.hpp slave/isolation_module_factory.hpp \
slave/cgroups_isolation_module.hpp \
slave/lxc_isolation_module.hpp \
Modified: incubator/mesos/trunk/src/files/files.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/files/files.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/files/files.cpp (original)
+++ incubator/mesos/trunk/src/files/files.cpp Mon Feb 25 19:45:05 2013
@@ -19,6 +19,7 @@
#include <stout/error.hpp>
#include <stout/hashmap.hpp>
#include <stout/json.hpp>
+#include <stout/lambda.hpp>
#include <stout/none.hpp>
#include <stout/numify.hpp>
#include <stout/option.hpp>
@@ -306,12 +307,13 @@ Future<Response> FilesProcess::read(cons
boost::shared_array<char> data(new char[length]);
return io::read(fd.get(), data.get(), static_cast<size_t>(length))
- .then(std::tr1::bind(_read,
- fd.get(),
- std::tr1::placeholders::_1,
- offset,
- data,
- request.query.get("jsonp")));
+ .then(lambda::bind(
+ _read,
+ fd.get(),
+ lambda::_1,
+ offset,
+ data,
+ request.query.get("jsonp")));
}
Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp Mon Feb 25 19:45:05 2013
@@ -580,6 +580,16 @@ void CgroupsIsolationModule::resourcesCh
}
+Future<ResourceStatistics> CgroupsIsolationModule::usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ ResourceStatistics result;
+ // TODO(bmahler): Compute resource usage.
+ return result;
+}
+
+
void CgroupsIsolationModule::processExited(pid_t pid, int status)
{
CgroupInfo* info = findCgroupInfo(pid);
Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp Mon Feb 25 19:45:05 2013
@@ -103,6 +103,10 @@ public:
const ExecutorID& executorId,
const Resources& resources);
+ virtual process::Future<ResourceStatistics> usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
virtual void processExited(pid_t pid, int status);
private:
Modified: incubator/mesos/trunk/src/slave/flags.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/flags.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/flags.hpp (original)
+++ incubator/mesos/trunk/src/slave/flags.hpp Mon Feb 25 19:45:05 2013
@@ -32,6 +32,10 @@ namespace mesos {
namespace internal {
namespace slave {
+// Default interval for resource monitoring.
+const Duration RESOURCE_MONITORING_INTERVAL = Seconds(5);
+
+
class Flags : public virtual flags::FlagsBase
{
public:
@@ -92,7 +96,7 @@ public:
"Maximum amount of time to wait before cleaning up\n"
"executor directories (e.g., 3days, 2weeks, etc).\n"
"Note that this delay may be shorter depending on\n"
- "the available disk usage.",
+ "the available disk usage",
GC_DELAY);
add(&Flags::disk_watch_interval,
@@ -101,6 +105,12 @@ public:
"to check the disk usage",
DISK_WATCH_INTERVAL);
+ add(&Flags::resource_monitoring_interval,
+ "resource_monitoring_interval",
+ "Periodic time interval for monitoring executor\n"
+ "resource usage (e.g., 10secs, 1min, etc)",
+ RESOURCE_MONITORING_INTERVAL);
+
#ifdef __linux__
add(&Flags::cgroups_hierarchy_root,
"cgroups_hierarchy_root",
@@ -125,6 +135,7 @@ public:
Duration executor_shutdown_grace_period;
Duration gc_delay;
Duration disk_watch_interval;
+ Duration resource_monitoring_interval;
#ifdef __linux__
std::string cgroups_hierarchy_root;
std::string cgroups_subsystems;
Modified: incubator/mesos/trunk/src/slave/isolation_module.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/isolation_module.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/isolation_module.hpp (original)
+++ incubator/mesos/trunk/src/slave/isolation_module.hpp Mon Feb 25 19:45:05 2013
@@ -23,8 +23,11 @@
#include <mesos/mesos.hpp>
+#include <process/future.hpp>
#include <process/process.hpp>
+#include <stout/hashmap.hpp>
+
#include "common/resources.hpp"
#include "slave/flags.hpp"
@@ -36,7 +39,6 @@ namespace slave {
// Forward declaration.
class Slave;
-
class IsolationModule : public process::Process<IsolationModule>
{
public:
@@ -46,30 +48,40 @@ public:
virtual ~IsolationModule() {}
// Called during slave initialization.
- virtual void initialize(const Flags& flags,
- const Resources& resources,
- bool local,
- const process::PID<Slave>& slave) = 0;
+ virtual void initialize(
+ const Flags& flags,
+ const Resources& resources,
+ bool local,
+ const process::PID<Slave>& slave) = 0;
// Called by the slave to launch an executor for a given framework.
- virtual void launchExecutor(const FrameworkID& frameworkId,
- const FrameworkInfo& frameworkInfo,
- const ExecutorInfo& executorInfo,
- const std::string& directory,
- const Resources& resources) = 0;
+ virtual void launchExecutor(
+ const FrameworkID& frameworkId,
+ const FrameworkInfo& frameworkInfo,
+ const ExecutorInfo& executorInfo,
+ const std::string& directory,
+ const Resources& resources) = 0;
// Terminate a framework's executor, if it is still running.
// The executor is expected to be gone after this method exits.
- virtual void killExecutor(const FrameworkID& frameworkId,
- const ExecutorID& executorId) = 0;
+ virtual void killExecutor(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId) = 0;
// Update the resource limits for a given framework. This method will
// be called only after an executor for the framework is started.
- virtual void resourcesChanged(const FrameworkID& frameworkId,
- const ExecutorID& executorId,
- const Resources& resources) = 0;
+ virtual void resourcesChanged(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Resources& resources) = 0;
+
+ // Returns the resource usage for the isolation module.
+ virtual process::Future<ResourceStatistics> usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId) = 0;
};
+
} // namespace slave {
} // namespace internal {
} // namespace mesos {
Modified: incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/lxc_isolation_module.cpp Mon Feb 25 19:45:05 2013
@@ -315,6 +315,16 @@ void LxcIsolationModule::resourcesChange
}
+Future<ResourceStatistics> LxcIsolationModule::usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ ResourceStatistics result;
+ // TODO(bmahler): Compute resource usage.
+ return result;
+}
+
+
void LxcIsolationModule::processExited(pid_t pid, int status)
{
foreachkey (const FrameworkID& frameworkId, infos) {
Modified: incubator/mesos/trunk/src/slave/lxc_isolation_module.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/lxc_isolation_module.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/lxc_isolation_module.hpp (original)
+++ incubator/mesos/trunk/src/slave/lxc_isolation_module.hpp Mon Feb 25 19:45:05 2013
@@ -22,6 +22,8 @@
#include <string>
#include <vector>
+#include <process/future.hpp>
+
#include <stout/hashmap.hpp>
#include "slave/isolation_module.hpp"
@@ -40,23 +42,31 @@ public:
virtual ~LxcIsolationModule();
- virtual void initialize(const Flags& flags,
- const Resources& resources,
- bool local,
- const process::PID<Slave>& slave);
-
- virtual void launchExecutor(const FrameworkID& frameworkId,
- const FrameworkInfo& frameworkInfo,
- const ExecutorInfo& executorInfo,
- const std::string& directory,
- const Resources& resources);
-
- virtual void killExecutor(const FrameworkID& frameworkId,
- const ExecutorID& executorId);
-
- virtual void resourcesChanged(const FrameworkID& frameworkId,
- const ExecutorID& executorId,
- const Resources& resources);
+ virtual void initialize(
+ const Flags& flags,
+ const Resources& resources,
+ bool local,
+ const process::PID<Slave>& slave);
+
+ virtual void launchExecutor(
+ const FrameworkID& frameworkId,
+ const FrameworkInfo& frameworkInfo,
+ const ExecutorInfo& executorInfo,
+ const std::string& directory,
+ const Resources& resources);
+
+ virtual void killExecutor(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+ virtual void resourcesChanged(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Resources& resources);
+
+ virtual process::Future<ResourceStatistics> usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
virtual void processExited(pid_t pid, int status);
@@ -67,9 +77,10 @@ private:
// Attempt to set a resource limit of a container for a given
// control group property (e.g. cpu.shares).
- bool setControlGroupValue(const std::string& container,
- const std::string& property,
- int64_t value);
+ bool setControlGroupValue(
+ const std::string& container,
+ const std::string& property,
+ int64_t value);
std::vector<std::string> getControlGroupOptions(const Resources& resources);
Added: incubator/mesos/trunk/src/slave/monitor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/monitor.cpp?rev=1449839&view=auto
==============================================================================
--- incubator/mesos/trunk/src/slave/monitor.cpp (added)
+++ incubator/mesos/trunk/src/slave/monitor.cpp Mon Feb 25 19:45:05 2013
@@ -0,0 +1,343 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#include <map>
+#include <string>
+
+#include <mesos/mesos.hpp>
+
+#include <process/clock.hpp>
+#include <process/defer.hpp>
+#include <process/delay.hpp>
+#include <process/future.hpp>
+#include <process/http.hpp>
+#include <process/process.hpp>
+#include <process/statistics.hpp>
+
+#include <stout/json.hpp>
+#include <stout/lambda.hpp>
+
+#include "slave/isolation_module.hpp"
+#include "slave/monitor.hpp"
+
+using namespace process;
+
+using std::map;
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+using process::wait; // Necessary on some OS's to disambiguate.
+
+// Resource statistics constants.
+// These match the names in the ResourceStatistics protobuf.
+// TODO(bmahler): Later, when we have a richer monitoring story,
+// we will want to publish these outisde of this file.
+const std::string CPU_TIME = "cpu_time";
+const std::string CPU_USAGE = "cpu_usage";
+const std::string MEMORY_RSS = "memory_rss";
+
+
+// Local function prototypes.
+void publish(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ResourceStatistics& statistics);
+
+Future<http::Response> _usage(
+ const hashmap<FrameworkID, hashmap<ExecutorID, ExecutorInfo> >& executors,
+ const map<string, double>& statistics,
+ const Option<string>& jsonp);
+
+class ResourceMonitorProcess : public Process<ResourceMonitorProcess>
+{
+public:
+ ResourceMonitorProcess(IsolationModule* _isolation)
+ : ProcessBase("monitor"), isolation(_isolation) {}
+
+ virtual ~ResourceMonitorProcess() {}
+
+ Future<Nothing> watch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ExecutorInfo& executorInfo,
+ const Duration& interval);
+
+ Future<Nothing> unwatch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+protected:
+ virtual void initialize()
+ {
+ route("/usage.json", &ResourceMonitorProcess::usage);
+ }
+
+private:
+ void collect(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Duration& interval);
+
+ void _collect(
+ const Future<ResourceStatistics>& statistics,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Duration& interval);
+
+ // Returns the usage information. Requests have no parameters.
+ Future<http::Response> usage(const http::Request& request);
+
+ IsolationModule* isolation;
+
+ // The executor info is stored for each watched executor.
+ hashmap<FrameworkID, hashmap<ExecutorID, ExecutorInfo> > watches;
+};
+
+
+Future<Nothing> ResourceMonitorProcess::watch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ExecutorInfo& executorInfo,
+ const Duration& interval)
+{
+ if (watches.contains(frameworkId) &&
+ watches[frameworkId].contains(executorId)) {
+ return Future<Nothing>::failed("Already watched");
+ }
+
+ watches[frameworkId][executorId] = executorInfo;
+
+ // Set up the cpu usage meter prior to collecting.
+ const string& prefix =
+ strings::join("/", frameworkId.value(), executorId.value(), "");
+
+ process::statistics->meter(
+ "monitor",
+ prefix + CPU_TIME,
+ new meters::TimeRate(prefix + CPU_USAGE));
+
+ // Schedule the resource collection.
+ delay(interval, self(), &Self::collect, frameworkId, executorId, interval);
+
+ return Nothing();
+}
+
+
+Future<Nothing> ResourceMonitorProcess::unwatch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ if (!watches.contains(frameworkId) ||
+ !watches[frameworkId].contains(executorId)) {
+ return Future<Nothing>::failed("Not watched");
+ }
+
+ watches[frameworkId].erase(executorId);
+
+ if (watches[frameworkId].empty()) {
+ watches.erase(frameworkId);
+ }
+
+ return Nothing();
+}
+
+
+void ResourceMonitorProcess::collect(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Duration& interval)
+{
+ // Has the executor been unwatched?
+ if (!watches.contains(frameworkId) ||
+ !watches[frameworkId].contains(executorId)) {
+ return;
+ }
+
+ isolation->usage(frameworkId, executorId).onAny(
+ defer(self(),
+ &Self::_collect,
+ lambda::_1,
+ frameworkId,
+ executorId,
+ interval));
+}
+
+
+void ResourceMonitorProcess::_collect(
+ const Future<ResourceStatistics>& statistics,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Duration& interval)
+{
+ CHECK(!statistics.isDiscarded());
+
+ // Has the executor been unwatched?
+ if (!watches.contains(frameworkId) ||
+ !watches[frameworkId].contains(executorId)) {
+ return;
+ }
+
+ if (statistics.isReady()) {
+ // Publish the data to the statistics module.
+ publish(frameworkId, executorId, statistics.get());
+ } else {
+ LOG(WARNING)
+ << "Failed to collect resources for executor " << executorId
+ << " of framework " << frameworkId << ": " << statistics.failure();
+ }
+
+ // Schedule the next collection.
+ delay(interval, self(), &Self::collect, frameworkId, executorId, interval);
+}
+
+
+// TODO(bmahler): With slave recovery, executor uuid's will be exposed
+// to the isolation module. This means that we will be able to publish
+// statistics per executor run, rather than across all runs.
+void publish(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ResourceStatistics& statistics)
+{
+ Seconds time(statistics.timestamp());
+
+ const string& prefix =
+ strings::join("/", frameworkId.value(), executorId.value(), "");
+
+ // Publish memory statistic.
+ process::statistics->set(
+ "monitor",
+ prefix + MEMORY_RSS,
+ statistics.memory_rss(),
+ time);
+
+ // Publish cpu usage statistics. The applied meter from watch()
+ // will publish the cpu usage percentage.
+ process::statistics->set(
+ "monitor",
+ prefix + CPU_TIME,
+ statistics.cpu_user_time() + statistics.cpu_system_time(),
+ time);
+}
+
+
+Future<http::Response> ResourceMonitorProcess::usage(
+ const http::Request& request)
+{
+ lambda::function<Future<http::Response>(const map<string, double>&)>
+ _usage = lambda::bind(
+ slave::_usage,
+ watches,
+ lambda::_1,
+ request.query.get("jsonp"));
+
+ return process::statistics->get("monitor").then(_usage);
+}
+
+
+Future<http::Response> _usage(
+ const hashmap<FrameworkID, hashmap<ExecutorID, ExecutorInfo> >& watches,
+ const map<string, double>& statistics,
+ const Option<string>& jsonp)
+{
+ JSON::Array result;
+
+ foreachkey (const FrameworkID& frameworkId, watches) {
+ foreachkey (const ExecutorID& executorId, watches.get(frameworkId).get()) {
+ const ExecutorInfo& info =
+ watches.get(frameworkId).get().get(executorId).get();
+ const string& prefix =
+ strings::join("/", frameworkId.value(), executorId.value(), "");
+
+ // Export zero values by default.
+ JSON::Object usage;
+ usage.values[CPU_USAGE] = 0;
+ usage.values[CPU_TIME] = 0;
+ usage.values[MEMORY_RSS] = 0;
+
+ // Set the usage data if present.
+ if (statistics.count(prefix + CPU_USAGE) > 0) {
+ usage.values[CPU_USAGE] = statistics.find(prefix + CPU_USAGE)->second;
+ }
+ if (statistics.count(prefix + CPU_TIME) > 0) {
+ usage.values[CPU_TIME] = statistics.find(prefix + CPU_TIME)->second;
+ }
+ if (statistics.count(prefix + MEMORY_RSS) > 0) {
+ usage.values[MEMORY_RSS] = statistics.find(prefix + MEMORY_RSS)->second;
+ }
+
+ JSON::Object entry;
+ entry.values["framework_id"] = frameworkId.value();
+ entry.values["executor_id"] = executorId.value();
+ entry.values["executor_name"] = info.name();
+ entry.values["source"] = info.source();
+ entry.values["resource_usage"] = usage;
+
+ result.values.push_back(entry);
+ }
+ }
+
+ return http::OK(result, jsonp);
+}
+
+
+ResourceMonitor::ResourceMonitor(IsolationModule* isolation)
+{
+ process = new ResourceMonitorProcess(isolation);
+ spawn(process);
+}
+
+
+ResourceMonitor::~ResourceMonitor()
+{
+ terminate(process);
+ wait(process);
+ delete process;
+}
+
+
+Future<Nothing> ResourceMonitor::watch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ExecutorInfo& executorInfo,
+ const Duration& interval)
+{
+ return dispatch(
+ process,
+ &ResourceMonitorProcess::watch,
+ frameworkId,
+ executorId,
+ executorInfo,
+ interval);
+}
+
+
+Future<Nothing> ResourceMonitor::unwatch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ return dispatch(
+ process, &ResourceMonitorProcess::unwatch, frameworkId, executorId);
+}
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
Added: incubator/mesos/trunk/src/slave/monitor.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/monitor.hpp?rev=1449839&view=auto
==============================================================================
--- incubator/mesos/trunk/src/slave/monitor.hpp (added)
+++ incubator/mesos/trunk/src/slave/monitor.hpp Mon Feb 25 19:45:05 2013
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 __SLAVE_MONITOR_HPP__
+#define __SLAVE_MONITOR_HPP__
+
+#include <string>
+
+#include <process/future.hpp>
+
+#include <stout/duration.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+#include "common/type_utils.hpp"
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+// Forward declarations.
+class ResourceMonitorProcess;
+
+
+// Provides resource monitoring for executors. Resource usage time
+// series are stored using the Statistics module. Usage information
+// is also exported via a JSON endpoint.
+// TODO(bmahler): Forward usage information to the master.
+// TODO(bmahler): Consider pulling out the resource collection into
+// a Collector abstraction. The monitor can then become a true
+// monitoring abstraction, allowing isolation modules to subscribe
+// to resource usage events. (e.g. get a future for the executor
+// hitting 75% memory consumption, the future would become ready
+// when this occurs, and the isolation module can discard the future
+// when no longer interested).
+class ResourceMonitor
+{
+public:
+ ResourceMonitor(IsolationModule* isolation);
+ ~ResourceMonitor();
+
+ // Starts monitoring resources for the given executor.
+ // Returns a failure if the executor is already being watched.
+ process::Future<Nothing> watch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ExecutorInfo& executorInfo,
+ const Duration& interval);
+
+ // Stops monitoring resources for the given executor.
+ // Returns a failure if the executor is unknown to the monitor.
+ process::Future<Nothing> unwatch(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+private:
+ ResourceMonitorProcess* process;
+};
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __SLAVE_MONITOR_HPP__
Modified: incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp Mon Feb 25 19:45:05 2013
@@ -266,6 +266,16 @@ ExecutorLauncher* ProcessBasedIsolationM
}
+Future<ResourceStatistics> ProcessBasedIsolationModule::usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ ResourceStatistics result;
+ // TODO(bmahler): Compute resource usage.
+ return result;
+}
+
+
void ProcessBasedIsolationModule::processExited(pid_t pid, int status)
{
foreachkey (const FrameworkID& frameworkId, infos) {
Modified: incubator/mesos/trunk/src/slave/process_based_isolation_module.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/process_based_isolation_module.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/process_based_isolation_module.hpp (original)
+++ incubator/mesos/trunk/src/slave/process_based_isolation_module.hpp Mon Feb 25 19:45:05 2013
@@ -23,6 +23,8 @@
#include <sys/types.h>
+#include <process/future.hpp>
+
#include <stout/hashmap.hpp>
#include "launcher/launcher.hpp"
@@ -44,23 +46,31 @@ public:
virtual ~ProcessBasedIsolationModule();
- virtual void initialize(const Flags& flags,
- const Resources& resources,
- bool local,
- const process::PID<Slave>& slave);
-
- virtual void launchExecutor(const FrameworkID& frameworkId,
- const FrameworkInfo& frameworkInfo,
- const ExecutorInfo& executorInfo,
- const std::string& directory,
- const Resources& resources);
-
- virtual void killExecutor(const FrameworkID& frameworkId,
- const ExecutorID& executorId);
-
- virtual void resourcesChanged(const FrameworkID& frameworkId,
- const ExecutorID& executorId,
- const Resources& resources);
+ virtual void initialize(
+ const Flags& flags,
+ const Resources& resources,
+ bool local,
+ const process::PID<Slave>& slave);
+
+ virtual void launchExecutor(
+ const FrameworkID& frameworkId,
+ const FrameworkInfo& frameworkInfo,
+ const ExecutorInfo& executorInfo,
+ const std::string& directory,
+ const Resources& resources);
+
+ virtual void killExecutor(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+ virtual void resourcesChanged(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const Resources& resources);
+
+ virtual process::Future<ResourceStatistics> usage(
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
virtual void processExited(pid_t pid, int status);
Modified: incubator/mesos/trunk/src/slave/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave/slave.cpp Mon Feb 25 19:45:05 2013
@@ -29,6 +29,7 @@
#include <stout/duration.hpp>
#include <stout/fs.hpp>
+#include <stout/lambda.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
@@ -71,7 +72,8 @@ Slave::Slave(const Resources& _resources
resources(_resources),
completedFrameworks(MAX_COMPLETED_FRAMEWORKS),
isolationModule(_isolationModule),
- files(_files) {}
+ files(_files),
+ monitor(isolationModule) {}
Slave::Slave(const flags::Flags<logging::Flags, slave::Flags>& _flags,
@@ -83,7 +85,8 @@ Slave::Slave(const flags::Flags<logging:
local(_local),
completedFrameworks(MAX_COMPLETED_FRAMEWORKS),
isolationModule(_isolationModule),
- files(_files)
+ files(_files),
+ monitor(isolationModule)
{
if (flags.resources.isNone()) {
// TODO(benh): Move this computation into Flags as the "default".
@@ -977,6 +980,12 @@ Framework* Slave::getFramework(const Fra
}
+void _watch(
+ const Future<Nothing>& watch,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+
// N.B. When the slave is running in "local" mode then the pid is
// uninteresting (and possibly could cause bugs).
void Slave::executorStarted(
@@ -984,7 +993,43 @@ void Slave::executorStarted(
const ExecutorID& executorId,
pid_t pid)
{
+ Framework* framework = getFramework(frameworkId);
+ if (framework == NULL) {
+ LOG(WARNING) << "Framework " << frameworkId
+ << " for executor '" << executorId
+ << "' is no longer valid";
+ return;
+ }
+ Executor* executor = framework->getExecutor(executorId);
+ if (executor == NULL) {
+ LOG(WARNING) << "Invalid executor '" << executorId
+ << "' of framework " << frameworkId
+ << " has started";
+ return;
+ }
+
+ monitor.watch(
+ frameworkId,
+ executorId,
+ executor->info,
+ flags.resource_monitoring_interval)
+ .onAny(lambda::bind(_watch, lambda::_1, frameworkId, executorId));
+}
+
+
+void _watch(
+ const Future<Nothing>& watch,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ CHECK(!watch.isDiscarded());
+
+ if (!watch.isReady()) {
+ LOG(ERROR) << "Failed to watch executor " << executorId
+ << " of framework " << frameworkId
+ << ": " << watch.failure();
+ }
}
@@ -1003,6 +1048,12 @@ void Slave::sendStatusUpdate(
}
+void _unwatch(
+ const Future<Nothing>& watch,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId);
+
+
// Called by the isolation module when an executor process terminates.
void Slave::executorTerminated(
const FrameworkID& frameworkId,
@@ -1020,6 +1071,10 @@ void Slave::executorTerminated(
? stringify(WEXITSTATUS(status))
: strsignal(WTERMSIG(status)));
+ // Stop monitoring this executor.
+ monitor.unwatch(frameworkId, executorId)
+ .onAny(lambda::bind(_unwatch, lambda::_1, frameworkId, executorId));
+
Framework* framework = getFramework(frameworkId);
if (framework == NULL) {
LOG(WARNING) << "Framework " << frameworkId
@@ -1089,6 +1144,21 @@ void Slave::executorTerminated(
}
+void _unwatch(
+ const Future<Nothing>& unwatch,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId)
+{
+ CHECK(!unwatch.isDiscarded());
+
+ if (!unwatch.isReady()) {
+ LOG(ERROR) << "Failed to unwatch executor " << executorId
+ << " of framework " << frameworkId
+ << ": " << unwatch.failure();
+ }
+}
+
+
void Slave::shutdownExecutor(Framework* framework, Executor* executor)
{
LOG(INFO) << "Shutting down executor '" << executor->id
Modified: incubator/mesos/trunk/src/slave/slave.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.hpp (original)
+++ incubator/mesos/trunk/src/slave/slave.hpp Mon Feb 25 19:45:05 2013
@@ -40,6 +40,7 @@
#include "slave/gc.hpp"
#include "slave/http.hpp"
#include "slave/isolation_module.hpp"
+#include "slave/monitor.hpp"
#include "slave/paths.hpp"
#include "slave/state.hpp"
@@ -236,6 +237,7 @@ private:
bool connected; // Flag to indicate if slave is registered.
GarbageCollector gc;
+ ResourceMonitor monitor;
state::SlaveState state;
};
Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Mon Feb 25 19:45:05 2013
@@ -61,6 +61,7 @@
// TODO(benh): Kill these since they pollute everything that includes this file.
using ::testing::_;
using ::testing::Invoke;
+using ::testing::Return;
namespace mesos {
namespace internal {
@@ -606,6 +607,10 @@ public:
{
EXPECT_CALL(*this, resourcesChanged(testing::_, testing::_, testing::_))
.Times(testing::AnyNumber());
+
+ ResourceStatistics empty;
+ EXPECT_CALL(*this, usage(testing::_, testing::_))
+ .WillRepeatedly(Return(empty));
}
virtual ~TestingIsolationModule() {}
@@ -668,6 +673,12 @@ public:
const ExecutorID&,
const Resources&));
+ MOCK_METHOD2(
+ usage,
+ process::Future<ResourceStatistics>(
+ const FrameworkID&,
+ const ExecutorID&));
+
std::map<ExecutorID, std::string> directories;
private:
Modified: incubator/mesos/trunk/third_party/libprocess/include/process/statistics.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/statistics.hpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/statistics.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/statistics.hpp Mon Feb 25 19:45:05 2013
@@ -51,12 +51,21 @@ public:
~Statistics();
// Returns the time series of a statistic.
- process::Future<std::map<Seconds, double> > get(
+ process::Future<std::map<Seconds, double> > timeseries(
const std::string& context,
const std::string& name,
const Option<Seconds>& start = None(),
const Option<Seconds>& stop = None());
+ // Returns the latest value of a statistic.
+ process::Future<Option<double> > get(
+ const std::string& context,
+ const std::string& name);
+
+ // Returns the latest values of all statistics in the context.
+ process::Future<std::map<std::string, double> > get(
+ const std::string& context);
+
// Adds a meter for the statistic with the provided context and name.
// get(context, meter->name) will return the metered time series.
// Returns an error if:
Modified: incubator/mesos/trunk/third_party/libprocess/src/statistics.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/statistics.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/statistics.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/statistics.cpp Mon Feb 25 19:45:05 2013
@@ -72,12 +72,16 @@ public:
virtual ~StatisticsProcess() {}
// Statistics implementation.
- map<Seconds, double> get(
+ map<Seconds, double> timeseries(
const string& context,
const string& name,
const Option<Seconds>& start,
const Option<Seconds>& stop);
+ Option<double> get(const string& context, const string& name);
+
+ map<string, double> get(const string& context);
+
Try<Nothing> meter(
const string& context,
const string& name,
@@ -115,7 +119,7 @@ private:
// Removes values for all statistics that occurred outside the time
// series window.
- // NOTE: Runs perpetually based on the STATISTICS_TRUNCATION_INTERVAL.
+ // NOTE: Runs periodically every STATISTICS_TRUNCATION_INTERVAL.
// NOTE: We always ensure there is at least 1 value left for a statistic,
// unless it is archived.
void truncate();
@@ -164,7 +168,7 @@ Try<Nothing> StatisticsProcess::meter(
}
-map<Seconds, double> StatisticsProcess::get(
+map<Seconds, double> StatisticsProcess::timeseries(
const string& context,
const string& name,
const Option<Seconds>& start,
@@ -187,6 +191,38 @@ map<Seconds, double> StatisticsProcess::
}
+Option<double> StatisticsProcess::get(const string& context, const string& name)
+{
+ if (!statistics.contains(context) ||
+ !statistics[context].contains(name) ||
+ statistics[context][name].values.empty()) {
+ return Option<double>::none();
+ } else {
+ return statistics[context][name].values.rbegin()->second;
+ }
+}
+
+
+map<string, double> StatisticsProcess::get(const string& context)
+{
+ map<string, double> results;
+
+ if (!statistics.contains(context)) {
+ return results;
+ }
+
+ foreachkey (const string& name, statistics[context]) {
+ const map<Seconds, double>& values = statistics[context][name].values;
+
+ if (!values.empty()) {
+ results[name] = values.rbegin()->second;
+ }
+ }
+
+ return results;
+}
+
+
void StatisticsProcess::set(
const string& context,
const string& name,
@@ -361,7 +397,8 @@ Future<Response> StatisticsProcess::seri
JSON::Array array;
- map<Seconds, double> values = get(context.get(), name.get(), start, stop);
+ const map<Seconds, double>& values =
+ timeseries(context.get(), name.get(), start, stop);
foreachpair (const Seconds& s, double value, values) {
JSON::Object object;
@@ -388,13 +425,28 @@ Statistics::~Statistics()
}
-Future<map<Seconds, double> > Statistics::get(
+Future<map<Seconds, double> > Statistics::timeseries(
const string& context,
const string& name,
const Option<Seconds>& start,
const Option<Seconds>& stop)
{
- return dispatch(process, &StatisticsProcess::get, context, name, start, stop);
+ return dispatch(
+ process, &StatisticsProcess::timeseries, context, name, start, stop);
+}
+
+
+Future<Option<double> > Statistics::get(
+ const string& context,
+ const string& name)
+{
+ return dispatch(process, &StatisticsProcess::get, context, name);
+}
+
+
+Future<map<string, double> > Statistics::get(const string& context)
+{
+ return dispatch(process, &StatisticsProcess::get, context);
}
Modified: incubator/mesos/trunk/third_party/libprocess/src/tests/statistics_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/tests/statistics_tests.cpp?rev=1449839&r1=1449838&r2=1449839&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/tests/statistics_tests.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/tests/statistics_tests.cpp Mon Feb 25 19:45:05 2013
@@ -24,7 +24,8 @@ TEST(Statistics, set)
Seconds now(Clock::now());
statistics.set("test", "statistic", 4.0, now);
- Future<map<Seconds, double> > values = statistics.get("test", "statistic");
+ Future<map<Seconds, double> > values =
+ statistics.timeseries("test", "statistic");
values.await();
@@ -47,7 +48,8 @@ TEST(Statistics, truncate)
statistics.set("test", "statistic", 3.0);
- Future<map<Seconds, double> > values = statistics.get("test", "statistic");
+ Future<map<Seconds, double> > values =
+ statistics.timeseries("test", "statistic");
values.await();
@@ -60,7 +62,7 @@ TEST(Statistics, truncate)
statistics.increment("test", "statistic");
- values = statistics.get("test", "statistic");
+ values = statistics.timeseries("test", "statistic");
values.await();
@@ -91,7 +93,8 @@ TEST(Statistics, meter) {
statistics.set("test", "statistic", 4.0, Seconds(now.secs() + 2.0));
// Check the raw statistic values.
- Future<map<Seconds, double> > values = statistics.get("test", "statistic");
+ Future<map<Seconds, double> > values =
+ statistics.timeseries("test", "statistic");
values.await();
@@ -106,7 +109,7 @@ TEST(Statistics, meter) {
EXPECT_EQ(4.0, values.get()[Seconds(now.secs() + 2.0)]);
// Now check the metered values.
- values = statistics.get("test", "metered");
+ values = statistics.timeseries("test", "metered");
values.await();
@@ -149,14 +152,15 @@ TEST(Statistics, archive)
// TODO(bmahler): Wait for JSON parsing to verify number 1.
- // Ensure the raw timeseries is present.
- Future<map<Seconds, double> > values = statistics.get("test", "statistic");
+ // Ensure the raw time series is present.
+ Future<map<Seconds, double> > values =
+ statistics.timeseries("test", "statistic");
values.await();
ASSERT_TRUE(values.isReady());
EXPECT_FALSE(values.get().empty());
// Ensure the metered timeseries is present.
- values = statistics.get("test", "metered");
+ values = statistics.timeseries("test", "metered");
values.await();
ASSERT_TRUE(values.isReady());
EXPECT_FALSE(values.get().empty());
@@ -165,13 +169,13 @@ TEST(Statistics, archive)
Clock::advance(STATISTICS_TRUNCATION_INTERVAL.secs() + 1);
// Ensure the raw statistics are gone.
- values = statistics.get("test", "statistic");
+ values = statistics.timeseries("test", "statistic");
values.await();
ASSERT_TRUE(values.isReady());
EXPECT_TRUE(values.get().empty());
// Ensure the metered statistics are gone.
- values = statistics.get("test", "metered");
+ values = statistics.timeseries("test", "metered");
values.await();
ASSERT_TRUE(values.isReady());
EXPECT_TRUE(values.get().empty());
@@ -179,7 +183,7 @@ TEST(Statistics, archive)
// Reactivate the statistic, and make sure the meter is still missing.
statistics.set("test", "statistic", 1.0, now);
- values = statistics.get("test", "metered");
+ values = statistics.timeseries("test", "metered");
values.await();
ASSERT_TRUE(values.isReady());
EXPECT_TRUE(values.get().empty());