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


C++ SlaveID::set_value方法代码示例

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


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

示例1:

// We aggregate resources from multiple slaves into the sorter.
// Since non-scalar resources don't aggregate well across slaves,
// we need to keep track of the SlaveIDs of the resources. This
// tests that no resources vanish in the process of aggregation
// by inspecting the result of 'allocation'.
TEST(SorterTest, MultipleSlaves)
{
  DRFSorter sorter;

  SlaveID slaveA;
  slaveA.set_value("agentA");

  SlaveID slaveB;
  slaveB.set_value("agentB");

  sorter.add("framework");

  Resources slaveResources =
    Resources::parse("cpus:2;mem:512;ports:[31000-32000]").get();

  sorter.add(slaveA, slaveResources);
  sorter.add(slaveB, slaveResources);

  sorter.allocated("framework", slaveA, slaveResources);
  sorter.allocated("framework", slaveB, slaveResources);

  EXPECT_EQ(2u, sorter.allocation("framework").size());
  EXPECT_EQ(slaveResources, sorter.allocation("framework", slaveA));
  EXPECT_EQ(slaveResources, sorter.allocation("framework", slaveB));
}
开发者ID:EronWright,项目名称:mesos,代码行数:30,代码来源:sorter_tests.cpp

示例2: devolve

SlaveID devolve(const v1::AgentID& agentId)
{
  // NOTE: Not using 'devolve<v1::AgentID, SlaveID>(agentId)' since
  // this will be a common 'devolve' call and we wanted to speed up
  // performance.

  SlaveID id;
  id.set_value(agentId.value());
  return id;
}
开发者ID:AbheekG,项目名称:mesos,代码行数:10,代码来源:devolve.cpp

示例3: driver

// Ensures that the driver can handle the FAILURE event.
TEST_F(SchedulerDriverEventTest, Failure)
{
    Try<Owned<cluster::Master>> master = StartMaster();
    ASSERT_SOME(master);

    MockScheduler sched;
    MesosSchedulerDriver driver(
        &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);

    EXPECT_CALL(sched, registered(&driver, _, _));

    Future<Message> frameworkRegisteredMessage =
        FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);

    driver.start();

    AWAIT_READY(frameworkRegisteredMessage);
    UPID frameworkPid = frameworkRegisteredMessage.get().to;

    // Send a failure for an executor, which should trigger executorLost callback.
    SlaveID slaveId;
    slaveId.set_value("S");

    ExecutorID executorId = DEFAULT_EXECUTOR_ID;

    const int32_t status = 255;

    Event event;
    event.set_type(Event::FAILURE);
    event.mutable_failure()->mutable_slave_id()->CopyFrom(slaveId);
    event.mutable_failure()->mutable_executor_id()->CopyFrom(executorId);
    event.mutable_failure()->set_status(status);

    Future<Nothing> executorLost;
    EXPECT_CALL(sched, executorLost(&driver, executorId, slaveId, status))
    .WillOnce(FutureSatisfy(&executorLost));

    process::post(master.get()->pid, frameworkPid, event);

    AWAIT_READY(executorLost);

    // Now, post a failure for a slave and expect a 'slaveLost'.
    event.mutable_failure()->clear_executor_id();

    Future<Nothing> slaveLost;
    EXPECT_CALL(sched, slaveLost(&driver, slaveId))
    .WillOnce(FutureSatisfy(&slaveLost));

    process::post(master.get()->pid, frameworkPid, event);

    AWAIT_READY(slaveLost);

    driver.stop();
    driver.join();
}
开发者ID:kaysoky,项目名称:mesos,代码行数:56,代码来源:scheduler_event_call_tests.cpp

示例4: createTask

