本文整理汇总了C++中TaskInfo::data方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskInfo::data方法的具体用法?C++ TaskInfo::data怎么用?C++ TaskInfo::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskInfo
的用法示例。
在下文中一共展示了TaskInfo::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteTask
void ExecuteTask (const TaskInfo& task) {
const string& executorId = task.executor().executor_id().value();
const string& data = task.data();
vector<string> args = split(data, '\n');
Resources resources = task.resources();
LOG(INFO)
<< "executor " << executorId
<< " with '" << join(args, " ") << "'"
<< " and " << resources;
Resources persistent = filterIsPersistentVolume(resources);
for (const auto& volume : persistent) {
const string& path = volume.disk().volume().container_path();
LOG(INFO)
<< "using persistent volume " << path;
os::mkdir(path + "/data");
os::mkdir(path + "/logs");
os::mkdir(path + "/apps");
string cmd = "ls -l " + path;
int r = system(cmd.c_str());
if (r) {
LOG(WARNING)
<< "failed with " << r;
}
}
size_t len = args.size();
char** a = static_cast<char**>(malloc(sizeof(char*) * (len + 1)));
for (size_t i = 0; i < len; ++i) {
a[i] = const_cast<char*>(args[i].c_str());
LOG(INFO)
<< i << ". argument: " << a[i];
}
a[len] = nullptr;
execv(args[0].c_str(), a);
LOG(FATAL)
<< "PANIC execv failed";
// upps, exec failed
_exit(1);
}
示例2: launchTask
//when the task before starting,
//it should check task.data() to determin
//what it will do, whether copy config?
//whether start fileserver?
//
//task.data() here format is :
//<isInitialMonNode>.<TaskType>
void CephExecutor::launchTask(ExecutorDriver* driver, const TaskInfo& task)
{
//set class member localSharedConfDirRoot
string cmd = "echo ~";
string r = runShellCommand(cmd);
localSharedConfigDirRoot = r == " " ? r :"/root";
LOG(INFO) << "localSharedConfigDirRoot is " << localSharedConfigDirRoot;
bool needCopyConfig = true;
bool needStartFileServer = false;
int taskType;
if (task.has_data()){
LOG(INFO) << "Got TaskInfo data: " << task.data();
vector<string> tokens = StringUtil::explode(task.data(),'.');
//split by '.', the first part is isInitialMonNode,
//second part is used for task type
if (tokens[0] == "1"){
needCopyConfig = false;
}
taskType = lexical_cast<int>(tokens[1]);
}
string localMountDir = localSharedConfigDirRoot +
"/" +localConfigDirName;
TaskStatus status;
status.mutable_task_id()->MergeFrom(task.task_id());
//make local shared dir, all type of task need this:
//TODO: check if already exists valid dirctory tree
if (!createLocalSharedConfigDir(localConfigDirName)) {
LOG(INFO) << "created local shared directory failed!";
status.set_state(TASK_FAILED);
driver->sendStatusUpdate(status);
return;
}
LOG(INFO) << "Create directory tree done.";
//mount shared local dir
if (needCopyConfig) {
string abPath = localMountDir + "/"
+ "/etc/ceph/";
if (!copySharedConfigDir(abPath)) {
LOG(INFO) << "Copy shared config file failed!";
status.set_state(TASK_FAILED);
driver->sendStatusUpdate(status);
return;
}
LOG(INFO) << "Copy config files done.";
}
//run docker command for MON and RADOSGW
string cName = getContainerName(task.task_id().value());
//set class member containerName, and myTaskId
//TODO: see if put these in registed is more proper
containerName = cName;
myTaskId = task.task_id();
//TODO: kill existing container in case conflict
runShellCommand("docker rm -f " + containerName);
string dockerCommand;
switch (taskType) {
case static_cast<int>(TaskType::MON):
needStartFileServer = true;
dockerCommand = constructMonCommand(
localMountDir,
cName);
downloadDockerImage("ceph/mon");
break;
case static_cast<int>(TaskType::OSD):
downloadDockerImage("ceph/osd");
//Will get osdId in FrameworkMessage
dockerCommand = "";
status.set_state(TASK_STARTING);
driver->sendStatusUpdate(status);
return;
case static_cast<int>(TaskType::RADOSGW):
downloadDockerImage("ceph/radosgw");
dockerCommand = constructRADOSGWCommand(
localMountDir,
cName);
break;
}
if (needStartFileServer) {
thread fileServerThread(fileServer,
7777,
localSharedConfigDirRoot + "/" + localConfigDirName + "/etc/ceph/");
fileServerThread.detach();
LOG(INFO) << "Mon fileserver started";
}
LOG(INFO) << "Stating container with command: ";
LOG(INFO) << dockerCommand;
//.........这里部分代码省略.........
示例3: launchTask
virtual void launchTask(ExecutorDriver* driver, const TaskInfo& task) {
localPeerCount++;
TaskStatus status;
status.mutable_task_id()->MergeFrom(task.task_id());
status.set_state(TASK_RUNNING);
driver->sendStatusUpdate(status);
//------------- START TASK OPERATIONS ----------
cout << "Running K3 Program: " << task.name() << endl;
string k3_cmd;
using namespace YAML;
Node hostParams = Load(task.data());
Node peerParams;
Node peers;
// vector<Node> peers;
cout << "WHAT I RECEIVED\n----------------------\n";
cout << Dump(hostParams);
cout << "\n---------------------------------\n";
k3_cmd = "cd $MESOS_SANDBOX && bash -c 'ulimit -c unlimited && ./" + hostParams["binary"].as<string>();
if (hostParams["logging"]) {
k3_cmd += " -l INFO ";
}
if (hostParams["resultVar"]) {
k3_cmd += " --result_path $MESOS_SANDBOX --result_var " + hostParams["resultVar"].as<string>();
}
string datavar, datapath;
string datapolicy = "default";
int peerStart = 0;
int peerEnd = 0;
for (const_iterator param=hostParams.begin(); param!=hostParams.end(); param++) {
string key = param->first.as<string>();
// cout << " PROCESSING: " << key << endl;
if (key == "logging" || key == "binary" ||
key == "server" || key == "server_group") {
continue;
}
if (key == "roles") {
continue;
}
else if (key == "peers") {
peerParams["peers"] = hostParams["peers"];
}
else if (key == "me") {
Node meList = param->second;
YAML::Emitter emit;
emit << YAML::Flow << meList;
for (std::size_t i=0; i<meList.size(); i++) {
peers.push_back(meList[i]);
}
}
else if (key == "data") {
// TODO: Datafiles per group. This is a hack
// that only includes the data files from the first peer group
// and assigns them to any peer
Node dataFilesNode = param->second[0];
for(YAML::const_iterator it=dataFilesNode.begin();it!=dataFilesNode.end();++it) {
DataFile f;
auto d = *it;
f.path = d["path"].as<string>();
f.varName = d["var"].as<string>();
f.policy = d["policy"].as<string>();
dataFiles.push_back(f);
}
}
//else if (key == "datavar") {
// datavar = param->second.as<string>();
//}
//else if (key == "datapath") {
// datapath = "{path: " + param->second.as<string>() + "}";
//}
//else if (key == "datapolicy") {
// datapolicy = param->second.as<string>();
//}
else if (key == "totalPeers") {
totalPeerCount = param->second.as<int>();
}
else if (key == "peerStart") {
peerStart = param->second.as<int>();
}
else if (key == "peerEnd") {
peerEnd = param->second.as<int>();
}
else if (key == "globals") {
// handled per peer
}
else {
// string value = i->second.as<string>();
//peerParams[key] = param->second;
//.........这里部分代码省略.........