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:07:02 UTC
svn commit: r1132247 -
/incubator/mesos/trunk/src/examples/python/test_framework.py
Author: benh
Date: Sun Jun 5 09:07:02 2011
New Revision: 1132247
URL: http://svn.apache.org/viewvc?rev=1132247&view=rev
Log:
Updates to the python tests to work with the new Resource and ExecutorID protobufs.
Modified:
incubator/mesos/trunk/src/examples/python/test_framework.py
Modified: incubator/mesos/trunk/src/examples/python/test_framework.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/python/test_framework.py?rev=1132247&r1=1132246&r2=1132247&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/python/test_framework.py (original)
+++ incubator/mesos/trunk/src/examples/python/test_framework.py Sun Jun 5 09:07:02 2011
@@ -23,6 +23,7 @@ class MyScheduler(mesos.Scheduler):
frameworkDir = os.path.abspath(os.path.dirname(sys.argv[0]))
execPath = os.path.join(frameworkDir, "test_executor")
execInfo = mesos_pb2.ExecutorInfo()
+ execInfo.executor_id.value = "default"
execInfo.uri = execPath
return execInfo
@@ -36,17 +37,24 @@ class MyScheduler(mesos.Scheduler):
if self.tasksLaunched < TOTAL_TASKS:
tid = self.tasksLaunched
self.tasksLaunched += 1
+
print "Accepting offer on %s to start task %d" % (offer.hostname, tid)
+
task = mesos_pb2.TaskDescription()
task.task_id.value = str(tid)
task.slave_id.value = offer.slave_id.value
task.name = "task %d" % tid
- cpu_param = task.params.param.add()
- cpu_param.key = "cpus"
- cpu_param.value = str(TASK_CPUS)
- mem_param = task.params.param.add()
- mem_param.key = "mem"
- mem_param.value = str(TASK_MEM)
+
+ cpus = task.resources.add()
+ cpus.name = "cpus"
+ cpus.type = mesos_pb2.Resource.SCALAR
+ cpus.scalar.value = TASK_CPUS
+
+ mem = task.resources.add()
+ mem.name = "mem"
+ mem.type = mesos_pb2.Resource.SCALAR
+ mem.scalar.value = TASK_MEM
+
tasks.append(task)
driver.replyToOffer(oid, tasks, {})