本文整理汇总了C++中ExecutorInfo::set_name方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutorInfo::set_name方法的具体用法?C++ ExecutorInfo::set_name怎么用?C++ ExecutorInfo::set_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutorInfo
的用法示例。
在下文中一共展示了ExecutorInfo::set_name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
// Find this executable's directory to locate executor.
string path = os::realpath(dirname(argv[0])).get();
string uri = path + "/test-executor";
if (getenv("MESOS_BUILD_DIR")) {
uri = string(getenv("MESOS_BUILD_DIR")) + "/src/test-executor";
}
mesos::internal::logging::Flags flags;
string role;
flags.add(&role,
"role",
"Role to use when registering",
"*");
Option<string> master;
flags.add(&master,
"master",
"ip:port of master to connect");
Try<Nothing> load = flags.load(None(), argc, argv);
if (load.isError()) {
cerr << load.error() << endl;
usage(argv[0], flags);
exit(1);
} else if (master.isNone()) {
cerr << "Missing --master" << endl;
usage(argv[0], flags);
exit(1);
}
ExecutorInfo executor;
executor.mutable_executor_id()->set_value("default");
executor.mutable_command()->set_value(uri);
executor.set_name("Test Executor (C++)");
executor.set_source("cpp_test");
TestScheduler scheduler(executor, role);
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Test Framework (C++)");
framework.set_role(role);
MesosSchedulerDriver driver(&scheduler, framework, master.get());
return driver.run() == DRIVER_STOPPED ? 0 : 1;
}
示例2: monitor
// This test verifies the correct handling of the statistics
// endpoint when statistics is missing in ResourceUsage.
TEST(MonitorTest, MissingStatistics)
{
ResourceMonitor monitor([]() -> Future<ResourceUsage> {
FrameworkID frameworkId;
frameworkId.set_value("framework");
ExecutorID executorId;
executorId.set_value("executor");
ExecutorInfo executorInfo;
executorInfo.mutable_executor_id()->CopyFrom(executorId);
executorInfo.mutable_framework_id()->CopyFrom(frameworkId);
executorInfo.set_name("name");
executorInfo.set_source("source");
Resources resources = Resources::parse("cpus:1;mem:2").get();
ResourceUsage usage;
ResourceUsage::Executor* executor = usage.add_executors();
executor->mutable_executor_info()->CopyFrom(executorInfo);
executor->mutable_allocated()->CopyFrom(resources);
return usage;
});
UPID upid("monitor", process::address());
Future<http::Response> response = http::get(upid, "statistics");
AWAIT_READY(response);
AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
AWAIT_EXPECT_RESPONSE_HEADER_EQ(
"application/json",
"Content-Type",
response);
AWAIT_EXPECT_RESPONSE_BODY_EQ("[]", response);
}
示例3: main
int main(int argc, char** argv)
{
if (argc != 3) {
std::cerr << "Usage: " << argv[0]
<< " <master> <balloon limit in MB>" << std::endl;
return -1;
}
// Verify the balloon limit.
Try<size_t> limit = numify<size_t>(argv[2]);
if (limit.isError()) {
std::cerr << "Balloon limit is not a valid number" << std::endl;
return -1;
}
if (limit.get() < EXECUTOR_MEMORY_MB) {
std::cerr << "Please use a balloon limit bigger than "
<< EXECUTOR_MEMORY_MB << " MB" << std::endl;
}
// Find this executable's directory to locate executor.
std::string path = os::realpath(::dirname(argv[0])).get();
std::string uri = path + "/balloon-executor";
if (getenv("MESOS_BUILD_DIR")) {
uri = std::string(::getenv("MESOS_BUILD_DIR")) + "/src/balloon-executor";
}
ExecutorInfo executor;
executor.mutable_executor_id()->set_value("default");
executor.mutable_command()->set_value(uri);
executor.set_name("Balloon Executor");
executor.set_source("balloon_test");
Resource* mem = executor.add_resources();
mem->set_name("mem");
mem->set_type(Value::SCALAR);
mem->mutable_scalar()->set_value(EXECUTOR_MEMORY_MB);
BalloonScheduler scheduler(executor, limit.get());
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Balloon Framework (C++)");
// TODO(vinod): Make checkpointing the default when it is default
// on the slave.
if (os::hasenv("MESOS_CHECKPOINT")) {
cout << "Enabling checkpoint for the framework" << endl;
framework.set_checkpoint(true);
}
MesosSchedulerDriver* driver;
if (os::hasenv("MESOS_AUTHENTICATE")) {
cout << "Enabling authentication for the framework" << endl;
if (!os::hasenv("DEFAULT_PRINCIPAL")) {
EXIT(1) << "Expecting authentication principal in the environment";
}
if (!os::hasenv("DEFAULT_SECRET")) {
EXIT(1) << "Expecting authentication secret in the environment";
}
Credential credential;
credential.set_principal(getenv("DEFAULT_PRINCIPAL"));
credential.set_secret(getenv("DEFAULT_SECRET"));
framework.set_principal(getenv("DEFAULT_PRINCIPAL"));
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1], credential);
} else {
framework.set_principal("balloon-framework-cpp");
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1]);
}
int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
// Ensure that the driver process terminates.
driver->stop();
delete driver;
return status;
}
示例4: main
int main(int argc, char** argv)
{
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <master>" << endl;
return -1;
}
// Find this executable's directory to locate executor.
string path = os::realpath(dirname(argv[0])).get();
string uri = path + "/long-lived-executor";
if (getenv("MESOS_BUILD_DIR")) {
uri = string(getenv("MESOS_BUILD_DIR")) + "/src/long-lived-executor";
}
ExecutorInfo executor;
executor.mutable_executor_id()->set_value("default");
executor.mutable_command()->set_value(uri);
executor.set_name("Long Lived Executor (C++)");
executor.set_source("cpp_long_lived_framework");
LongLivedScheduler scheduler(executor);
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Long Lived Framework (C++)");
// TODO(vinod): Make checkpointing the default when it is default
// on the slave.
if (os::hasenv("MESOS_CHECKPOINT")) {
cout << "Enabling checkpoint for the framework" << endl;
framework.set_checkpoint(true);
}
MesosSchedulerDriver* driver;
if (os::hasenv("MESOS_AUTHENTICATE")) {
cout << "Enabling authentication for the framework" << endl;
if (!os::hasenv("DEFAULT_PRINCIPAL")) {
EXIT(1) << "Expecting authentication principal in the environment";
}
if (!os::hasenv("DEFAULT_SECRET")) {
EXIT(1) << "Expecting authentication secret in the environment";
}
Credential credential;
credential.set_principal(getenv("DEFAULT_PRINCIPAL"));
credential.set_secret(getenv("DEFAULT_SECRET"));
framework.set_principal(getenv("DEFAULT_PRINCIPAL"));
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1], credential);
} else {
framework.set_principal("long-lived-framework-cpp");
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1]);
}
int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
// Ensure that the driver process terminates.
driver->stop();
delete driver;
return status;
}
示例5: main
int main(int argc, char** argv)
{
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <master>" << endl;
return -1;
}
// Find this executable's directory to locate executor.
string uri;
Option<string> value = os::getenv("MESOS_BUILD_DIR");
if (value.isSome()) {
uri = path::join(value.get(), "src", "long-lived-executor");
} else {
uri = path::join(
os::realpath(Path(argv[0]).dirname()).get(),
"long-lived-executor");
}
ExecutorInfo executor;
executor.mutable_executor_id()->set_value("default");
executor.mutable_command()->set_value(uri);
executor.set_name("Long Lived Executor (C++)");
executor.set_source("cpp_long_lived_framework");
LongLivedScheduler scheduler(executor);
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Long Lived Framework (C++)");
value = os::getenv("MESOS_CHECKPOINT");
if (value.isSome()) {
framework.set_checkpoint(
numify<bool>(value.get()).get());
}
MesosSchedulerDriver* driver;
if (os::getenv("MESOS_AUTHENTICATE").isSome()) {
cout << "Enabling authentication for the framework" << endl;
value = os::getenv("DEFAULT_PRINCIPAL");
if (value.isNone()) {
EXIT(1) << "Expecting authentication principal in the environment";
}
Credential credential;
credential.set_principal(value.get());
framework.set_principal(value.get());
value = os::getenv("DEFAULT_SECRET");
if (value.isNone()) {
EXIT(1) << "Expecting authentication secret in the environment";
}
credential.set_secret(value.get());
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1], credential);
} else {
framework.set_principal("long-lived-framework-cpp");
driver = new MesosSchedulerDriver(
&scheduler, framework, argv[1]);
}
int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
// Ensure that the driver process terminates.
driver->stop();
delete driver;
return status;
}
示例6: monitor
// TODO(bmahler): Add additional tests:
// 1. Check that the data has been published to statistics.
// 2. Check that metering is occurring on subsequent resource data.
TEST(MonitorTest, WatchUnwatch)
{
FrameworkID frameworkId;
frameworkId.set_value("framework");
ExecutorID executorId;
executorId.set_value("executor");
ExecutorInfo executorInfo;
executorInfo.mutable_executor_id()->CopyFrom(executorId);
executorInfo.mutable_framework_id()->CopyFrom(frameworkId);
executorInfo.set_name("name");
executorInfo.set_source("source");
ResourceStatistics initialStatistics;
initialStatistics.set_cpus_user_time_secs(0);
initialStatistics.set_cpus_system_time_secs(0);
initialStatistics.set_cpus_limit(2.5);
initialStatistics.set_mem_rss_bytes(0);
initialStatistics.set_mem_limit_bytes(2048);
initialStatistics.set_timestamp(Clock::now().secs());
ResourceStatistics statistics;
statistics.set_cpus_nr_periods(100);
statistics.set_cpus_nr_throttled(2);
statistics.set_cpus_user_time_secs(4);
statistics.set_cpus_system_time_secs(1);
statistics.set_cpus_throttled_time_secs(0.5);
statistics.set_cpus_limit(2.5);
statistics.set_mem_rss_bytes(1024);
statistics.set_mem_limit_bytes(2048);
statistics.set_timestamp(
initialStatistics.timestamp() +
slave::RESOURCE_MONITORING_INTERVAL.secs());
TestingIsolator isolator;
process::spawn(isolator);
Future<Nothing> usage1, usage2;
EXPECT_CALL(isolator, usage(frameworkId, executorId))
.WillOnce(DoAll(FutureSatisfy(&usage1),
Return(initialStatistics)))
.WillOnce(DoAll(FutureSatisfy(&usage2),
Return(statistics)));
slave::ResourceMonitor monitor(&isolator);
// We pause the clock first in order to make sure that we can
// advance time below to force the 'delay' in
// ResourceMonitorProcess::watch to execute.
process::Clock::pause();
monitor.watch(
frameworkId,
executorId,
executorInfo,
slave::RESOURCE_MONITORING_INTERVAL);
// Now wait for ResouorceMonitorProcess::watch to finish so we can
// advance time to cause collection to begin.
process::Clock::settle();
process::Clock::advance(slave::RESOURCE_MONITORING_INTERVAL);
process::Clock::settle();
AWAIT_READY(usage1);
// Wait until the isolator has finished returning the statistics.
process::Clock::settle();
// The second collection will populate the cpus_usage.
process::Clock::advance(slave::RESOURCE_MONITORING_INTERVAL);
process::Clock::settle();
AWAIT_READY(usage2);
// Wait until the isolator has finished returning the statistics.
process::Clock::settle();
process::UPID upid("monitor", process::ip(), process::port());
Future<Response> response = process::http::get(upid, "usage.json");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
AWAIT_EXPECT_RESPONSE_HEADER_EQ(
"application/json",
"Content-Type",
response);
// TODO(bmahler): Verify metering directly through statistics.
AWAIT_EXPECT_RESPONSE_BODY_EQ(
strings::format(
"[{"
"\"executor_id\":\"executor\","
"\"executor_name\":\"name\","
"\"framework_id\":\"framework\","
"\"resource_usage\":{"
//.........这里部分代码省略.........
示例7: main
int main(int argc, char** argv)
{
// Find this executable's directory to locate executor.
string path = os::realpath(dirname(argv[0])).get();
string uri = path + "/test-executor";
if (getenv("MESOS_BUILD_DIR")) {
uri = string(getenv("MESOS_BUILD_DIR")) + "/src/test-executor";
}
mesos::internal::logging::Flags flags;
string role;
flags.add(&role,
"role",
"Role to use when registering",
"*");
Option<string> master;
flags.add(&master,
"master",
"ip:port of master to connect");
Try<Nothing> load = flags.load(None(), argc, argv);
if (load.isError()) {
cerr << load.error() << endl;
usage(argv[0], flags);
exit(1);
} else if (master.isNone()) {
cerr << "Missing --master" << endl;
usage(argv[0], flags);
exit(1);
}
ExecutorInfo executor;
executor.mutable_executor_id()->set_value("default");
executor.mutable_command()->set_value(uri);
executor.set_name("Test Executor (C++)");
executor.set_source("cpp_test");
TestScheduler scheduler(executor, role);
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Test Framework (C++)");
framework.set_role(role);
// TODO(vinod): Make checkpointing the default when it is default
// on the slave.
if (os::hasenv("MESOS_CHECKPOINT")) {
cout << "Enabling checkpoint for the framework" << endl;
framework.set_checkpoint(true);
}
MesosSchedulerDriver* driver;
if (os::hasenv("MESOS_AUTHENTICATE")) {
cout << "Enabling authentication for the framework" << endl;
if (!os::hasenv("DEFAULT_PRINCIPAL")) {
EXIT(1) << "Expecting authentication principal in the environment";
}
if (!os::hasenv("DEFAULT_SECRET")) {
EXIT(1) << "Expecting authentication secret in the environment";
}
Credential credential;
credential.set_principal(getenv("DEFAULT_PRINCIPAL"));
credential.set_secret(getenv("DEFAULT_SECRET"));
driver = new MesosSchedulerDriver(
&scheduler, framework, master.get(), credential);
} else {
driver = new MesosSchedulerDriver(
&scheduler, framework, master.get());
}
int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
delete driver;
return status;
}
示例8: main
int main(int argc, char** argv)
{
string seedUrl, master;
shift;
while (true) {
string s = argc>0 ? argv[0] : "--help";
if (argc > 1 && s == "--seedUrl") {
seedUrl = argv[1];
shift; shift;
} else if (argc > 1 && s == "--master") {
master = argv[1];
shift; shift;
} else {
break;
}
}
if (master.length() == 0 || seedUrl.length() == 0) {
printf("Usage: rendler --seedUrl <URL> --master <ip>:<port>\n");
exit(1);
}
// Find this executable's directory to locate executor.
string path = realpath(dirname(argv[0]), NULL);
string crawlerURI = path + "/crawl_executor";
string rendererURI = path + "/render_executor";
cout << crawlerURI << endl;
cout << rendererURI << endl;
ExecutorInfo crawler;
crawler.mutable_executor_id()->set_value("Crawler");
crawler.mutable_command()->set_value(crawlerURI);
crawler.set_name("Crawl Executor (C++)");
crawler.set_source("cpp");
ExecutorInfo renderer;
renderer.mutable_executor_id()->set_value("Renderer");
renderer.mutable_command()->set_value(rendererURI);
renderer.set_name("Render Executor (C++)");
renderer.set_source("cpp");
Rendler scheduler(crawler, renderer, seedUrl);
FrameworkInfo framework;
framework.set_user(""); // Have Mesos fill in the current user.
framework.set_name("Rendler Framework (C++)");
//framework.set_role(role);
framework.set_principal("rendler-cpp");
// Set up the signal handler for SIGINT for clean shutdown.
struct sigaction action;
action.sa_handler = SIGINTHandler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
sigaction(SIGINT, &action, NULL);
schedulerDriver = new MesosSchedulerDriver(&scheduler, framework, master);
int status = schedulerDriver->run() == DRIVER_STOPPED ? 0 : 1;
// Ensure that the driver process terminates.
schedulerDriver->stop();
shutdown();
delete schedulerDriver;
return status;
}