本文整理汇总了C++中SlaveInfo::mutable_id方法的典型用法代码示例。如果您正苦于以下问题:C++ SlaveInfo::mutable_id方法的具体用法?C++ SlaveInfo::mutable_id怎么用?C++ SlaveInfo::mutable_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SlaveInfo
的用法示例。
在下文中一共展示了SlaveInfo::mutable_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registrar
TEST_P(Registrar_BENCHMARK_Test, performance)
{
Registrar registrar(flags, state);
AWAIT_READY(registrar.recover(master));
vector<SlaveInfo> infos;
Attributes attributes = Attributes::parse("foo:bar;baz:quux");
Resources resources =
Resources::parse("cpus(*):1.0;mem(*):512;disk(*):2048").get();
size_t slaveCount = GetParam();
// Create slaves.
for (size_t i = 0; i < slaveCount; ++i) {
// Simulate real slave information.
SlaveInfo info;
info.set_hostname("localhost");
info.mutable_id()->set_value(
std::string("201310101658-2280333834-5050-48574-") + stringify(i));
info.mutable_resources()->MergeFrom(resources);
info.mutable_attributes()->MergeFrom(attributes);
infos.push_back(info);
}
// Admit slaves.
Stopwatch watch;
watch.start();
Future<bool> result;
foreach (const SlaveInfo& info, infos) {
result = registrar.apply(Owned<Operation>(new AdmitSlave(info)));
}
示例2: 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);
}