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 2017/03/16 20:29:19 UTC
mesos git commit: Renamed `adjustOfferOperation` to
`injectAllocationInfo`.
Repository: mesos
Updated Branches:
refs/heads/master 505486b77 -> 74af382d7
Renamed `adjustOfferOperation` to `injectAllocationInfo`.
Method name `protobuf::adjustOfferOperation` is renamed to
`protobuf::injectAllocationInfo`.
Review: https://reviews.apache.org/r/57630/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/74af382d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/74af382d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/74af382d
Branch: refs/heads/master
Commit: 74af382d77cec9a48f4ec3b7619f4c9d4061710f
Parents: 505486b
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Mar 16 13:28:44 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Mar 16 13:28:44 2017 -0700
----------------------------------------------------------------------
src/common/protobuf_utils.cpp | 22 +++++++++++-----------
src/common/protobuf_utils.hpp | 2 +-
src/master/allocator/mesos/hierarchical.cpp | 2 +-
src/master/master.cpp | 2 +-
src/tests/hierarchical_allocator_tests.cpp | 4 ++--
src/tests/protobuf_utils_tests.cpp | 16 ++++++++--------
6 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 138e288..3bae2b5 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -432,11 +432,11 @@ Label createLabel(const string& key, const Option<string>& value)
}
-void adjustOfferOperation(
+void injectAllocationInfo(
Offer::Operation* operation,
const Resource::AllocationInfo& allocationInfo)
{
- auto adjustResources = [](
+ auto inject = [](
RepeatedPtrField<Resource>* resources,
const Resource::AllocationInfo& allocationInfo) {
foreach (Resource& resource, *resources) {
@@ -451,10 +451,10 @@ void adjustOfferOperation(
Offer::Operation::Launch* launch = operation->mutable_launch();
foreach (TaskInfo& task, *launch->mutable_task_infos()) {
- adjustResources(task.mutable_resources(), allocationInfo);
+ inject(task.mutable_resources(), allocationInfo);
if (task.has_executor()) {
- adjustResources(
+ inject(
task.mutable_executor()->mutable_resources(),
allocationInfo);
}
@@ -467,7 +467,7 @@ void adjustOfferOperation(
operation->mutable_launch_group();
if (launchGroup->has_executor()) {
- adjustResources(
+ inject(
launchGroup->mutable_executor()->mutable_resources(),
allocationInfo);
}
@@ -475,10 +475,10 @@ void adjustOfferOperation(
TaskGroupInfo* taskGroup = launchGroup->mutable_task_group();
foreach (TaskInfo& task, *taskGroup->mutable_tasks()) {
- adjustResources(task.mutable_resources(), allocationInfo);
+ inject(task.mutable_resources(), allocationInfo);
if (task.has_executor()) {
- adjustResources(
+ inject(
task.mutable_executor()->mutable_resources(),
allocationInfo);
}
@@ -487,7 +487,7 @@ void adjustOfferOperation(
}
case Offer::Operation::RESERVE: {
- adjustResources(
+ inject(
operation->mutable_reserve()->mutable_resources(),
allocationInfo);
@@ -495,7 +495,7 @@ void adjustOfferOperation(
}
case Offer::Operation::UNRESERVE: {
- adjustResources(
+ inject(
operation->mutable_unreserve()->mutable_resources(),
allocationInfo);
@@ -503,7 +503,7 @@ void adjustOfferOperation(
}
case Offer::Operation::CREATE: {
- adjustResources(
+ inject(
operation->mutable_create()->mutable_volumes(),
allocationInfo);
@@ -511,7 +511,7 @@ void adjustOfferOperation(
}
case Offer::Operation::DESTROY: {
- adjustResources(
+ inject(
operation->mutable_destroy()->mutable_volumes(),
allocationInfo);
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index ddfac24..cb7907b 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -159,7 +159,7 @@ Label createLabel(
// without an `AllocationInfo`. This allows the master to
// inject the offer's `AllocationInfo` into the operation's
// resources.
-void adjustOfferOperation(
+void injectAllocationInfo(
Offer::Operation* operation,
const Resource::AllocationInfo& allocationInfo);
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 37fb7a6..4830d1e 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -733,7 +733,7 @@ void HierarchicalAllocatorProcess::updateAllocation(
foreach (const Offer::Operation& operation, operations) {
// The operations should have been normalized by the master via
- // `protobuf::adjustOfferOperation()`.
+ // `protobuf::injectAllocationInfo()`.
//
// TODO(bmahler): Check that the operations have the allocation
// info set. The master should enforce this. E.g.
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index d43350d..fa7141a 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3829,7 +3829,7 @@ void Master::accept(
// inject the offer's allocation info into the operation's
// resources if the scheduler has not done so already.
foreach (Offer::Operation& operation, *accept.mutable_operations()) {
- protobuf::adjustOfferOperation(&operation, allocationInfo.get());
+ protobuf::injectAllocationInfo(&operation, allocationInfo.get());
}
CHECK_SOME(slaveId);
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index dce619e..e343dc3 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -4363,7 +4363,7 @@ TEST_P(HierarchicalAllocatorTestWithParam, AllocateSharedResources)
"5", "role1", "id1", None(), None(), true);
Offer::Operation create = CREATE(volume);
- protobuf::adjustOfferOperation(&create, allocationInfo);
+ protobuf::injectAllocationInfo(&create, allocationInfo);
// Launch a task using the shared volume.
TaskInfo task = createTask(
@@ -4372,7 +4372,7 @@ TEST_P(HierarchicalAllocatorTestWithParam, AllocateSharedResources)
"echo abc > path1/file");
Offer::Operation launch = LAUNCH({task});
- protobuf::adjustOfferOperation(&launch, allocationInfo);
+ protobuf::injectAllocationInfo(&launch, allocationInfo);
// Ensure the CREATE operation can be applied.
Try<Resources> updated =
http://git-wip-us.apache.org/repos/asf/mesos/blob/74af382d/src/tests/protobuf_utils_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/protobuf_utils_tests.cpp b/src/tests/protobuf_utils_tests.cpp
index 2c32d56..f10d9a4 100644
--- a/src/tests/protobuf_utils_tests.cpp
+++ b/src/tests/protobuf_utils_tests.cpp
@@ -64,9 +64,9 @@ TEST(ProtobufUtilTest, GetRoles)
}
-// Tests that offer operations can be adjusted to include
+// Tests that offer operations can be injected to include
// the appropriate allocation info, if not already set.
-TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
+TEST(ProtobufUtilTest, InjectAllocationInfoInOfferOperation)
{
Resources resources = Resources::parse("cpus:1").get();
@@ -87,7 +87,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
taskInfo.mutable_executor()->CopyFrom(executorInfo);
Offer::Operation launch = LAUNCH({taskInfo});
- protobuf::adjustOfferOperation(&launch, allocationInfo);
+ protobuf::injectAllocationInfo(&launch, allocationInfo);
ASSERT_EQ(1, launch.launch().task_infos_size());
@@ -104,7 +104,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
taskGroupInfo.add_tasks()->CopyFrom(taskInfo);
Offer::Operation launchGroup = LAUNCH_GROUP(executorInfo, taskGroupInfo);
- protobuf::adjustOfferOperation(&launchGroup, allocationInfo);
+ protobuf::injectAllocationInfo(&launchGroup, allocationInfo);
ASSERT_EQ(1, launchGroup.launch_group().task_group().tasks_size());
@@ -119,7 +119,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
// reservation, but for now this just sets the resources in
// order to verify the allocation info injection.
Offer::Operation reserve = RESERVE(resources);
- protobuf::adjustOfferOperation(&reserve, allocationInfo);
+ protobuf::injectAllocationInfo(&reserve, allocationInfo);
EXPECT_EQ(allocatedResources, reserve.reserve().resources());
@@ -127,7 +127,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
// reservation, but for now this just sets the resources in
// order to verify the allocation info injection.
Offer::Operation unreserve = UNRESERVE(resources);
- protobuf::adjustOfferOperation(&unreserve, allocationInfo);
+ protobuf::injectAllocationInfo(&unreserve, allocationInfo);
EXPECT_EQ(allocatedResources, unreserve.unreserve().resources());
@@ -135,7 +135,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
// volume, but for now this just sets the resources in order
// to verify the allocation info injection.
Offer::Operation create = CREATE(resources);
- protobuf::adjustOfferOperation(&create, allocationInfo);
+ protobuf::injectAllocationInfo(&create, allocationInfo);
EXPECT_EQ(allocatedResources, create.create().volumes());
@@ -143,7 +143,7 @@ TEST(ProtobufUtilTest, AdjustAllocationInfoInOfferOperation)
// volume, but for now this just sets the resources in order
// to verify the allocation info injection.
Offer::Operation destroy = DESTROY(resources);
- protobuf::adjustOfferOperation(&destroy, allocationInfo);
+ protobuf::injectAllocationInfo(&destroy, allocationInfo);
EXPECT_EQ(allocatedResources, destroy.destroy().volumes());
}