You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2015/04/25 23:33:34 UTC

[07/11] mesos git commit: Removed 'uuid' field from UPDATE call.

Removed 'uuid' field from UPDATE call.

Review: https://reviews.apache.org/r/33465


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/32d1b67d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/32d1b67d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/32d1b67d

Branch: refs/heads/master
Commit: 32d1b67dded33c5859c271306538bb58a5de04be
Parents: c3de1e8
Author: Vinod Kone <vi...@gmail.com>
Authored: Wed Apr 22 19:16:51 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sat Apr 25 11:32:48 2015 -1000

----------------------------------------------------------------------
 include/mesos/scheduler/scheduler.proto         |  3 +--
 src/examples/low_level_scheduler_libprocess.cpp | 22 +++++++++++---------
 src/examples/low_level_scheduler_pthread.cpp    | 22 +++++++++++---------
 src/sched/sched.cpp                             |  6 +++---
 src/scheduler/scheduler.cpp                     | 15 ++++++++-----
 src/tests/scheduler_tests.cpp                   |  1 +
 6 files changed, 39 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/include/mesos/scheduler/scheduler.proto
----------------------------------------------------------------------
diff --git a/include/mesos/scheduler/scheduler.proto b/include/mesos/scheduler/scheduler.proto
index ec9adf6..5ca64cb 100644
--- a/include/mesos/scheduler/scheduler.proto
+++ b/include/mesos/scheduler/scheduler.proto
@@ -57,8 +57,7 @@ message Event {
   }
 
   message Update {
-    required bytes uuid = 1; // TODO(benh): Replace with UpdateID.
-    required TaskStatus status = 2;
+    required TaskStatus status = 1;
   }
 
   message Message {

http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/src/examples/low_level_scheduler_libprocess.cpp
----------------------------------------------------------------------
diff --git a/src/examples/low_level_scheduler_libprocess.cpp b/src/examples/low_level_scheduler_libprocess.cpp
index b55ad60..bee2e7e 100644
--- a/src/examples/low_level_scheduler_libprocess.cpp
+++ b/src/examples/low_level_scheduler_libprocess.cpp
@@ -142,7 +142,7 @@ public:
           cout << endl << "Received an UPDATE event" << endl;
 
           // TODO(zuyu): Do batch processing of UPDATE events.
-          statusUpdate(event.update().uuid(), event.update().status());
+          statusUpdate(event.update().status());
           break;
         }
 
@@ -251,7 +251,7 @@ private:
     }
   }
 
-  void statusUpdate(const string& uuid, const TaskStatus& status)
+  void statusUpdate(const TaskStatus& status)
   {
     cout << "Task " << status.task_id() << " is in state " << status.state();
 
@@ -260,16 +260,18 @@ private:
     }
     cout << endl;
 
-    Call call;
-    call.mutable_framework_info()->CopyFrom(framework);
-    call.set_type(Call::ACKNOWLEDGE);
+    if (status.has_uuid()) {
+      Call call;
+      call.mutable_framework_info()->CopyFrom(framework);
+      call.set_type(Call::ACKNOWLEDGE);
 
-    Call::Acknowledge* ack = call.mutable_acknowledge();
-    ack->mutable_slave_id()->CopyFrom(status.slave_id());
-    ack->mutable_task_id ()->CopyFrom(status.task_id ());
-    ack->set_uuid(uuid);
+      Call::Acknowledge* ack = call.mutable_acknowledge();
+      ack->mutable_slave_id()->CopyFrom(status.slave_id());
+      ack->mutable_task_id ()->CopyFrom(status.task_id ());
+      ack->set_uuid(status.uuid());
 
-    mesos.send(call);
+      mesos.send(call);
+    }
 
     if (status.state() == TASK_FINISHED) {
       ++tasksFinished;

http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/src/examples/low_level_scheduler_pthread.cpp
----------------------------------------------------------------------
diff --git a/src/examples/low_level_scheduler_pthread.cpp b/src/examples/low_level_scheduler_pthread.cpp
index 64a0e44..fb8cd66 100644
--- a/src/examples/low_level_scheduler_pthread.cpp
+++ b/src/examples/low_level_scheduler_pthread.cpp
@@ -163,7 +163,7 @@ public:
           cout << endl << "Received an UPDATE event" << endl;
 
           // TODO(zuyu): Do batch processing of UPDATE events.
-          statusUpdate(event.update().uuid(), event.update().status());
+          statusUpdate(event.update().status());
           break;
         }
 
