本文整理汇总了C++中TaskInfo::get_timestamp方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskInfo::get_timestamp方法的具体用法?C++ TaskInfo::get_timestamp怎么用?C++ TaskInfo::get_timestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskInfo
的用法示例。
在下文中一共展示了TaskInfo::get_timestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finish_task
int TaskManager::finish_task(const bool result, const TaskInfo & task)
{
int ret = OB_SUCCESS;
if (task.get_token() != task_token_)
{
TBSYS_LOG(ERROR, "check task token failed:token[%ld], task[%ld]",
task_token_, task.get_token());
ret = OB_ERROR;
}
else
{
map<uint64_t, TaskInfo>::iterator it;
int64_t timestamp = tbsys::CTimeUtil::getTime();
tbsys::CThreadGuard lock(&lock_);
int64_t task_count = get_server_task_count(task.get_location()[task.get_index()].chunkserver_);
if (task_count < 1)
{
TBSYS_LOG(WARN, "check server task count failed:task[%lu], count[%ld]", task.get_id(), task_count);
}
else
{
TBSYS_LOG(DEBUG, "server ip = %ld, task_count = %ld",
task.get_location()[task.get_index()].chunkserver_.get_ipv4(),
task_count);
// wait timeout for next dispatch
working_queue_[task.get_location()[task.get_index()].chunkserver_] = --task_count;
// print_access_server();
}
it = doing_queue_.find(task.get_id());
if (it != doing_queue_.end())
{
if (true == result)
{
++total_finish_count_;
total_finish_time_ += timestamp - task.get_timestamp();
complete_queue_.insert(pair<uint64_t, TaskInfo>(task.get_id(), task));
doing_queue_.erase(it);
}
// WARN: not insert into wait queue for timeout if result != true
}
else
{
it = complete_queue_.find(task.get_id());
if (it != complete_queue_.end())
{
if (true == result)
{
// for compute average finish time
++total_finish_count_;
total_finish_time_ += timestamp - task.get_timestamp();
}
TBSYS_LOG(WARN, "find the task already finished:task[%lu]", task.get_id());
}
else
{
TBSYS_LOG(ERROR, "not find this task in doing and complete queue:task[%lu]", task.get_id());
ret = OB_ERROR;
}
}
}
TBSYS_LOG(INFO, "finish monitor task [id=%lu] stat:wait[%lu], doing[%lu], finish[%lu], avg_time[%ld]", task.get_id(),
wait_queue_.size(), doing_queue_.size(), complete_queue_.size(), total_finish_time_ / total_finish_count_);
return ret;
}