Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 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));
   }
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
 }