EXPECT_TRUE(agent_event == NULL && belong_to_this == true);


  /* 模拟收到已完成的sub task备份包 */
  agent_event = rpc_event2;
  /* 检查结果 */
  ret = scan_request.agent_event_finish(agent_event, belong_to_this);
  EXPECT_TRUE(ret == OB_SUCCESS);
  EXPECT_TRUE(belong_to_this == false);   /// rpc_event2已经收到过,重复包无效
} 




#if 0
  ObMergerTabletLocationCache cache;
  EXPECT_TRUE(cache.size() == 0);
  int ret = cache.clear();
  EXPECT_TRUE(ret != OB_SUCCESS);

  ret = cache.init(1000, 100, timeout);
  EXPECT_TRUE(ret == OB_SUCCESS);
  EXPECT_TRUE(cache.size() == 0);
  ret = cache.clear();
  EXPECT_TRUE(ret == OB_SUCCESS);
  
  char temp[100];
  char temp_end[100];
  uint64_t count = 0;
  // not more than 10 bit rows because of the string key
  const uint64_t START_ROW = 10L;
Exemplo n.º 2
0
TEST_F(TestObRpcScan, test_single_table_scan)
{
  /// 0. start packet handler thread
  CThread packet_hanlder_thread;
  packet_hanlder_thread.start(&handler, NULL);

  /// 1. setup transport
  /// 2. setup servers (root, ups, CSes)
  /// 3. setup scan request (location list, scan range)

  TBSYS_LOG(INFO, "( 1 )");
  tbnet::Transport * transport = new tbnet::Transport();
  tbnet::DefaultPacketStreamer * streamer = new tbnet::DefaultPacketStreamer();
  ObPacketFactory * factory = new ObPacketFactory();
  streamer->setPacketFactory(factory);
  ObClientManager client_manager;
  client_manager.initialize(transport, streamer);
  transport->start();
#if 0
  EXPECT_CALL(client_manager, post_request(_,_,_,_,_,_,_))
    .Times(AtLeast(1))
    .WillRepeatedly(Invoke(callback_func));
  EXPECT_CALL(client_manager, handlePacket(_,_))
    .Times(AtLeast(1))
    .WillOnce(Return(OB_SUCCESS))
    .WillOnce(Return((tbnet::IPacketHandler::HPRetCode)0));
#endif

  TBSYS_LOG(INFO, "( 2 )");
  ObServer update_server;
  ObServer root_server;
  ObServer merge_server;
  update_server.set_ipv4_addr(addr, MockUpdateServer::UPDATE_SERVER_PORT);
  root_server.set_ipv4_addr(addr, MockRootServer::ROOT_SERVER_PORT);
  ObMergerRpcProxy proxy(3, timeout, root_server, merge_server);

  ObMergerRpcStub stub;
  ThreadSpecificBuffer buffer;
  stub.init(&buffer, &client_manager);
  ObMergerRootRpcProxy rpc(0, timeout, root_server);
  EXPECT_TRUE(OB_SUCCESS == rpc.init(&stub));

  merge_server.set_ipv4_addr(addr, 10256);
  ObMergerTabletLocationCache * location = new ObMergerTabletLocationCache;
  location->init(50000 * 5, 1000, 100000);

  TBSYS_LOG(INFO, "( 3 )");
  // start root server
  MockRootServer root;
  tbsys::CThread root_server_thread;
  MockServerRunner test_root_server(root);
  root_server_thread.start(&test_root_server, NULL);

  /// (4) do it!
  MockObMergerAsyncRpcStub async;
  async.init(&buffer, &client_manager);
  ObMergerLocationCacheProxy location_proxy(root_server, &rpc, location);
  ObRpcScan scan;
  ObRowkeyInfo rowkey_info;
  ObRowkeyColumn column;
  column.length_ = 4;
  column.column_id_ = 102;
  column.type_ = ObIntType;
  rowkey_info.add_column(column);
#if 0
  ObSqlExpression p, p_end;
  ExprItem item_a, item_op, item_const;
  bool is_cond = false;
  /* 101 <= column <= 107 */
  item_a.type_ = T_REF_COLUMN;
  item_a.value_.cell_.tid = 123;
  item_a.value_.cell_.cid = 102;
  item_op.type_ = T_OP_LT;
  item_op.value_.int_ = 2;  /* 2 operands */
  item_const.type_ = T_INT;
  item_const.value_.int_ = 107;
  ASSERT_EQ(OB_SUCCESS, p.add_expr_item(item_a));
  ASSERT_EQ(OB_SUCCESS, p.add_expr_item(item_const));
  ASSERT_EQ(OB_SUCCESS, p.add_expr_item(item_op));
  ASSERT_EQ(OB_SUCCESS, p.add_expr_item_end());
  ASSERT_EQ(OB_SUCCESS, p.is_simple_condition(is_cond));
  ASSERT_EQ(true, is_cond);


  item_a.type_ = T_REF_COLUMN;
  item_a.value_.cell_.tid = 123;
  item_a.value_.cell_.cid = 102;
  item_op.type_ = T_OP_GE;
  item_op.value_.int_ = 2;  /* 2 operands */
  item_const.type_ = T_INT;
  item_const.value_.int_ = 101;
  ASSERT_EQ(OB_SUCCESS, p_end.add_expr_item(item_a));
  ASSERT_EQ(OB_SUCCESS, p_end.add_expr_item(item_const));
  ASSERT_EQ(OB_SUCCESS, p_end.add_expr_item(item_op));
  ASSERT_EQ(OB_SUCCESS, p_end.add_expr_item_end());
  ASSERT_EQ(OB_SUCCESS, p_end.is_simple_condition(is_cond));
  ASSERT_EQ(true, is_cond);

  scan.add_filter(p);
  scan.add_filter(p_end);
#endif
  scan.set_table(test::ObFakeTable::TABLE_ID);
  scan.set_rowkey_info(rowkey_info);
  scan.add_output_column(ExprGen::create_expr_by_id(1));

  EXPECT_CALL(async, scan(_,_,_,_))
    .Times(AtLeast(1))
    .WillRepeatedly(Invoke(callback_scan_async));

  EXPECT_CALL(async, get_session_next(_,_,_,_,_))
    .Times(AtLeast(1))
    .WillRepeatedly(Invoke(callback_session_async));




  ASSERT_TRUE(OB_SUCCESS == scan.init(&location_proxy, &async));
  ASSERT_TRUE(OB_SUCCESS == scan.open());

  const ObRow * cur_row = NULL;
  while(1)
  {
    int ret = OB_SUCCESS;

    TBSYS_LOG(INFO, "get_next_row() - begin");
    if (OB_ITER_END == (ret = scan.get_next_row(cur_row)))
    {
      TBSYS_LOG(INFO, "get_next_row() - iter_end");
      break;
    }
    else if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(WARN, "get next row failed. ret=%d", ret);
      break;
    }
    /*TBSYS_LOG(DEBUG, "[id:%lu][key:%.*s][obj:dumped bellow]", cur_row->table_id_, cur_row->row_key_.length(),
      cur_row->row_key_.ptr());
      cur_row->value_.dump();
      */
    if (NULL != cur_row)
    {
      TBSYS_LOG(INFO, "row info:[SEE_DEBUG_LEVEL]");
      cur_row->dump();
    }
    else
    {
      TBSYS_LOG(WARN, "no current row");
    }
    TBSYS_LOG(INFO, "get_next_row() - end");
  }
  TBSYS_LOG(INFO, "scannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnning - terminatet");
  //sleep(10);

  scan.close();

  usleep(1000 * 1000 * 2);
  TBSYS_LOG(INFO, "( request sent )");
  transport->stop();
  test_root_server.~MockServerRunner();
  root_server_thread.join();
}