当前位置: 首页>>代码示例>>C++>>正文


C++ ObServer::to_string方法代码示例

本文整理汇总了C++中ObServer::to_string方法的典型用法代码示例。如果您正苦于以下问题:C++ ObServer::to_string方法的具体用法?C++ ObServer::to_string怎么用?C++ ObServer::to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObServer的用法示例。


在下文中一共展示了ObServer::to_string方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sum_cluster_stats

    int ObAppStats::sum_cluster_stats(const ObRole server_type, const common::ObArrayHelper<common::ObServer>& server_array)
    {
      ObStatManager node_stats;
      node_stats.set_server_type(server_type);
      char addr_string[MAX_SERVER_NUM];
      int ret = OB_SUCCESS;

      for (int i = 0; i < server_array.get_array_index(); i++)
      {
        ObServer addr = *server_array.at(i);
        addr.to_string(addr_string, MAX_SERVER_NUM);
        ObClientRpcStub remote_stub;
        if (OB_SUCCESS != (ret = remote_stub.initialize(addr,
                &GFactory::get_instance().get_base_client().get_client_mgr())))
        {
          fprintf(stderr, "initialize server stub error\n");
          break;
        }
        else if (OB_SUCCESS != (ret = remote_stub.fetch_stats(node_stats)))
        {
          fprintf(stderr, "fetch server (%s) stats error\n", addr_string);
          break;
        }
        if (store_.current.begin(mod_) == store_.current.end(mod_))
          store_.current = node_stats;
        else
          store_.current.add(node_stats);
      }

      return ret;
    }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:31,代码来源:ob_cluster_stats.cpp

示例2: get_clog_master

void get_clog_master(MockClient &client)
{
  ObServer server;
  int err = client.get_clog_master(server, timeout);
  char addr[256];
  fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
  server.to_string(addr, sizeof(addr));
  fprintf(stdout, "%s\n", addr);
}
开发者ID:mrunix,项目名称:oceanbase,代码行数:9,代码来源:ups_admin.cpp

示例3: run

