You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/05/29 19:40:46 UTC

[08/35] git commit: Removed logging process from Mesos (now in libprocess).

Removed logging process from Mesos (now in libprocess).

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


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

Branch: refs/heads/master
Commit: 6ff3edff0351aefbd2858e7ca4b098c09efd3fc5
Parents: 1f14533
Author: Benjamin Hindman <be...@twitter.com>
Authored: Sun May 26 23:27:00 2013 -0700
Committer: Benjamin Hindman <be...@twitter.com>
Committed: Tue May 28 14:18:39 2013 -0700

----------------------------------------------------------------------
 src/logging/logging.cpp |  110 +----------------------------------------
 1 files changed, 3 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/6ff3edff/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index c36f7fa..7386e5e 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -21,21 +21,12 @@
 
 #include <glog/logging.h>
 
-#include <map>
 #include <string>
-#include <vector>
 
-#include <process/delay.hpp>
-#include <process/future.hpp>
-#include <process/http.hpp>
 #include <process/once.hpp>
-#include <process/process.hpp>
-#include <process/timeout.hpp>
 
-#include <stout/duration.hpp>
 #include <stout/error.hpp>
 #include <stout/exit.hpp>
-#include <stout/numify.hpp>
 #include <stout/os.hpp>
 #include <stout/path.hpp>
 #include <stout/stringify.hpp>
@@ -43,107 +34,14 @@
 
 #include "logging/logging.hpp"
 
-using namespace process;
-using namespace process::http;
+using process::Once;
 
-using std::map;
 using std::string;
-using std::vector;
 
 namespace mesos {
 namespace internal {
 namespace logging {
 
-class LoggingProcess : public Process<LoggingProcess>
-{
-public:
-  LoggingProcess()
-    : ProcessBase("logging"),
-      original(FLAGS_v)
-  {
-    // Make sure all reads/writes can be done atomically (i.e., to
-    // make sure VLOG(*) statements don't read partial writes).
-    // TODO(benh): Use "atomics" primitives for doing reads/writes of
-    // FLAGS_v anyway to account for proper memory barriers.
-    CHECK(sizeof(FLAGS_v) == sizeof(int32_t));
-  }
-
-  virtual ~LoggingProcess() {}
-
-protected:
-  virtual void initialize()
-  {
-    route("/toggle", &This::toggle);
-  }
-
-private:
-  Future<Response> toggle(const Request& request)
-  {
-    Option<string> level = request.query.get("level");
-    Option<string> duration = request.query.get("duration");
-
-    if (level.isNone() && duration.isNone()) {
-      return OK(stringify(FLAGS_v) + "\n");
-    }
-
-    if (level.isSome() && duration.isNone()) {
-      return BadRequest("Expecting 'duration=value' in query.\n");
-    } else if (level.isNone() && duration.isSome()) {
-      return BadRequest("Expecting 'level=value' in query.\n");
-    }
-
-    Try<int> v = numify<int>(level.get());
-
-    if (v.isError()) {
-      return BadRequest(v.error() + ".\n");
-    }
-
-    if (v.get() < 0) {
-      return BadRequest("Invalid level '" + stringify(v.get()) + "'.\n");
-    } else if (v.get() < original) {
-      return BadRequest("'" + stringify(v.get()) + "' < original level.\n");
-    }
-
-    Try<Duration> d = Duration::parse(duration.get());
-
-    if (d.isError()) {
-      return BadRequest(d.error() + ".\n");
-    }
-
-    // Set the logging level.
-    set(v.get());
-
-    // Start a revert timer (if necessary).
-    if (v.get() != original) {
-      timeout = d.get();
-      delay(timeout.remaining(), this, &This::revert);
-    }
-
-    return OK();
-  }
-
-  void set(int v)
-  {
-    if (FLAGS_v != v) {
-      VLOG(FLAGS_v) << "Setting verbose logging level to " << v;
-      FLAGS_v = v;
-      __sync_synchronize(); // Ensure 'FLAGS_v' visible in other threads.
-    }
-  }
-
-  void revert()
-  {
-    if (timeout.remaining() == Seconds(0)) {
-      set(original);
-    }
-  }
-
-  Timeout timeout;
-
-  const int32_t original; // Original value of FLAGS_v.
-};
-
-
 // Persistent copy of argv0 since InitGoogleLogging requires the
 // string we pass to it to be accessible indefinitely.
 string argv0;
@@ -193,10 +91,6 @@ void initialize(
   VLOG(1) << "Logging to " <<
     (flags.log_dir.isSome() ? flags.log_dir.get() : "STDERR");
 
-  // TODO(benh): Make sure this always succeeds and never actually
-  // exits (i.e., use a supervisor which re-spawns appropriately).
-  spawn(new LoggingProcess(), true);
-
   if (installFailureSignalHandler) {
     // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
     // by default.
@@ -207,9 +101,11 @@ void initialize(
     // of its lovely information.
     struct sigaction action;
     action.sa_handler = handler;
+
     // Do not block additional signals while in the handler.
     sigemptyset(&action.sa_mask);
     action.sa_flags = 0;
+
     if (sigaction(SIGPIPE, &action, NULL) < 0) {
       PLOG(FATAL) << "Failed to set sigaction";
     }