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 10:21:56 UTC

svn commit: r1131999 - in /incubator/mesos/trunk: include/ src/examples/ src/launcher/ src/sched/ src/swig/ src/tests/

Author: benh
Date: Sun Jun  5 08:21:55 2011
New Revision: 1131999

URL: http://svn.apache.org/viewvc?rev=1131999&view=rev
Log:
Removed string_map typedef and changed name of data_string to bytes.

Modified:
    incubator/mesos/trunk/include/mesos.hpp
    incubator/mesos/trunk/include/mesos_exec.hpp
    incubator/mesos/trunk/include/mesos_sched.hpp
    incubator/mesos/trunk/src/examples/cpp_test_framework.cpp
    incubator/mesos/trunk/src/launcher/launcher.cpp
    incubator/mesos/trunk/src/launcher/launcher.hpp
    incubator/mesos/trunk/src/launcher/main.cpp
    incubator/mesos/trunk/src/sched/sched.cpp
    incubator/mesos/trunk/src/swig/mesos.i
    incubator/mesos/trunk/src/tests/test_master.cpp

Modified: incubator/mesos/trunk/include/mesos.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/mesos.hpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/include/mesos.hpp (original)
+++ incubator/mesos/trunk/include/mesos.hpp Sun Jun  5 08:21:55 2011
@@ -11,17 +11,12 @@ namespace mesos {
 
 // Various Mesos structs that include binary data, such as task descriptions,
 // use a std::string to hold it so they can conveniently store the size as
-// well as the data in one object. We typedef such strings as data_strings
+// well as the data in one object. We typedef such strings as bytes
 // for two reasons:
 // 1) It makes the purpose of fields (human-readable vs opaque) apparent.
 // 2) It makes it possible to specify a different typemap for these strings
 //    in SWIG code (e.g. to map them to byte[]'s in Java).
-typedef std::string data_string;
-
-
-// Convenience typedef for map<string, string>, which is used for
-// key-value parameters throughout the Mesos API
-typedef std::map<std::string, std::string> string_map;
+typedef std::string bytes;
 
 
 struct TaskDescription
@@ -29,15 +24,16 @@ struct TaskDescription
   TaskDescription() {}
 
   TaskDescription(TaskID _taskId, SlaveID _slaveId, const std::string& _name,
-      const string_map& _params, const data_string& _arg)
+                  const std::map<std::string, std::string>& _params,
+                  const bytes& _arg)
     : taskId(_taskId), slaveId(_slaveId), name(_name),
       params(_params), arg(_arg) {}
 
   TaskID taskId;
   SlaveID slaveId;
   std::string name;
-  string_map params;
-  data_string arg;
+  std::map<std::string, std::string> params;
+  bytes arg;
 };
 
 
@@ -45,12 +41,12 @@ struct TaskStatus
 {
   TaskStatus() {}
 
-  TaskStatus(TaskID _taskId, TaskState _state, const data_string& _data)
+  TaskStatus(TaskID _taskId, TaskState _state, const bytes& _data)
     : taskId(_taskId), state(_state), data(_data) {}
 
   TaskID taskId;
   TaskState state;
-  data_string data;
+  bytes data;
 };
 
 
@@ -60,12 +56,12 @@ struct SlaveOffer
 
   SlaveOffer(SlaveID _slaveId,
              const std::string& _host,
-             const string_map& _params)
+             const std::map<std::string, std::string>& _params)
     : slaveId(_slaveId), host(_host), params(_params) {}
 
   SlaveID slaveId;
   std::string host;
-  string_map params;
+  std::map<std::string, std::string> params;
 };
 
 
@@ -73,12 +69,12 @@ struct FrameworkMessage
 {
   FrameworkMessage() {}
 
-  FrameworkMessage(SlaveID _slaveId, TaskID _taskId, const data_string& _data)
+  FrameworkMessage(SlaveID _slaveId, TaskID _taskId, const bytes& _data)
     : slaveId(_slaveId), taskId(_taskId), data(_data) {}
 
   SlaveID slaveId;
   TaskID taskId;
-  data_string data;
+  bytes data;
 };
 
 
