本文整理汇总了C++中Future::disk_statistics方法的典型用法代码示例。如果您正苦于以下问题:C++ Future::disk_statistics方法的具体用法?C++ Future::disk_statistics怎么用?C++ Future::disk_statistics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Future
的用法示例。
在下文中一共展示了Future::disk_statistics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fetcher
//.........这里部分代码省略.........
Resource volume = createPersistentVolume(
Megabytes(4),
DEFAULT_TEST_ROLE,
"id1",
"path1",
None(),
None(),
DEFAULT_CREDENTIAL.principal());
Resources taskResources = Resources::parse("cpus:1;mem:128").get();
taskResources += createDiskResource(
"3",
DEFAULT_TEST_ROLE,
None(),
None());
taskResources += volume;
// Create a task that uses 2MB disk.
TaskInfo task = createTask(
offer.slave_id(),
taskResources,
"dd if=/dev/zero of=file bs=1048576 count=2 && "
"dd if=/dev/zero of=path1/file bs=1048576 count=2 && "
"sleep 1000");
Future<TaskStatus> status1;
Future<TaskStatus> status2;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&status1))
.WillOnce(FutureArg<1>(&status2))
.WillRepeatedly(Return()); // Ignore subsequent updates.
driver.acceptOffers(
{offer.id()},
{CREATE(volume),
LAUNCH({task})});
AWAIT_READY(status1);
EXPECT_EQ(task.task_id(), status1->task_id());
EXPECT_EQ(TASK_RUNNING, status1->state());
Future<hashset<ContainerID>> containers = containerizer->containers();
AWAIT_READY(containers);
ASSERT_EQ(1u, containers->size());
const ContainerID& containerId = *(containers->begin());
// Wait until disk usage can be retrieved.
Duration elapsed = Duration::zero();
while (true) {
Future<ResourceStatistics> usage = containerizer->usage(containerId);
AWAIT_READY(usage);
ASSERT_TRUE(usage->has_disk_limit_bytes());
EXPECT_EQ(Megabytes(3), Bytes(usage->disk_limit_bytes()));
if (usage->has_disk_used_bytes()) {
EXPECT_LE(usage->disk_used_bytes(), usage->disk_limit_bytes());
}
ASSERT_EQ(2u, usage->disk_statistics().size());
bool done = true;
foreach (const DiskStatistics& statistics, usage->disk_statistics()) {
ASSERT_TRUE(statistics.has_limit_bytes());
EXPECT_EQ(
statistics.has_persistence() ? Megabytes(4) : Megabytes(3),
statistics.limit_bytes());
if (!statistics.has_used_bytes()) {
done = false;
} else {
EXPECT_GT(
statistics.has_persistence() ? Megabytes(4) : Megabytes(3),
statistics.used_bytes());
}
}
if (done) {
break;
}
ASSERT_LT(elapsed, Seconds(5));
os::sleep(Milliseconds(1));
elapsed += Milliseconds(1);
}
driver.killTask(task.task_id());
AWAIT_READY(status2);
EXPECT_EQ(task.task_id(), status2->task_id());
EXPECT_EQ(TASK_KILLED, status2->state());
driver.stop();
driver.join();
}