当前位置: 首页>>代码示例>>C++>>正文


C++ TaskInfo::labels方法代码示例

本文整理汇总了C++中TaskInfo::labels方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskInfo::labels方法的具体用法?C++ TaskInfo::labels怎么用?C++ TaskInfo::labels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskInfo的用法示例。


在下文中一共展示了TaskInfo::labels方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: slaveLaunchExecutorEnvironmentDecorator

  // In this hook, we create a temporary file and add its path to an
  // environment variable.  Later on, this environment variable is
  // looked up by the removeExecutorHook to locate and delete this
  // file.
  virtual Result<Environment> slaveLaunchExecutorEnvironmentDecorator(
      const ExecutorInfo& executorInfo,
      const TaskInfo& taskInfo)
  {
    LOG(INFO) << "Executing 'slaveLaunchExecutorEnvironmentDecorator' hook";

    // Find the label value for the label that was created in the
    // label decorator hook above.
    Option<string> labelValue;
    foreach (const Label& label, taskInfo.labels().labels()) {
      if (label.key() == testLabelKey) {
        labelValue = label.value();
        CHECK_EQ(labelValue.get(), testLabelValue);
      }
    }
    CHECK_SOME(labelValue);

    // Create a temporary file.
    Try<string> file = os::mktemp();
    CHECK_SOME(file);
    CHECK_SOME(os::write(file.get(), labelValue.get()));

    // Inject file path into command environment.
    Environment environment;
    Environment::Variable* variable = environment.add_variables();
    variable->set_name(testEnvironmentVariableName);
    variable->set_value(file.get());

    return environment;
  }
开发者ID:abhishekamralkar,项目名称:mesos,代码行数:34,代码来源:test_hook_module.cpp

示例2: createTask

Task createTask(
    const TaskInfo& task,
    const TaskState& state,
    const FrameworkID& frameworkId)
{
  Task t;
  t.mutable_framework_id()->MergeFrom(frameworkId);
  t.set_state(state);
  t.set_name(task.name());
  t.mutable_task_id()->MergeFrom(task.task_id());
  t.mutable_slave_id()->MergeFrom(task.slave_id());
  t.mutable_resources()->MergeFrom(task.resources());

  if (task.has_executor()) {
    t.mutable_executor_id()->CopyFrom(task.executor().executor_id());
  }

  t.mutable_labels()->MergeFrom(task.labels());

  if (task.has_discovery()) {
    t.mutable_discovery()->MergeFrom(task.discovery());
  }

  return t;
}
开发者ID:abhishekamralkar,项目名称:mesos,代码行数:25,代码来源:protobuf_utils.cpp

示例3: createTask

Task createTask(
    const TaskInfo& task,
    const TaskState& state,
    const FrameworkID& frameworkId)
{
  Task t;
  t.mutable_framework_id()->CopyFrom(frameworkId);
  t.set_state(state);
  t.set_name(task.name());
  t.mutable_task_id()->CopyFrom(task.task_id());
  t.mutable_slave_id()->CopyFrom(task.slave_id());
  t.mutable_resources()->CopyFrom(task.resources());

  if (task.has_executor()) {
    t.mutable_executor_id()->CopyFrom(task.executor().executor_id());
  }

  if (task.has_labels()) {
    t.mutable_labels()->CopyFrom(task.labels());
  }

  if (task.has_discovery()) {
    t.mutable_discovery()->CopyFrom(task.discovery());
  }

  if (task.has_container()) {
    t.mutable_container()->CopyFrom(task.container());
  }

  // Copy `user` if set.
  if (task.has_command() && task.command().has_user()) {
    t.set_user(task.command().user());
  } else if (task.has_executor() && task.executor().command().has_user()) {
    t.set_user(task.executor().command().user());
  }

  return t;
}
开发者ID:OvertimeDog,项目名称:mesos,代码行数:38,代码来源:protobuf_utils.cpp

示例4: masterLaunchTaskLabelDecorator

  virtual Result<Labels> masterLaunchTaskLabelDecorator(
      const TaskInfo& taskInfo,
      const FrameworkInfo& frameworkInfo,
      const SlaveInfo& slaveInfo)
  {
    LOG(INFO) << "Executing 'masterLaunchTaskLabelDecorator' hook";

    Labels labels;

    // Set one known label.
    Label* newLabel = labels.add_labels();
    newLabel->set_key(testLabelKey);
    newLabel->set_value(testLabelValue);

    // Remove the 'testRemoveLabelKey' label which was set by the test.
    foreach (const Label& oldLabel, taskInfo.labels().labels()) {
      if (oldLabel.key() != testRemoveLabelKey) {
        labels.add_labels()->CopyFrom(oldLabel);
      }
    }

    return labels;
  }
开发者ID:AbheekG,项目名称:mesos,代码行数:23,代码来源:test_hook_module.cpp

示例5: slaveRunTaskLabelDecorator

  // TODO(nnielsen): Split hook tests into multiple modules to avoid
  // interference.
  virtual Result<Labels> slaveRunTaskLabelDecorator(
      const TaskInfo& taskInfo,
      const ExecutorInfo& executorInfo,
      const FrameworkInfo& frameworkInfo,
      const SlaveInfo& slaveInfo)
  {
    LOG(INFO) << "Executing 'slaveRunTaskLabelDecorator' hook";

    Labels labels;

    // Set one known label.
    Label* newLabel = labels.add_labels();
    newLabel->set_key("baz");
    newLabel->set_value("qux");

    // Remove label which was set by test.
    foreach (const Label& oldLabel, taskInfo.labels().labels()) {
      if (oldLabel.key() != "foo") {
        labels.add_labels()->CopyFrom(oldLabel);
      }
    }

    return labels;
  }
开发者ID:AbheekG,项目名称:mesos,代码行数:26,代码来源:test_hook_module.cpp


注:本文中的TaskInfo::labels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。