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:26:47 UTC

svn commit: r1132333 - in /incubator/mesos/trunk/src/python: native/ src/

Author: benh
Date: Sun Jun  5 09:26:46 2011
New Revision: 1132333

URL: http://svn.apache.org/viewvc?rev=1132333&view=rev
Log:
Updated Python port to match new framework message API changes, but other things are still broken ... :(

Modified:
    incubator/mesos/trunk/src/python/native/mesos_executor_driver_impl.cpp
    incubator/mesos/trunk/src/python/native/mesos_scheduler_driver_impl.cpp
    incubator/mesos/trunk/src/python/native/proxy_executor.cpp
    incubator/mesos/trunk/src/python/native/proxy_executor.hpp
    incubator/mesos/trunk/src/python/native/proxy_scheduler.cpp
    incubator/mesos/trunk/src/python/native/proxy_scheduler.hpp
    incubator/mesos/trunk/src/python/src/mesos.py

Modified: incubator/mesos/trunk/src/python/native/mesos_executor_driver_impl.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/mesos_executor_driver_impl.cpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/mesos_executor_driver_impl.cpp (original)
+++ incubator/mesos/trunk/src/python/native/mesos_executor_driver_impl.cpp Sun Jun  5 09:26:46 2011
@@ -272,18 +272,12 @@ PyObject* MesosExecutorDriverImpl_sendFr
     return NULL;
   }
 
-  PyObject* msgObj = NULL;
-  FrameworkMessage msg;
-  if (!PyArg_ParseTuple(args, "O", &msgObj)) {
-    return NULL;
-  }
-  if (!readPythonProtobuf(msgObj, &msg)) {
-    PyErr_Format(PyExc_Exception,
-                 "Could not deserialize Python FrameworkMessage");
+  const char* data;
+  if (!PyArg_ParseTuple(args, "s", &data)) {
     return NULL;
   }
 
-  int res = self->driver->sendFrameworkMessage(msg);
+  int res = self->driver->sendFrameworkMessage(data);
   return PyInt_FromLong(res); // Sets an exception if creating the int fails
 }
 

Modified: incubator/mesos/trunk/src/python/native/mesos_scheduler_driver_impl.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/mesos_scheduler_driver_impl.cpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/mesos_scheduler_driver_impl.cpp (original)
+++ incubator/mesos/trunk/src/python/native/mesos_scheduler_driver_impl.cpp Sun Jun  5 09:26:46 2011
@@ -398,18 +398,26 @@ PyObject* MesosSchedulerDriverImpl_sendF
     return NULL;
   }
 
-  PyObject* msgObj = NULL;
-  FrameworkMessage msg;
-  if (!PyArg_ParseTuple(args, "O", &msgObj)) {
+
+  PyObject* sidObj = NULL;
+  PyObject* eidObj = NULL;
+  PyObject* dataObj = NULL;
+  SlaveID sid;
+  ExecutorID eid;
+  const char* data;
+  if (!PyArg_ParseTuple(args, "OOs", &sidObj, &eidObj, &data)) {
+    return NULL;
+  }
+  if (!readPythonProtobuf(sidObj, &sid)) {
+    PyErr_Format(PyExc_Exception, "Could not deserialize Python SlaveID");
     return NULL;
   }
-  if (!readPythonProtobuf(msgObj, &msg)) {
-    PyErr_Format(PyExc_Exception,
-                 "Could not deserialize Python FrameworkMessage");
+  if (!readPythonProtobuf(eidObj, &eid)) {
+    PyErr_Format(PyExc_Exception, "Could not deserialize Python ExecutorID");
     return NULL;
   }
 
-  int res = self->driver->sendFrameworkMessage(msg);
+  int res = self->driver->sendFrameworkMessage(sid, eid, data);
   return PyInt_FromLong(res); // Sets an exception if creating the int fails
 }
 

Modified: incubator/mesos/trunk/src/python/native/proxy_executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/proxy_executor.cpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/proxy_executor.cpp (original)
+++ incubator/mesos/trunk/src/python/native/proxy_executor.cpp Sun Jun  5 09:26:46 2011
@@ -113,23 +113,17 @@ cleanup:
 
 
 void ProxyExecutor::frameworkMessage(ExecutorDriver* driver,
-                                     const FrameworkMessage& message)
+                                     const string& data)
 {
   InterpreterLock lock;
   
-  PyObject* messageObj = NULL;
   PyObject* res = NULL;
   
-  messageObj = createPythonProtobuf(message, "FrameworkMessage");
-  if (messageObj == NULL) {
-    goto cleanup; // createPythonProtobuf will have set an exception
-  }
-
   res = PyObject_CallMethod(impl->pythonExecutor,
                             (char*) "frameworkMessage",
-                            (char*) "OO",
+                            (char*) "Os",
                             impl,
-                            messageObj);
+                            data.c_str());
   if (res == NULL) {
     cerr << "Failed to call executor's frameworkMessage" << endl;
     goto cleanup;
@@ -140,7 +134,6 @@ cleanup:
     PyErr_Print();
     driver->stop();
   }