@@ -96,16 +92,16 @@ struct ExecutorInfo
 {
   ExecutorInfo() {}
   
-  ExecutorInfo(const std::string& _uri, const data_string& _initArg)
+  ExecutorInfo(const std::string& _uri, const bytes& _initArg)
     : uri(_uri), initArg(_initArg) {}
   
-  ExecutorInfo(const std::string& _uri, const data_string& _initArg,
-      const string_map& _params)
+  ExecutorInfo(const std::string& _uri, const bytes& _initArg,
+               const std::map<std::string, std::string>& _params)
     : uri(_uri), initArg(_initArg), params(_params) {}
 
   std::string uri;
-  data_string initArg;
-  string_map params;
+  bytes initArg;
+  std::map<std::string, std::string> params;
 };
 
 

Modified: incubator/mesos/trunk/include/mesos_exec.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/mesos_exec.hpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/include/mesos_exec.hpp (original)
+++ incubator/mesos/trunk/include/mesos_exec.hpp Sun Jun  5 08:21:55 2011
@@ -21,8 +21,8 @@ struct ExecutorArgs
   ExecutorArgs() {}
 
   ExecutorArgs(SlaveID _slaveId, const std::string& _host,
-      FrameworkID _frameworkId, const std::string& _frameworkName,
-      const data_string& _data)
+               FrameworkID _frameworkId, const std::string& _frameworkName,
+               const bytes& _data)
     : slaveId(_slaveId), host(_host), frameworkId(_frameworkId),
       frameworkName(_frameworkName), data(_data) {};
 
@@ -30,7 +30,7 @@ struct ExecutorArgs
   std::string host;
   FrameworkID frameworkId;
   std::string frameworkName;
-  data_string data;
+  bytes data;
 };
 
 

Modified: incubator/mesos/trunk/include/mesos_sched.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/mesos_sched.hpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/include/mesos_sched.hpp (original)
+++ incubator/mesos/trunk/include/mesos_sched.hpp Sun Jun  5 08:21:55 2011
@@ -68,9 +68,9 @@ public:
   virtual int killTask(TaskID tid) { return -1; }
   virtual int replyToOffer(OfferID oid,
 			   const std::vector<TaskDescription>& task,
-			   const string_map& params) { return -1; }
+			   const std::map<std::string, std::string>& params) { return -1; }
   virtual int reviveOffers() { return -1; }
-  virtual int sendHints(const string_map& hints) { return -1; }
+  virtual int sendHints(const std::map<std::string, std::string>& hints) { return -1; }
 };
 
 
@@ -107,7 +107,7 @@ public:
    *            for the same framework
    */
   MesosSchedulerDriver(Scheduler* sched,
-		       const string_map& params,
+		       const std::map<std::string, std::string>& params,
 		       FrameworkID fid = "");
 
 #ifndef SWIG
@@ -145,9 +145,9 @@ public:
   virtual int killTask(TaskID tid);
   virtual int replyToOffer(OfferID offerId,
 			   const std::vector<TaskDescription>& task,
-			   const string_map& params);
+			   const std::map<std::string, std::string>& params);
   virtual int reviveOffers();
-  virtual int sendHints(const string_map& hints);
+  virtual int sendHints(const std::map<std::string, std::string>& hints);
 
   // Scheduler getter; required by some of the SWIG proxies
   virtual Scheduler* getScheduler() { return sched; }

Modified: incubator/mesos/trunk/src/examples/cpp_test_framework.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/cpp_test_framework.cpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/cpp_test_framework.cpp (original)
+++ incubator/mesos/trunk/src/examples/cpp_test_framework.cpp Sun Jun  5 08:21:55 2011
@@ -60,7 +60,7 @@ public:
         tasks.push_back(desc);
       }
     }
-    string_map params;
+    map<string, string> params;
     params["timeout"] = "-1";
     d->replyToOffer(id, tasks, params);
   }