@@ -299,7 +299,7 @@ private:
     }
   }
 
-  void statusUpdate(const string& uuid, const TaskStatus& status)
+  void statusUpdate(const TaskStatus& status)
   {
     cout << "Task " << status.task_id() << " is in state " << status.state();
 
@@ -308,16 +308,18 @@ private:
     }
     cout << endl;
 
-    Call call;
-    call.set_type(Call::ACKNOWLEDGE);
-    call.mutable_framework_info()->CopyFrom(framework);
+    if (status.has_uuid()) {
+      Call call;
+      call.set_type(Call::ACKNOWLEDGE);
+      call.mutable_framework_info()->CopyFrom(framework);
 
-    Call::Acknowledge* ack = call.mutable_acknowledge();
-    ack->mutable_slave_id()->CopyFrom(status.slave_id());
-    ack->mutable_task_id ()->CopyFrom(status.task_id ());
-    ack->set_uuid(uuid);
+      Call::Acknowledge* ack = call.mutable_acknowledge();
+      ack->mutable_slave_id()->CopyFrom(status.slave_id());
+      ack->mutable_task_id ()->CopyFrom(status.task_id ());
+      ack->set_uuid(status.uuid());
 
-    mesos.send(call);
+      mesos.send(call);
+    }
 
     if (status.state() == TASK_FINISHED) {
       ++tasksFinished;

http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 66fd2b3..8c366ec 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -698,9 +698,9 @@ protected:
     // ensure that a 0.22.0 scheduler driver supports explicit
     // acknowledgements, even if running against a 0.21.0 cluster.
     //
-    // TODO(bmahler): Update the slave / executor driver to ensure
-    // that 'uuid' is set accurately by the time it reaches the
-    // scheduler driver. This will be required for pure bindings.
+    // TODO(bmahler): Update master and slave to ensure that 'uuid' is
+    // set accurately by the time it reaches the scheduler driver.
+    // This will be required for pure bindings.
     if (from == UPID() || pid == UPID()) {
       status.clear_uuid();
     } else {

http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/src/scheduler/scheduler.cpp
----------------------------------------------------------------------
diff --git a/src/scheduler/scheduler.cpp b/src/scheduler/scheduler.cpp
index 2047ee4..d3d28ee 100644
--- a/src/scheduler/scheduler.cpp
+++ b/src/scheduler/scheduler.cpp
@@ -44,6 +44,7 @@
 #include <process/future.hpp>
 #include <process/id.hpp>
 #include <process/mutex.hpp>
+#include <process/pid.hpp>
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
@@ -642,8 +643,15 @@ protected:
 
     update->mutable_status()->set_timestamp(message.update().timestamp());
 
-    update->set_uuid(message.update().uuid());
-    update->mutable_status()->set_uuid(message.update().uuid());
+    // If the update is generated by the master it doesn't need to be
+    // acknowledged; so we unset the UUID inside TaskStatus.
+    // TODO(vinod): Update master and slave to ensure that 'uuid' is
+    // set accurately by the time it reaches the scheduler.
+    if (UPID(message.pid()) == UPID()) {
+      update->mutable_status()->clear_uuid();
+    } else {
+      update->mutable_status()->set_uuid(message.update().uuid());
+    }
 
     receive(from, event);
   }
@@ -729,9 +737,6 @@ protected:
     status->set_message(message);
     status->set_timestamp(Clock::now().secs());
 
-    update->set_uuid(UUID::random().toBytes());
-    status->set_uuid(update->uuid());
-
     receive(None(), event);
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/32d1b67d/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 54d6bc9..f2cb1d8 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -308,6 +308,7 @@ TEST_F(SchedulerTest, ReconcileTask)
   event = events.get();
   AWAIT_READY(event);
   EXPECT_EQ(Event::UPDATE, event.get().type());
+  EXPECT_FALSE(event.get().update().status().has_uuid());
   EXPECT_EQ(TASK_RUNNING, event.get().update().status().state());
   EXPECT_EQ(TaskStatus::REASON_RECONCILIATION,
             event.get().update().status().reason());