TEST(TypeUtilsTest, TaskGroupEquality)
{
  SlaveID slaveId;
  slaveId.set_value("default-agent");

  Resources resources = Resources::parse("cpus:0.1;mem:32;disk:32").get();

  TaskInfo task1 =
    createTask(slaveId, resources, "default-command1");

  TaskInfo task2 =
    createTask(slaveId, resources, "default-command2");

  // Compare task groups with identical tasks.
  {
    TaskGroupInfo taskGroup1;
    taskGroup1.add_tasks()->CopyFrom(task1);
    taskGroup1.add_tasks()->CopyFrom(task2);

    TaskGroupInfo taskGroup2;
    taskGroup2.add_tasks()->CopyFrom(task1);
    taskGroup2.add_tasks()->CopyFrom(task2);

    EXPECT_EQ(taskGroup1, taskGroup2);
  }

  // Compare task groups with identical tasks but ordered differently.
  {
    TaskGroupInfo taskGroup1;
    taskGroup1.add_tasks()->CopyFrom(task1);
    taskGroup1.add_tasks()->CopyFrom(task2);

    TaskGroupInfo taskGroup2;
    taskGroup2.add_tasks()->CopyFrom(task2);
    taskGroup2.add_tasks()->CopyFrom(task1);

    EXPECT_EQ(taskGroup1, taskGroup2);
  }

  // Compare task groups with unequal tasks.
  {
    TaskGroupInfo taskGroup1;
    taskGroup1.add_tasks()->CopyFrom(task1);
    taskGroup1.add_tasks()->CopyFrom(task2);

    TaskGroupInfo taskGroup2;
    taskGroup2.add_tasks()->CopyFrom(task1);

    EXPECT_FALSE(taskGroup1 == taskGroup2);
  }
}
开发者ID:ChrisPaprocki,项目名称:mesos,代码行数:51,代码来源:type_utils_tests.cpp

示例5: tie

// This test measures the performance of the `master::call::GetState`
// v1 api (and also measures master v0 '/state' endpoint as the
// baseline). We set up a lot of master state from artificial agents
// similar to the master failover benchmark.
TEST_P(MasterStateQuery_BENCHMARK_Test, GetState)
{
  size_t agentCount;
  size_t frameworksPerAgent;
  size_t tasksPerFramework;
  size_t completedFrameworksPerAgent;
  size_t tasksPerCompletedFramework;

  tie(agentCount,
    frameworksPerAgent,
    tasksPerFramework,
    completedFrameworksPerAgent,
    tasksPerCompletedFramework) = GetParam();

  // Disable authentication to avoid the overhead, since we don't care about
  // it in this test.
  master::Flags masterFlags = CreateMasterFlags();
  masterFlags.authenticate_agents = false;

  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  vector<Owned<TestSlave>> slaves;

  for (size_t i = 0; i < agentCount; i++) {
    SlaveID slaveId;
    slaveId.set_value("agent" + stringify(i));

    slaves.push_back(Owned<TestSlave>(new TestSlave(
        master.get()->pid,
        slaveId,
        frameworksPerAgent,
        tasksPerFramework,
        completedFrameworksPerAgent,
        tasksPerCompletedFramework)));
  }

  cout << "Test setup: "
       << agentCount << " agents with a total of "
       << frameworksPerAgent * tasksPerFramework * agentCount
       << " running tasks and "
       << completedFrameworksPerAgent * tasksPerCompletedFramework * agentCount
       << " completed tasks" << endl;

  list<Future<Nothing>> reregistered;

  foreach (const Owned<TestSlave>& slave, slaves) {
    reregistered.push_back(slave->reregister());
  }
开发者ID:ederst,项目名称:mesos,代码行数:53,代码来源:master_benchmarks.cpp

示例6: driver

// Ensures that the driver can handle the FAILURE event.
TEST_F(SchedulerDriverEventTest, Failure)
{
  Try<PID<Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<Message> frameworkRegisteredMessage =
    FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);

  driver.start();

  AWAIT_READY(frameworkRegisteredMessage);
  UPID frameworkPid = frameworkRegisteredMessage.get().to;

  // Send a failure for an executor, this should be dropped
  // to match the existing behavior of the scheduler driver.
  SlaveID slaveId;
  slaveId.set_value("S");

  Event event;
  event.set_type(Event::FAILURE);
  event.mutable_failure()->mutable_slave_id()->CopyFrom(slaveId);
  event.mutable_failure()->mutable_executor_id()->set_value("E");

  process::post(master.get(), frameworkPid, event);

  // Now, post a failure for a slave and expect a 'slaveLost'.
  event.mutable_failure()->clear_executor_id();

  Future<Nothing> slaveLost;
  EXPECT_CALL(sched, slaveLost(&driver, slaveId))
    .WillOnce(FutureSatisfy(&slaveLost));

  process::post(master.get(), frameworkPid, event);

  AWAIT_READY(slaveLost);
}
开发者ID:lodejard,项目名称:mesos,代码行数:43,代码来源:scheduler_event_call_tests.cpp