void BalanceTestRpc::run(tbsys::CThread *thread, void *arg)
{
  UNUSED(thread);
  UNUSED(arg);
  TBSYS_LOG(INFO, "balance test rpc thread begin");
  while(!_stop)
  {
    TBSYS_LOG(DEBUG, "balance test rpc thread running");
    MigrateMsg *msg = NULL;
    int ret = pop_migrate_msg(msg);
    if (OB_SUCCESS == ret)
    {
      assert(server_);
      if (blocked_cs_ == msg->src_cs_)
      {
        char addr_buf1[OB_IP_STR_BUFF];
        blocked_cs_.to_string(addr_buf1, OB_IP_STR_BUFF);
        TBSYS_LOG(DEBUG, "drop migrate msg, src_cs=%s", addr_buf1);
      }
      else if (blocked_dest_cs_ == msg->dest_cs_)
      {
        char addr_buf1[OB_IP_STR_BUFF];
        blocked_dest_cs_.to_string(addr_buf1, OB_IP_STR_BUFF);
        TBSYS_LOG(DEBUG, "drop migrate msg, dest_cs=%s", addr_buf1);
      }
      else
      {
        server_->migrate_over(msg->range_, msg->src_cs_, msg->dest_cs_, msg->keep_src_, 2);
      }
      delete_migrate_msg(msg);
    }
    else
    {
      usleep(500*1000);
    }
  }
  TBSYS_LOG(INFO, "balance test rpc thread finished");
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:38,代码来源:ob_new_balance_test.cpp

示例4: main

int main(int argc, char ** argv)
{
  UNUSED(argc);
  UNUSED(argv);
  int ret = OB_SUCCESS;
  //char * test = "00596331192663719";
  char * test = "00912219024438372";
  ObString rowkey;
  rowkey.assign(test, strlen(test));
  char temp[1024];
  hex_to_str(rowkey.ptr(), rowkey.length(), temp, 1024);
  printf("test2str:test[%s], str[%s]\n", test, temp);

  int64_t ip = 539289610; //488957962; //522512394;
  ObServer server;
  server.set_ipv4_addr(ip, 1024);
  static const int32_t MAX_SERVER_ADDR_SIZE = 128;
  char server_addr[MAX_SERVER_ADDR_SIZE];
  server.to_string(server_addr, MAX_SERVER_ADDR_SIZE);
  printf("server:[%ld], server[%s]\n", ip, server_addr);
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:22,代码来源:dump2str.cpp

示例5: refresh

    int32_t ObClusterStats::refresh()
    {
      int ret = 0;
      ObRole server_type = store_.diff.get_server_type();
      if (server_type == OB_ROOTSERVER)
      {
        ret = ObServerStats::refresh();
      }
      else if (server_type == OB_UPDATESERVER)
      {
        ObServer update_server;
        ret = rpc_stub_.get_update_server(update_server);
        ObClientRpcStub update_stub;
        if (OB_SUCCESS == ret)
        {
          ret = update_stub.initialize(update_server,
              &GFactory::get_instance().get_base_client().get_client_mgr());
        }
        if (OB_SUCCESS == ret)
        {
          ret = update_stub.fetch_stats(store_.current);
        }
      }
      else if (server_type == OB_CHUNKSERVER
          || server_type == OB_MERGESERVER)
      {
        ObChunkServerManager obsm;
        ret = rpc_stub_.rs_dump_cs_info(obsm);
        if (OB_SUCCESS == ret)
        {
          ObChunkServerManager::const_iterator it = obsm.begin();
          ObServer node;
          char ipstr[OB_MAX_SERVER_ADDR_SIZE];
          int alive_server_count = 0;
          while (it != obsm.end())
          {
            node = it->server_;
            if (server_type == OB_CHUNKSERVER)
              node.set_port(it->port_cs_);
            else
              node.set_port(it->port_ms_);

            node.to_string(ipstr, OB_MAX_SERVER_ADDR_SIZE);
            /*
            fprintf(stderr, "dump server ip:%s, server status:%ld, serving:%d\n",
                ipstr, it->status_, ObServerStatus::STATUS_SERVING);
                */

            if (it->status_ != ObServerStatus::STATUS_DEAD)
            {
              ObClientRpcStub node_stub;
              ObStatManager node_stats;
              node_stats.set_server_type(server_type);
              ret = node_stub.initialize( node, &GFactory::get_instance().get_base_client().get_client_mgr());
              if (OB_SUCCESS != ret) { ++it; continue ;}
              ret = node_stub.fetch_stats(node_stats);
              //printf("ret=%d, node_stats:%lu\n", ret, node_stats.get_server_type());
              if (OB_SUCCESS != ret) { ++it; continue ;}
              if (alive_server_count == 0)
                store_.current = node_stats;
              else
                store_.current.add(node_stats);
              ++alive_server_count;
            }
            ++it;
          }

          if (0 == alive_server_count)
          {
            fprintf(stderr, "no any alive servers, cannot collect data.\n");
          }

        }

      }
      return ret;
    }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:77,代码来源:ob_cluster_stats.cpp

示例6: get_tablet_info


//.........这里部分代码省略.........
  {
    param.set(OB_INVALID_ID,table_name,range); //use table name
    param.set_is_read_consistency(false);
  }

  if ((OB_SUCCESS == ret) && ((ret = scan(root_server_,timeout,param,scanner)) != OB_SUCCESS) )
  {
    TBSYS_LOG(ERROR,"get tablet from rootserver failed:[%d]",ret);
  }
  
  ObServer server;
  char tmp_buf[32];
  ObString start_key;
  ObString end_key; 
  ObCellInfo * cell = NULL;
  ObScannerIterator iter; 
  bool row_change = false;
   
  if (OB_SUCCESS == ret) 
  { 
    int64_t ip = 0;
    int64_t port = 0;
    int64_t version = 0;
    iter = scanner.begin();
    ret = iter.get_cell(&cell, &row_change);
    row_change = false;

    while((OB_SUCCESS == ret) && index < size)
    {
      if (ret != OB_SUCCESS)
      {
        TBSYS_LOG(ERROR, "get cell from scanner iterator failed:ret[%d]", ret);
      }
      else if (row_change)
      {
        TBSYS_LOG(DEBUG,"row changed,ignore"); 
        hex_dump(cell->row_key_.ptr(),cell->row_key_.length(),false,TBSYS_LOG_LEVEL_INFO);
        break; //just get one row        
      } 
      else if (cell != NULL)
      {
        end_key.assign(cell->row_key_.ptr(), cell->row_key_.length());
        if ((cell->column_name_.compare("1_port") == 0) 
            || (cell->column_name_.compare("2_port") == 0) 
            || (cell->column_name_.compare("3_port") == 0))
        {
          ret = cell->value_.get_int(port);
          TBSYS_LOG(DEBUG,"port is %ld",port);
        }
        else if ((cell->column_name_.compare("1_ipv4") == 0)
            || (cell->column_name_.compare("2_ipv4") == 0)
            || (cell->column_name_.compare("3_ipv4") == 0))
        {
          ret = cell->value_.get_int(ip);
          TBSYS_LOG(DEBUG,"ip is %ld",ip);
        }
        else if (cell->column_name_.compare("1_tablet_version") == 0 ||
            cell->column_name_.compare("2_tablet_version") == 0 ||
            cell->column_name_.compare("3_tablet_version") == 0)
        {
          ret = cell->value_.get_int(version);
          hex_dump(cell->row_key_.ptr(),cell->row_key_.length(),false,TBSYS_LOG_LEVEL_INFO);
          TBSYS_LOG(DEBUG,"tablet_version is %d",version);
        }

        if (OB_SUCCESS == ret)
        {
          if (0 != port && 0 != ip && 0 != version)
          {
            server.set_ipv4_addr(ip, port);
            server.to_string(tmp_buf,sizeof(tmp_buf));
            TBSYS_LOG(INFO,"add tablet s:%s,%ld",tmp_buf,version);
            ObTabletLocation addr(version, server);
            location[index++] = addr;
            ip = port = version = 0;
          }
        }
        else 
        {
          TBSYS_LOG(ERROR, "check get value failed:ret[%d]", ret);
        }

        if (++iter == scanner.end())
          break;
        ret = iter.get_cell(&cell, &row_change);
      }
      else
      {
        //impossible
      }
    }
  }

  if (OB_SUCCESS == ret)
  {
    size = index;
    TBSYS_LOG(INFO,"get %d tablets from rootserver",size);
  }
  return ret;
}
开发者ID:CCoder123,项目名称:pproj,代码行数:101,代码来源:ob_root_server_rpc.cpp

示例7: get_table_tablet


//.........这里部分代码省略.........
              ++count;
            }
            list.clear();
            start_key = end_key;
            end_key.assign(cell->row_key_.ptr(), cell->row_key_.length());
          }
          else
          {
            end_key.assign(cell->row_key_.ptr(), cell->row_key_.length());
            if ((cell->column_name_.compare("1_ms_port") == 0) 
                || (cell->column_name_.compare("2_ms_port") == 0) 
                || (cell->column_name_.compare("3_ms_port") == 0))
            {
              ret = cell->value_.get_int(port);
            }
            else if ((cell->column_name_.compare("1_ipv4") == 0)
                || (cell->column_name_.compare("2_ipv4") == 0)
                || (cell->column_name_.compare("3_ipv4") == 0))
            {
              ret = cell->value_.get_int(ip);
            }
            else if ((cell->column_name_.compare("1_tablet_version") == 0)
                || (cell->column_name_.compare("2_tablet_version") == 0)
                || (cell->column_name_.compare("3_tablet_version") == 0))
            {
              ret = cell->value_.get_int(version);
              if (OB_SUCCESS == ret)
              {
                if (0 == port || port == 0)
                {
                  TBSYS_LOG(WARN, "%s", "check port or ip failed");
                }
                else
                {
                  server.set_ipv4_addr(ip, port);
                  ObTabletLocation addr(version, server);
                  if (OB_SUCCESS != (ret = list.add(addr)))
                  {
                    TBSYS_LOG(ERROR, "add addr failed:server[%d], port[%d], ret[%d]", 
                        server.get_ipv4(), server.get_port(), ret);
                  }
                  else
                  {
                    server.to_string(server_addr, MAX_SERVER_ADDR_SIZE);
                    TBSYS_LOG(DEBUG, "add addr succ:server[%s], version:%ld", server_addr, version);
                  }
                }
                ip = port = version = 0;
              }

            }

            if (ret != OB_SUCCESS)
            {
              TBSYS_LOG(ERROR, "check get value failed:ret[%d]", ret);
              break;
            }
          }
        }

        // for the last row 
        if ((OB_SUCCESS == ret) && (start_key != end_key))
        {
          ret = init_new_task(name, start_key, end_key, scan_param, task);
          if (ret != OB_SUCCESS)
          {
            TBSYS_LOG(ERROR, "init new task failed:ret[%d]", ret);
          }
          else
          {
            ret = insert_new_task(list, task);
            if (ret != OB_SUCCESS)
            {
              TBSYS_LOG(ERROR, "insert new task failed:ret[%d]", ret);
            }
            ++count;
          }

          if (OB_SUCCESS == ret)
          {
            // modify last row key for next get root table
            uint64_t len = end_key.length();
            if (MAX_LEN > len + 1)
            {
              memcpy(last_tablet_rowkey, end_key.ptr(), len);
              last_tablet_rowkey[len] = 0;
              row_key.assign(last_tablet_rowkey, len + 1);
            }
            else
            {
              TBSYS_LOG(ERROR, "check end key failed:len[%lu]", len);
            }
          }
        }
        list.clear();
      }
    }
  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:101,代码来源:task_factory.cpp

