本文整理汇总了C++中TaskPtr::TaskStarting方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskPtr::TaskStarting方法的具体用法?C++ TaskPtr::TaskStarting怎么用?C++ TaskPtr::TaskStarting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskPtr
的用法示例。
在下文中一共展示了TaskPtr::TaskStarting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScheduleOneTask
int32_t DefaultScheduler::ScheduleOneTask(const TaskPtr& task_ptr) {
// set task_ad & hard constraints
ClassAdPtr taskad_hard_constraint(new ClassAd(*task_ptr->GetTaskHardClassAd()));
string taskad_hard = ClassAdComplement::AdTostring(taskad_hard_constraint);
// set soft constraints
vector<string> soft_list;
list<ClassAdPtr> classad_soft_list = task_ptr->GetTaskSoftList();
for (list<ClassAdPtr>::iterator it = classad_soft_list.begin();
it != classad_soft_list.end(); ++it)
{
string soft_constraint = ClassAdComplement::AdTostring(*it);
soft_list.push_back(soft_constraint);
}
// match
string result;
if (SendRequestConstraint(taskad_hard, soft_list, result) != 0) {
// TODO
// continue;
return -1;
}
if ("" == result) {
// TODO
return -1;
}
int32_t task_id = task_ptr->GetTaskId();
int32_t job_id = task_ptr->GetJobId();
JobPtr job_ptr = JobPoolI::Instance()->GetJobPtr(job_id);
printf("Match result:\n job_id: %d, task_id: %d, result: %s\n", job_id, task_id, result.c_str());
// new action event
EventPtr event(new StartTaskEvent(job_id, task_id, result, taskad_hard));
// Push event into Queue
EventDispatcherI::Instance()->Dispatch(event->GetType())->PushBack(event);
// write map & task
vector<string> vec_ip_port;
StringUtility::Split(result.c_str(), vec_ip_port, ":");
if (vec_ip_port.size() != 2) {
LOG4CPLUS_ERROR(logger, "result is illegal" << result);
return -1;
}
job_ptr->WriteMap(task_id, vec_ip_port[0]);
task_ptr->SetEsIp(vec_ip_port[0]);
// add used resource
GroupPoolI::Instance()->AddUsedResource(task_ptr);
task_ptr->TaskStarting();
return 0;
}