You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2018/01/11 20:39:33 UTC

[3/3] mesos git commit: Replaced `convertResourceFormat` with `downgradeResources` accordingly.

Replaced `convertResourceFormat` with `downgradeResources` accordingly.

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


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

Branch: refs/heads/master
Commit: e5bc824fbbc377f614b6e1d8a0be9b69c2af2c60
Parents: 15faeea
Author: Michael Park <mp...@apache.org>
Authored: Mon Jan 8 12:47:41 2018 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Thu Jan 11 12:01:41 2018 -0800

----------------------------------------------------------------------
 src/master/registry_operations.cpp | 36 +++++++++++++++------------------
 src/master/registry_operations.hpp |  6 +++---
 2 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e5bc824f/src/master/registry_operations.cpp
----------------------------------------------------------------------
diff --git a/src/master/registry_operations.cpp b/src/master/registry_operations.cpp
index ff3c274..c417c4d 100644
--- a/src/master/registry_operations.cpp
+++ b/src/master/registry_operations.cpp
@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include <stout/check.hpp>
+
 #include "master/registry_operations.hpp"
 
 #include "common/resources_utils.hpp"
@@ -38,15 +40,13 @@ Try<bool> AdmitSlave::perform(Registry* registry, hashset<SlaveID>* slaveIDs)
     return Error("Agent already admitted");
   }
 
-  // Convert the resource format back to `PRE_RESERVATION_REFINEMENT` so
-  // the data stored in the registry can be read by older master versions.
-  SlaveInfo _info(info);
-  convertResourceFormat(_info.mutable_resources(),
-      PRE_RESERVATION_REFINEMENT);
+  // Downgrade the resources such that an older master can recover from
+  // the checkpointed registry state.
+  CHECK_SOME(downgradeResources(&info));
 
   Registry::Slave* slave = registry->mutable_slaves()->add_slaves();
-  slave->mutable_info()->CopyFrom(_info);
-  slaveIDs->insert(_info.id());
+  slave->mutable_info()->CopyFrom(info);
+  slaveIDs->insert(info.id());
   return true; // Mutation.
 }
 
@@ -78,13 +78,11 @@ Try<bool> UpdateSlave::perform(Registry* registry, hashset<SlaveID>* slaveIDs)
         return false; // No mutation.
       }
 
-      // Convert the resource format back to `PRE_RESERVATION_REFINEMENT` so
-      // the data stored in the registry can be read by older master versions.
-      SlaveInfo _info(info);
-      convertResourceFormat(_info.mutable_resources(),
-          PRE_RESERVATION_REFINEMENT);
+      // Downgrade the resources such that an older master can recover from
+      // the checkpointed registry state.
+      CHECK_SOME(downgradeResources(&info));
 
-      slave->mutable_info()->CopyFrom(_info);
+      slave->mutable_info()->CopyFrom(info);
       return true; // Mutation.
     }
   }
@@ -184,19 +182,17 @@ Try<bool> MarkSlaveReachable::perform(
     LOG(WARNING) << "Allowing UNKNOWN agent to reregister: " << info;
   }
 
-  // Convert the resource format back to `PRE_RESERVATION_REFINEMENT` so
-  // the data stored in the registry can be read by older master versions.
-  SlaveInfo _info(info);
-  convertResourceFormat(_info.mutable_resources(),
-    PRE_RESERVATION_REFINEMENT);
+  // Downgrade the resources such that an older master can recover from
+  // the checkpointed registry state.
+  CHECK_SOME(downgradeResources(&info));
 
   // Add the slave to the admitted list, even if we didn't find it
   // in the unreachable list. This accounts for when the slave was
   // unreachable for a long time, was GC'd from the unreachable
   // list, but then eventually reregistered.
   Registry::Slave* slave = registry->mutable_slaves()->add_slaves();
-  slave->mutable_info()->CopyFrom(_info);
-  slaveIDs->insert(_info.id());
+  slave->mutable_info()->CopyFrom(info);
+  slaveIDs->insert(info.id());
 
   return true; // Mutation.
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/e5bc824f/src/master/registry_operations.hpp
----------------------------------------------------------------------
diff --git a/src/master/registry_operations.hpp b/src/master/registry_operations.hpp
index 41047f0..c07268e 100644
--- a/src/master/registry_operations.hpp
+++ b/src/master/registry_operations.hpp
@@ -37,7 +37,7 @@ protected:
   virtual Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs);
 
 private:
-  const SlaveInfo info;
+  SlaveInfo info;
 };
 
 
@@ -51,7 +51,7 @@ protected:
   virtual Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs);
 
 private:
-  const SlaveInfo info;
+  SlaveInfo info;
 };
 
 
@@ -88,7 +88,7 @@ protected:
   virtual Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs);
 
 private:
-  const SlaveInfo info;
+  SlaveInfo info;
 };