You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/06/04 18:45:25 UTC

[1/2] mesos git commit: Added support for reporting qdisc statistics.

Repository: mesos
Updated Branches:
  refs/heads/master 2b2618f85 -> 9d9777307


Added support for reporting qdisc statistics.

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


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

Branch: refs/heads/master
Commit: d431f049ee77fbb2bfd52e8eac6a031f62209ea3
Parents: 2b2618f
Author: Paul Brett <pa...@twopensource.com>
Authored: Thu Jun 4 09:32:04 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Jun 4 09:38:24 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am                           |  3 +-
 src/linux/routing/queueing/fq_codel.cpp   |  7 +++++
 src/linux/routing/queueing/fq_codel.hpp   | 11 +++++++
 src/linux/routing/queueing/ingress.cpp    |  6 ++++
 src/linux/routing/queueing/ingress.hpp    |  9 ++++++
 src/linux/routing/queueing/internal.hpp   | 39 +++++++++++++++++++++++++
 src/linux/routing/queueing/statistics.hpp | 40 ++++++++++++++++++++++++++
 7 files changed, 114 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 66030c4..cc3d2e6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -549,7 +549,8 @@ if WITH_NETWORK_ISOLATOR
 	linux/routing/queueing/discipline.hpp				\
 	linux/routing/queueing/fq_codel.hpp				\
 	linux/routing/queueing/ingress.hpp				\
-	linux/routing/queueing/internal.hpp
+	linux/routing/queueing/internal.hpp				\
+	linux/routing/queueing/statistics.hpp
 
   libmesos_no_3rdparty_la_SOURCES +=					\
 	slave/containerizer/isolators/network/port_mapping.cpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/fq_codel.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/fq_codel.cpp b/src/linux/routing/queueing/fq_codel.cpp
index 976c6a7..3db5b93 100644
--- a/src/linux/routing/queueing/fq_codel.cpp
+++ b/src/linux/routing/queueing/fq_codel.cpp
@@ -120,6 +120,13 @@ Try<bool> remove(const string& link)
   return internal::remove(link, EGRESS_ROOT, KIND);
 }
 
+
+Result<hashmap<std::string, uint64_t>> statistics(const std::string& link)
+{
+  return internal::statistics(link, EGRESS_ROOT, KIND);
+}
+
+
 } // namespace fq_codel {
 } // namespace queueing {
 } // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/fq_codel.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/fq_codel.hpp b/src/linux/routing/queueing/fq_codel.hpp
index 49c8df6..412af2d 100644
--- a/src/linux/routing/queueing/fq_codel.hpp
+++ b/src/linux/routing/queueing/fq_codel.hpp
@@ -19,8 +19,11 @@
 #ifndef __LINUX_ROUTING_QUEUEING_FQ_CODEL_HPP__
 #define __LINUX_ROUTING_QUEUEING_FQ_CODEL_HPP__
 
+#include <stdint.h>
+
 #include <string>
 
+#include <stout/hashmap.hpp>
 #include <stout/try.hpp>
 
 #include "linux/routing/handle.hpp"
@@ -58,6 +61,14 @@ Try<bool> create(const std::string& link);
 // false if the fq_codel queueing discipline is not found.
 Try<bool> remove(const std::string& link);
 
+
+// Returns the set of common Traffic Control statistics for the
+// fq_codel queueing discipline on the link, None() if the link or
+// qdisc does not exist or an error if we cannot cannot determine the
+// result.
+Result<hashmap<std::string, uint64_t>> statistics(const std::string& link);
+
+
 } // namespace fq_codel {
 } // namespace queueing {
 } // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/ingress.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp
index e96f547..d5fa629 100644
--- a/src/linux/routing/queueing/ingress.cpp
+++ b/src/linux/routing/queueing/ingress.cpp
@@ -108,6 +108,12 @@ Try<bool> remove(const string& link)
   return internal::remove(link, INGRESS_ROOT, KIND);
 }
 
+
+Result<hashmap<std::string, uint64_t>> statistics(const std::string& link)
+{
+  return internal::statistics(link, INGRESS_ROOT, KIND);
+}
+
 } // namespace ingress {
 } // namespace queueing {
 } // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/ingress.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.hpp b/src/linux/routing/queueing/ingress.hpp
index 2b7e1d3..4bd7241 100644
--- a/src/linux/routing/queueing/ingress.hpp
+++ b/src/linux/routing/queueing/ingress.hpp
@@ -19,8 +19,11 @@
 #ifndef __LINUX_ROUTING_QUEUEING_INGRESS_HPP__
 #define __LINUX_ROUTING_QUEUEING_INGRESS_HPP__
 
+#include <stdint.h>
+
 #include <string>
 
