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 05:16:23 UTC
svn commit: r1131524 - in /incubator/mesos/trunk: include/ src/
src/swig/java/ src/tests/
Author: benh
Date: Sun Jun 5 03:16:23 2011
New Revision: 1131524
URL: http://svn.apache.org/viewvc?rev=1131524&view=rev
Log:
Task ID and Framework ID also converted to strings
Modified:
incubator/mesos/trunk/include/nexus_types.h
incubator/mesos/trunk/include/nexus_types.hpp
incubator/mesos/trunk/src/cpp_test_framework.cpp
incubator/mesos/trunk/src/master.cpp
incubator/mesos/trunk/src/memhog.cpp
incubator/mesos/trunk/src/nexus_exec.cpp
incubator/mesos/trunk/src/nexus_sched.cpp
incubator/mesos/trunk/src/swig/java/TestFramework.java
incubator/mesos/trunk/src/test_framework.cpp
incubator/mesos/trunk/src/tests/test_master.cpp
Modified: incubator/mesos/trunk/include/nexus_types.h
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/nexus_types.h?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/include/nexus_types.h (original)
+++ incubator/mesos/trunk/include/nexus_types.h Sun Jun 5 03:16:23 2011
@@ -3,8 +3,8 @@
#include <stdint.h>
-typedef int32_t framework_id;
-typedef int32_t task_id;
+typedef const char *framework_id;
+typedef const char *task_id;
typedef const char *slave_id;
typedef const char *offer_id;
typedef int32_t nexus_handle;
Modified: incubator/mesos/trunk/include/nexus_types.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/include/nexus_types.hpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/include/nexus_types.hpp (original)
+++ incubator/mesos/trunk/include/nexus_types.hpp Sun Jun 5 03:16:23 2011
@@ -8,10 +8,10 @@
namespace nexus {
-typedef framework_id FrameworkID; // Unique within master
-typedef task_id TaskID; // Unique within framework
-typedef std::string SlaveID; // Unique within master
-typedef std::string OfferID; // Unique within master
+typedef std::string FrameworkID; // Unique within master
+typedef std::string TaskID; // Unique within framework
+typedef std::string SlaveID; // Unique within master
+typedef std::string OfferID; // Unique within master
typedef task_state TaskState;
}
Modified: incubator/mesos/trunk/src/cpp_test_framework.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/cpp_test_framework.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/cpp_test_framework.cpp (original)
+++ incubator/mesos/trunk/src/cpp_test_framework.cpp Sun Jun 5 03:16:23 2011
@@ -47,7 +47,10 @@ public:
int32_t cpus = lexical_cast<int32_t>(offer.params.find("cpus")->second);
int64_t mem = lexical_cast<int64_t>(offer.params.find("mem")->second);
if ((tasksLaunched < totalTasks) && (cpus >= 1 && mem >= 33554432)) {
- TaskID tid = tasksLaunched++;
+ stringstream ss;
+ ss<<tasksLaunched++;
+ TaskID tid = ss.str();
+
cout << endl << "Starting task " << tid << endl;
string name = "Task " + lexical_cast<string>(tid);
map<string, string> taskParams;
Modified: incubator/mesos/trunk/src/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master.cpp (original)
+++ incubator/mesos/trunk/src/master.cpp Sun Jun 5 03:16:23 2011
@@ -111,14 +111,14 @@ public:
Master::Master(const bool ft, const string zk)
- : isFT(ft), zkserver(zk), leaderDetector(NULL), nextFrameworkId(0), nextSlaveId("0"),
+ : isFT(ft), zkserver(zk), leaderDetector(NULL), nextFrameworkId("0"), nextSlaveId("0"),
nextSlotOfferId("0"), allocatorType("simple")
{}
Master::Master(const string& _allocatorType, const bool ft, const string zk)
- : isFT(ft), zkserver(zk), leaderDetector(NULL), nextFrameworkId(0), nextSlaveId("0"),
- nextSlotOfferId("0"), allocatorType(_allocatorType)
+ : isFT(ft), zkserver(zk), leaderDetector(NULL), nextFrameworkId("0"), nextSlaveId("0"),
+ nextSlotOfferId("m0"), allocatorType(_allocatorType)
{}
@@ -257,7 +257,12 @@ void Master::operator () ()
switch (receive()) {
case F2M_REGISTER_FRAMEWORK: {
- FrameworkID fid = nextFrameworkId++;
+ FrameworkID fid = nextFrameworkId;
+
+ stringstream ss;
+ ss << (atoi(nextFrameworkId.c_str())+1);
+ nextFrameworkId = ss.str();
+
Framework *framework = new Framework(from(), fid);
unpack<F2M_REGISTER_FRAMEWORK>(framework->name,
framework->user,
Modified: incubator/mesos/trunk/src/memhog.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/memhog.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/memhog.cpp (original)
+++ incubator/mesos/trunk/src/memhog.cpp Sun Jun 5 03:16:23 2011
@@ -60,7 +60,10 @@ public:
int32_t cpus = lexical_cast<int32_t>(offer.params.find("cpus")->second);
int64_t mem = lexical_cast<int64_t>(offer.params.find("mem")->second);
if ((tasksLaunched < totalTasks) && (cpus >= 1 && mem >= memToRequest)) {
- TaskID tid = tasksLaunched++;
+ stringstream ss;
+ ss<<tasksLaunched++;
+ TaskID tid = ss.str();
+
cout << endl << "accepting it to start task " << tid << endl;
map<string, string> taskParams;
taskParams["cpus"] = "1";
Modified: incubator/mesos/trunk/src/nexus_exec.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/nexus_exec.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/nexus_exec.cpp (original)
+++ incubator/mesos/trunk/src/nexus_exec.cpp Sun Jun 5 03:16:23 2011
@@ -265,7 +265,7 @@ public:
{
exec->init(exec,
args.slaveId.c_str(),
- args.frameworkId,
+ args.frameworkId.c_str(),
args.frameworkName.c_str(),
args.data.data(),
args.data.size());
@@ -276,7 +276,7 @@ public:
// Convert params to key=value list
Params paramsObj(task.params);
string paramsStr = paramsObj.str();
- nexus_task_desc td = { task.taskId,
+ nexus_task_desc td = { task.taskId.c_str(),
task.slaveId.c_str(),
task.name.c_str(),
paramsStr.c_str(),
@@ -287,13 +287,13 @@ public:
virtual void killTask(TaskID taskId)
{
- exec->kill(exec, taskId);
+ exec->kill(exec, taskId.c_str());
}
virtual void frameworkMessage(const FrameworkMessage& message)
{
nexus_framework_message msg = { message.slaveId.c_str(),
- message.taskId,
+ message.taskId.c_str(),
message.data.data(),
message.data.size() };
exec->message(exec, &msg);
Modified: incubator/mesos/trunk/src/nexus_sched.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/nexus_sched.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/nexus_sched.cpp (original)
+++ incubator/mesos/trunk/src/nexus_sched.cpp Sun Jun 5 03:16:23 2011
@@ -77,7 +77,7 @@ public:
: master(_master),
driver(_driver),
sched(_sched),
- fid(-1),
+ fid("-1"),
terminate(false),
frameworkName(_frameworkName),
execInfo(_execInfo) {}
@@ -485,7 +485,7 @@ public:
virtual void registered(SchedulerDriver*, FrameworkID frameworkId)
{
- sched->registered(sched, frameworkId);
+ sched->registered(sched, frameworkId.c_str());
}
virtual void resourceOffer(SchedulerDriver*,
@@ -521,7 +521,7 @@ public:
virtual void statusUpdate(SchedulerDriver*, TaskStatus &status)
{
- nexus_task_status c_status = { status.taskId,
+ nexus_task_status c_status = { status.taskId.c_str(),
status.state,
status.data.data(),
status.data.size() };
@@ -531,7 +531,7 @@ public:
virtual void frameworkMessage(SchedulerDriver*, FrameworkMessage &message)
{
nexus_framework_message c_message = { message.slaveId.c_str(),
- message.taskId,
+ message.taskId.c_str(),
message.data.data(),
message.data.size() };
sched->framework_message(sched, &c_message);
Modified: incubator/mesos/trunk/src/swig/java/TestFramework.java
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/swig/java/TestFramework.java?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/swig/java/TestFramework.java (original)
+++ incubator/mesos/trunk/src/swig/java/TestFramework.java Sun Jun 5 03:16:23 2011
@@ -30,7 +30,7 @@ public class TestFramework {
}
@Override
- public void registered(SchedulerDriver d, int fid) {
+ public void registered(SchedulerDriver d, String fid) {
System.out.println("Registered! FID = " + fid);
}
@@ -47,11 +47,12 @@ public class TestFramework {
taskParams.set("cpus", "1");
taskParams.set("mem", "134217728");
System.out.println("Launching task " + taskId);
- tasks.add(new TaskDescription(launchedTasks++,
+ tasks.add(new TaskDescription(Integer.toString(launchedTasks),
offer.getSlaveId(),
"task " + taskId,
taskParams,
new byte[0]));
+ launchedTasks++;
}
StringMap params = new StringMap();
params.set("timeout", "1");
Modified: incubator/mesos/trunk/src/test_framework.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/test_framework.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/test_framework.cpp (original)
+++ incubator/mesos/trunk/src/test_framework.cpp Sun Jun 5 03:16:23 2011
@@ -20,7 +20,9 @@ void slot_offer(nexus_sched *sched, offe
cout << "Refusing it" << endl;
nexus_sched_reply_to_offer(sched, oid, 0, 0, "timeout=-1");
} else {
- task_id tid = tasksStarted++;
+ char tidStr[20];
+ sprintf(tidStr, "%d", tasksStarted++);
+ task_id tid = tidStr;
cout << "Accepting it to start task " << tid << endl;
nexus_task_desc desc = { tid, slots[0].sid, "task",
"cpus=1\nmem=33554432", 0, 0 };
Modified: incubator/mesos/trunk/src/tests/test_master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_master.cpp?rev=1131524&r1=1131523&r2=1131524&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_master.cpp Sun Jun 5 03:16:23 2011
@@ -117,9 +117,9 @@ TEST(MasterTest, DuplicateTaskIdsInRespo
map<string, string> params;
params["cpus"] = "1";
params["mem"] = lexical_cast<string>(1 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
- tasks.push_back(TaskDescription(2, 0, "", params, ""));
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
+ tasks.push_back(TaskDescription("2", "0", "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -136,7 +136,7 @@ TEST(MasterTest, TooMuchMemoryInTask)
map<string, string> params;
params["cpus"] = "1";
params["mem"] = lexical_cast<string>(4 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -153,7 +153,7 @@ TEST(MasterTest, TooMuchCpuInTask)
map<string, string> params;
params["cpus"] = "4";
params["mem"] = lexical_cast<string>(1 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -170,7 +170,7 @@ TEST(MasterTest, TooLittleCpuInTask)
map<string, string> params;
params["cpus"] = "0";
params["mem"] = lexical_cast<string>(1 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -187,7 +187,7 @@ TEST(MasterTest, TooLittleMemoryInTask)
map<string, string> params;
params["cpus"] = "1";
params["mem"] = "1";
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -204,8 +204,8 @@ TEST(MasterTest, TooMuchMemoryAcrossTask
map<string, string> params;
params["cpus"] = "1";
params["mem"] = lexical_cast<string>(2 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
- tasks.push_back(TaskDescription(2, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
+ tasks.push_back(TaskDescription("2", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -222,8 +222,8 @@ TEST(MasterTest, TooMuchCpuAcrossTasks)
map<string, string> params;
params["cpus"] = "2";
params["mem"] = lexical_cast<string>(1 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
- tasks.push_back(TaskDescription(2, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
+ tasks.push_back(TaskDescription("2", "0", "", params, ""));
FixedResponseScheduler sched(tasks);
NexusSchedulerDriver driver(&sched, master);
driver.run();
@@ -262,7 +262,7 @@ TEST(MasterTest, ResourcesReofferedAfter
map<string, string> params;
params["cpus"] = "0";
params["mem"] = lexical_cast<string>(1 * Gigabyte);
- tasks.push_back(TaskDescription(1, 0, "", params, ""));
+ tasks.push_back(TaskDescription("1", "0", "", params, ""));
FixedResponseScheduler sched1(tasks);
NexusSchedulerDriver driver1(&sched1, master);
driver1.run();