当前位置: 首页>>代码示例>>C++>>正文


C++ TaskInfo::get_token方法代码示例

本文整理汇总了C++中TaskInfo::get_token方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskInfo::get_token方法的具体用法?C++ TaskInfo::get_token怎么用?C++ TaskInfo::get_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskInfo的用法示例。


在下文中一共展示了TaskInfo::get_token方法的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;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:65,代码来源:task_manager.cpp


注:本文中的TaskInfo::get_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。