+#include <stout/hashmap.hpp>
 #include <stout/try.hpp>
 
 #include "linux/routing/handle.hpp"
@@ -49,6 +52,12 @@ Try<bool> create(const std::string& link);
 // qdisc is not found.
 Try<bool> remove(const std::string& link);
 
+// Returns the set of common Traffic Control statistics for the
+// ingress queueing discipline on the link, None() if the link or
+// qdisc does not exist or an error if we cannot cannot determine the
+// result.
+Result<hashmap<std::string, uint64_t>> statistics(const std::string& link);
+
 } // namespace ingress {
 } // namespace queueing {
 } // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/internal.hpp b/src/linux/routing/queueing/internal.hpp
index 3713f6a..49d8166 100644
--- a/src/linux/routing/queueing/internal.hpp
+++ b/src/linux/routing/queueing/internal.hpp
@@ -44,6 +44,7 @@
 #include "linux/routing/link/internal.hpp"
 
 #include "linux/routing/queueing/discipline.hpp"
+#include "linux/routing/queueing/statistics.hpp"
 
 namespace routing {
 namespace queueing {
@@ -289,6 +290,44 @@ inline Try<bool> remove(
   return true;
 }
 
+
+// Returns the set of common Traffic Control statistics for the
+// queueing discipline on the link, None() if the link or qdisc does
+// not exist or an error if we cannot cannot determine the result.
+inline Result<hashmap<std::string, uint64_t>> statistics(
+    const std::string& _link,
+    const Handle& parent,
+    const std::string& kind)
+{
+  Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
+  if (link.isError()) {
+    return Error(link.error());
+  } else if (link.isNone()) {
+    return None();
+  }
+
+  Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), parent, kind);
+  if (qdisc.isError()) {
+    return Error(qdisc.error());
+  } else if (qdisc.isNone()) {
+    return None();
+  }
+
+  hashmap<std::string, uint64_t> results;
+  char name[32];
+
+  // NOTE: We use '<=' here because RTNL_TC_STATS_MAX is set to be the
+  // value of the last enum entry.
+  for(size_t i = 0; i <= static_cast<size_t>(RTNL_TC_STATS_MAX); i++) {
+    if(rtnl_tc_stat2str(static_cast<rtnl_tc_stat>(i), name, sizeof(name))) {
+      results[name] = rtnl_tc_get_stat(
+          TC_CAST(qdisc.get().get()),
+          static_cast<rtnl_tc_stat>(i));
+    }
+  }
+  return results;
+}
+
 } // namespace internal {
 } // namespace queueing {
 } // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d431f049/src/linux/routing/queueing/statistics.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/statistics.hpp b/src/linux/routing/queueing/statistics.hpp