示例7: registrar

TEST_F(RegistrarTest, recover)
{
  Registrar registrar(state);

  SlaveInfo slave;
  slave.set_hostname("localhost");
  SlaveID id;
  id.set_value("1");
  slave.mutable_id()->CopyFrom(id);

  // Operations preceding recovery will fail.
  AWAIT_EXPECT_FAILED(registrar.admit(slave));
  AWAIT_EXPECT_FAILED(registrar.readmit(slave));
  AWAIT_EXPECT_FAILED(registrar.remove(slave));

  MasterInfo info;
  info.set_id("foobar");
  info.set_ip(0);
  info.set_port(5050);
  info.set_pid("0:5050");

  Future<Registry> registry = registrar.recover(info);

  // Before waiting for the recovery to complete, invoke some
  // operations to ensure they do not fail.
  Future<bool> admit = registrar.admit(slave);
  Future<bool> readmit = registrar.readmit(slave);
  Future<bool> remove = registrar.remove(slave);

  AWAIT_READY(registry);
  EXPECT_EQ(info, registry.get().master().info());

  AWAIT_EQ(true, admit);
  AWAIT_EQ(true, readmit);
  AWAIT_EQ(true, remove);
}
开发者ID:tedyoung,项目名称:mesos,代码行数:36,代码来源:registrar_tests.cpp

示例8: driver

// Ensures the scheduler driver can handle the UPDATE event.
TEST_F(SchedulerDriverEventTest, Update)
{
  Try<PID<Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<Message> frameworkRegisteredMessage =
    FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);

  driver.start();

  AWAIT_READY(frameworkRegisteredMessage);
  UPID frameworkPid = frameworkRegisteredMessage.get().to;

  FrameworkRegisteredMessage message;
  ASSERT_TRUE(message.ParseFromString(frameworkRegisteredMessage.get().body));

  FrameworkID frameworkId = message.framework_id();

  SlaveID slaveId;
  slaveId.set_value("S");

  TaskID taskId;
  taskId.set_value("T");

  ExecutorID executorId;
  executorId.set_value("E");

  // Generate an update that needs no acknowledgement.
  Event event;
  event.set_type(Event::UPDATE);
  event.mutable_update()->mutable_status()->CopyFrom(
      protobuf::createStatusUpdate(
          frameworkId,
          slaveId,
          taskId,
          TASK_RUNNING,
          TaskStatus::SOURCE_MASTER,
          None(),
          "message",
          None(),
          executorId).status());

  Future<Nothing> statusUpdate;
  Future<Nothing> statusUpdate2;
  EXPECT_CALL(sched, statusUpdate(&driver, event.update().status()))
    .WillOnce(FutureSatisfy(&statusUpdate))
    .WillOnce(FutureSatisfy(&statusUpdate2));

  process::post(master.get(), frameworkPid, event);

  AWAIT_READY(statusUpdate);

  // Generate an update that requires acknowledgement.
  event.mutable_update()->mutable_status()->set_uuid(UUID::random().toBytes());

  Future<mesos::scheduler::Call> acknowledgement = DROP_CALL(
      mesos::scheduler::Call(), mesos::scheduler::Call::ACKNOWLEDGE, _, _);

  process::post(master.get(), frameworkPid, event);

  AWAIT_READY(statusUpdate2);
  AWAIT_READY(acknowledgement);
}
开发者ID:Parshuramsk,项目名称:mesos,代码行数:70,代码来源:scheduler_event_call_tests.cpp

示例9: LOG

