本文整理汇总了C++中CommandInfo类的典型用法代码示例。如果您正苦于以下问题:C++ CommandInfo类的具体用法?C++ CommandInfo怎么用?C++ CommandInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(MesosContainerizerProcessTest, MultipleURIs)
{
CommandInfo commandInfo;
CommandInfo::URI uri;
uri.set_value("hdfs:///uri1");
uri.set_executable(false);
commandInfo.add_uris()->MergeFrom(uri);
uri.set_value("hdfs:///uri2");
uri.set_executable(true);
commandInfo.add_uris()->MergeFrom(uri);
string directory = "/tmp/directory";
Option<string> user("user");
Flags flags;
flags.frameworks_home = "/tmp/frameworks";
flags.hadoop_home = "/tmp/hadoop";
map<string, string> environment =
fetcherEnvironment(commandInfo, directory, user, flags);
EXPECT_EQ(5u, environment.size());
EXPECT_EQ(
"hdfs:///uri1+0X hdfs:///uri2+1X", environment["MESOS_EXECUTOR_URIS"]);
EXPECT_EQ(directory, environment["MESOS_WORK_DIRECTORY"]);
EXPECT_EQ(user.get(), environment["MESOS_USER"]);
EXPECT_EQ(flags.frameworks_home, environment["MESOS_FRAMEWORKS_HOME"]);
EXPECT_EQ(flags.hadoop_home, environment["HADOOP_HOME"]);
}
示例2: TEST_F
TEST_F(FetcherEnvironmentTest, MultipleURIs)
{
CommandInfo commandInfo;
CommandInfo::URI uri;
uri.set_value("hdfs:///uri1");
uri.set_executable(false);
commandInfo.add_uris()->MergeFrom(uri);
uri.set_value("hdfs:///uri2");
uri.set_executable(true);
commandInfo.add_uris()->MergeFrom(uri);
string directory = "/tmp/directory";
Option<string> user("user");
slave::Flags flags;
flags.frameworks_home = "/tmp/frameworks";
flags.hadoop_home = "/tmp/hadoop";
map<string, string> environment =
fetcher::environment(commandInfo, directory, user, flags);
EXPECT_EQ(5u, environment.size());
EXPECT_EQ(stringify(JSON::Protobuf(commandInfo)),
environment["MESOS_COMMAND_INFO"]);
EXPECT_EQ(directory, environment["MESOS_WORK_DIRECTORY"]);
EXPECT_EQ(user.get(), environment["MESOS_USER"]);
EXPECT_EQ(flags.frameworks_home, environment["MESOS_FRAMEWORKS_HOME"]);
EXPECT_EQ(flags.hadoop_home, environment["HADOOP_HOME"]);
}
示例3: run
Try<Subprocess> run(
const string& _command,
const Option<string>& rootfs = None())
{
slave::MesosContainerizerLaunch::Flags launchFlags;
CommandInfo command;
command.set_value(_command);
launchFlags.command = JSON::Protobuf(command);
launchFlags.directory = "/tmp";
launchFlags.pipe_read = open("/dev/zero", O_RDONLY);
launchFlags.pipe_write = open("/dev/null", O_WRONLY);
launchFlags.rootfs = rootfs;
vector<string> argv(2);
argv[0] = "mesos-containerizer";
argv[1] = slave::MesosContainerizerLaunch::NAME;
Try<Subprocess> s = subprocess(
path::join(tests::flags.build_dir, "src", "mesos-containerizer"),
argv,
Subprocess::PATH("/dev/null"),
Subprocess::FD(STDOUT_FILENO),
Subprocess::FD(STDERR_FILENO),
launchFlags,
None(),
None(),
lambda::bind(&clone, lambda::_1));
close(launchFlags.pipe_read.get());
close(launchFlags.pipe_write.get());
return s;
}
示例4: TEST_F
TEST_F(DockerTest, ROOT_DOCKER_CheckPortResource)
{
const string containerName = NAME_PREFIX + "-port-resource-test";
Owned<Docker> docker(Docker::create(tests::flags.docker,
tests::flags.docker_socket,
false).get());
// Make sure the container is removed.
Future<Nothing> remove = docker->rm(containerName, true);
ASSERT_TRUE(process::internal::await(remove, Seconds(10)));
ContainerInfo containerInfo;
containerInfo.set_type(ContainerInfo::DOCKER);
ContainerInfo::DockerInfo dockerInfo;
dockerInfo.set_image("busybox");
dockerInfo.set_network(ContainerInfo::DockerInfo::BRIDGE);
ContainerInfo::DockerInfo::PortMapping portMapping;
portMapping.set_host_port(10000);
portMapping.set_container_port(80);
dockerInfo.add_port_mappings()->CopyFrom(portMapping);
containerInfo.mutable_docker()->CopyFrom(dockerInfo);
CommandInfo commandInfo;
commandInfo.set_shell(false);
commandInfo.set_value("true");
Resources resources =
Resources::parse("ports:[9998-9999];ports:[10001-11000]").get();
Future<Nothing> run = docker->run(
containerInfo,
commandInfo,
containerName,
"dir",
"/mnt/mesos/sandbox",
resources);
// Port should be out side of the provided ranges.
AWAIT_EXPECT_FAILED(run);
resources = Resources::parse("ports:[9998-9999];ports:[10000-11000]").get();
Try<string> directory = environment->mkdtemp();
CHECK_SOME(directory) << "Failed to create temporary directory";
run = docker->run(
containerInfo,
commandInfo,
containerName,
directory.get(),
"/mnt/mesos/sandbox",
resources);
AWAIT_READY(run);
}
示例5: CommandInfo
CarsorSelectReAction* MakimonoItem::getSelectReaction(){
// TODO: 巻物のセレクトの実装
CommandInfo* com = new CommandInfo(m_scene);
com->addCarsor(new YomuCommand(m_scene));
com->addCarsor(new NageruCommand(m_scene));
com->addCarsor(new OkuCommand(m_scene));
com->addCarsor(new SetumeiCommand(m_scene));
return com;
}
示例6: CommandInfo
CarsorSelectReAction* EatingItem::getSelectReaction(){
CommandInfo* command = new CommandInfo(m_scene);
command->addCarsor(new TaberuCommand(m_scene));
command->addCarsor(new NageruCommand(m_scene));
command->addCarsor(new OkuCommand(m_scene));
command->addCarsor(new SetumeiCommand(m_scene));
return command;
}
示例7: buildTask
TaskInfo buildTask (string hostname, string id, const SlaveID& slave) {
hostProfile profile = hostList[hostname];
// Define the Docker container.
/* Since there is no "executor" to manage the tasks, the
container will be built and attached directly into the task below */
ContainerInfo container;
container.set_type(container.DOCKER);
ContainerInfo::DockerInfo docker;
docker.set_image(DOCKER_IMAGE);
container.mutable_docker()->MergeFrom(docker);
// Mount local volume inside Container
Volume * volume = container.add_volumes();
volume->set_container_path("/mnt");
volume->set_host_path("/local/mesos");
volume->set_mode(Volume_Mode_RW);
// Define the task
TaskInfo task;
task.set_name("K3-" + k3binary);
task.mutable_task_id()->set_value(id);
task.mutable_slave_id()->MergeFrom(slave);
task.mutable_container()->MergeFrom(container);
//task.set_data(stringify(localTasks));
// Define include files for the command
CommandInfo command;
CommandInfo_URI * k3_bin = command.add_uris();
k3_bin->set_value(fileServer + "/" + k3binary);
k3_bin->set_executable(true);
k3_bin->set_extract(false);
// CommandInfo_URI * k3_args = command.add_uris();
// k3_args->set_value(runpath + "/k3input.yaml");
// command.set_value("$MESOS_SANDBOX/" + k3binary + " -l INFO -p " +
// "$MESOS_SANDBOX/k3input.yaml");
task.mutable_command()->MergeFrom(command);
// Option A for doing resources management (see scheduler for option B)
Resource* resource;
resource = task.add_resources();
resource->set_name("cpus");
resource->set_type(Value::SCALAR);
resource->mutable_scalar()->set_value(profile.cpu);
resource = task.add_resources();
resource->set_name("mem");
resource->set_type(Value::SCALAR);
resource->mutable_scalar()->set_value(profile.mem);
return task;
}
示例8: offers
void offers(const vector<Offer>& offers)
{
CHECK_EQ(SUBSCRIBED, state);
static const Try<Resources> TASK_RESOURCES = Resources::parse(resources);
if (TASK_RESOURCES.isError()) {
EXIT(EXIT_FAILURE)
<< "Failed to parse resources '" << resources << "': "
<< TASK_RESOURCES.error();
}
foreach (const Offer& offer, offers) {
Resources offered = offer.resources();
if (!launched && offered.flatten().contains(TASK_RESOURCES.get())) {
TaskInfo task;
task.set_name(name);
task.mutable_task_id()->set_value(name);
task.mutable_agent_id()->MergeFrom(offer.agent_id());
// Takes resources first from the specified role, then from '*'.
Option<Resources> resources =
offered.find(TASK_RESOURCES.get().flatten(frameworkInfo.role()));
CHECK_SOME(resources);
task.mutable_resources()->CopyFrom(resources.get());
CommandInfo* commandInfo = task.mutable_command();
if (shell) {
CHECK_SOME(command);
commandInfo->set_shell(true);
commandInfo->set_value(command.get());
} else {
// TODO(gilbert): Treat 'command' as executable value and arguments.
commandInfo->set_shell(false);
}
if (environment.isSome()) {
Environment* environment_ = commandInfo->mutable_environment();
foreachpair (
const string& name, const string& value, environment.get()) {
Environment::Variable* environmentVariable =
environment_->add_variables();
environmentVariable->set_name(name);
environmentVariable->set_value(value);
}
}
示例9: TestArgsInRange
common::Error TestArgsInRange(const CommandInfo& cmd, commands_args_t argv) {
const size_t argc = argv.size();
const uint16_t max = cmd.GetMaxArgumentsCount();
const uint8_t min = cmd.GetMinArgumentsCount();
if (argc > max || argc < min) {
std::string buff =
common::MemSPrintf("Invalid input argument for command: '%s', passed %d arguments, must be in range %u - %u.",
cmd.name, argc, min, max);
return common::make_error(buff);
}
return common::Error();
}
示例10: populateTasks
vector<TaskInfo> populateTasks(
const string& cmd,
const string& healthCmd,
const Offer& offer,
int gracePeriodSeconds = 0,
const Option<int>& consecutiveFailures = None(),
const Option<map<string, string> >& env = None())
{
CommandInfo healthCommand;
healthCommand.set_value(healthCmd);
return populateTasks(
cmd,
healthCommand,
offer,
gracePeriodSeconds,
consecutiveFailures,
env);
}
示例11: Failure
Future<Option<ContainerLaunchInfo>> LinuxFilesystemIsolatorProcess::prepare(
const ContainerID& containerId,
const ContainerConfig& containerConfig)
{
const string& directory = containerConfig.directory();
Option<string> user;
if (containerConfig.has_user()) {
user = containerConfig.user();
}
if (infos.contains(containerId)) {
return Failure("Container has already been prepared");
}
Owned<Info> info(new Info(
directory,
containerConfig.executor_info()));
infos.put(containerId, info);
ContainerLaunchInfo launchInfo;
launchInfo.set_namespaces(CLONE_NEWNS);
// Prepare the commands that will be run in the container's mount
// namespace right after forking the executor process. We use these
// commands to mount those volumes specified in the container info
// so that they don't pollute the host mount namespace.
Try<string> _script = script(containerId, containerConfig);
if (_script.isError()) {
return Failure("Failed to generate isolation script: " + _script.error());
}
CommandInfo* command = launchInfo.add_commands();
command->set_value(_script.get());
return update(containerId, containerConfig.executor_info().resources())
.then([launchInfo]() -> Future<Option<ContainerLaunchInfo>> {
return launchInfo;
});
}
示例12: TEST_F
// This test verifies mounting in an absolute path when running a
// docker container works.
TEST_F(DockerTest, ROOT_DOCKER_MountAbsolute)
{
Owned<Docker> docker = Docker::create(
tests::flags.docker,
tests::flags.docker_socket,
false).get();
ContainerInfo containerInfo;
containerInfo.set_type(ContainerInfo::DOCKER);
Try<string> directory = environment->mkdtemp();
CHECK_SOME(directory) << "Failed to create temporary directory";
const string testFile = path::join(directory.get(), "test_file");
EXPECT_SOME(os::write(testFile, "data"));
Volume* volume = containerInfo.add_volumes();
volume->set_host_path(testFile);
volume->set_container_path("/tmp/test_file");
volume->set_mode(Volume::RO);
ContainerInfo::DockerInfo dockerInfo;
dockerInfo.set_image("busybox");
containerInfo.mutable_docker()->CopyFrom(dockerInfo);
CommandInfo commandInfo;
commandInfo.set_shell(true);
commandInfo.set_value("ls /tmp/test_file");
Future<Nothing> run = docker->run(
containerInfo,
commandInfo,
NAME_PREFIX + "-mount-absolute-test",
directory.get(),
directory.get());
AWAIT_READY(run);
}
示例13: validateUris
static Try<Nothing> validateUris(const CommandInfo& commandInfo)
{
foreach (const CommandInfo::URI& uri, commandInfo.uris()) {
Try<Nothing> uriValidation = Fetcher::validateUri(uri.value());
if (uriValidation.isError()) {
return Error(uriValidation.error());
}
if (uri.has_output_file()) {
Try<Nothing> outputFileValidation =
Fetcher::validateOutputFile(uri.output_file());
if (outputFileValidation.isError()) {
return Error(outputFileValidation.error());
}
}
}
return Nothing();
}
示例14: Nothing
Future<Nothing> Fetcher::fetch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const string& sandboxDirectory,
const Option<string>& user,
const SlaveID& slaveId,
const Flags& flags)
{
if (commandInfo.uris().size() == 0) {
return Nothing();
}
return dispatch(process.get(),
&FetcherProcess::fetch,
containerId,
commandInfo,
sandboxDirectory,
user,
slaveId,
flags);
}
示例15: TEST_F
TEST_F(SlaveTest, ShutdownUnregisteredExecutor)
{
Try<PID<Master> > master = StartMaster();
ASSERT_SOME(master);
// Need flags for 'executor_registration_timeout'.
slave::Flags flags = CreateSlaveFlags();
// Set the isolation flag so we know a MesoContainerizer will be created.
flags.isolation = "posix/cpu,posix/mem";
Try<MesosContainerizer*> containerizer =
MesosContainerizer::create(flags, false);
CHECK_SOME(containerizer);
Try<PID<Slave> > slave = StartSlave(containerizer.get());
ASSERT_SOME(slave);
MockScheduler sched;
MesosSchedulerDriver driver(
&sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
EXPECT_CALL(sched, registered(&driver, _, _))
.Times(1);
Future<vector<Offer> > offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
driver.start();
AWAIT_READY(offers);
EXPECT_NE(0u, offers.get().size());
// Launch a task with the command executor.
TaskInfo task;
task.set_name("");
task.mutable_task_id()->set_value("1");
task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
task.mutable_resources()->MergeFrom(offers.get()[0].resources());
CommandInfo command;
command.set_value("sleep 10");
task.mutable_command()->MergeFrom(command);
vector<TaskInfo> tasks;
tasks.push_back(task);
// Drop the registration message from the executor to the slave.
Future<process::Message> registerExecutor =
DROP_MESSAGE(Eq(RegisterExecutorMessage().GetTypeName()), _, _);
driver.launchTasks(offers.get()[0].id(), tasks);
AWAIT_READY(registerExecutor);
Clock::pause();
Future<TaskStatus> status;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&status));
// Ensure that the slave times out and kills the executor.
Future<Nothing> destroyExecutor =
FUTURE_DISPATCH(_, &MesosContainerizerProcess::destroy);
Clock::advance(flags.executor_registration_timeout);
AWAIT_READY(destroyExecutor);
Clock::settle(); // Wait for Containerizer::destroy to complete.
// Now advance time until the reaper reaps the executor.
while (status.isPending()) {
Clock::advance(Seconds(1));
Clock::settle();
}
AWAIT_READY(status);
ASSERT_EQ(TASK_FAILED, status.get().state());
Clock::resume();
driver.stop();
driver.join();
Shutdown(); // Must shutdown before 'containerizer' gets deallocated.
}