Пример #1
0
int cmd_remove_block(const VSTRING& param)
{
  uint32_t flag = 0;
  uint32_t block_id = atoi(param[0].c_str());
  uint64_t server_id = 0;
  if (param.empty())
  {
    fprintf(stderr, "invalid parameter, param.empty\n");
    return TFS_ERROR;
  }
  if (param.size() == 1)
  {
    flag = 1;
  }
  else if (param.size() == 2 )
  {
    if (param[1].length() == 1)
      flag = atoi(param[1].c_str());
    else
    {
      server_id = Func::get_host_ip(param[1].c_str());
      if (0 == server_id)
      {
        fprintf(stderr, "invalid addr %s\n", param[1].c_str());
        return TFS_ERROR;
      }
    }
  }
  if (0 == block_id)
  {
    fprintf(stderr, "invalid blockid %s\n", param[0].c_str());
    return TFS_ERROR;
  }

  ClientCmdMessage req_cc_msg;
  req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
  req_cc_msg.set_value1(server_id);
  req_cc_msg.set_value3(block_id);
  req_cc_msg.set_value4(flag);

  int32_t status = TFS_ERROR;

  send_msg_to_server(g_tfs_client->get_server_id(), &req_cc_msg, status);

  if (param.size() == 1)
    ToolUtil::print_info(status, "removeblock %s", param[0].c_str());
  else if (param.size() == 2)
    ToolUtil::print_info(status, "removeblock %s %s", param[0].c_str(), param[1].c_str());
  return status;
}
Пример #2
0
int cmd_remove_family(const VSTRING& param)
{
  if (param.empty())
  {
    fprintf(stderr, "invalid parameter, param.empty\n");
    return TFS_ERROR;
  }
  int64_t family_id = strtoull(param[0].c_str(), NULL, 10);
  if (family_id <= 0)
  {
    fprintf(stderr, "invalid familyid %s\n", param[0].c_str());
    return TFS_ERROR;
  }

  ClientCmdMessage req_cc_msg;
  req_cc_msg.set_cmd(CLIENT_CMD_DELETE_FAMILY);
  req_cc_msg.set_value3(family_id);

  int32_t status = TFS_ERROR;
  send_msg_to_server(g_tfs_client->get_server_id(), &req_cc_msg, status);

  ToolUtil::print_info(status, "remove family %s, ret: %d", param[0].c_str(), status);
  return status;
}
Пример #3
0
int cmd_remove_block(const VSTRING& param)
{
  uint32_t flag = 0;
  if (param.empty())
  {
    fprintf(stderr, "invalid parameter, param.empty\n");
    return TFS_ERROR;
  }
  uint64_t block_id = strtoull(param[0].c_str(), NULL, 10);
  if (0 == block_id)
  {
    fprintf(stderr, "invalid blockid %s\n", param[0].c_str());
    return TFS_ERROR;
  }
  uint64_t server_id = 0;
  if (param.size() == 1)
  {
    flag = 1;//default
  }
  else if (param.size() == 2)
  {
    if (param[1].length() == 1)
    {
      flag = atoi(param[1].c_str());
      if (1 != flag && 2 != flag && 4 != flag)
      {
        fprintf(stderr, "removeblock's flag parameter invalid\n");
        return TFS_ERROR;
      }
    }
    else//ds_ip:port
    {
      //flag = 8;//HANDLE_DELETE_BLOCK_FLAG_ONLY_ONE_RELATION
      server_id = Func::get_host_ip(param[1].c_str());
      if (0 == server_id)
      {
        fprintf(stderr, "invalid addr %s\n", param[1].c_str());
        return TFS_ERROR;
      }
    }
  }
  else
  {
    fprintf(stderr, "removeblock's parameter invalid\n");
    return TFS_ERROR;
  }

  ClientCmdMessage req_cc_msg;
  req_cc_msg.set_cmd(CLIENT_CMD_EXPBLK);
  req_cc_msg.set_value1(server_id);
  req_cc_msg.set_value3(block_id);
  req_cc_msg.set_value4(flag);

  int32_t status = TFS_ERROR;
  send_msg_to_server(g_tfs_client->get_server_id(), &req_cc_msg, status);

  if (STATUS_MESSAGE_OK == status)
    status = TFS_SUCCESS;
  else
    status = TFS_ERROR;

  if (1 == flag || 2 == flag || 4 == flag)
    ToolUtil::print_info(status, "removeblock: %s", param[0].c_str());
  else//flag=8,ds_ip:port
    ToolUtil::print_info(status, "removeblock: %s from ds:%s", param[0].c_str(), param[1].c_str());
  return status;
}