本文整理汇总了C++中Future::has_response方法的典型用法代码示例。如果您正苦于以下问题:C++ Future::has_response方法的具体用法?C++ Future::has_response怎么用?C++ Future::has_response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Future
的用法示例。
在下文中一共展示了Future::has_response方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mesos
// This test verifies that reconciliation of an unknown operation that belongs
// to an unknown agent results in `OPERATION_UNKNOWN`.
TEST_P(OperationReconciliationTest, UnknownOperationUnknownAgent)
{
Clock::pause();
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
auto scheduler = std::make_shared<MockHTTPScheduler>();
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(scheduler::SendSubscribe(DEFAULT_FRAMEWORK_INFO));
Future<scheduler::Event::Subscribed> subscribed;
EXPECT_CALL(*scheduler, subscribed(_, _))
.WillOnce(FutureArg<1>(&subscribed));
// Ignore heartbeats.
EXPECT_CALL(*scheduler, heartbeat(_))
.WillRepeatedly(Return());
// Decline all offers.
EXPECT_CALL(*scheduler, offers(_, _))
.WillRepeatedly(scheduler::DeclineOffers());
scheduler::TestMesos mesos(master.get()->pid, GetParam(), scheduler);
AWAIT_READY(subscribed);
FrameworkID frameworkId(subscribed->framework_id());
AgentID agentId;
agentId.set_value("agent");
OperationID operationId;
operationId.set_value("operation");
scheduler::Call::ReconcileOperations::Operation operation;
operation.mutable_operation_id()->CopyFrom(operationId);
operation.mutable_agent_id()->CopyFrom(agentId);
const Future<scheduler::APIResult> result =
mesos.call({createCallReconcileOperations(frameworkId, {operation})});
AWAIT_READY(result);
// The master should respond with '200 OK' and with a `scheduler::Response`.
ASSERT_EQ(process::http::Status::OK, result->status_code());
ASSERT_TRUE(result->has_response());
const scheduler::Response response = result->response();
ASSERT_EQ(scheduler::Response::RECONCILE_OPERATIONS, response.type());
ASSERT_TRUE(response.has_reconcile_operations());
const scheduler::Response::ReconcileOperations& reconcile =
response.reconcile_operations();
ASSERT_EQ(1, reconcile.operation_statuses_size());
const OperationStatus& operationStatus = reconcile.operation_statuses(0);
EXPECT_EQ(operationId, operationStatus.operation_id());
EXPECT_EQ(OPERATION_UNKNOWN, operationStatus.state());
EXPECT_FALSE(operationStatus.has_uuid());
}
示例2: MockResourceProvider
//.........这里部分代码省略.........
None(),
operationId)}));
AWAIT_READY(applyOperation);
// Simulate master failover.
EXPECT_CALL(*scheduler, disconnected(_));
detector->appoint(None());
master->reset();
master = StartMaster();
ASSERT_SOME(master);
// Settle the clock to ensure the master finishes recovering the registry.
Clock::settle();
Future<SlaveReregisteredMessage> slaveReregistered = FUTURE_PROTOBUF(
SlaveReregisteredMessage(), master.get()->pid, slave.get()->pid);
updateSlaveMessage = FUTURE_PROTOBUF(UpdateSlaveMessage(), _, _);
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(scheduler::SendSubscribe(frameworkInfo, frameworkId));
Future<scheduler::Event::Subscribed> frameworkResubscribed;
EXPECT_CALL(*scheduler, subscribed(_, _))
.WillOnce(FutureArg<1>(&frameworkResubscribed));
// Simulate a new master detected event to the agent and the scheduler.
detector->appoint(master.get()->pid);
// Advance the clock, so that the agent re-registers.
Clock::advance(slaveFlags.registration_backoff_factor);
// Resume the clock to avoid deadlocks related to agent registration.
// See MESOS-8828.
Clock::resume();
// Wait for the framework and agent to re-register.
AWAIT_READY(slaveReregistered);
AWAIT_READY(updateSlaveMessage);
AWAIT_READY(frameworkResubscribed);
Clock::pause();
// Test explicit reconciliation
{
scheduler::Call::ReconcileOperations::Operation operation;
operation.mutable_operation_id()->CopyFrom(operationId);
operation.mutable_agent_id()->CopyFrom(agentId);
const Future<scheduler::APIResult> result =
mesos.call({createCallReconcileOperations(frameworkId, {operation})});
AWAIT_READY(result);
// The master should respond with '200 OK' and with a `scheduler::Response`.
ASSERT_EQ(process::http::Status::OK, result->status_code());
ASSERT_TRUE(result->has_response());
const scheduler::Response response = result->response();
ASSERT_EQ(scheduler::Response::RECONCILE_OPERATIONS, response.type());
ASSERT_TRUE(response.has_reconcile_operations());
const scheduler::Response::ReconcileOperations& reconcile =
response.reconcile_operations();
ASSERT_EQ(1, reconcile.operation_statuses_size());
const OperationStatus& operationStatus = reconcile.operation_statuses(0);
EXPECT_EQ(operationId, operationStatus.operation_id());
EXPECT_EQ(OPERATION_PENDING, operationStatus.state());
EXPECT_FALSE(operationStatus.has_uuid());
}
// Test implicit reconciliation
{
const Future<scheduler::APIResult> result =
mesos.call({createCallReconcileOperations(frameworkId, {})});
AWAIT_READY(result);
// The master should respond with '200 OK' and with a `scheduler::Response`.
ASSERT_EQ(process::http::Status::OK, result->status_code());
ASSERT_TRUE(result->has_response());
const scheduler::Response response = result->response();
ASSERT_EQ(scheduler::Response::RECONCILE_OPERATIONS, response.type());
ASSERT_TRUE(response.has_reconcile_operations());
const scheduler::Response::ReconcileOperations& reconcile =
response.reconcile_operations();
ASSERT_EQ(1, reconcile.operation_statuses_size());
const OperationStatus& operationStatus = reconcile.operation_statuses(0);
EXPECT_EQ(operationId, operationStatus.operation_id());
EXPECT_EQ(OPERATION_PENDING, operationStatus.state());
EXPECT_FALSE(operationStatus.has_uuid());
}
}