Exemple #1
0
int DsCommitCompactBlockCompleteToNsMessage::serialize(common::Stream& output) const
{
    int32_t ret = output.set_int64(seqno_);
    if (common::TFS_SUCCESS == ret)
    {
        int64_t pos = 0;
        ret = block_info_.serialize(output.get_free(), output.get_free_length(), pos);
    }
    if (common::TFS_SUCCESS == ret)
    {
        output.pour(block_info_.length());
        ret = output.set_int8(result_.size());
    }
    if (common::TFS_SUCCESS == ret)
    {
        std::vector<std::pair<uint64_t, int8_t> >::const_iterator iter = result_.begin();
        for (; iter != result_.end() && common::TFS_SUCCESS == ret; ++iter)
        {
            ret = output.set_int64(iter->first);
            if (common::TFS_SUCCESS == ret)
            {
                ret = output.set_int8(iter->second);
            }
        }
    }
    return ret;
}
 int ECMarshallingMessage::serialize(common::Stream& output) const
 {
   const int32_t MEMBER_NUM = GET_DATA_MEMBER_NUM(family_aid_info_) + GET_CHECK_MEMBER_NUM(family_aid_info_);
   int32_t ret = output.set_int64(family_id_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(seqno_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(expire_time_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = (NULL != family_members_ && MEMBER_NUM > 0 && MEMBER_NUM <= MAX_MARSHALLING_NUM) ? common::TFS_SUCCESS : common::EXIT_PARAMETER_ERROR;
     if (TFS_SUCCESS == ret)
     {
       ret = output.set_int32(family_aid_info_);
     }
   }
   if (common::TFS_SUCCESS == ret)
   {
     for (int32_t index = 0; index < MEMBER_NUM && TFS_SUCCESS == ret; ++index)
     {
       int64_t pos = 0;
       ret = family_members_[index].serialize(output.get_free(), output.get_free_length() , pos);
       if (TFS_SUCCESS == ret)
         output.pour(family_members_[index].length());
     }
   }
  return ret;
 }
 int GetTableFromRtsResponseMessage::serialize(common::Stream& output) const 
 {
   int32_t iret = output.set_int64(version_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_int64(length_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_bytes(tables_, length_);
   }
   return iret;
 }
Exemple #4
0
 int BlockWriteCompleteMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = block_info_.block_id_ <= 0 ? common::TFS_ERROR : common::TFS_SUCCESS;
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(server_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     int64_t pos = 0;
     ret = block_info_.serialize(output.get_free(), output.get_free_length(), pos);
     if (common::TFS_SUCCESS == ret)
     {
       output.pour(block_info_.length());
     }
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(lease_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(write_complete_status_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(unlink_flag_);
   }
   return ret;
 }
Exemple #5
0
 int GetFamilyInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(family_id_);
   }
   return ret;
 }
Exemple #6
0
 int RemoveBlockResponseMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(block_id_);
   if (common::TFS_SUCCESS == ret)
   {
     output.set_int64(seqno_);
   }
   return ret;
 }
Exemple #7
0
 int GetFamilyInfoResponseMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int64(family_id_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(family_aid_info_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     const int32_t MEMBER_NUM = GET_DATA_MEMBER_NUM(family_aid_info_) + GET_CHECK_MEMBER_NUM(family_aid_info_);
     for (int32_t index = 0; index < MEMBER_NUM; ++index)
       {
         ret = output.set_int64(members_[index].first);
         if (common::TFS_SUCCESS == ret)
           ret = output.set_int64(members_[index].second);
       }
   }
   return ret;
 }
Exemple #8
0
 int WriteDataResponseMessage::serialize(common::Stream& output) const
 {
   int32_t ret = output.set_int64(server_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(offset_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(status_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     int64_t pos = 0;
     ret = info_.serialize(output.get_free(), output.get_free_length(), pos);
     if (common::TFS_SUCCESS == ret)
       output.pour(info_.length());
   }
   return ret;
 }
Exemple #9
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;
    }
Exemple #10
0
 int ReportCheckBlockResponseMessage::serialize(common::Stream& output) const
 {
   int ret = output.set_int64(server_id_);
   if (TFS_SUCCESS == ret)
   {
     ret = output.set_int64(seqno_);
   }
   if (TFS_SUCCESS == ret)
   {
     ret = output.set_int32(result_.size());
   }
   for (uint32_t index = 0; index < result_.size() && TFS_SUCCESS == ret; index++)
   {
     int64_t pos = 0;
     ret = result_[index].serialize(output.get_free(), output.get_free_length(), pos);
     if (TFS_SUCCESS == ret)
     {
       output.pour(result_[index].length());
     }
   }
   return ret;
 }
Exemple #11
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;
}
Exemple #12
0
 int RemoveBlockMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(0);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     output.set_int8(response_flag_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(seqno_);
   }
   return ret;
 }