Modified: incubator/mesos/trunk/src/launcher/launcher.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/launcher.cpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/launcher.cpp (original)
+++ incubator/mesos/trunk/src/launcher/launcher.cpp Sun Jun  5 08:21:55 2011
@@ -39,7 +39,7 @@ ExecutorLauncher::ExecutorLauncher(Frame
                                    const string& _slavePid,
                                    const string& _hadoopHome,
                                    bool _redirectIO,
-                                   const string_map& _params)
+                                   const map<string, string>& _params)
   : frameworkId(_frameworkId), executorUri(_executorUri), user(_user),
     workDirectory(_workDirectory), slavePid(_slavePid),
     hadoopHome(_hadoopHome), redirectIO(_redirectIO), params(_params)

Modified: incubator/mesos/trunk/src/launcher/launcher.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/launcher.hpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/launcher.hpp (original)
+++ incubator/mesos/trunk/src/launcher/launcher.hpp Sun Jun  5 08:21:55 2011
@@ -1,6 +1,7 @@
 #ifndef __LAUNCHER_HPP__
 #define __LAUNCHER_HPP__
 
+#include <map>
 #include <string>
 #include <vector>
 
@@ -11,6 +12,7 @@
 
 namespace mesos { namespace internal { namespace launcher {
 
+using std::map;
 using std::string;
 using std::vector;
 
@@ -35,13 +37,13 @@ protected:
   string slavePid;
   string hadoopHome;
   bool redirectIO;   // Whether to redirect stdout and stderr to files
-  string_map params; // Key-value params in framework's ExecutorInfo
+  map<string, string> params; // Key-value params in framework's ExecutorInfo
 
 public:
   ExecutorLauncher(FrameworkID _frameworkId, const string& _executorUri,
                    const string& _user, const string& _workDirectory,
                    const string& _slavePid, const string& _hadoopHome,
-                   bool _redirectIO, const string_map& _params);
+                   bool _redirectIO, const map<string, string>& _params);
 
   virtual ~ExecutorLauncher();
 

Modified: incubator/mesos/trunk/src/launcher/main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/main.cpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/main.cpp (original)
+++ incubator/mesos/trunk/src/launcher/main.cpp Sun Jun  5 08:21:55 2011
@@ -23,7 +23,7 @@ const char * getenvOrFail(const char *va
 
 int main(int argc, char **argv)
 {
-  string_map params;   // Empty map
+  map<string, string> params;   // Empty map
   ExecutorLauncher(getenvOrFail("MESOS_FRAMEWORK_ID"),
                    getenvOrFail("MESOS_EXECUTOR_URI"),
                    getenvOrFail("MESOS_USER"),

Modified: incubator/mesos/trunk/src/sched/sched.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/sched/sched.cpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/sched/sched.cpp (original)
+++ incubator/mesos/trunk/src/sched/sched.cpp Sun Jun  5 08:21:55 2011
@@ -434,7 +434,7 @@ MesosSchedulerDriver::MesosSchedulerDriv
 
 
 MesosSchedulerDriver::MesosSchedulerDriver(Scheduler* sched,
-					   const string_map &params,
+					   const map<std::string, std::string> &params,
 					   FrameworkID fid)
 {
   Configurator configurator;
@@ -619,7 +619,7 @@ int MesosSchedulerDriver::killTask(TaskI
 
 int MesosSchedulerDriver::replyToOffer(OfferID offerId,
 				       const vector<TaskDescription> &tasks,
-				       const string_map &params)
+				       const map<std::string, std::string> &params)
 {
   Lock lock(&mutex);
 
@@ -672,7 +672,7 @@ int MesosSchedulerDriver::sendFrameworkM
 }
 
 
-int MesosSchedulerDriver::sendHints(const string_map& hints)
+int MesosSchedulerDriver::sendHints(const map<std::string, std::string>& hints)
 {
   Lock lock(&mutex);
 

Modified: incubator/mesos/trunk/src/swig/mesos.i
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/swig/mesos.i?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/swig/mesos.i (original)
+++ incubator/mesos/trunk/src/swig/mesos.i Sun Jun  5 08:21:55 2011
@@ -29,49 +29,49 @@
 #ifdef SWIGJAVA
   /* Typemaps for vector<char> to map it to a byte array */
   /* Based on a post at http://www.nabble.com/Swing-to-Java:-using-native-types-for-vector%3CT%3E-td22504981.html */
-  %naturalvar mesos::data_string; 
+  %naturalvar mesos::bytes; 
 
-  %typemap(jni) mesos::data_string "jbyteArray" 
-  %typemap(jtype) mesos::data_string "byte[]" 
-  %typemap(jstype) mesos::data_string "byte[]" 
+  %typemap(jni) mesos::bytes "jbyteArray" 
+  %typemap(jtype) mesos::bytes "byte[]" 
+  %typemap(jstype) mesos::bytes "byte[]" 
 
-  %typemap(out) mesos::data_string 
+  %typemap(out) mesos::bytes 
   %{ 
      $result = jenv->NewByteArray($1.size()); 
      jenv->SetByteArrayRegion($result, 0, $1.size(), (jbyte *) &$1[0]); 
   %} 
 
-  %typemap(javaout) mesos::data_string 
+  %typemap(javaout) mesos::bytes 
   { 
     return $jnicall; 
   } 
 
-  %typemap(jni) const mesos::data_string & "jbyteArray" 
-  %typemap(jtype) const mesos::data_string & "byte[]" 
-  %typemap(jstype) const mesos::data_string & "byte[]" 
+  %typemap(jni) const mesos::bytes & "jbyteArray" 
+  %typemap(jtype) const mesos::bytes & "byte[]" 
+  %typemap(jstype) const mesos::bytes & "byte[]" 
 
-  %typemap(in) const mesos::data_string & 
+  %typemap(in) const mesos::bytes & 
   %{ if(!$input) { 
        SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
-         "null mesos::data_string"); 
+         "null mesos::bytes"); 
        return $null; 
       } 
       const jsize $1_size = jenv->GetArrayLength($input); 
       jbyte *$1_ptr = jenv->GetByteArrayElements($input, NULL); 
-      mesos::data_string $1_str((char *) $1_ptr, $1_size); 
+      mesos::bytes $1_str((char *) $1_ptr, $1_size); 
       jenv->ReleaseByteArrayElements($input, $1_ptr, JNI_ABORT); 
       $1 = &$1_str; 
   %} 
 
-  %typemap(javain) const mesos::data_string & "$javainput" 
+  %typemap(javain) const mesos::bytes & "$javainput" 
 
-  %typemap(out) const mesos::data_string & 
+  %typemap(out) const mesos::bytes & 
   %{ 
      $result = jenv->NewByteArray($1->size()); 
      jenv->SetByteArrayRegion($result, 0, $1->size(), (jbyte *) &(*$1)[0]); 
   %} 
 
-  %typemap(javaout) const mesos::data_string & 
+  %typemap(javaout) const mesos::bytes & 
   { 
     return $jnicall; 
   } 

Modified: incubator/mesos/trunk/src/tests/test_master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_master.cpp?rev=1131999&r1=1131998&r2=1131999&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_master.cpp Sun Jun  5 08:21:55 2011
@@ -66,7 +66,7 @@ public:
       EXPECT_EQ(lexical_cast<string>(1 * Gigabyte), mem);
     }
     vector<TaskDescription> tasks;
-    d->replyToOffer(id, tasks, string_map());
+    d->replyToOffer(id, tasks, map<string, string>());
     d->stop();
   }
 }; 
@@ -117,7 +117,7 @@ public:
                              OfferID id,
                              const vector<SlaveOffer>& offers) {
     LOG(INFO) << "FixedResponseScheduler got a slot offer";
-    d->replyToOffer(id, response, string_map());
+    d->replyToOffer(id, response, map<string, string>());
   }
   
   virtual void error(SchedulerDriver* d,