本文整理汇总了C++中offer::Operation::mutable_create方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::mutable_create方法的具体用法?C++ Operation::mutable_create怎么用?C++ Operation::mutable_create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类offer::Operation
的用法示例。
在下文中一共展示了Operation::mutable_create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CREATE
// Helpers for creating offer operations.
inline Offer::Operation CREATE(const Resources& volumes)
{
Offer::Operation operation;
operation.set_type(Offer::Operation::CREATE);
operation.mutable_create()->mutable_volumes()->CopyFrom(volumes);
return operation;
}
示例2:
TEST(SorterTest, Update)
{
DRFSorter sorter;
sorter.add("a");
sorter.add("b");
sorter.add(Resources::parse("cpus:10;mem:10;disk:10").get());
sorter.allocated("a", Resources::parse("cpus:10;mem:10;disk:10").get());
// Construct an offer operation.
Resource volume = Resources::parse("disk", "5", "*").get();
volume.mutable_disk()->mutable_persistence()->set_id("ID");
volume.mutable_disk()->mutable_volume()->set_container_path("data");
Offer::Operation create;
create.set_type(Offer::Operation::CREATE);
create.mutable_create()->add_volumes()->CopyFrom(volume);
// Compute the updated allocation.
Resources allocation = sorter.allocation("a");
Try<Resources> newAllocation = allocation.apply(create);
ASSERT_SOME(newAllocation);
// Update the resources for the client.
sorter.update("a", allocation, newAllocation.get());
EXPECT_EQ(newAllocation.get(), sorter.allocation("a"));
}