コード例 #1
0
ファイル: multi_write.cpp プロジェクト: CCoder123/pproj
int main(int argc, char **argv)
{
  CmdLine clp;
  parse_cmd_line(argc, argv, clp);

  TBSYS_LOGGER.rotateLog("multi_write.log");
  TBSYS_LOGGER.setFileName("multi_write.log");
  TBSYS_LOGGER.setLogLevel("info");
  clp.log_all();

  ob_init_memory_pool();

  ObSchemaManager schema_mgr;
  if (NULL != clp.schema_file)
  {
    tbsys::CConfig config;
    if (!schema_mgr.parse_from_file(clp.schema_file, config))
    {
      TBSYS_LOG(WARN, "parse schema fail");
      exit(-1);
    }
  }
  else if (OB_SUCCESS != fetch_schema(clp.root_addr, clp.root_port, schema_mgr))
  {
    TBSYS_LOG(WARN, "fetch schema fail");
    exit(-1);
  }
  schema_mgr.print_info();

  MutatorBuilder mb;
  mb.init(schema_mgr,
          clp.prefix_start, clp.suffix_length,
          clp.merge_addr, clp.merge_port, clp.table_start_version,
          clp.max_cell, clp.max_row, clp.max_suffix);
  if (OB_SUCCESS != mb.init_prefix_end(clp.prefix_end))
  {
    TBSYS_LOG(WARN, "init prerfix end fail");
    exit(-1);
  }

  ObServer dst_host;
  dst_host.set_ipv4_addr(clp.serv_addr, clp.serv_port);
  MockClient client;
  client.init(dst_host);
  for (int64_t i = 0; i < clp.mutator_num; i++)
  {
    ObMutator mutator;
    PageArena<char> allocer;
    int ret = OB_SUCCESS;
    if (OB_SUCCESS != (ret = mb.build_mutator(mutator, allocer, clp.using_id)))
    {
      TBSYS_LOG(WARN, "build_mutator fail ret=%d\n", ret);
      break;
    }
    int64_t timeu = tbsys::CTimeUtil::getTime();
    ret = client.ups_apply(mutator, TIMEOUT_MS);
    TBSYS_LOG(INFO, "apply ret=%d timeu=%ld\n", ret, tbsys::CTimeUtil::getTime() - timeu);
  }
  client.destroy();
}
コード例 #2
0
ファイル: multi_write.cpp プロジェクト: CCoder123/pproj
int fetch_schema(const char *root_addr, const int32_t root_port, ObSchemaManager &schema_mgr)
{
  int ret = OB_SUCCESS;
  ObServer dst_host;
  dst_host.set_ipv4_addr(root_addr, root_port);
  MockClient client;
  client.init(dst_host);
  ret = client.fetch_schema(0, schema_mgr, TIMEOUT_MS);
  client.destroy();
  return ret;
}
コード例 #3
0
ファイル: test_ups_client.cpp プロジェクト: CCoder123/pproj
int main(int argc, char **argv)
{
  int err = OB_SUCCESS;
  ob_init_memory_pool();
  CParam param;
  err = parse_cmd_args(argc,argv, param);
  MockClient client;
  if (OB_SUCCESS == err)
  {
    init_mock_client(param.server_addr_, param.server_port_, client);  
    err = apply(param, client);
    if (err != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "check apply mutation failed:ret[%d]", err);
    }
  }
  client.destroy();
  delete param.schema_mgr_;
  return err;
}
コード例 #4
0
ファイル: total_scan.cpp プロジェクト: CCoder123/pproj
int main(int argc, char **argv)
{
  CmdLine clp;
  parse_cmd_line(argc, argv, clp);

  TBSYS_LOGGER.rotateLog("total_scan.log");
  TBSYS_LOGGER.setFileName("total_scan.log");
  TBSYS_LOGGER.setLogLevel("info");
  clp.log_all();

  ob_init_memory_pool();

  ObSchemaManager schema_mgr;
  if (NULL != clp.schema_file)
  {
    tbsys::CConfig config;
    if (!schema_mgr.parse_from_file(clp.schema_file, config))
    {
      TBSYS_LOG(WARN, "parse schema fail");
      exit(-1);
    }
  }
  else if (OB_SUCCESS != fetch_schema(clp.root_addr, clp.root_port, schema_mgr))
  {
    TBSYS_LOG(WARN, "fetch schema fail");
    exit(-1);
  }
  schema_mgr.print_info();

  MutatorBuilder mb;
  mb.init(schema_mgr, clp.prefix_start, clp.suffix_length, clp.serv_addr, clp.serv_port, clp.table_start_version, clp.max_cell);

  ObServer dst_host;
  dst_host.set_ipv4_addr(clp.serv_addr, clp.serv_port);
  MockClient client;
  client.init(dst_host);
  scan_check_all(mb, client, clp.table_start_version, clp.using_id, clp.check);
  client.destroy();
}
コード例 #5
0
ファイル: ups_admin.cpp プロジェクト: mrunix/oceanbase
int main(int argc, char** argv)
{
  setlocale(LC_ALL, "");
  TBSYS_LOGGER.setFileName("ups_admin.log", true);
  TBSYS_LOG(INFO, "ups_admin start==================================================");
  ob_init_memory_pool();

  CmdLineParam clp;
  parse_cmd_line(argc, argv, clp);

  timeout = clp.timeout?: timeout;

  MockClient client;
  init_mock_client(clp.serv_addr, clp.serv_port, clp.login_type, client);

  PageArena<char> allocer;
  int rc = 0;

  if (0 == strcmp("apply", clp.cmd_type))
  {
    apply(clp.ini_fname, allocer, client);
  }
  else if (0 == strcmp("get_clog_status", clp.cmd_type))
  {
    get_clog_status(client);
  }
  else if (0 == strcmp("get_max_log_seq", clp.cmd_type))
  {
    get_max_log_seq(client);
  }
  else if (0 == strcmp("get_clog_cursor", clp.cmd_type))
  {
    get_clog_cursor(client);
  }
  else if (0 == strcmp("get_clog_master", clp.cmd_type))
  {
    get_clog_master(client);
  }
  else if (0 == strcmp("get_log_sync_delay_stat", clp.cmd_type))
  {
    get_log_sync_delay_stat(client);
  }
  else if (0 == strcmp("get", clp.cmd_type))
  {
    get(clp.ini_fname, allocer, client, clp.version_range,clp.expected_result_fname,
      clp.schema_fname);
  }
  else if (0 == strcmp("param_get", clp.cmd_type))
  {
    param_get(clp.ini_fname, client);
  }
  else if (0 == strcmp("scan", clp.cmd_type))
  {
    scan(clp.ini_fname, allocer, client, clp.version_range,clp.expected_result_fname,
      clp.schema_fname);
  }
  else if (0 == strcmp("total_scan", clp.cmd_type))
  {
    total_scan(clp.ini_fname, allocer, client, clp.version_range);
  }
  else if (0 == strcmp("minor_freeze", clp.cmd_type))
  {
    minor_freeze(client);
  }
  else if (0 == strcmp("major_freeze", clp.cmd_type))
  {
    major_freeze(client);
  }
  else if (0 == strcmp("fetch_schema", clp.cmd_type))
  {
    fetch_schema(client, clp.timestamp);
  }
  else if (0 == strcmp("get_sstable_range_list", clp.cmd_type))
  {
    get_sstable_range_list(client, clp.timestamp, clp.session_id);
  }
  else if (0 == strcmp("drop", clp.cmd_type))
  {
    drop(client);
  }
  else if (0 == strcmp("dump_memtable", clp.cmd_type))
  {
    dump_memtable(clp.ini_fname, client);
  }
  else if (0 == strcmp("dump_schemas", clp.cmd_type))
  {
    dump_schemas(client);
  }
  else if (0 == strcmp("force_fetch_schema", clp.cmd_type))
  {
    force_fetch_schema(client);
  }
  else if (0 == strcmp("reload_conf", clp.cmd_type))
  {
    reload_conf(clp.ini_fname, client);
  }
  else if (0 == strcmp("memory_watch", clp.cmd_type))
  {
    memory_watch(client);
  }
  else if (0 == strcmp("memory_limit", clp.cmd_type))
  {
    memory_limit(clp.memory_limit, clp.memtable_limit, client);
  }
  else if (0 == strcmp("priv_queue_conf", clp.cmd_type))
  {
    priv_queue_conf(clp.priv_queue_conf, client);
  }
  else if (0 == strcmp("clear_active_memtable", clp.cmd_type))
  {
    clear_active_memtable(client);
  }
  else if (0 == strcmp("get_last_frozen_version", clp.cmd_type))
  {
    get_last_frozen_version(client);
  }
  else if (0 == strcmp("fetch_ups_stat_info", clp.cmd_type))
  {
    fetch_ups_stat_info(client);
  }
  else if (0 == strcmp("get_bloomfilter", clp.cmd_type))
  {
    get_bloomfilter(client, clp.timestamp);
  }
  else if (0 == strcmp("store_memtable", clp.cmd_type))
  {
    store_memtable(client, clp.timestamp);
  }
  else if (0 == strcmp("erase_sstable", clp.cmd_type))
  {
    erase_sstable(client);
  }
  else if (0 == strcmp("load_new_store", clp.cmd_type))
  {
    load_new_store(client);
  }
  else if (0 == strcmp("reload_all_store", clp.cmd_type))
  {
    reload_all_store(client);
  }
  else if (0 == strcmp("reload_store", clp.cmd_type))
  {
    reload_store(client, clp.timestamp);
  }
  else if (0 == strcmp("umount_store", clp.cmd_type))
  {
    umount_store(client, clp.ini_fname);
  }
  else if (0 == strcmp("force_report_frozen_version", clp.cmd_type))
  {
    force_report_frozen_version(client);
  }
  else if (0 == strcmp("switch_commit_log", clp.cmd_type))
  {
    switch_commit_log(client);
  }
  else if (0 == strcmp("get_table_time_stamp", clp.cmd_type))
  {
    get_table_time_stamp(client, clp.timestamp);
  }
  else if (0 == strcmp("disable_memtable_checksum", clp.cmd_type))
  {
    disable_memtable_checksum(client);
  }
  else if (0 == strcmp("enable_memtable_checksum", clp.cmd_type))
  {
    enable_memtable_checksum(client);
  }
  else if (0 == strcmp("immediately_drop_memtable", clp.cmd_type))
  {
    immediately_drop_memtable(client);
  }
  else if (0 == strcmp("delay_drop_memtable", clp.cmd_type))
  {
    delay_drop_memtable(client);
  }
  else if (0 == strcmp("minor_load_bypass", clp.cmd_type))
  {
    rc = minor_load_bypass(client);
  }
  else if (0 == strcmp("major_load_bypass", clp.cmd_type))
  {
    rc = major_load_bypass(client);
  }
  else if(0 == strcmp("list_sessions", clp.cmd_type))
  {
    client.list_sessions(timeout);
  }
  else if(0 == strcmp("kill_session", clp.cmd_type))
  {
    client.kill_session(timeout, clp.session_id);
  }
  else if (0 == strcmp("change_log_level", clp.cmd_type))
  {
    change_log_level(client, clp.log_level);
  }
  else if (0 == strcmp("get_slave_ups_info", clp.cmd_type))
  {
    get_slave_ups_info(client);
  }
  else if (0 == strcmp("print_scanner", clp.cmd_type))
  {
    print_scanner(clp.ini_fname);
  }
  else if (0 == strcmp("print_schema", clp.cmd_type))
  {
    print_schema(clp.ini_fname);
  }
  else if (0 == strcmp("sql_query", clp.cmd_type))
  {
    execute_sql(client, clp.sql_query);
  }
  else if (0 == strcmp("ups_show_sessions", clp.cmd_type))
  {
    ups_show_sessions(client);
  }
  else if (0 == strcmp("ups_kill_session", clp.cmd_type))
  {
    ups_kill_session(static_cast<uint32_t>(clp.session_id), client);
  }
  else
  {
    print_usage();
  }

  if (!clp.quickly_exit)
  {
    client.destroy();
    TBSYS_LOG(INFO, "ups_admin end==================================================");
    return rc;
  }
  else
  {
    TBSYS_LOG(INFO, "ups_admin killed==================================================");
    fflush(stdout);
    fflush(stderr);
    _exit(rc);
  }
}
コード例 #6
0
ファイル: mock_client.cpp プロジェクト: Abioy/oceanbase
int main(int argc, char** argv)
{
  const int32_t MOCK_SERVER_LISTEN_PORT = 8888;
  MockClient client;
  ObServer dst_host;
  const char* dst_addr = "localhost";
  dst_host.set_ipv4_addr(dst_addr, MOCK_SERVER_LISTEN_PORT);
  client.init(dst_host);

  // init cell info
  static const int64_t ROW_NUM = 1;
  static const int64_t COL_NUM = 10;

  ObCellInfo cell_infos[ROW_NUM][COL_NUM];
  char row_key_strs[ROW_NUM][50];
  uint64_t table_id = 10;
  // init cell infos
  for (int64_t i = 0; i < ROW_NUM; ++i)
  {
    sprintf(row_key_strs[i], "row_key_%08ld", i);
    for (int64_t j = 0; j < COL_NUM; ++j)
    {
      cell_infos[i][j].table_id_ = table_id;
      cell_infos[i][j].row_key_.assign(row_key_strs[i], strlen(row_key_strs[i]));
      //cell_infos[i][j].op_info_.set_sem_ob();

      cell_infos[i][j].column_id_ = j + 1;

      cell_infos[i][j].value_.set_int(1000 + i * COL_NUM + j);
    }
  }

  // scan memtable
  ObScanner scanner;
  ObScanParam scan_param;
  //ObOperateInfo op_info;
  ObString table_name;
  ObRange range;
  const int64_t version = 999;
  range.start_key_ = cell_infos[0][0].row_key_;
  range.end_key_ = cell_infos[ROW_NUM - 1][0].row_key_;
  range.border_flag_.set_inclusive_start();
  range.border_flag_.set_inclusive_end();

  scan_param.set(table_id, table_name, range);
  //scan_param.set_timestamp(version);
  //scan_param.set_is_read_frozen_only(false);
  ObVersionRange version_range;
  version_range.start_version_ = version;
  version_range.end_version_ = version;
  version_range.border_flag_.set_inclusive_start();
  version_range.border_flag_.set_inclusive_end();
  scan_param.set_version_range(version_range);
  for (int64_t i = 0; i < COL_NUM; ++i)
  {
    scan_param.add_column(cell_infos[0][i].column_id_);
  }


  int64_t count = 0;
  const int64_t timeout = 10 * 1000L;

  int err = client.ups_scan(scan_param, scanner, timeout);
  fprintf(stderr, "ups_scan err=%d\n", err);

  // check result
  count = 0;
  ObScannerIterator iter;
  for (iter = scanner.begin(); iter != scanner.end(); iter++)
  {
    ObCellInfo ci;
    ObCellInfo expected = cell_infos[count / COL_NUM][count % COL_NUM];
    EXPECT_EQ(OB_SUCCESS, iter.get_cell(ci));
    check_cell(expected, ci);
    ++count;
  }
  EXPECT_EQ(ROW_NUM * COL_NUM, count);
  fprintf(stderr, "cell_num=%ld\n", count);

  client.destroy();
  return 0;
}