Example #1
0
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();
}
Example #2
0
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();
}
Example #3
0
void scan_check_all(MutatorBuilder &mb, MockClient &client, const int64_t table_start_version, const bool using_id, const bool check)
{
  for (int64_t i = 0; i < mb.get_schema_num(); ++i)
  {
    ObScanParam scan_param;
    prepare_scan_param(scan_param, mb.get_schema(i), table_start_version, using_id);
    int ret = OB_SUCCESS;
    bool is_fullfilled = false;
    int64_t fullfilled_item_num = 0;
    RowChecker rc;
    int64_t row_counter = 0;
    ObScanner scanner;
    while (!is_fullfilled
          && OB_SUCCESS == ret)
    {
      int64_t timeu = tbsys::CTimeUtil::getTime();
      ret = client.ups_scan(scan_param, scanner, TIMEOUT_MS);
      TBSYS_LOG(INFO, "scan ret=%d timeu=%ld", ret, tbsys::CTimeUtil::getTime() - timeu);
      if (check
          && OB_SUCCESS == ret)
      {
        while (OB_SUCCESS == scanner.next_cell())
        {
          ObCellInfo *ci = NULL;
          bool is_row_changed = false;
          if (OB_SUCCESS == scanner.get_cell(&ci, &is_row_changed))
          {
            if (!using_id)
            {
              trans_name2id(*ci, mb.get_schema(i));
            }
            if (is_row_changed && 0 != rc.cell_num())
            {
              std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
              //fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());

              bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
              //fprintf(stderr, "[get_row check_ret=%d] ", bret);

              bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
              //fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
              TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
            }
            if (is_row_changed
                && 0 != rc.rowkey_num()
                && rc.is_prefix_changed(ci->row_key_))
            {
              std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
              //fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());

              bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
              //fprintf(stderr, "row_key check_ret=%d\n", bret);
              TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
            }
            rc.add_cell(ci);
            if (is_row_changed)
            {
              rc.add_rowkey(ci->row_key_);
              row_counter++;
            }
          }
        }
        if (0 != rc.cell_num())
        {
          std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
          //fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());

          bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
          //fprintf(stderr, "[get_row check_ret=%d] ", bret);

          bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
          //fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
          TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
        }
      }
      scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_item_num);
      ObRange *range = const_cast<ObRange*>(scan_param.get_range());
      scanner.get_last_row_key(range->start_key_);
      range->border_flag_.unset_min_value();
      range->border_flag_.unset_inclusive_start();
    }
    if (check
        && 0 != rc.rowkey_num())
    {
      std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
      //fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());

      bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
      //fprintf(stderr, "row_key check_ret=%d\n", bret);
      TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
    }
    TBSYS_LOG(INFO, "table_id=%lu row_counter=%ld", mb.get_schema(i).get_table_id(), row_counter);
  }
}
Example #4
0
int main(int argc, char **argv)
{
  CmdLine clp;
  parse_cmd_line(argc, argv, clp);

  char buffer[1024];
  sprintf(buffer, "multi_write.%ld.log", clp.prefix_start);
  TBSYS_LOGGER.rotateLog(buffer);
  TBSYS_LOGGER.setFileName(buffer);
  TBSYS_LOGGER.setLogLevel(getenv("log_level")? getenv("log_level"): clp.log_level);
  clp.log_all();
  TBSYS_LOG(INFO, "cmdline: %s", my_str_join(argc, argv));
  TBSYS_LOG(INFO, "getpid()=%d", getpid());

  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.schema_addr, clp.schema_port, schema_mgr))
  {
    TBSYS_LOG(WARN, "fetch schema fail");
    exit(-1);
  }
  schema_mgr.print_info();

  ClientWrapper client;
  client.init(clp.write_addr, static_cast<int32_t>(clp.write_port));

  MutatorBuilder mb;
  mb.init4write(schema_mgr, clp.prefix_start,
                clp.read_addr, static_cast<int32_t>(clp.read_port),
                clp.table_start_version, clp.using_id,
                clp.suffix_length, clp.max_suffix, clp.prefix_end, clp.max_row, &client);

  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, clp.max_cell)))
    {
      TBSYS_LOG(WARN, "build_mutator fail ret=%d\n", ret);
      break;
    }
    while (true)
    {
      int64_t timeu = tbsys::CTimeUtil::getTime();
      ret = client.apply(mutator);
      TBSYS_LOG(DEBUG, "apply ret=%d timeu=%ld\n", ret, tbsys::CTimeUtil::getTime() - timeu);
      if (OB_SUCCESS == ret)
      {
        break;
      }
    }
  }
}