示例#1
0
文件: ns_define.cpp 项目: 0huah0/tfs
 void print_servers(const common::ArrayHelper<uint64_t>& servers, std::string& result)
 {
   for (int32_t i = 0; i < servers.get_array_index(); ++i)
   {
     result += "/";
     result += tbsys::CNetUtil::addrToString(*servers.at(i));
   }
 }
示例#2
0
 bool ServerCollect::remove(const common::ArrayHelper<BlockCollect*>& blocks)
 {
   RWLock::Lock lock(mutex_, WRITE_LOCKER);
   for (int32_t i = 0; i < blocks.get_array_index(); ++i)
   {
     remove_(*blocks.at(i));
   }
   return true;
 }
示例#3
0
 int FamilyCollect::add(const common::ArrayHelper<std::pair<uint64_t, int32_t> >& members)
 {
   const int32_t MEMBER_NUM = get_data_member_num() + get_check_member_num();
   int32_t ret = (members.get_array_index() > MEMBER_NUM || members.get_array_index() <= 0)
          ? EXIT_PARAMETER_ERROR : TFS_SUCCESS;
   if (TFS_SUCCESS == ret)
   {
     for (int64_t index = 0; index < members.get_array_index(); ++index)
     {
       members_[index] = *members.at(index);
     }
   }
   return ret;
 }
示例#4
0
 bool ServerCollect::get_range_blocks_(common::ArrayHelper<BlockCollect*>& blocks, const uint32_t begin, const int32_t count) const
 {
   blocks.clear();
   int32_t actual = 0;
   BlockCollect query(begin);
   BLOCKS_ITER iter = 0 == begin ? hold_->begin() : hold_->upper_bound(&query);
   while(iter != hold_->end() && actual < count)
   {
     blocks.push_back((*iter));
     actual++;
     iter++;
   }
   return actual < count;
 }
示例#5
0
 bool ServerCollect::remove_writable_(const common::ArrayHelper<BlockCollect*>& blocks)
 {
   RWLock::Lock lock(mutex_, WRITE_LOCKER);
   BlockCollect* block = NULL;
   for (int32_t i = 0; i < blocks.get_array_index(); ++i)
   {
     block = *blocks.at(i);
     TBSYS_LOG(DEBUG, "%s remove_writable: is_full: %d, servers size: %d",
       tbsys::CNetUtil::addrToString(id()).c_str(), block->is_full(), block->get_servers_size());
     if (!block->is_writable() || !is_equal_group(block->id()))
        hold_master_->erase(block);
     if (block->is_full() || !is_equal_group(block->id()))
        writable_->erase(block);
   }
   return true;
 }
示例#6
0
文件: aop_meta.cpp 项目: alimy/tfs
 int OpMeta::get_members(common::ArrayHelper< BlockReplicaInfo >& helper) const
 {
   tbutil::Mutex::Lock lock(mutex_);
   int ret = TFS_SUCCESS;
   if (helper.get_array_size() < server_size_)
   {
     ret = EXIT_PARAMETER_ERROR;
   }
   else
   {
     for (int index = 0; index < server_size_; index++)
     {
       helper.push_back(std::make_pair(members_[index].server_, members_[index].info_));
     }
   }
   return ret;
 }