new file mode 100644
index 0000000..fe419a6
--- /dev/null
+++ b/src/linux/routing/queueing/statistics.hpp
@@ -0,0 +1,40 @@
+/**
+ * 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 __LINUX_ROUTING_QUEUEING_STATISTICS_HPP__
+#define __LINUX_ROUTING_QUEUEING_STATISTICS_HPP__
+
+namespace routing {
+namespace queueing {
+namespace statistics {
+
+constexpr char PACKETS[] = "packets";
+constexpr char BYTES[] = "bytes";
+constexpr char RATE_BPS[] = "rate_bps";
+constexpr char RATE_PPS[] = "rate_pps";
+constexpr char QLEN[] = "qlen";
+constexpr char BACKLOG[] = "backlog";
+constexpr char DROPS[] = "drops";
+constexpr char REQUEUES[] = "requeues";
+constexpr char OVERLIMITS[] = "overlimits";
+
+} // namespace statistics {
+} // namespace queueing {
+} // namespace routing {
+
+#endif // __LINUX_ROUTING_QUEUEING_STATISTICS_HPP__


[2/2] mesos git commit: Added tests for the new qdisc statistics functions.

Posted by ji...@apache.org.
Added tests for the new qdisc statistics functions.

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


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

Branch: refs/heads/master
Commit: 9d977730705feb15bcfbbaa14506db97ff91d9bb
Parents: d431f04
Author: Paul Brett <pa...@twopensource.com>
Authored: Thu Jun 4 09:39:34 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Jun 4 09:39:35 2015 -0700

----------------------------------------------------------------------
 src/tests/routing_tests.cpp | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9d977730/src/tests/routing_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/routing_tests.cpp b/src/tests/routing_tests.cpp
index 687c2fd..96be25f 100644
--- a/src/tests/routing_tests.cpp
+++ b/src/tests/routing_tests.cpp
@@ -52,6 +52,7 @@
 
 #include "linux/routing/queueing/fq_codel.hpp"
 #include "linux/routing/queueing/ingress.hpp"
+#include "linux/routing/queueing/statistics.hpp"
 
 using namespace process;
 
@@ -429,6 +430,10 @@ TEST_F(RoutingVethTest, ROOT_IngressQdisc)
   EXPECT_SOME_FALSE(ingress::exists(TEST_VETH_LINK));
   EXPECT_SOME_FALSE(ingress::exists(TEST_PEER_LINK));
 
+  // Interfaces without qdisc established no data.
+  EXPECT_NONE(ingress::statistics(TEST_VETH_LINK));
+  EXPECT_NONE(ingress::statistics(TEST_PEER_LINK));
+
   // Try to create an ingress filter on an non-existant interface.
   EXPECT_ERROR(ingress::create("noSuchInterface"));
 
@@ -439,6 +444,22 @@ TEST_F(RoutingVethTest, ROOT_IngressQdisc)
   EXPECT_SOME_TRUE(ingress::exists(TEST_VETH_LINK));
   EXPECT_SOME_FALSE(ingress::exists(TEST_PEER_LINK));
 
+  // Interfaces which exist return at least the core statisitcs.
+  Result<hashmap<string, uint64_t>> stats = ingress::statistics(TEST_VETH_LINK);
+  ASSERT_SOME(stats);
+  EXPECT_TRUE(stats.get().contains(statistics::PACKETS));
+  EXPECT_TRUE(stats.get().contains(statistics::BYTES));
+  EXPECT_TRUE(stats.get().contains(statistics::RATE_BPS));
+  EXPECT_TRUE(stats.get().contains(statistics::RATE_PPS));
+  EXPECT_TRUE(stats.get().contains(statistics::QLEN));
+  EXPECT_TRUE(stats.get().contains(statistics::BACKLOG));
+  EXPECT_TRUE(stats.get().contains(statistics::DROPS));
+  EXPECT_TRUE(stats.get().contains(statistics::REQUEUES));
+  EXPECT_TRUE(stats.get().contains(statistics::OVERLIMITS));
+
+  // Interface without qdisc returns no data.
+  EXPECT_NONE(ingress::statistics(TEST_PEER_LINK));
+
   // Try to create a second ingress filter on an existing interface.
   EXPECT_SOME_FALSE(ingress::create(TEST_VETH_LINK));
   EXPECT_SOME_TRUE(ingress::exists(TEST_VETH_LINK));
@@ -473,6 +494,10 @@ TEST_F(RoutingVethTest, ROOT_FqCodeQdisc)
   EXPECT_SOME_FALSE(fq_codel::exists(TEST_VETH_LINK));
   EXPECT_SOME_FALSE(fq_codel::exists(TEST_PEER_LINK));
 
+  // Interfaces without qdisc established no data.
+  EXPECT_NONE(fq_codel::statistics(TEST_VETH_LINK));
+  EXPECT_NONE(fq_codel::statistics(TEST_PEER_LINK));
+
   // Try to create an fq_codel filter on an non-existant interface.
   EXPECT_ERROR(fq_codel::create("noSuchInterface"));
 
@@ -483,6 +508,23 @@ TEST_F(RoutingVethTest, ROOT_FqCodeQdisc)
   EXPECT_SOME_TRUE(fq_codel::exists(TEST_VETH_LINK));
   EXPECT_SOME_FALSE(fq_codel::exists(TEST_PEER_LINK));
 
+  // Interfaces which exist return at least the core statisitcs.
+  Result<hashmap<string, uint64_t>> stats =
+      fq_codel::statistics(TEST_VETH_LINK);
+  ASSERT_SOME(stats);
+  EXPECT_TRUE(stats.get().contains(statistics::PACKETS));
+  EXPECT_TRUE(stats.get().contains(statistics::BYTES));
+  EXPECT_TRUE(stats.get().contains(statistics::RATE_BPS));
+  EXPECT_TRUE(stats.get().contains(statistics::RATE_PPS));
+  EXPECT_TRUE(stats.get().contains(statistics::QLEN));
+  EXPECT_TRUE(stats.get().contains(statistics::BACKLOG));
+  EXPECT_TRUE(stats.get().contains(statistics::DROPS));
+  EXPECT_TRUE(stats.get().contains(statistics::REQUEUES));
+  EXPECT_TRUE(stats.get().contains(statistics::OVERLIMITS));
+
+  // Interface without qdisc returns no data.
+  EXPECT_NONE(fq_codel::statistics(TEST_PEER_LINK));
+
   // Try to create a second fq_codel filter on an existing interface.
   EXPECT_SOME_FALSE(fq_codel::create(TEST_VETH_LINK));
   EXPECT_SOME_TRUE(fq_codel::exists(TEST_VETH_LINK));