Repository: mesos
Updated Branches:
  refs/heads/master ca4224305 -> bb0d506b5


Add support for non-subscribe HTTP calls in the master.

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


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

Branch: refs/heads/master
Commit: bb0d506b5605ece740594693be4aa681ef26ca48
Parents: ca42243
Author: Vinod Kone <[email protected]>
Authored: Sat Aug 8 18:18:51 2015 -0700
Committer: Vinod Kone <[email protected]>
Committed: Sat Aug 8 18:32:19 2015 -0700

----------------------------------------------------------------------
 src/master/http.cpp   | 72 ++++++++++++++++++++++++++++++++++++++--------
 src/master/master.cpp |  8 +++---
 2 files changed, 64 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bb0d506b/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 4dcbc0f..1702b07 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -376,23 +376,71 @@ Future<Response> Master::Http::call(const Request& 
request) const
     responseContentType = ContentType::PROTOBUF;
   }
 
+  if (call.type() == scheduler::Call::SUBSCRIBE) {
+    Pipe pipe;
+    OK ok;
+
+    ok.type = Response::PIPE;
+    ok.reader = pipe.reader();
+
+    HttpConnection http {pipe.writer(), responseContentType};
+    master->subscribe(http, call.subscribe());
+
+    return ok;
+  }
+
+  // We consolidate the framework lookup logic here because it is
+  // common for all the call handlers.
+  Framework* framework = master->getFramework(call.framework_id());
+
+  if (framework == NULL) {
+    return BadRequest("Framework cannot be found");
+  }
+
   switch (call.type()) {
-    case scheduler::Call::SUBSCRIBE: {
-      Pipe pipe;
-      OK ok;
+    case scheduler::Call::TEARDOWN:
+      master->removeFramework(framework);
+      return Accepted();
 
-      ok.type = Response::PIPE;
-      ok.reader = pipe.reader();
+    case scheduler::Call::ACCEPT:
+      master->accept(framework, call.accept());
+      return Accepted();
 
-      HttpConnection http {pipe.writer(), responseContentType};
-      master->subscribe(http, call.subscribe());
+    case scheduler::Call::DECLINE:
+      master->decline(framework, call.decline());
+      return Accepted();
+
+    case scheduler::Call::REVIVE:
+      master->revive(framework);
+      return Accepted();
+
+    case scheduler::Call::KILL:
+      master->kill(framework, call.kill());
+      return Accepted();
+
+    case scheduler::Call::SHUTDOWN:
+      master->shutdown(framework, call.shutdown());
+      return Accepted();
+
+    case scheduler::Call::ACKNOWLEDGE:
+      master->acknowledge(framework, call.acknowledge());
+      return Accepted();
+
+    case scheduler::Call::RECONCILE:
+      master->reconcile(framework, call.reconcile());
+      return Accepted();
+
+    case scheduler::Call::MESSAGE:
+      master->message(framework, call.message());
+      return Accepted();
+
+    case scheduler::Call::REQUEST:
+      master->request(framework, call.request());
+      return Accepted();
 
-      return ok;
-    }
     default:
-      // TODO(bmahler): Log fatally here once all calls are
-      // implemented, since validation should catch this.
-      break;
+      // Should be caught during call validation above.
+      LOG(FATAL) << "Unexpected " << call.type() << " call";
   }
 
   return NotImplemented();

http://git-wip-us.apache.org/repos/asf/mesos/blob/bb0d506b/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 0330f94..5ff0ea1 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1808,8 +1808,8 @@ void Master::subscribe(
     }
   }
 
-  LOG(INFO) << "Received registration request for"
-            << " http framework '" << frameworkInfo.name() << "'";
+  LOG(INFO) << "Received subscription request for"
+            << " HTTP framework '" << frameworkInfo.name() << "'";
 
   if (validationError.isSome()) {
     LOG(INFO) << "Refusing subscription of framework"
@@ -1835,8 +1835,8 @@ void Master::_subscribe(
 {
   const FrameworkInfo& frameworkInfo = subscribe.framework_info();
 
-  LOG(INFO) << "Subscribing framework " << frameworkInfo.name()
-            << " with checkpointing "
+  LOG(INFO) << "Subscribing framework '" << frameworkInfo.name()
+            << "' with checkpointing "
             << (frameworkInfo.checkpoint() ? "enabled" : "disabled")
             << " and capabilities " << frameworkInfo.capabilities();
 

Reply via email to