本文整理汇总了C++中SlaveInfo类的典型用法代码示例。如果您正苦于以下问题:C++ SlaveInfo类的具体用法?C++ SlaveInfo怎么用?C++ SlaveInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SlaveInfo类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_P
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: devolve
SlaveInfo devolve(const v1::AgentInfo& agentInfo)
{
SlaveInfo info = devolve<SlaveInfo>(agentInfo);
// We set 'checkpoint' to 'true' since the v1::AgentInfo doesn't
// have 'checkpoint' but all "agents" were checkpointing by default
// when v1::AgentInfo was introduced. See MESOS-2317.
info.set_checkpoint(true);
return info;
}
示例3: registered
virtual void registered(ExecutorDriver* driver,
const ExecutorInfo& executorInfo,
const FrameworkInfo& frameworkInfo,
const SlaveInfo& slaveInfo)
{
cout << "Registered executor on " << slaveInfo.hostname() << endl;
}
示例4: masterSlaveLostHook
virtual Try<Nothing> masterSlaveLostHook(const SlaveInfo& slaveInfo)
{
LOG(INFO) << "Executing 'masterSlaveLostHook' in agent '"
<< slaveInfo.id() << "'";
// TODO(nnielsen): Add argument to signal(), so we can filter messages from
// the `masterSlaveLostHook` from `slaveRemoveExecutorHook`.
// NOTE: Will not be a problem **as long as** the test doesn't start any
// tasks.
HookProcess hookProcess;
process::spawn(&hookProcess);
Future<Nothing> future =
process::dispatch(hookProcess, &HookProcess::await);
process::dispatch(hookProcess, &HookProcess::signal);
// Make sure we don't terminate the process before the message self-send has
// completed.
future.await();
process::terminate(hookProcess);
process::wait(hookProcess);
return Nothing();
}
示例5: registered
void registered (ExecutorDriver* driver,
const ExecutorInfo& executorInfo,
const FrameworkInfo& frameworkInfo,
const SlaveInfo& slaveInfo) override {
_executorId = executorInfo.executor_id().value();
cout
<< "Registered executor " << _executorId << " on "
<< slaveInfo.hostname()
<< endl;
string data;
slaveInfo.SerializeToString(&data);
driver->sendFrameworkMessage(data);
}
示例6: registered
virtual void registered(ExecutorDriver* driver,
const ExecutorInfo& executorInfo,
const FrameworkInfo& frameworkInfo,
const SlaveInfo& slaveInfo)
{
host_name= slaveInfo.hostname();
localPeerCount = 0;
totalPeerCount = 0;
}
示例7: slaveAttributesDecorator
virtual Result<Attributes> slaveAttributesDecorator(
const SlaveInfo& slaveInfo)
{
LOG(INFO) << "Executing 'slaveAttributesDecorator' hook";
Attributes attributes = slaveInfo.attributes();
attributes.add(Attributes::parse("rack", "rack1"));
return attributes;
}
示例8: registered
void CephExecutor::registered(
ExecutorDriver* driver,
const ExecutorInfo& executorInfo,
const FrameworkInfo& frameworkInfo,
const SlaveInfo& slaveInfo)
{
//set class member myHostname
myHostname = slaveInfo.hostname();
LOG(INFO) << "Registered executor on " << myHostname;
//sandboxAbsolutePath
char temp[4096];
sandboxAbsolutePath = getcwd(temp, 4096) ? string(temp) : std::string("");
LOG(INFO) << "sandbox absolute path: " << sandboxAbsolutePath;
}
示例9: TEST_F
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);
}
示例10: convert
jobject convert(JNIEnv* env, const SlaveInfo& slaveInfo)
{
string data;
slaveInfo.SerializeToString(&data);
// byte[] data = ..;
jbyteArray jdata = env->NewByteArray(data.size());
env->SetByteArrayRegion(jdata, 0, data.size(), (jbyte*) data.data());
// SlaveInfo slaveInfo = SlaveInfo.parseFrom(data);
jclass clazz = FindMesosClass(env, "org/apache/mesos/Protos$SlaveInfo");
jmethodID parseFrom =
env->GetStaticMethodID(clazz, "parseFrom",
"([B)Lorg/apache/mesos/Protos$SlaveInfo;");
jobject jslaveInfo = env->CallStaticObjectMethod(clazz, parseFrom, jdata);
return jslaveInfo;
}
示例11: slaveResourcesDecorator
virtual Result<Resources> slaveResourcesDecorator(
const SlaveInfo& slaveInfo)
{
LOG(INFO) << "Executing 'slaveResourcesDecorator' hook";
Resources resources;
// Remove the existing "cpus" resource, it will be overwritten by the
// current hook. Keep other resources unchanged.
foreach (const Resource& resource, slaveInfo.resources()) {
if (resource.name() != "cpus") {
resources += resource;
}
}
// Force the value of "cpus" to 4 and add a new custom resource named "foo"
// of type set.
resources += Resources::parse("cpus:4;foo:{bar,baz}").get();
return resources;
}
示例12: Resources
bool operator == (const SlaveInfo& left, const SlaveInfo& right)
{
return left.hostname() == right.hostname() &&
Resources(left.resources()) == Resources(right.resources()) &&
internal::Attributes(left.attributes()) ==
internal::Attributes(right.attributes()) &&
left.id() == right.id() &&
left.checkpoint() == right.checkpoint() &&
left.port() == right.port();
}
示例13: Resources
inline bool operator == (const SlaveInfo& left, const SlaveInfo& right)
{
return left.hostname() == right.hostname() &&
left.webui_hostname() == right.webui_hostname() &&
Resources(left.resources()) == Resources(right.resources()) &&
internal::Attributes(left.attributes()) ==
internal::Attributes(right.attributes()) &&
left.has_webui_port() == right.has_webui_port() &&
(!left.has_webui_port() || (left.webui_port() == right.webui_port())) &&
left.has_id() == right.has_id() &&
(!left.has_id() || (left.id() == right.id())) &&
left.has_checkpoint() == right.has_checkpoint() &&
(!left.has_checkpoint() || (left.checkpoint() == right.checkpoint()));
}
示例14: reregistered
virtual void reregistered(ExecutorDriver* driver,
const SlaveInfo& slaveInfo)
{
cout << "Re-registered executor on " << slaveInfo.hostname() << endl;
}