Exemple #13
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;
    }
Exemple #14
0
 int MasterAndSlaveHeartMessage::serialize(common::Stream& output) const
 {
   int64_t pos = 0;
   int32_t ret = ns_identity_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == ret)
   {
     output.pour(ns_identity_.length());
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(lease_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int8(keepalive_type_);
   }
   return ret;
 }
Exemple #15
0
 int UpdateBlockInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(block_id_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(server_id_);
   }
   int32_t have_block = block_info_.block_id_ > 0 ? 1 : 0;
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(have_block);
   }
   int64_t pos = 0;
   if (common::TFS_SUCCESS == ret
     && have_block)
   {
     ret = block_info_.serialize(output.get_free(), output.get_free_length(), pos);
     if (common::TFS_SUCCESS == ret)
     {
       output.pour(block_info_.length());
     }
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(repair_);
   }
   int32_t have_sdbm = db_stat_.item_count_ > 0 ? 0 : 1;
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(have_sdbm);
   }
   if (common::TFS_SUCCESS == ret
     && have_sdbm)
   {
     pos = 0;
     ret = db_stat_.serialize(output.get_free(), output.get_free_length(), pos);
     if (common::TFS_SUCCESS == ret)
     {
       output.pour(db_stat_.length());
     }
   }
   return ret;
 }
Exemple #16
0
    int WriteRawIndexMessage::serialize(common::Stream& output) const
    {
      int32_t iret = output.set_int32(block_id_);

      if (common::TFS_SUCCESS == iret)
      {
        iret = output.set_int64(family_id_);
      }

      if (common::TFS_SUCCESS == iret)
      {
        iret = output.set_int32(index_op_);
      }

      if (common::TFS_SUCCESS == iret)
      {
        iret = output.set_int32(index_vec_.size());
      }

      for (uint32_t i = 0; i < index_vec_.size() && common::TFS_SUCCESS == iret; i++)
      {
        if (common::TFS_SUCCESS == iret)
        {
          iret = output.set_int32(index_vec_[i].block_id_);
        }

        if (common::TFS_SUCCESS == iret)
        {
          iret = output.set_int32(index_vec_[i].size_);
        }

        if (common::TFS_SUCCESS == iret && index_vec_[i].size_ > 0)
        {
          iret = output.set_bytes(index_vec_[i].data_, index_vec_[i].size_);
        }
      }

      return iret;
    }
Exemple #17
0
 int MasterAndSlaveHeartResponseMessage::serialize(common::Stream& output) const
 {
   int64_t pos = 0;
   int32_t ret = ns_identity_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == ret)
   {
     output.pour(ns_identity_.length());
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(lease_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(lease_expired_time_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(renew_lease_interval_time_);
   }
   return ret;
 }
 int ResolveBlockVersionConflictMessage::serialize(common::Stream& output) const
 {
   int32_t ret = output.set_int32(block_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(members_.size());
   }
   if (common::TFS_SUCCESS == ret)
   {
     std::vector<std::pair<uint64_t, common::BlockInfo> >::const_iterator iter = members_.begin();
     for (; iter != members_.end() && common::TFS_SUCCESS == ret; ++iter)
     {
       ret = output.set_int64(iter->first);
       if (common::TFS_SUCCESS == ret)
       {
         int64_t pos = 0;
         ret = iter->second.serialize(output.get_free(), output.get_free_length(), pos);
         if (common::TFS_SUCCESS == ret)
           output.pour(iter->second.length());
       }
     }
   }
   return ret;
 }