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/06/21 20:51:35 UTC

[1/3] mesos git commit: Added Sorter::allocation() overload for getting resources of a particular slave.

Repository: mesos
Updated Branches:
  refs/heads/master effc3636d -> 441dd02cd


Added Sorter::allocation() overload for getting resources of a particular slave.

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


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

Branch: refs/heads/master
Commit: 1e596419298998eaff95e7ac9394ca6355879925
Parents: ac58067
Author: Vinod Kone <vi...@gmail.com>
Authored: Fri Jun 19 17:30:09 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Jun 21 11:50:58 2015 -0700

----------------------------------------------------------------------
 src/master/allocator/sorter/drf/sorter.cpp | 14 ++++++++++++++
 src/master/allocator/sorter/drf/sorter.hpp |  2 ++
 src/master/allocator/sorter/sorter.hpp     |  6 ++++++
 src/tests/sorter_tests.cpp                 | 21 ++++++++++-----------
 4 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1e596419/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index 12434a0..85eef6b 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -156,10 +156,24 @@ void DRFSorter::update(
 
 hashmap<SlaveID, Resources> DRFSorter::allocation(const string& name)
 {
+  CHECK(contains(name));
+
   return allocations[name].resources;
 }
 
 
+Resources DRFSorter::allocation(const string& name, const SlaveID& slaveId)
+{
+  CHECK(contains(name));
+
+  if (allocations[name].resources.contains(slaveId)) {
+    return allocations[name].resources[slaveId];
+  }
+
+  return Resources();
+}
+
+
 void DRFSorter::unallocated(
     const string& name,
     const SlaveID& slaveId,

http://git-wip-us.apache.org/repos/asf/mesos/blob/1e596419/src/master/allocator/sorter/drf/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.hpp b/src/master/allocator/sorter/drf/sorter.hpp
index d38925e..6aec14f 100644
--- a/src/master/allocator/sorter/drf/sorter.hpp
+++ b/src/master/allocator/sorter/drf/sorter.hpp
@@ -91,6 +91,8 @@ public:
 
   virtual hashmap<SlaveID, Resources> allocation(const std::string& name);
 
+  virtual Resources allocation(const std::string& name, const SlaveID& slaveId);
+
   virtual void add(const SlaveID& slaveId, const Resources& resources);
 
   virtual void remove(const SlaveID& slaveId, const Resources& resources);

http://git-wip-us.apache.org/repos/asf/mesos/blob/1e596419/src/master/allocator/sorter/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/sorter.hpp b/src/master/allocator/sorter/sorter.hpp
index 9f7d3cc..536a7ad 100644
--- a/src/master/allocator/sorter/sorter.hpp
+++ b/src/master/allocator/sorter/sorter.hpp
@@ -80,6 +80,12 @@ public:
   // Returns the resources that have been allocated to this client.
   virtual hashmap<SlaveID, Resources> allocation(const std::string& client) = 0;
 
+  // Returns the given slave's resources that have been allocated to
+  // this client.
+  virtual Resources allocation(
+      const std::string& client,
+      const SlaveID& slaveId) = 0;
+
   // Add resources to the total pool of resources this
   // Sorter should consider.
   virtual void add(const SlaveID& slaveId, const Resources& resources) = 0;

http://git-wip-us.apache.org/repos/asf/mesos/blob/1e596419/src/tests/sorter_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/sorter_tests.cpp b/src/tests/sorter_tests.cpp
index 4013886..0db9a04 100644
--- a/src/tests/sorter_tests.cpp
+++ b/src/tests/sorter_tests.cpp
@@ -235,7 +235,7 @@ TEST(SorterTest, UpdateAllocation)
   volume.mutable_disk()->mutable_volume()->set_container_path("data");
 
   // Compute the updated allocation.
-  Resources oldAllocation = sorter.allocation("a")[slaveId];
+  Resources oldAllocation = sorter.allocation("a", slaveId);
   Try<Resources> newAllocation = oldAllocation.apply(CREATE(volume));
   ASSERT_SOME(newAllocation);
 
@@ -245,6 +245,7 @@ TEST(SorterTest, UpdateAllocation)
   hashmap<SlaveID, Resources> allocation = sorter.allocation("a");
   EXPECT_EQ(1u, allocation.size());
   EXPECT_EQ(newAllocation.get(), allocation[slaveId]);
+  EXPECT_EQ(newAllocation.get(), sorter.allocation("a", slaveId));
 }
 
 
@@ -274,10 +275,9 @@ TEST(SorterTest, MultipleSlaves)
   sorter.allocated("framework", slaveA, slaveResources);
   sorter.allocated("framework", slaveB, slaveResources);
 
-  hashmap<SlaveID, Resources> allocation = sorter.allocation("framework");
-  EXPECT_EQ(2u, allocation.size());
-  EXPECT_EQ(slaveResources, allocation[slaveA]);
-  EXPECT_EQ(slaveResources, allocation[slaveB]);
+  EXPECT_EQ(2u, sorter.allocation("framework").size());
+  EXPECT_EQ(slaveResources, sorter.allocation("framework", slaveA));
+  EXPECT_EQ(slaveResources, sorter.allocation("framework", slaveB));
 }
 
 