void CephSchedulerAgent<T>::resourceOffers(
      T* driver,
      const vector<Offer>& offers)
{
  LOG(INFO) << "Received " << offers.size() << " offers! ";
  TaskType taskType;
  int token;
  int isInitialMonNode = 0;
  //handle waiting OSD task, give them osdID to start docker
  handleWaitingOSDTasks(driver);
  Phase currentPhase = stateMachine->getCurrentPhase();
  //try start new node
  foreach (const Offer& offer, offers) {
    //check offer with the correct role
    LOG(INFO) << "Hostname: " << offer.hostname();
    if (!hasRole(offer, config->role)) {
      LOG(INFO) << "Decline this offer. Host " << offer.hostname() << " don't have correct role:"
          << config->role;
      Filters refuse;
      refuse.set_refuse_seconds(86400.0);
      driver->declineOffer(offer.id(),refuse);
      continue;
    }
    //reload or new hostconfig
    stateMachine->addConfig(offer.hostname());
    tryLaunchDiskTask(driver, offer, offer.hostname());
    bool accept = stateMachine->nextMove(taskType,token,offer.hostname());
    if (!accept) {
      LOG(INFO) << "In the "
          << static_cast<int>(currentPhase)
          << " Staging Phase, cannot accept offer from "
          << offer.hostname()
          << " in this phase";
      driver->declineOffer(offer.id());
      continue;
    }
    LOG(INFO) << "Check offer's resources from " <<offer.hostname();
    if (offerNotEnoughResources(offer,taskType)) {
      LOG(INFO) << "Not enough, decline it from " << offer.hostname();
      driver->declineOffer(offer.id());
      continue;
    }
    if (currentPhase == Phase::WAINTING_REQUEST){
      accept = fetchPendingRESTfulRequest();
      if (!accept){
        LOG(INFO) << "No pending OSD RESTful request.";
        driver->declineOffer(offer.id());
        stateMachine->decreaseOSDIndex();
        continue;
      }
    }

    LOG(INFO) << "Accepted offer from" << offer.hostname() << ", launch "
        << static_cast<int>(taskType) <<":" << token << " node";
    if (taskType == TaskType::MON && token == 0) {
        LOG(INFO) << "This is the initial MON";
        isInitialMonNode = 1;
    }
    string taskId;
    string executorId;
    launchNode(
        driver,
        offer,
        taskType,
        token,
        isInitialMonNode,
        taskId,
        executorId);
    stateMachine->addStagingTask(
        taskId,
        executorId,
        taskType,
        offer.hostname(),
        offer.slave_id().value());
    if (!isInitialMonNode && taskType == TaskType::OSD) {
      ceph::TaskState initialMon = stateMachine->getInitialMon();
      const string m = lexical_cast<string>(static_cast<int>(MessageToExecutor::REGISTER_OSD));
      ExecutorID eId;
      eId.set_value(initialMon.executorId);
      SlaveID sId;
      sId.set_value(initialMon.slaveId);
      driver->sendFrameworkMessage(
          eId,
          sId,
          m);
    }//end if

  }//end foreach
开发者ID:nqn,项目名称:ceph-mesos,代码行数:88,代码来源:CephSchedulerAgent.hpp

示例10: model

// This test ensures we don't break the API when it comes to JSON
// representation of tasks. Also, we want to ensure that tasks are
// modeled the same way when using 'Task' vs. 'TaskInfo'.
TEST(HTTP, ModelTask)
{
  TaskID taskId;
  taskId.set_value("t");

  SlaveID slaveId;
  slaveId.set_value("s");

  ExecutorID executorId;
  executorId.set_value("t");

  FrameworkID frameworkId;
  frameworkId.set_value("f");

  TaskState state = TASK_RUNNING;

  vector<TaskStatus> statuses;

  TaskStatus status;
  status.mutable_task_id()->CopyFrom(taskId);
  status.set_state(state);
  status.mutable_slave_id()->CopyFrom(slaveId);
  status.mutable_executor_id()->CopyFrom(executorId);
  status.set_timestamp(0.0);

  statuses.push_back(status);

  TaskInfo task;
  task.set_name("task");
  task.mutable_task_id()->CopyFrom(taskId);
  task.mutable_slave_id()->CopyFrom(slaveId);
  task.mutable_command()->set_value("echo hello");

  Task task_ = protobuf::createTask(task, state, frameworkId);
  task_.add_statuses()->CopyFrom(statuses[0]);

  JSON::Value object = model(task, frameworkId, state, statuses);
  JSON::Value object_ = model(task_);

  Try<JSON::Value> expected = JSON::parse(
      "{"
      "  \"executor_id\":\"\","
      "  \"framework_id\":\"f\","
      "  \"id\":\"t\","
      "  \"name\":\"task\","
      "  \"resources\":"
      "  {"
      "    \"cpus\":0,"
      "    \"disk\":0,"
      "    \"mem\":0"
      "  },"
      "  \"slave_id\":\"s\","
      "  \"state\":\"TASK_RUNNING\","
      "  \"statuses\":"
      "  ["
      "    {"
      "      \"state\":\"TASK_RUNNING\","
      "      \"timestamp\":0"
      "    }"
      "  ]"
      "}");

  ASSERT_SOME(expected);

  EXPECT_EQ(expected.get(), object);
  EXPECT_EQ(expected.get(), object_);

  // Ensure both are modeled the same.
  EXPECT_EQ(object, object_);
}
开发者ID:HaiyangWang,项目名称:mesos,代码行数:73,代码来源:http_tests.cpp

示例11: createTask

// This test ensures we don't break the API when it comes to JSON
// representation of tasks.
TEST(HTTPTest, ModelTask)
{
  TaskID taskId;
  taskId.set_value("t");

  SlaveID slaveId;
  slaveId.set_value("s");

  ExecutorID executorId;
  executorId.set_value("t");

  FrameworkID frameworkId;
  frameworkId.set_value("f");

  TaskState state = TASK_RUNNING;

  vector<TaskStatus> statuses;

  TaskStatus status;
  status.mutable_task_id()->CopyFrom(taskId);
  status.set_state(state);
  status.mutable_slave_id()->CopyFrom(slaveId);
  status.mutable_executor_id()->CopyFrom(executorId);
  status.set_timestamp(0.0);

  statuses.push_back(status);

  Labels labels;
  labels.add_labels()->CopyFrom(createLabel("ACTION", "port:7987 DENY"));

  Ports ports;
  Port* port = ports.add_ports();
  port->set_number(80);
  port->mutable_labels()->CopyFrom(labels);

  DiscoveryInfo discovery;
  discovery.set_visibility(DiscoveryInfo::CLUSTER);
  discovery.set_name("discover");
  discovery.mutable_ports()->CopyFrom(ports);

  TaskInfo taskInfo;
  taskInfo.set_name("task");
  taskInfo.mutable_task_id()->CopyFrom(taskId);
  taskInfo.mutable_slave_id()->CopyFrom(slaveId);
  taskInfo.mutable_command()->set_value("echo hello");
  taskInfo.mutable_discovery()->CopyFrom(discovery);

  Task task = createTask(taskInfo, state, frameworkId);
  task.add_statuses()->CopyFrom(statuses[0]);

  JSON::Value object = model(task);

  Try<JSON::Value> expected = JSON::parse(
      "{"
      "  \"executor_id\":\"\","
      "  \"framework_id\":\"f\","
      "  \"id\":\"t\","
      "  \"name\":\"task\","
      "  \"resources\":"
      "  {"
      "    \"cpus\":0,"
      "    \"disk\":0,"
      "    \"gpus\":0,"
      "    \"mem\":0"
      "  },"
      "  \"slave_id\":\"s\","
      "  \"state\":\"TASK_RUNNING\","
      "  \"statuses\":"
      "  ["
      "    {"
      "      \"state\":\"TASK_RUNNING\","
      "      \"timestamp\":0"
      "    }"
      "  ],"
      " \"discovery\":"
      " {"
      "   \"name\":\"discover\","
      "   \"ports\":"
      "   {"
      "     \"ports\":"
      "     ["
      "       {"
      "         \"number\":80,"
      "         \"labels\":"
      "         {"
      "           \"labels\":"
      "           ["
      "             {"
      "              \"key\":\"ACTION\","
      "              \"value\":\"port:7987 DENY\""
      "             }"
      "           ]"
      "         }"
      "       }"
      "     ]"
      "   },"
      "   \"visibility\":\"CLUSTER\""
      " }"
//.........这里部分代码省略.........
开发者ID:AbheekG,项目名称:mesos,代码行数:101,代码来源:http_tests.cpp


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