本文整理汇总了C++中Try::kilobytes方法的典型用法代码示例。如果您正苦于以下问题:C++ Try::kilobytes方法的具体用法?C++ Try::kilobytes怎么用?C++ Try::kilobytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Try
的用法示例。
在下文中一共展示了Try::kilobytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: driver
//.........这里部分代码省略.........
SlaveID slaveId = slaveRegisteredMessage.get().slave_id();
MockScheduler sched;
MesosSchedulerDriver driver(
&sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
Future<FrameworkID> frameworkId;
EXPECT_CALL(sched, registered(&driver, _, _))
.WillOnce(FutureArg<1>(&frameworkId));
// Wait for an offer, and start a task.
Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
driver.start();
AWAIT_READY(frameworkId);
AWAIT_READY(offers);
EXPECT_NE(0u, offers.get().size());
// Start a task that spams stdout with 11 MB of (mostly blank) output.
// The logrotate container logger module is loaded with parameters that limit
// the log size to five files of 2 MB each. After the task completes, there
// should be five files with a total size of 9 MB. The first 2 MB file
// should have been deleted. The "stdout" file should be 1 MB large.
TaskInfo task = createTask(
offers.get()[0],
"i=0; while [ $i -lt 11264 ]; "
"do printf '%-1024d\\n' $i; i=$((i+1)); done");
Future<TaskStatus> statusRunning;
Future<TaskStatus> statusFinished;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&statusRunning))
.WillOnce(FutureArg<1>(&statusFinished))
.WillRepeatedly(Return()); // Ignore subsequent updates.
driver.launchTasks(offers.get()[0].id(), {task});
AWAIT_READY(statusRunning);
EXPECT_EQ(TASK_RUNNING, statusRunning.get().state());
AWAIT_READY(statusFinished);
EXPECT_EQ(TASK_FINISHED, statusFinished.get().state());
driver.stop();
driver.join();
Shutdown();
// The `LogrotateContainerLogger` spawns some `mesos-logrotate-logger`
// processes above, which continue running briefly after the container exits.
// Once they finish reading the container's pipe, they should exit.
Try<os::ProcessTree> pstrees = os::pstree(0);
ASSERT_SOME(pstrees);
foreach (const os::ProcessTree& pstree, pstrees.get().children) {
ASSERT_EQ(pstree.process.pid, waitpid(pstree.process.pid, NULL, 0));
}
// Check for the expected log rotation.
string sandboxDirectory = path::join(
slave::paths::getExecutorPath(
flags.work_dir,
slaveId,
frameworkId.get(),
statusRunning->executor_id()),
"runs",
"latest");
ASSERT_TRUE(os::exists(sandboxDirectory));
// The leading log file should be about half full (1 MB).
string stdoutPath = path::join(sandboxDirectory, "stdout");
ASSERT_TRUE(os::exists(stdoutPath));
// NOTE: We don't expect the size of the leading log file to be precisely
// one MB since there is also the executor's output besides the task's stdout.
Try<Bytes> stdoutSize = os::stat::size(stdoutPath);
ASSERT_SOME(stdoutSize);
EXPECT_LE(1024, stdoutSize->kilobytes());
EXPECT_GE(1050, stdoutSize->kilobytes());
// We should only have files up to "stdout.4".
stdoutPath = path::join(sandboxDirectory, "stdout.5");
EXPECT_FALSE(os::exists(stdoutPath));
// The next four rotated log files (2 MB each) should be present.
for (int i = 1; i < 5; i++) {
stdoutPath = path::join(sandboxDirectory, "stdout." + stringify(i));
ASSERT_TRUE(os::exists(stdoutPath));
// NOTE: The rotated files are written in contiguous blocks, meaning that
// each file may be less than the maximum allowed size.
stdoutSize = os::stat::size(stdoutPath);
EXPECT_LE(2040, stdoutSize->kilobytes());
EXPECT_GE(2048, stdoutSize->kilobytes());
}
}