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


C++ ObServer类代码示例

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


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

示例1: get_ms

int ObSchemaServiceMsProvider::get_ms(const ObScanParam &scan_param, const int64_t retry_num, ObServer &ms)
{
  int ret = OB_SUCCESS;
  UNUSED(scan_param);
  if (0 < retry_num
      && 0 != ms.get_port()
      && 0 != ms.get_ipv4())
  {
    update_ms_retry(ms);
  }
  if (did_need_reset())
  {
    if (OB_SUCCESS != (ret = reset()))
    {
      TBSYS_LOG(WARN, "failed to init schema service ms provider, err=%d", ret);
    }
  }
  if (OB_SUCCESS == ret)
  {
    if (retry_num >= count_)
    {
      TBSYS_LOG(DEBUG, "no more ms for scan, retry=%ld count=%ld", retry_num, count_);
      ret = OB_MS_ITER_END;
    }
    else
    {
      tbsys::CRLockGuard guard(rwlock_);
      ms = ms_carray_[retry_num].ms_;
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:32,代码来源:ob_schema_service_ms_provider.cpp

示例2: do_post_packet

     /**
     * post_packet is async version of send_packet. donot wait for response packet.
     */
    int ObClientManager::do_post_packet(const ObServer& server, ObPacket* packet,
        tbnet::IPacketHandler* handler, void* args) const
    {
      int rc = OB_SUCCESS;
      if (NULL == packet) 
      {
        rc = OB_INVALID_ARGUMENT;
      }
      else if (!inited_) 
      {
        rc = OB_NOT_INIT;
        TBSYS_LOG(ERROR, "cannot post packet, ClientManager not initialized.");
        packet->free();
      }
      else
      {
        bool send_ok = connmgr_->sendPacket(server.get_ipv4_server_id(), packet, handler, args);
        if (!send_ok)
        {
          rc = OB_PACKET_NOT_SENT;
          TBSYS_LOG(WARN, "cannot post packet, maybe send queue is full or disconnect.dest_server:%s",
              server.to_cstring());
          packet->free();
        }
      } 

      return rc;
    }
开发者ID:Abioy,项目名称:oceanbase,代码行数:31,代码来源:ob_client_manager.cpp

示例3: TEST_F

TEST_F(TestTabletLocationItem, test_serialize)
{
  ObMergerTabletLocation server;
  ObMergerTabletLocationList list;
  list.set_timestamp(1000); 
  ObTabletLocation temp_server;
  ObServer chunkserver;
  for (int32_t i = 0; i < ObMergerTabletLocationList::MAX_REPLICA_COUNT; ++i)
  {
    chunkserver.set_ipv4_addr(i + 300000, i + 1024);
    temp_server.tablet_version_ = i;
    temp_server.chunkserver_ = chunkserver;
    EXPECT_TRUE(OB_SUCCESS == list.add(temp_server));
    EXPECT_TRUE(i + 1 == list.size());
  }
  
  list.print_info();
  int64_t size = list.get_serialize_size();
  EXPECT_TRUE(size != 0);
  
  char * temp = new char[size];
  EXPECT_TRUE(NULL != temp);
  int64_t pos = 0;
  EXPECT_TRUE(OB_SUCCESS != list.serialize(temp, size - 1 , pos));
  pos = 0;
  EXPECT_TRUE(OB_SUCCESS == list.serialize(temp, size, pos));
  EXPECT_TRUE(pos == size);
  
  ObMergerTabletLocationList list2;
  pos = 0;
  EXPECT_TRUE(OB_SUCCESS == list2.deserialize(temp, size, pos));
  list2.print_info();
  list.print_info();
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:34,代码来源:test_merger_tablet_location_item.cpp

示例4: guard

int ObSchemaServiceMsProvider::reset()
{
  int ret = OB_SUCCESS;
  tbsys::CWLockGuard guard(rwlock_);
  count_ = 0;
  ObChunkServerManager::const_iterator it;
  for (it = server_manager_.begin();
       server_manager_.end() != it && count_ < MAX_SERVER_COUNT;
       ++it)
  {
    if (ObServerStatus::STATUS_DEAD != it->ms_status_)
    {
      ObServer ms = it->server_;
      ms.set_port(it->port_ms_);
      ms_carray_[count_].ms_ = ms;
      ms_carray_[count_].retry_count_ = 0;
      ++count_;
      TBSYS_LOG(DEBUG, "schema service ms provider found count_=%ld, ms=%s", count_, to_cstring(ms));
    }
  } // end for
  // shuffle the server list after reset
  if (count_ > 0)
  {
    // std::random_shuffle(ms_carray_, ms_carray_ + count_);
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:27,代码来源:ob_schema_service_ms_provider.cpp

示例5: out_buffer

int MockRootServer::handle_get_updater(ObPacket * ob_packet)
{
  int ret = OB_SUCCESS;
  ObDataBuffer* data = ob_packet->get_buffer();
  if (NULL == data)
  {
    ret = OB_ERROR;
  }
  
  tbnet::Connection* connection = ob_packet->get_connection();
  ThreadSpecificBuffer::Buffer* thread_buffer = response_packet_buffer_.get_buffer();
  if (NULL == thread_buffer)
  {
    ret = OB_ERROR;
  }
  else
  {
    thread_buffer->reset();
    ObDataBuffer out_buffer(thread_buffer->current(), thread_buffer->remain());
    
    ObResultCode result_msg;
    result_msg.result_code_ = ret;
    ret = result_msg.serialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
    
    // new version
    int32_t channel_id = ob_packet->getChannelId();
    ObServer server;
    server.set_ipv4_addr("localhost", MockUpdateServer::UPDATE_SERVER_PORT); 
    ret = server.serialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
    ret = send_response(OB_REPORT_TABLETS_RESPONSE, 1, out_buffer, connection, channel_id);
  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:33,代码来源:mock_root_server.cpp

示例6: rs_dump_cs_info

int ObClientServerStub::get_cs_and_ms()
{
  int                   ret = OB_SUCCESS;
  ObChunkServerManager  obcsm;
  ObChunkServerManager::const_iterator it;
  ObServer              server;
  
  ret = rs_dump_cs_info(obcsm);
  if (OB_SUCCESS != ret)
  {
    fprintf(stderr, "Get chunk server manager error!\n");
    return ret;
  }

  for (it = obcsm.begin(); it != obcsm.end(); ++it)
  {
    ObServer node;
    node = it->server_;
    node.set_port(it->port_cs_);
    chunk_server_list_.push_back(node);
    node.set_port(it->port_ms_);
    merge_server_list_.push_back(node);
  }

  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:26,代码来源:client_rpc.cpp

示例7: TBSYS_LOG

int ObScanHelperImpl::mutate(ObMutator& mutator)
{
  int ret = OB_SUCCESS;
  if (!check_inner_stat())
  {
    ret = OB_NOT_INIT;
    TBSYS_LOG(ERROR, "scan help not init");
  }
  else
  {
    ObServer ups;
    if (OB_SUCCESS != (ret = ups_provider_->get_ups(ups)))
    {
      TBSYS_LOG(WARN, "failed to get ups, err=%d", ret);
    }
    else if (0 == ups.get_port() || 0 == ups.get_ipv4())
    {
      ret = OB_INVALID_ARGUMENT;
      TBSYS_LOG(WARN, "invalid update server address");
    }
    else if (OB_SUCCESS != (ret = rpc_stub_->mutate(ups, mutator, mutate_timeout_us_)))
    {
      TBSYS_LOG(WARN, "failed to mutate, mutate_timeout_us_=%ld, ups=%s, err=%d",
          mutate_timeout_us_, to_cstring(ups), ret);
    }
    else
    {
      TBSYS_LOG(DEBUG, "ups mutate succ, ups=%s", to_cstring(ups));
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:32,代码来源:ob_scan_helper_impl.cpp

示例8: 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

示例9: 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

示例10: main

int main(int argc, char* argv[])
{
  ObServer cs;
  cs.set_ipv4_addr("localhost", 3500);

  BaseClient client;
  client.initialize();
  
  ObServer root;
  root.set_ipv4_addr("10.232.35.40", 2500);

  ThreadSpecificBuffer buffer;
  ObRootServerRpcStub server;
  
  do
  {
    int ret = server.init(root, client.get_rpc());
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "init failed");
      break;
    } 

    int64_t timeout = 2000;
    int64_t timestamp = 0;
    // heartbeat 
    ret = server.renew_heartbeat(timeout, cs, timestamp); 
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "renew heartbeat failed:ret[%d]", ret);
      break;
    }
    else
    {
      printf("get new lease time[%ld]\n", timestamp);
    }

    sleep(1);
    
    // fetch schema
    timestamp = 1282900503726484;
    ObSchemaManager schema;
    ret = server.fetch_schema(timeout, timestamp, schema);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "fetch schema failed:ret[%d]", ret);
      break;
    }
    else
    {
      printf("fetch schema succ:appname[%s]\n", schema.get_app_name());
      schema.print_info();
    }
  } while(0);
  client.destory();
  return 0;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:57,代码来源:test_root_rpc_client.cpp

示例11:

MockNodeServer::MockNodeServer(int32_t port, int64_t retry_time, int64_t timeout, ObServer monitor, char* app_name, char* instance_name, char* hostname)
{
  port_ = port;
  retry_times_ = retry_time;
  timeout_ = timeout;
  monitor_.set_ipv4_addr(monitor.get_ipv4(), monitor.get_port());

  app_name_ = app_name;
  instance_name_ = instance_name;
  hostname_ = hostname;
  status_ = UNKNOWN;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:12,代码来源:mock_node_server.cpp

示例12: ObServerStats

 ObAppStats::ObAppStats(ObClientRpcStub &stub, const ObRole server_type, const char* config_file_name)
   : ObServerStats(stub, server_type)
 {
   root_server_array_.init(MAX_SERVER_NUM, root_servers_, 0);
   tbsys::CConfig config;
   if(config.load(config_file_name))
   {
     fprintf(stderr, "load file %s error\n", config_file_name);
   }
   else
   {
     master_index_ = -1;
     int count = config.getInt(SERVER_SECTION, "cluster_count", 0);
     if (count <= 0)
     {
       fprintf(stderr, "cluster_count %d cannot < 0\n", count);
     }
     else
     {
       const int MAX_LEN = 64;
       char ipname[MAX_LEN];
       char portname[MAX_LEN];
       char ip[MAX_LEN];
       char mastername[MAX_LEN];
       int32_t port = 0;
       int is_master = 0;
       ObServer server;
       for (int i = 0; i < count ; ++i)
       {
         snprintf(ipname, MAX_LEN, "rs%d_ip", i);
         snprintf(portname, MAX_LEN, "rs%d_port", i);
         snprintf(mastername, MAX_LEN, "rs%d_is_master", i);
         if (OB_SUCCESS != load_string(config, ip, MAX_LEN, SERVER_SECTION, ipname, true))
         {
           fprintf(stderr, "%s is null\n", ipname);
           break;
         }
         port = config.getInt(SERVER_SECTION, portname, 0);
         if (port <= 0)
         {
           fprintf(stderr, "%s is 0\n", portname);
           break;
         }
         is_master = config.getInt(SERVER_SECTION, mastername, 0);
         if (is_master > 0) master_index_ = i;
         server.set_ipv4_addr(ip, port);
         root_server_array_.push_back(server);
       }
     }
   }
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:51,代码来源:ob_cluster_stats.cpp

示例13: fetch_update_server

int ObMergerRpcStub::fetch_update_server(
    const int64_t timeout, const ObServer & root_server,
    ObServer & update_server, bool for_merge) const
{
    int ret = OB_SUCCESS;
    ObDataBuffer data_buff;
    ret = get_rpc_buffer(data_buff);
    // step 1. send get update server info request
    if (OB_SUCCESS == ret)
    {
        ret = rpc_frame_->send_request(root_server,
                                       for_merge ? OB_GET_UPDATE_SERVER_INFO_FOR_MERGE : OB_GET_UPDATE_SERVER_INFO,
                                       DEFAULT_VERSION, timeout, data_buff);
        if (ret != OB_SUCCESS)
        {
            TBSYS_LOG(WARN, "send request to root server for find update server failed:ret[%d]", ret);
        }
    }

    // step 2. deserialize restult code
    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_code failed:pos[%ld], ret[%d]", pos, ret);
        }
        else
        {
            ret = result_code.result_code_;
        }
    }

    // step 3. deserialize update server addr
    if (OB_SUCCESS == ret)
    {
        ret = update_server.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
        if (ret != OB_SUCCESS)
        {
            TBSYS_LOG(WARN, "deserialize server failed:pos[%ld], ret[%d]", pos, ret);
        }
        else
        {
            TBSYS_LOG(DEBUG, "find update server succ:addr[%d], port[%d]", update_server.get_ipv4(),
                      update_server.get_port());
        }
    }
    return ret;
}
开发者ID:wjhh2008,项目名称:oceanbase,代码行数:51,代码来源:ob_rpc_stub.cpp

示例14: send_freeze_memtable_resp

    int ObUpsRpcStub :: send_freeze_memtable_resp(const ObServer& root_server,
        const ObServer& ups_master, const int64_t schema_timestamp, const int64_t timeout_us)
    {
      int err = OB_SUCCESS;
      ObDataBuffer data_buff;
      ObServer update_server;

      if (NULL == client_mgr_)
      {
        TBSYS_LOG(WARN, "invalid status, client_mgr_[%p]", client_mgr_);
        err = OB_ERROR;
      }
      else
      {
        err = get_thread_buffer_(data_buff);
      }

      // serialize ups_master
      if (OB_SUCCESS == err)
      {
        err = ups_master.serialize(data_buff.get_data(), data_buff.get_capacity(),
            data_buff.get_position());
      }

      // serialize timestamp
      if (OB_SUCCESS == err)
      {
        err = common::serialization::encode_vi64(data_buff.get_data(), 
            data_buff.get_capacity(), data_buff.get_position(), schema_timestamp);
      }

      // step 1. send freeze memtable resp
      if (OB_SUCCESS == err)
      {
        err = client_mgr_->send_request(root_server, 
            OB_WAITING_JOB_DONE, DEFAULT_VERSION, timeout_us, data_buff);
        if (err != OB_SUCCESS)
        {
          TBSYS_LOG(ERROR, "send freeze memtable failed, err[%d].", err);
        }
      }

      // step 2. deserialize the response code
      int64_t pos = 0;
      if (OB_SUCCESS == err)
      {
        ObResultCode result_code;
        err = result_code.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
        if (OB_SUCCESS != err)
        {
          TBSYS_LOG(ERROR, "deserialize result_code failed:pos[%ld], err[%d].", pos, err);
        }
        else
        {
          err = result_code.result_code_;
        }
      }

      return err;
    }
开发者ID:CCoder123,项目名称:pproj,代码行数:60,代码来源:ob_ups_rpc_stub.cpp

示例15: async_heartbeat

int ObRootServerRpcStub::async_heartbeat(const ObServer & client)
{
  int ret = OB_SUCCESS;
  ObDataBuffer data_buff;
  ret = get_frame_buffer(data_buff);

  // step 1. serialize client server addr to data_buff
  if (OB_SUCCESS == ret)
  {
    ret = client.serialize(data_buff.get_data(), 
        data_buff.get_capacity(), data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize client server addr failed:ret[%d].", ret);
    }
  }

  // step 2. rpc frame send request and receive the response
  if (OB_SUCCESS == ret)
  {
    ret = rpc_frame_->post_request(root_server_, 
        OB_HEARTBEAT, DEFAULT_VERSION, data_buff);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "post request to root server "
          "for heartbeat failed:ret[%d].", ret);
    }
  }

  // step 3. dont care server's response packet.
  return ret;
}
开发者ID:CCoder123,项目名称:pproj,代码行数:32,代码来源:ob_root_server_rpc.cpp


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