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(); }
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; }
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(); }
void init_mock_client(const char *addr, int32_t port, const char *login_type, MockClient &client) { ObServer dst_host; dst_host.set_ipv4_addr(addr, port); client.init(dst_host); if (0 == strcmp(login_type, "direct")) { // do nothing } else if (0 == strcmp(login_type, "master_ups")) { ObUpsList ups_list; if (OB_SUCCESS == client.get_ups_list(ups_list, timeout)) { for (int64_t i = 0; i < ups_list.ups_count_; i++) { if (UPS_MASTER == ups_list.ups_array_[i].stat_) { client.set_server(ups_list.ups_array_[i].addr_); break; } } } } else if (0 == strcmp(login_type, "random_ms")) { MsList ms_list; ms_list.init(dst_host, client.get_rpc()); ms_list.runTimerTask(); client.set_server(ms_list.get_one()); } else { fprintf(stdout, "Invalid login_type [%s]\n", login_type); exit(-1); } }
void init_mock_client(const char *addr, int32_t port, MockClient &client) { ObServer dst_host; dst_host.set_ipv4_addr(addr, port); client.init(dst_host); }
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; }