@@ -320,10 +320,9 @@ TEST(SorterTest, MultipleSlavesUpdateAllocation)
   sorter.update("framework", slaveA, slaveResources, newAllocation.get());
   sorter.update("framework", slaveB, slaveResources, newAllocation.get());
 
-  hashmap<SlaveID, Resources> allocation = sorter.allocation("framework");
-  EXPECT_EQ(2u, allocation.size());
-  EXPECT_EQ(newAllocation.get(), allocation[slaveA]);
-  EXPECT_EQ(newAllocation.get(), allocation[slaveB]);
+  EXPECT_EQ(2u, sorter.allocation("framework").size());
+  EXPECT_EQ(newAllocation.get(), sorter.allocation("framework", slaveA));
+  EXPECT_EQ(newAllocation.get(), sorter.allocation("framework", slaveB));
 }
 
 
@@ -440,8 +439,8 @@ TEST(SorterTest, RevocableResources)
   sorter.allocated("b", slaveId, b);
 
   // Check that the allocations are correct.
-  ASSERT_EQ(a, sorter.allocation("a")[slaveId]);
-  ASSERT_EQ(b, sorter.allocation("b")[slaveId]);
+  ASSERT_EQ(a, sorter.allocation("a", slaveId));
+  ASSERT_EQ(b, sorter.allocation("b", slaveId));
 
   // Check that the sort is correct.
   list<string> sorted = sorter.sort();


[3/3] mesos git commit: Sped up Allocator::updateSlave() and Allocator::updateAllocation().

Posted by vi...@apache.org.
Sped up Allocator::updateSlave() and Allocator::updateAllocation().

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


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

Branch: refs/heads/master
Commit: 441dd02cd52a400ef14cc32e5fb5c875f6b81150
Parents: 1e59641
Author: Vinod Kone <vi...@gmail.com>
Authored: Fri Jun 19 17:39:07 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Jun 21 11:50:59 2015 -0700

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/441dd02c/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 646ee8c..7097482 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -570,7 +570,7 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::updateSlave(
   // Calculate the current allocation of oversubscribed resources.
   Resources allocation;
   foreachkey (const std::string& role, roles) {
-    allocation += roleSorter->allocation(role)[slaveId].revocable();
+    allocation += roleSorter->allocation(role, slaveId).revocable();
   }
 
   // Update the available resources.
@@ -675,7 +675,7 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::updateAllocation(
     frameworkSorters[frameworks[frameworkId].role];
 
   Resources allocation =
-    frameworkSorter->allocation(frameworkId.value())[slaveId];
+    frameworkSorter->allocation(frameworkId.value(), slaveId);
 
   // Update the allocated resources.
   Try<Resources> updatedAllocation = allocation.apply(operations);


[2/3] mesos git commit: Added benchmark test for Allocator::updateSlave().

Posted by vi...@apache.org.
Added benchmark test for Allocator::updateSlave().

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


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

Branch: refs/heads/master
Commit: ac5806779e5438e99fbe53ade57c1d09bda7485d
Parents: effc363
Author: Vinod Kone <vi...@gmail.com>
Authored: Fri Jun 19 16:58:38 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Jun 21 11:50:58 2015 -0700

----------------------------------------------------------------------
 src/tests/hierarchical_allocator_tests.cpp | 29 +++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ac580677/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index d2f65d7..3258840 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -986,12 +986,12 @@ INSTANTIATE_TEST_CASE_P(
     ::testing::Values(1000U, 5000U, 10000U, 20000U, 30000U, 50000U));
 
 
-TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
+TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
 {
   Clock::pause();
 
-  // How many 'addSlave' that have been processed. This is used to
-  // determine the termination condition.
+  // Number of allocations. This is used to determine the termination
+  // condition.
   atomic<size_t> finished(0);
 
   auto offerCallback = [&finished](
@@ -1002,7 +1002,11 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
 
   initialize({}, master::Flags(), offerCallback);
 
+  // Add a framework that can accept revocable resources.
   FrameworkInfo framework = createFrameworkInfo("*");
+  framework.add_capabilities()->set_type(
+      FrameworkInfo::Capability::REVOCABLE_RESOURCES);
+
   allocator->addFramework(framework.id(), framework, {});
 
   size_t slaveCount = GetParam();
@@ -1027,12 +1031,29 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddSlave)
     allocator->addSlave(slave.id(), slave, slave.resources(), used);
   }
 
-  // Wait for all the 'addSlave' to be processed.
+  // Wait for all the 'addSlave' operations to be processed.
   while (finished.load() != slaveCount) {
     os::sleep(Milliseconds(10));
   }
 
   cout << "Added " << slaveCount << " slaves in " << watch.elapsed() << endl;
+
+  // Oversubscribed resources on each slave.
+  Resource oversubscribed = Resources::parse("cpus", "10", "*").get();
+  oversubscribed.mutable_revocable();
+
+  watch.start(); // Reset.
+
+  foreach (const SlaveInfo& slave, slaves) {
+    allocator->updateSlave(slave.id(), oversubscribed);
+  }
+
+  // Wait for all the 'updateSlave' operations to be processed.
+  while (finished.load() != 2 * slaveCount) {
+    os::sleep(Milliseconds(10));
+  }
+
+  cout << "Updated " << slaveCount << " slaves in " << watch.elapsed() << endl;
 }
 
 } // namespace tests {