示例8: scan

int ObMergerRpcStub::scan(
    const int64_t timeout, const ObServer & server,
    const ObScanParam & scan_param, ObScanner & scanner) const
{
    int ret = OB_SUCCESS;
    ObDataBuffer data_buff;
    int64_t start_time = tbsys::CTimeUtil::getTime();
    ret = get_rpc_buffer(data_buff);
    // step 1. serialize ObScanParam to the data_buff
    if (OB_SUCCESS == ret)
    {
        ret = scan_param.serialize(data_buff.get_data(), data_buff.get_capacity(),
                                   data_buff.get_position());
        if (OB_SUCCESS != ret)
        {
            TBSYS_LOG(WARN, "serialize scan param failed:ret[%d]", ret);
        }
    }
    // step 2. send request for scan data
    if (OB_SUCCESS == ret)
    {
        ret = rpc_frame_->send_request(server, OB_SCAN_REQUEST, DEFAULT_VERSION,
                                       timeout, data_buff);
        if (ret != OB_SUCCESS)
        {
            TBSYS_LOG(WARN, "send scan request to server failed:ret[%d], timeout=%ld",
                      ret, timeout);
        }
    }
    // step 3. deserialize the response result
    int64_t pos = 0;
    if (OB_SUCCESS == ret)
    {
        ObResultCode result_code;
        ret = result_code.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
        if (OB_SUCCESS != ret)
        {
            TBSYS_LOG(WARN, "deserialize result failed:pos[%ld], ret[%d]", pos, ret);
        }
        else
        {
            ret = result_code.result_code_;
        }
    }

    // step 4. deserialize the scanner
    if (OB_SUCCESS == ret)
    {
        ret = scanner.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
        if (OB_SUCCESS != ret)
        {
            TBSYS_LOG(WARN, "deserialize scanner from buff failed:pos[%ld], ret[%d]", pos, ret);
        }
    }

    // write debug log
    const int32_t MAX_SERVER_ADDR_SIZE = 128;
    char server_addr[MAX_SERVER_ADDR_SIZE];
    server.to_string(server_addr, MAX_SERVER_ADDR_SIZE);
    bool is_fullfilled = false;
    int64_t fullfilled_item_num = 0;
    scanner.get_is_req_fullfilled(is_fullfilled,fullfilled_item_num);
    if (OB_SUCCESS == ret)
    {
        TBSYS_LOG(DEBUG, "scan data succ from server:addr[%s]", server_addr);
    }
    else
    {
        TBSYS_LOG(WARN, "scan data failed from server:addr[%s], "
                  "version_range=%s, ret[%d]",
                  server_addr, range2str(scan_param.get_version_range()), ret);
    }

    int64_t consume_time = tbsys::CTimeUtil::getTime() - start_time;
    if ((double)consume_time > (double)timeout * 0.8)
    {
        TBSYS_LOG(WARN, "slow ups scan, ups_addr=%s, timeout=%ld, consume=%ld",
                  server.to_cstring(), timeout, consume_time);
    }
    return ret;
}
开发者ID:wjhh2008,项目名称:oceanbase,代码行数:81,代码来源:ob_rpc_stub.cpp


注:本文中的ObServer::to_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。