本文整理汇总了C++中TaskStatus::mutable_container_status方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskStatus::mutable_container_status方法的具体用法?C++ TaskStatus::mutable_container_status怎么用?C++ TaskStatus::mutable_container_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskStatus
的用法示例。
在下文中一共展示了TaskStatus::mutable_container_status方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTaskStatus
TaskStatus createTaskStatus(
TaskStatus status,
const id::UUID& uuid,
double timestamp,
const Option<TaskState>& state,
const Option<string>& message,
const Option<TaskStatus::Source>& source,
const Option<TaskStatus::Reason>& reason,
const Option<string>& data,
const Option<bool>& healthy,
const Option<CheckStatusInfo>& checkStatus,
const Option<Labels>& labels,
const Option<ContainerStatus>& containerStatus,
const Option<TimeInfo>& unreachableTime)
{
status.set_uuid(uuid.toBytes());
status.set_timestamp(timestamp);
if (state.isSome()) {
status.set_state(state.get());
}
if (message.isSome()) {
status.set_message(message.get());
}
if (source.isSome()) {
status.set_source(source.get());
}
if (reason.isSome()) {
status.set_reason(reason.get());
}
if (data.isSome()) {
status.set_data(data.get());
}
if (healthy.isSome()) {
status.set_healthy(healthy.get());
}
if (checkStatus.isSome()) {
status.mutable_check_status()->CopyFrom(checkStatus.get());
}
if (labels.isSome()) {
status.mutable_labels()->CopyFrom(labels.get());
}
if (containerStatus.isSome()) {
status.mutable_container_status()->CopyFrom(containerStatus.get());
}
if (unreachableTime.isSome()) {
status.mutable_unreachable_time()->CopyFrom(unreachableTime.get());
}
return status;
}
示例2: slaveTaskStatusDecorator
virtual Result<TaskStatus> slaveTaskStatusDecorator(
const FrameworkID& frameworkId,
const TaskStatus& status)
{
LOG(INFO) << "Executing 'slaveTaskStatusDecorator' hook";
Labels labels;
// Set one known label.
Label* newLabel = labels.add_labels();
newLabel->set_key("bar");
newLabel->set_value("qux");
// Remove label which was set by test.
foreach (const Label& oldLabel, status.labels().labels()) {
if (oldLabel.key() != "foo") {
labels.add_labels()->CopyFrom(oldLabel);
}
}
TaskStatus result;
result.mutable_labels()->CopyFrom(labels);
// Set an IP address, a network isolation group, and a known label
// in network info. This data is later validated by the
// 'HookTest.VerifySlaveTaskStatusDecorator' test.
NetworkInfo* networkInfo =
result.mutable_container_status()->add_network_infos();
// TODO(CD): Deprecated -- remove after 0.27.0.
networkInfo->set_ip_address("4.3.2.1");
NetworkInfo::IPAddress* ipAddress =
networkInfo->add_ip_addresses();
ipAddress->set_ip_address("4.3.2.1");
networkInfo->add_groups("public");
Label* networkInfoLabel = networkInfo->mutable_labels()->add_labels();
networkInfoLabel->set_key("net_foo");
networkInfoLabel->set_value("net_bar");
return result;
}
示例3: launchTask
void launchTask(ExecutorDriver* driver, const TaskInfo& task)
{
if (run.isSome()) {
// TODO(alexr): Use `protobuf::createTaskStatus()`
// instead of manually setting fields.
TaskStatus status;
status.mutable_task_id()->CopyFrom(task.task_id());
status.set_state(TASK_FAILED);
status.set_message(
"Attempted to run multiple tasks using a \"docker\" executor");
driver->sendStatusUpdate(status);
return;
}
// Capture the TaskID.
taskId = task.task_id();
// Capture the kill policy.
if (task.has_kill_policy()) {
killPolicy = task.kill_policy();
}
LOG(INFO) << "Starting task " << taskId.get();
CHECK(task.has_container());
CHECK(task.has_command());
CHECK(task.container().type() == ContainerInfo::DOCKER);
Try<Docker::RunOptions> runOptions = Docker::RunOptions::create(
task.container(),
task.command(),
containerName,
sandboxDirectory,
mappedDirectory,
task.resources() + task.executor().resources(),
cgroupsEnableCfs,
taskEnvironment,
None(), // No extra devices.
defaultContainerDNS
);
if (runOptions.isError()) {
// TODO(alexr): Use `protobuf::createTaskStatus()`
// instead of manually setting fields.
TaskStatus status;
status.mutable_task_id()->CopyFrom(task.task_id());
status.set_state(TASK_FAILED);
status.set_message(
"Failed to create docker run options: " + runOptions.error());
driver->sendStatusUpdate(status);
_stop();
return;
}
// We're adding task and executor resources to launch docker since
// the DockerContainerizer updates the container cgroup limits
// directly and it expects it to be the sum of both task and
// executor resources. This does leave to a bit of unaccounted
// resources for running this executor, but we are assuming
// this is just a very small amount of overcommit.
run = docker->run(
runOptions.get(),
Subprocess::FD(STDOUT_FILENO),
Subprocess::FD(STDERR_FILENO));
run->onAny(defer(self(), &Self::reaped, lambda::_1));
// Delay sending TASK_RUNNING status update until we receive
// inspect output. Note that we store a future that completes
// after the sending of the running update. This allows us to
// ensure that the terminal update is sent after the running
// update (see `reaped()`).
inspect = docker->inspect(containerName, DOCKER_INSPECT_DELAY)
.then(defer(self(), [=](const Docker::Container& container) {
if (!killed) {
containerPid = container.pid;
// TODO(alexr): Use `protobuf::createTaskStatus()`
// instead of manually setting fields.
TaskStatus status;
status.mutable_task_id()->CopyFrom(taskId.get());
status.set_state(TASK_RUNNING);
status.set_data(container.output);
if (container.ipAddress.isSome()) {
// TODO(karya): Deprecated -- Remove after 0.25.0 has shipped.
Label* label = status.mutable_labels()->add_labels();
label->set_key("Docker.NetworkSettings.IPAddress");
label->set_value(container.ipAddress.get());
NetworkInfo* networkInfo =
status.mutable_container_status()->add_network_infos();
// Copy the NetworkInfo if it is specified in the
// ContainerInfo. A Docker container has at most one
// NetworkInfo, which is validated in containerizer.
if (task.container().network_infos().size() > 0) {
//.........这里部分代码省略.........