You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/10/08 20:45:51 UTC

[4/8] git commit: Properly deprecated ReregisterSlaveMessage::slave_id.

Properly deprecated ReregisterSlaveMessage::slave_id.

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


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

Branch: refs/heads/master
Commit: 5da57a7ef769d12bfbdb64f365b409853fdd9935
Parents: 8f4dd63
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Thu Sep 25 16:59:19 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Oct 8 11:45:11 2014 -0700

----------------------------------------------------------------------
 src/master/master.cpp       | 9 +++------
 src/master/master.hpp       | 9 +++++----
 src/messages/messages.proto | 7 ++++---
 src/slave/slave.cpp         | 4 ++--
 4 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5da57a7e/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index a1716f4..eb7b210 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -583,7 +583,6 @@ void Master::initialize()
 
   install<ReregisterSlaveMessage>(
       &Master::reregisterSlave,
-      &ReregisterSlaveMessage::slave_id,
       &ReregisterSlaveMessage::slave,
       &ReregisterSlaveMessage::executor_infos,
       &ReregisterSlaveMessage::tasks,
@@ -2981,7 +2980,7 @@ void Master::_registerSlave(
         stringify(slaveInfo.id()));
     send(pid, message);
   } else {
-    Slave* slave = new Slave(slaveInfo, slaveInfo.id(), pid, Clock::now());
+    Slave* slave = new Slave(slaveInfo, pid, Clock::now());
 
     LOG(INFO) << "Registered slave " << *slave;
     ++metrics.slave_registrations;
@@ -2993,7 +2992,6 @@ void Master::_registerSlave(
 
 void Master::reregisterSlave(
     const UPID& from,
-    const SlaveID& slaveId,
     const SlaveInfo& slaveInfo,
     const vector<ExecutorInfo>& executorInfos,
     const vector<Task>& tasks,
@@ -3009,7 +3007,6 @@ void Master::reregisterSlave(
       .onReady(defer(self(),
                      &Self::reregisterSlave,
                      from,
-                     slaveId,
                      slaveInfo,
                      executorInfos,
                      tasks,
@@ -3036,7 +3033,7 @@ void Master::reregisterSlave(
     // re-registering. This is because a non-strict registrar cannot
     // enforce this. We've already told frameworks the tasks were
     // lost so it's important to deny the slave from re-registering.
-    LOG(WARNING) << "Slave " << slaveId << " at " << from
+    LOG(WARNING) << "Slave " << slaveInfo.id() << " at " << from
                  << " (" << slaveInfo.hostname() << ") attempted to "
                  << "re-register after removal; shutting it down";
 
@@ -3171,7 +3168,7 @@ void Master::_reregisterSlave(
     send(pid, message);
   } else {
     // Re-admission succeeded.
-    Slave* slave = new Slave(slaveInfo, slaveInfo.id(), pid, Clock::now());
+    Slave* slave = new Slave(slaveInfo, pid, Clock::now());
     slave->reregisteredTime = Clock::now();
 
     LOG(INFO) << "Re-registered slave " << *slave;

http://git-wip-us.apache.org/repos/asf/mesos/blob/5da57a7e/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 5cafae3..0f0b205 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -160,7 +160,6 @@ public:
       const SlaveInfo& slaveInfo);
   void reregisterSlave(
       const process::UPID& from,
-      const SlaveID& slaveId,
       const SlaveInfo& slaveInfo,
       const std::vector<ExecutorInfo>& executorInfos,
       const std::vector<Task>& tasks,
@@ -815,16 +814,18 @@ private:
 struct Slave
 {
   Slave(const SlaveInfo& _info,
-        const SlaveID& _id,
         const process::UPID& _pid,
         const process::Time& time)
-    : id(_id),
+    : id(_info.id()),
       info(_info),
       pid(_pid),
       registeredTime(time),
       connected(true),
       active(true),
-      observer(NULL) {}
+      observer(NULL)
+  {
+    CHECK(_info.has_id());
+  }
 
   ~Slave() {}
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/5da57a7e/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 9ff06b3..16d9d67 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -231,9 +231,10 @@ message RegisterSlaveMessage {
 
 
 message ReregisterSlaveMessage {
-  // TODO(bmahler): Deprecate and remove the explicit slave_id as
-  // SlaveInfo already includes this information.
-  required SlaveID slave_id = 1;
+  // TODO(bmahler): slave_id is deprecated.
+  // 0.21.0: Now an optional field. Always written, never read.
+  // 0.22.0: Remove this field.
+  optional SlaveID slave_id = 1;
   required SlaveInfo slave = 2;
   repeated ExecutorInfo executor_infos = 4;
   repeated Task tasks = 3;

http://git-wip-us.apache.org/repos/asf/mesos/blob/5da57a7e/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 853c350..ee3d649 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -879,7 +879,7 @@ void Slave::doReliableRegistration(const Duration& duration)
 
   CHECK(state == DISCONNECTED) << state;
 
-  if (info.id() == "") {
+  if (!info.has_id()) {
     // Registering for the first time.
     RegisterSlaveMessage message;
     message.mutable_slave()->CopyFrom(info);
@@ -887,7 +887,7 @@ void Slave::doReliableRegistration(const Duration& duration)
   } else {
     // Re-registering, so send tasks running.
     ReregisterSlaveMessage message;
-    // TODO(bmahler): deprecate this.
+    // TODO(bmahler): Remove in 0.22.0.
     message.mutable_slave_id()->CopyFrom(info.id());
     message.mutable_slave()->CopyFrom(info);