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:19:32 UTC
svn commit: r1131536 - in /incubator/mesos/trunk: include/ src/
src/swig/java/ src/tests/
Author: benh
Date: Sun Jun 5 03:19:31 2011
New Revision: 1131536
URL: http://svn.apache.org/viewvc?rev=1131536&view=rev
Log:
All tests now work. TaskIds are ints again.
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/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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/include/nexus_types.h (original)
+++ incubator/mesos/trunk/include/nexus_types.h Sun Jun 5 03:19:31 2011
@@ -4,7 +4,7 @@
#include <stdint.h>
typedef const char *framework_id;
-typedef const char *task_id;
+typedef int32_t 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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/include/nexus_types.hpp (original)
+++ incubator/mesos/trunk/include/nexus_types.hpp Sun Jun 5 03:19:31 2011
@@ -9,7 +9,7 @@
namespace nexus {
typedef std::string FrameworkID; // Unique within master
-typedef std::string TaskID; // Unique within framework
+typedef task_id 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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/cpp_test_framework.cpp (original)
+++ incubator/mesos/trunk/src/cpp_test_framework.cpp Sun Jun 5 03:19:31 2011
@@ -47,9 +47,7 @@ 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)) {
- stringstream ss;
- ss<<tasksLaunched++;
- TaskID tid = ss.str();
+ TaskID tid = tasksLaunched++;
cout << endl << "Starting task " << tid << endl;
string name = "Task " + lexical_cast<string>(tid);
Modified: incubator/mesos/trunk/src/memhog.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/memhog.cpp?rev=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/memhog.cpp (original)
+++ incubator/mesos/trunk/src/memhog.cpp Sun Jun 5 03:19:31 2011
@@ -60,9 +60,7 @@ 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)) {
- stringstream ss;
- ss<<tasksLaunched++;
- TaskID tid = ss.str();
+ TaskID tid = tasksLaunched++;
cout << endl << "accepting it to start task " << tid << endl;
map<string, string> taskParams;
Modified: incubator/mesos/trunk/src/nexus_exec.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/nexus_exec.cpp?rev=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/nexus_exec.cpp (original)
+++ incubator/mesos/trunk/src/nexus_exec.cpp Sun Jun 5 03:19:31 2011
@@ -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.c_str(),
+ nexus_task_desc td = { task.taskId,
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.c_str());
+ exec->kill(exec, taskId);
}
virtual void frameworkMessage(const FrameworkMessage& message)
{
nexus_framework_message msg = { message.slaveId.c_str(),
- message.taskId.c_str(),
+ message.taskId,
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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/nexus_sched.cpp (original)
+++ incubator/mesos/trunk/src/nexus_sched.cpp Sun Jun 5 03:19:31 2011
@@ -522,7 +522,7 @@ public:
virtual void statusUpdate(SchedulerDriver*, TaskStatus &status)
{
- nexus_task_status c_status = { status.taskId.c_str(),
+ nexus_task_status c_status = { status.taskId,
status.state,
status.data.data(),
status.data.size() };
@@ -532,7 +532,7 @@ public:
virtual void frameworkMessage(SchedulerDriver*, FrameworkMessage &message)
{
nexus_framework_message c_message = { message.slaveId.c_str(),
- message.taskId.c_str(),
+ message.taskId,
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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/swig/java/TestFramework.java (original)
+++ incubator/mesos/trunk/src/swig/java/TestFramework.java Sun Jun 5 03:19:31 2011
@@ -47,7 +47,7 @@ public class TestFramework {
taskParams.set("cpus", "1");
taskParams.set("mem", "134217728");
System.out.println("Launching task " + taskId);
- tasks.add(new TaskDescription(Integer.toString(launchedTasks),
+ tasks.add(new TaskDescription(launchedTasks,
offer.getSlaveId(),
"task " + taskId,
taskParams,
Modified: incubator/mesos/trunk/src/test_framework.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/test_framework.cpp?rev=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/test_framework.cpp (original)
+++ incubator/mesos/trunk/src/test_framework.cpp Sun Jun 5 03:19:31 2011
@@ -20,9 +20,7 @@ void slot_offer(nexus_sched *sched, offe
cout << "Refusing it" << endl;
nexus_sched_reply_to_offer(sched, oid, 0, 0, "timeout=-1");
} else {
- char tidStr[20];
- sprintf(tidStr, "%d", tasksStarted++);
- task_id tid = tidStr;
+ task_id tid = tasksStarted++;
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=1131536&r1=1131535&r2=1131536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_master.cpp Sun Jun 5 03:19:31 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-0", "", params, ""));
+ tasks.push_back(TaskDescription(2, "0-0", "", params, ""));
+ tasks.push_back(TaskDescription(1, "0-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-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-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-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-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-0", "", params, ""));
+ tasks.push_back(TaskDescription(2, "0-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-0", "", params, ""));
+ tasks.push_back(TaskDescription(2, "0-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-0", "", params, ""));
FixedResponseScheduler sched1(tasks);
NexusSchedulerDriver driver1(&sched1, master);
driver1.run();