| 341 | class MockCluster { |
| 342 | public: |
| 343 | struct Config : ConfigBase<Config> { |
| 344 | struct ChainTableConfig : ConfigBase<ChainTableConfig> { |
| 345 | CONFIG_ITEM(table_id, 1u); |
| 346 | CONFIG_ITEM(num_chains, 128u); |
| 347 | CONFIG_ITEM(num_replica, 1u); |
| 348 | }; |
| 349 | |
| 350 | CONFIG_ITEM(num_meta, 3); |
| 351 | CONFIG_OBJ(mock_meta, meta::server::Config, [](meta::server::Config &cfg) { |
| 352 | cfg.set_iflags_chain_allocation(true); |
| 353 | cfg.set_inodeId_check_unique(true); |
| 354 | cfg.set_inodeId_abort_on_duplicate(true); |
| 355 | cfg.set_check_file_hole(false); |
| 356 | cfg.set_otrunc_replace_file(true); |
| 357 | cfg.set_otrunc_replace_file_threshold(1_GB); |
| 358 | cfg.session_manager().set_enable(false); |
| 359 | cfg.session_manager().set_scan_interval(10_ms); |
| 360 | cfg.gc().set_check_session(true); |
| 361 | cfg.gc().set_scan_interval(10_ms); |
| 362 | cfg.gc().set_retry_delay(100_ms); |
| 363 | cfg.distributor().set_update_interval(50_ms); |
| 364 | cfg.set_dynamic_stripe(true); |
| 365 | cfg.set_enable_new_chunk_engine(folly::Random::oneIn(2)); |
| 366 | cfg.set_idempotent_rename(true); |
| 367 | cfg.event_trace_log().set_enabled(true); |
| 368 | cfg.event_trace_log().set_dump_interval(5_s); |
| 369 | cfg.event_trace_log().set_max_num_writers(8); |
| 370 | }); |
| 371 | CONFIG_OBJ(mock_mgmtd, mgmtd::MockMgmtd::Config); |
| 372 | CONFIG_OBJ(mgmtd_client, client::MgmtdClientForServer::Config, [](client::MgmtdClientForServer::Config &cfg) { |
| 373 | cfg.set_enable_auto_heartbeat(false); // currently heartbeat is not needed in meta test |
| 374 | cfg.set_mgmtd_server_addresses({net::Address::from("TCP://127.0.0.1:8000").value()}); // just a fake TCP address. |
| 375 | }); |
| 376 | |
| 377 | CONFIG_OBJ_ARRAY(chain_tables, ChainTableConfig, 64, [](std::array<ChainTableConfig, 64> &cfg) { |
| 378 | cfg[0].set_table_id(1); |
| 379 | cfg[0].set_num_chains(100 * 16); |
| 380 | cfg[0].set_num_replica(1); |
| 381 | cfg[1].set_table_id(2); |
| 382 | cfg[1].set_num_chains(64 * 16); |
| 383 | cfg[1].set_num_replica(2); |
| 384 | cfg[2].set_table_id(3); |
| 385 | cfg[2].set_num_chains(180 * 16); |
| 386 | cfg[2].set_num_replica(2); |
| 387 | return 3; |
| 388 | }); |
| 389 | }; |
| 390 | |
| 391 | static MockCluster create(std::shared_ptr<IKVEngine> engine, const Config &config) { |
| 392 | MockCluster cluster(std::move(engine), config); |