You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/06/19 01:46:33 UTC

[1/2] git commit: Added logging for ip resolution errors in libprocess.

Repository: mesos
Updated Branches:
  refs/heads/master 02fa100ea -> eb1b7c56d


Added logging for ip resolution errors in libprocess.

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


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

Branch: refs/heads/master
Commit: daf033c7934a39613e11018e5fd23ec357a2656d
Parents: 02fa100
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Wed Jun 18 16:37:35 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jun 18 16:41:08 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/http.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/daf033c7/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index eb20380..4ef00d1 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -79,6 +79,15 @@ Future<Response> request(
     return Failure("Failed to cloexec: " + cloexec.error());
   }
 
+  // We use inet_ntop since inet_ntoa is not thread-safe!
+  char ip[INET_ADDRSTRLEN];
+  if (inet_ntop(AF_INET, (in_addr*) &upid.ip, ip, INET_ADDRSTRLEN) == NULL) {
+    return Failure(ErrnoError("Failed to get human-readable IP address for '" +
+                              stringify(upid.ip) + "'"));
+  }
+
+  const string host = string(ip) + ":" + stringify(upid.port);
+
   sockaddr_in addr;
   memset(&addr, 0, sizeof(addr));
   addr.sin_family = AF_INET;
@@ -87,7 +96,7 @@ Future<Response> request(
 
   if (connect(s, (sockaddr*) &addr, sizeof(addr)) < 0) {
     os::close(s);
-    return Failure(string("Failed to connect: ") + strerror(errno));
+    return Failure(ErrnoError("Failed to connect to '" + host + "'"));
   }
 
   std::ostringstream out;
@@ -111,14 +120,8 @@ Future<Response> request(
     headers = _headers.get();
   }
 
-  // Need to specify the 'Host' header. We use inet_ntop since
-  // inet_ntoa is not thread-safe!
-  char ip[INET_ADDRSTRLEN];
-  if (inet_ntop(AF_INET, (in_addr*) &upid.ip, ip, INET_ADDRSTRLEN) == NULL) {
-    return Failure(ErrnoError("Failed to create 'Host' header"));
-  }
-
-  headers["Host"] = string(ip) + ":" + stringify(upid.port);
+  // Need to specify the 'Host' header.
+  headers["Host"] = host;
 
   // Tell the server to close the connection when it's done.
   headers["Connection"] = "close";


[2/2] git commit: Added process delegate for accessing the scheduler endpoint.

Posted by bm...@apache.org.
Added process delegate for accessing the scheduler endpoint.

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


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

Branch: refs/heads/master
Commit: eb1b7c56d1b51d82666336a99efdb5f0044dc48e
Parents: daf033c
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Wed Jun 18 16:43:47 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jun 18 16:43:47 2014 -0700

----------------------------------------------------------------------
 include/mesos/scheduler.hpp | 13 ++++++++-----
 src/sched/sched.cpp         | 33 +++++++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/eb1b7c56/include/mesos/scheduler.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/scheduler.hpp b/include/mesos/scheduler.hpp
index d224945..e6c9c78 100644
--- a/include/mesos/scheduler.hpp
+++ b/include/mesos/scheduler.hpp
@@ -417,7 +417,13 @@ public:
   virtual Status reconcileTasks(
       const std::vector<TaskStatus>& statuses);
 
+protected:
+  // Used to detect (i.e., choose) the master.
+  internal::MasterDetector* detector;
+
 private:
+  void initialize();
+
   Scheduler* scheduler;
   FrameworkInfo framework;
   std::string master;
@@ -439,11 +445,8 @@ private:
 
   const Credential* credential;
 
-  void initialize();
-
-protected:
-  // Used to detect (i.e., choose) the master.
-  internal::MasterDetector* detector;
+  // Scheduler process ID.
+  std::string schedulerId;
 };
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/eb1b7c56/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index a82a39d..003e685 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -105,6 +105,7 @@ public:
                    Scheduler* _scheduler,
                    const FrameworkInfo& _framework,
                    const Option<Credential>& _credential,
+                   const string& schedulerId,
                    MasterDetector* _detector,
                    pthread_mutex_t* _mutex,
                    pthread_cond_t* _cond)
@@ -118,7 +119,7 @@ public:
       // http://www.erlang.org/doc/reference_manual/processes.html#id84804.
       // Consider using unique PIDs throughout libprocess and relying
       // on name registration to identify the process without the PID.
-    : ProcessBase("scheduler-" + UUID::random().toString()),
+    : ProcessBase(schedulerId),
       metrics(*this),
       driver(_driver),
       scheduler(_scheduler),
@@ -1095,7 +1096,7 @@ void MesosSchedulerDriver::initialize() {
   }
 
   // Initialize libprocess.
-  process::initialize();
+  process::initialize(schedulerId);
 
   // TODO(benh): Replace whitespace in framework.name() with '_'?
   logging::initialize(framework.name(), flags);
@@ -1151,13 +1152,14 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     Scheduler* _scheduler,
     const FrameworkInfo& _framework,
     const string& _master)
-  : scheduler(_scheduler),
+  : detector(NULL),
+    scheduler(_scheduler),
     framework(_framework),
     master(_master),
     process(NULL),
     status(DRIVER_NOT_STARTED),
     credential(NULL),
-    detector(NULL)
+    schedulerId("scheduler-" + UUID::random().toString())
 {
   initialize();
 }
@@ -1170,13 +1172,14 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     const FrameworkInfo& _framework,
     const string& _master,
     const Credential& _credential)
-  : scheduler(_scheduler),
+  : detector(NULL),
+    scheduler(_scheduler),
     framework(_framework),
     master(_master),
     process(NULL),
     status(DRIVER_NOT_STARTED),
     credential(new Credential(_credential)),
-    detector(NULL)
+    schedulerId("scheduler-" + UUID::random().toString())
 {
   initialize();
 }
@@ -1246,11 +1249,25 @@ Status MesosSchedulerDriver::start()
 
   if (credential == NULL) {
     process = new SchedulerProcess(
-        this, scheduler, framework, None(), detector, &mutex, &cond);
+        this,
+        scheduler,
+        framework,
+        None(),
+        schedulerId,
+        detector,
+        &mutex,
+        &cond);
   } else {
     const Credential& cred = *credential;
     process = new SchedulerProcess(
-        this, scheduler, framework, cred, detector, &mutex, &cond);
+        this,
+        scheduler,
+        framework,
+        cred,
+        schedulerId,
+        detector,
+        &mutex,
+        &cond);
   }
 
   spawn(process);