Exemplo n.º 1
0
 int BatchSetBlockInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t iret = output.set_int32(block_infos_.size());
   if (common::TFS_SUCCESS == iret)
   {
     std::map<uint32_t, common::BlockInfoSeg>::const_iterator it = block_infos_.begin();
     common::BlockInfoSeg* block_info = NULL;
     for (; it != block_infos_.end(); it++)
     {
       block_info = const_cast< common::BlockInfoSeg*>(&it->second);
       if (block_info->has_lease()
           && !block_info->ds_.empty())
       {
         block_info->ds_.push_back(ULONG_LONG_MAX);
         block_info->ds_.push_back(static_cast<uint64_t> (block_info->version_));
         block_info->ds_.push_back(static_cast<uint64_t> (block_info->lease_id_));
       }
       //block id
       iret = output.set_int32(it->first);
       if (common::TFS_SUCCESS != iret)
         break;
       // dataserver list
       iret = output.set_vint64(block_info->ds_);
       if (common::TFS_SUCCESS != iret)
         break;
       // reparse, avoid push verion&lease again when clone twice;
       common::BasePacket::parse_special_ds(block_info->ds_, block_info->version_, block_info->lease_id_);
     }
   }
   return iret;
 }
Exemplo n.º 2
0
 int WriteDataMessage::serialize(common::Stream& output) const
 {
   if (has_lease())
   {
     ds_.push_back(ULONG_LONG_MAX);
     ds_.push_back(static_cast<uint64_t>(version_));
     ds_.push_back(static_cast<uint64_t>(lease_id_));
   }
   int64_t pos = 0;
   int32_t iret = write_data_info_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(write_data_info_.length());
     iret = output.set_vint64(ds_);
   }
   if (common::TFS_SUCCESS == iret
       && write_data_info_.length_ > 0)
   {
     iret = output.set_bytes(data_, write_data_info_.length_);
   }
   // reparse, avoid push verion&lease again when clone twice;
   if (common::TFS_SUCCESS == iret)
   {
     parse_special_ds(ds_, version_, lease_id_);
   }
   return iret;
 }
Exemplo n.º 3
0
    int RespListBlockMessage::serialize(common::Stream& output)  const
    {
      int32_t ret = output.set_int32(status_type_);
      if (common::TFS_SUCCESS == ret)
      {
        if (status_type_ & common::LB_BLOCK)
        {
          ret = output.set_vint64(blocks_);
        }

        if (common::TFS_SUCCESS == ret
          && status_type_ & common::LB_PAIRS)
        {
          ret = output.set_int32(block_pairs_.size());
          if (common::TFS_SUCCESS == ret)
          {
            std::map<uint64_t, std::vector<int32_t> >:: const_iterator iter =
              block_pairs_.begin();
            for (; iter != block_pairs_.end(); ++iter)
            {
              ret = output.set_int64(iter->first);
              if (common::TFS_SUCCESS != ret)
                break;
              ret = output.set_vint32(iter->second);
              if (common::TFS_SUCCESS != ret)
                break;
            }
          }
        }

        if (common::TFS_SUCCESS == ret
           && status_type_ & common::LB_INFOS)
        {
          ret = output.set_int32(block_infos_.size());
          if (common::TFS_SUCCESS == ret)
          {
            std::vector<common::BlockInfoV2>::const_iterator iter =
              block_infos_.begin();
            for (; iter != block_infos_.end(); ++iter)
            {
              int64_t pos = 0;
              ret = iter->serialize(output.get_free(), output.get_free_length(), pos);
              if (common::TFS_SUCCESS == ret)
                output.pour(iter->length());
              else
                break;
            }
          }
        }
      }
      return ret;
    }
Exemplo n.º 4
0
 int GetBlockInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(block_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_vint64(fail_server_);
   }
   return ret;
 }
Exemplo n.º 5
0
 int MasterAndSlaveHeartResponseMessage::serialize(common::Stream& output) const 
 {
   int64_t pos = 0;
   int32_t iret = ns_identity_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(ns_identity_.length());
     if (ns_identity_.flags_ == HEART_GET_DATASERVER_LIST_FLAGS_YES)
     {
       iret = output.set_vint64(ds_list_);
     }
   }
   return iret;
 }
Exemplo n.º 6
0
int NsRequestCompactBlockMessage::serialize(common::Stream& output) const
{
    int32_t ret = output.set_int32(block_id_);
    if (common::TFS_SUCCESS == ret)
    {
        ret = output.set_vint64(servers_);
    }
    if (common::TFS_SUCCESS == ret)
    {
        ret = output.set_int64(seqno_);
    }
    if (common::TFS_SUCCESS == ret)
    {
        ret = output.set_int32(expire_time_);
    }
    return ret;
}
Exemplo n.º 7
0
    int UnlinkFileMessage::serialize(common::Stream& output) const
    {
      if (has_lease())
      {
        dataservers_.push_back(ULONG_LONG_MAX);
        dataservers_.push_back(static_cast<uint64_t> (version_));
        dataservers_.push_back(static_cast<uint64_t> (lease_id_));
      }

      int64_t pos = 0;
      int32_t ret = unlink_file_info_.serialize(output.get_free(), output.get_free_length(), pos);
      if (common::TFS_SUCCESS == ret)
      {
        output.pour(unlink_file_info_.length());
      }
      if (common::TFS_SUCCESS == ret)
      {
        ret = output.set_vint64(dataservers_);
      }
      if (common::TFS_SUCCESS == ret)
      {
        ret = output.set_int32(option_flag_);
      }
      if (common::TFS_SUCCESS == ret)
      {
        BasePacket::parse_special_ds(dataservers_, version_, lease_id_);
      }
      if (common::TFS_SUCCESS == ret)
      {
        ret = output.set_int64(lease_id_ext_);
      }
      if (common::TFS_SUCCESS == ret)
      {
        if (common::INVALID_FAMILY_ID != family_info_.family_id_)
        {
          int64_t pos = 0;
          ret = family_info_.serialize(output.get_free(), output.get_free_length(), pos);
          if (common::TFS_SUCCESS == ret)
          {
            output.pour(family_info_.length());
          }
        }
      }
      return ret;
    }
Exemplo n.º 8
0
 int SetBlockInfoMessage::serialize(common::Stream& output)  const
 {
   if (has_lease()
     && !ds_.empty())
   {
     ds_.push_back(ULONG_LONG_MAX);
     ds_.push_back(static_cast<uint64_t> (version_));
     ds_.push_back(static_cast<uint64_t> (lease_id_));
   }
   int32_t iret = output.set_int32(block_id_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_vint64(ds_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     // reparse, avoid push verion&lease again when clone twice;
     common::BasePacket::parse_special_ds(ds_, version_, lease_id_);
   }
   return iret;
 }
Exemplo n.º 9
0
 int CheckBlockResponseMessage::serialize(common::Stream& output) const
 {
   return output.set_vint64(blocks_);
 }