-  Py_XDECREF(messageObj);
   Py_XDECREF(res);
 }
 

Modified: incubator/mesos/trunk/src/python/native/proxy_executor.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/proxy_executor.hpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/proxy_executor.hpp (original)
+++ incubator/mesos/trunk/src/python/native/proxy_executor.hpp Sun Jun  5 09:26:46 2011
@@ -32,7 +32,7 @@ public:
   virtual void killTask(ExecutorDriver* driver, const TaskID& taskId);
 
   virtual void frameworkMessage(ExecutorDriver* driver,
-                                const FrameworkMessage& message);
+                                const std::string& data);
 
   virtual void shutdown(ExecutorDriver* driver);
 

Modified: incubator/mesos/trunk/src/python/native/proxy_scheduler.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/proxy_scheduler.cpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/proxy_scheduler.cpp (original)
+++ incubator/mesos/trunk/src/python/native/proxy_scheduler.cpp Sun Jun  5 09:26:46 2011
@@ -222,23 +222,32 @@ cleanup:
 
 
 void ProxyScheduler::frameworkMessage(SchedulerDriver* driver,
-                                      const FrameworkMessage& message)
+                                      const SlaveID& slaveId,
+                                      const ExecutorID& executorId,
+                                      const string& data)
 {
   InterpreterLock lock;
-  
-  PyObject* msg = NULL;
+
+  PyObject* sid = NULL;
+  PyObject* eid = NULL;
   PyObject* res = NULL;
   
-  msg = createPythonProtobuf(message, "FrameworkMessage");
-  if (msg == NULL) {
+  sid = createPythonProtobuf(slaveId, "SlaveID");
+  if (sid == NULL) {
+    goto cleanup; // createPythonProtobuf will have set an exception
+  }
+  eid = createPythonProtobuf(executorId, "ExecutorID");
+  if (sid == NULL) {
     goto cleanup; // createPythonProtobuf will have set an exception
   }
 
   res = PyObject_CallMethod(impl->pythonScheduler,
                             (char*) "frameworkMessage",
-                            (char*) "OO",
+                            (char*) "OOOs",
                             impl,
-                            msg);
+                            sid,
+                            eid,
+                            data.c_str());
   if (res == NULL) {
     cerr << "Failed to call scheduler's frameworkMessage" << endl;
     goto cleanup;
@@ -249,7 +258,8 @@ cleanup:
     PyErr_Print();
     driver->stop();
   }
-  Py_XDECREF(msg);
+  Py_XDECREF(sid);
+  Py_XDECREF(eid);
   Py_XDECREF(res);
 }
 

Modified: incubator/mesos/trunk/src/python/native/proxy_scheduler.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/native/proxy_scheduler.hpp?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/native/proxy_scheduler.hpp (original)
+++ incubator/mesos/trunk/src/python/native/proxy_scheduler.hpp Sun Jun  5 09:26:46 2011
@@ -44,7 +44,9 @@ public:
                             const TaskStatus& status);
 
   virtual void frameworkMessage(SchedulerDriver* driver,
-                                const FrameworkMessage& message);
+                                const SlaveID& slaveId,
+                                const ExecutorID& executorId,
+                                const std::string& data);
 
   virtual void slaveLost(SchedulerDriver* driver,
                          const SlaveID& slaveId);

Modified: incubator/mesos/trunk/src/python/src/mesos.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/python/src/mesos.py?rev=1132333&r1=1132332&r2=1132333&view=diff
==============================================================================
--- incubator/mesos/trunk/src/python/src/mesos.py (original)
+++ incubator/mesos/trunk/src/python/src/mesos.py Sun Jun  5 09:26:46 2011
@@ -26,7 +26,7 @@ class SchedulerDriver:
   def stop(self): pass
   def join(self): pass
   def run(self): pass
-  def sendFrameworkMessage(self, message): pass
+  def sendFrameworkMessage(self, slaveId, executorId, data): pass
   def killTask(self, taskId): pass
   def replyToOffer(self, offerId, tasks, params = None): pass
   def reviveOffers(self): pass
@@ -55,7 +55,7 @@ class ExecutorDriver:
   def join(self): pass
   def run(self): pass
   def sendStatusUpdate(self, status): pass
-  def sendFrameworkMessage(self, message): pass
+  def sendFrameworkMessage(self, data): pass
 
 
 # Alias the MesosSchedulerDriverImpl from _mesos. Ideally we would make this