You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/05/17 01:14:43 UTC

[3/3] mesos git commit: Refactored log Metrics into separate files.

Refactored log Metrics into separate files.

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


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

Branch: refs/heads/master
Commit: 302bb9aff020e41c82a43745779f418250dd2ddb
Parents: fff43d2
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Sep 30 11:23:21 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue May 16 18:04:01 2017 -0700

----------------------------------------------------------------------
 src/CMakeLists.txt  |  1 +
 src/Makefile.am     |  2 ++
 src/log/log.cpp     | 17 ----------------
 src/log/log.hpp     | 13 +++---------
 src/log/metrics.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/log/metrics.hpp | 46 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 103 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eef718d..a038c0b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -337,6 +337,7 @@ set(LOG_SRC
   log/leveldb.cpp
   log/log.cpp
   log/main.cpp
+  log/metrics.cpp
   log/recover.cpp
   log/replica.cpp
   log/tool/benchmark.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 6bb81fd..1522c5b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1362,6 +1362,7 @@ liblog_la_SOURCES =							\
   log/coordinator.cpp							\
   log/leveldb.cpp							\
   log/log.cpp								\
+  log/metrics.cpp							\
   log/recover.cpp							\
   log/replica.cpp							\
   log/tool/benchmark.cpp						\
@@ -1374,6 +1375,7 @@ liblog_la_SOURCES +=							\
   log/coordinator.hpp							\
   log/leveldb.hpp							\
   log/log.hpp								\
+  log/metrics.hpp							\
   log/network.hpp							\
   log/recover.hpp							\
   log/replica.hpp							\

http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/log/log.cpp
----------------------------------------------------------------------
diff --git a/src/log/log.cpp b/src/log/log.cpp
index 2301eef..dcb66f7 100644
--- a/src/log/log.cpp
+++ b/src/log/log.cpp
@@ -280,23 +280,6 @@ void LogProcess::discarded()
 }
 
 
-LogProcess::Metrics::Metrics(
-    const LogProcess& process,
-    const Option<string>& prefix)
-  : recovered(
-        prefix.getOrElse("") + "log/recovered",
-        defer(process, &LogProcess::_recovered))
-{
-  process::metrics::add(recovered);
-}
-
-
-LogProcess::Metrics::~Metrics()
-{
-  process::metrics::remove(recovered);
-}
-
-
 /////////////////////////////////////////////////
 // Implementation of LogReaderProcess.
 /////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/log/log.hpp
----------------------------------------------------------------------
diff --git a/src/log/log.hpp b/src/log/log.hpp
index a600025..097aeef 100644
--- a/src/log/log.hpp
+++ b/src/log/log.hpp
@@ -31,6 +31,7 @@
 #include <stout/nothing.hpp>
 
 #include "log/coordinator.hpp"
+#include "log/metrics.hpp"
 #include "log/network.hpp"
 #include "log/recover.hpp"
 #include "log/replica.hpp"
@@ -100,16 +101,8 @@ private:
   zookeeper::Group* group;
   process::Future<zookeeper::Group::Membership> membership;
 
-  struct Metrics
-  {
-    explicit Metrics(
-        const LogProcess& process,
-        const Option<std::string>& prefix);
-
-    ~Metrics();
-
-    process::metrics::Gauge recovered;
-  } metrics;
+  friend Metrics;
+  Metrics metrics;
 };
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/log/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/log/metrics.cpp b/src/log/metrics.cpp
new file mode 100644
index 0000000..90b6988
--- /dev/null
+++ b/src/log/metrics.cpp
@@ -0,0 +1,51 @@
+// 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 "log/metrics.hpp"
+
+#include <process/defer.hpp>
+
+#include <process/metrics/metrics.hpp>
+
+#include "log/log.hpp"
+
+using std::string;
+
+using process::defer;
+
+namespace mesos {
+namespace internal {
+namespace log {
+
+Metrics::Metrics(
+    const LogProcess& process,
+    const Option<string>& prefix)
+  : recovered(
+        prefix.getOrElse("") + "log/recovered",
+        defer(process, &LogProcess::_recovered))
+{
+  process::metrics::add(recovered);
+}
+
+
+Metrics::~Metrics()
+{
+  process::metrics::remove(recovered);
+}
+
+} // namespace log {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/302bb9af/src/log/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/log/metrics.hpp b/src/log/metrics.hpp
new file mode 100644
index 0000000..23ba6eb
--- /dev/null
+++ b/src/log/metrics.hpp
@@ -0,0 +1,46 @@
+// 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 __LOG_METRICS_HPP__
+#define __LOG_METRICS_HPP__
+
+#include <string>
+
+#include <process/metrics/gauge.hpp>
+
+namespace mesos {
+namespace internal {
+namespace log {
+
+// Forward declaration.
+class LogProcess;
+
+struct Metrics
+{
+  Metrics(
+      const LogProcess& process,
+      const Option<std::string>& prefix);
+
+  ~Metrics();
+
+  process::metrics::Gauge recovered;
+};
+
+} // namespace log {
+} // namespace internal {
+} // namespace mesos {
+
+#endif  // __LOG_METRICS_HPP__