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 2011/06/05 11:23:59 UTC

svn commit: r1132317 - in /incubator/mesos/trunk/src/master: slaves_manager.cpp slaves_manager.hpp

Author: benh
Date: Sun Jun  5 09:23:59 2011
New Revision: 1132317

URL: http://svn.apache.org/viewvc?rev=1132317&view=rev
Log:
Added /slaves/activated and /slaves/deactivated HTTP endpoints.

Modified:
    incubator/mesos/trunk/src/master/slaves_manager.cpp
    incubator/mesos/trunk/src/master/slaves_manager.hpp

Modified: incubator/mesos/trunk/src/master/slaves_manager.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/slaves_manager.cpp?rev=1132317&r1=1132316&r2=1132317&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/slaves_manager.cpp (original)
+++ incubator/mesos/trunk/src/master/slaves_manager.cpp Sun Jun  5 09:23:59 2011
@@ -649,6 +649,8 @@ SlavesManager::SlavesManager(const Confi
   install("remove", &SlavesManager::remove);
   install("activate", &SlavesManager::activate);
   install("deactivate", &SlavesManager::deactivate);
+  install("activated", &SlavesManager::activated);
+  install("deactivated", &SlavesManager::deactivated);
 }
 
 
@@ -970,3 +972,39 @@ Promise<HttpResponse> SlavesManager::dea
     return HttpInternalServerErrorResponse();
   }
 }
+
+
+Promise<HttpResponse> SlavesManager::activated(const HttpRequest& request)
+{
+  LOG(INFO) << "Slaves manager received HTTP request for activated slaves";
+
+  ostringstream out;
+
+  foreachpair (const string& hostname, uint16_t port, active) {
+    out << hostname << ":" << port << "\n";
+  }
+
+  HttpOKResponse response;
+  response.headers["Content-Type"] = "text/plain";
+  response.headers["Content-Length"] = lexical_cast<string>(out.str().size());
+  response.body = out.str().data();
+  return response;
+}
+
+
+Promise<HttpResponse> SlavesManager::deactivated(const HttpRequest& request)
+{
+  LOG(INFO) << "Slaves manager received HTTP request for deactivated slaves";
+
+  ostringstream out;
+
+  foreachpair (const string& hostname, uint16_t port, inactive) {
+    out << hostname << ":" << port << "\n";
+  }
+
+  HttpOKResponse response;
+  response.headers["Content-Type"] = "text/plain";
+  response.headers["Content-Length"] = lexical_cast<string>(out.str().size());
+  response.body = out.str().data();
+  return response;
+}

Modified: incubator/mesos/trunk/src/master/slaves_manager.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/slaves_manager.hpp?rev=1132317&r1=1132316&r2=1132317&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/slaves_manager.hpp (original)
+++ incubator/mesos/trunk/src/master/slaves_manager.hpp Sun Jun  5 09:23:59 2011
@@ -45,6 +45,8 @@ private:
   process::Promise<process::HttpResponse> remove(const process::HttpRequest& request);
   process::Promise<process::HttpResponse> activate(const process::HttpRequest& request);
   process::Promise<process::HttpResponse> deactivate(const process::HttpRequest& request);
+  process::Promise<process::HttpResponse> activated(const process::HttpRequest& request);
+  process::Promise<process::HttpResponse> deactivated(const process::HttpRequest& request);
 
   const process::PID<Master> master;