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/05/23 02:17:29 UTC

[2/2] mesos git commit: Added 'updateSlave()' API call to Allocator.

Added 'updateSlave()' API call to Allocator.

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


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

Branch: refs/heads/master
Commit: ebb8b590b30b16657eda5ec2ee0e38085384ee5a
Parents: 5e20c58
Author: Vinod Kone <vi...@gmail.com>
Authored: Thu May 21 16:24:44 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri May 22 17:05:13 2015 -0700

----------------------------------------------------------------------
 include/mesos/master/allocator.hpp          |  9 +++++++++
 src/master/allocator/mesos/allocator.hpp    | 21 +++++++++++++++++++++
 src/master/allocator/mesos/hierarchical.hpp | 20 ++++++++++++++++++++
 src/tests/mesos.hpp                         | 15 +++++++++++++++
 4 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ebb8b590/include/mesos/master/allocator.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/master/allocator.hpp b/include/mesos/master/allocator.hpp
index 0328ae4..8347cfa 100644
--- a/include/mesos/master/allocator.hpp
+++ b/include/mesos/master/allocator.hpp
@@ -96,6 +96,15 @@ public:
   virtual void removeSlave(
       const SlaveID& slaveId) = 0;
 
+  // Note that 'oversubscribed' resources include the total amount of
+  // oversubscribed resources that are allocated and available.
+  // TODO(vinod): Instead of just oversubscribed resources have this
+  // method take total resources. We can then reuse this method to
+  // update slave's total resources in the future.
+  virtual void updateSlave(
+      const SlaveID& slave,
+      const Resources& oversubscribed) = 0;
+
   // Offers are sent only for activated slaves.
   virtual void activateSlave(
       const SlaveID& slaveId) = 0;

http://git-wip-us.apache.org/repos/asf/mesos/blob/ebb8b590/src/master/allocator/mesos/allocator.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/allocator.hpp b/src/master/allocator/mesos/allocator.hpp
index e6f6114..b57b03d 100644
--- a/src/master/allocator/mesos/allocator.hpp
+++ b/src/master/allocator/mesos/allocator.hpp
@@ -76,6 +76,10 @@ public:
   void removeSlave(
       const SlaveID& slaveId);
 
+  void updateSlave(
+      const SlaveID& slave,
+      const Resources& oversubscribed);
+
   void activateSlave(
       const SlaveID& slaveId);
 
@@ -154,6 +158,10 @@ public:
   virtual void removeSlave(
       const SlaveID& slaveId) = 0;
 
+  virtual void updateSlave(
+      const SlaveID& slave,
+      const Resources& oversubscribed) = 0;
+
   virtual void activateSlave(
       const SlaveID& slaveId) = 0;
 
@@ -303,6 +311,19 @@ inline void MesosAllocator<AllocatorProcess>::removeSlave(
 
 
 template <typename AllocatorProcess>
+inline void MesosAllocator<AllocatorProcess>::updateSlave(
+    const SlaveID& slaveId,
+    const Resources& oversubscribed)
+{
+  process::dispatch(
+      process,
+      &MesosAllocatorProcess::updateSlave,
+      slaveId,
+      oversubscribed);
+}
+
+
+template <typename AllocatorProcess>
 inline void MesosAllocator<AllocatorProcess>::activateSlave(
     const SlaveID& slaveId)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ebb8b590/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 4b36d42..9c949b4 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -103,6 +103,10 @@ public:
   void removeSlave(
       const SlaveID& slaveId);
 
+  void updateSlave(
+      const SlaveID& slave,
+      const Resources& oversubscribed);
+
   void deactivateSlave(
       const SlaveID& slaveId);
 
@@ -483,6 +487,22 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::removeSlave(
 
 template <class RoleSorter, class FrameworkSorter>
 void
+HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::updateSlave(
+    const SlaveID& slaveId,
+    const Resources& oversubscribed)
+{
+  CHECK(initialized);
+  CHECK(slaves.contains(slaveId));
+
+  LOG(INFO) << "Slave " << slaveId << " updated with oversubscribed resources "
+            << oversubscribed;
+
+  // TODO(vinod): Implement this.
+}
+
+
+template <class RoleSorter, class FrameworkSorter>
+void
 HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::activateSlave(
     const SlaveID& slaveId)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ebb8b590/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 924b0ff..b8f7a2f 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -869,6 +869,12 @@ ACTION_P(InvokeRemoveSlave, allocator)
 }
 
 
+ACTION_P(InvokeUpdateSlave, allocator)
+{
+  allocator->real->updateSlave(arg0, arg1);
+}
+
+
 ACTION_P(InvokeActivateSlave, allocator)
 {
   allocator->real->activateSlave(arg0);
@@ -982,6 +988,11 @@ public:
     EXPECT_CALL(*this, removeSlave(_))
       .WillRepeatedly(DoDefault());
 
+    ON_CALL(*this, updateSlave(_, _))
+      .WillByDefault(InvokeUpdateSlave(this));
+    EXPECT_CALL(*this, updateSlave(_, _))
+      .WillRepeatedly(DoDefault());
+
     ON_CALL(*this, activateSlave(_))
       .WillByDefault(InvokeActivateSlave(this));
     EXPECT_CALL(*this, activateSlave(_))
@@ -1050,6 +1061,10 @@ public:
   MOCK_METHOD1(removeSlave, void(
       const SlaveID&));
 
+  MOCK_METHOD2(updateSlave, void(
+      const SlaveID&,
+      const Resources&));
+
   MOCK_METHOD1(activateSlave, void(
       const SlaveID&));