| 44 | } |
| 45 | |
| 46 | CoTryTask<void> handleInitFileSystem(AdminEnv &env, |
| 47 | const argparse::ArgumentParser &parser, |
| 48 | Dispatcher::OutputTable &table) { |
| 49 | auto tableId = flat::ChainTableId(parser.get<uint32_t>("chaintableid")); |
| 50 | auto chunksize = parser.get<uint32_t>("chunksize"); |
| 51 | auto stripesize = parser.get<uint32_t>("stripesize"); |
| 52 | |
| 53 | auto chainAlloc = std::make_unique<meta::server::ChainAllocator>(nullptr); |
| 54 | auto rootLayout = meta::Layout::newEmpty(tableId, chunksize, stripesize); |
| 55 | auto op = meta::server::MetaStore::initFileSystem(*chainAlloc, rootLayout); |
| 56 | auto handler = [&](kv::IReadWriteTransaction &txn) -> CoTryTask<void> { co_return co_await op->run(txn); }; |
| 57 | |
| 58 | auto commitRes = co_await kv::WithTransaction(getRetryStrategy()) |
| 59 | .run(env.kvEngineGetter()->createReadWriteTransaction(), std::move(handler)); |
| 60 | if (commitRes.hasError()) { |
| 61 | co_return makeError(commitRes.error().code(), fmt::format("Failed to init filesystem: {}", commitRes.error())); |
| 62 | }; |
| 63 | |
| 64 | table.push_back({fmt::format("Init filesystem, root directory layout: chain table {}, chunksize {}, stripesize {}\n", |
| 65 | tableId, |
| 66 | chunksize, |
| 67 | stripesize)}); |
| 68 | |
| 69 | co_return Void{}; |
| 70 | } |
| 71 | |
| 72 | CoTryTask<void> handleInitConfig(AdminEnv &env, |
| 73 | Dispatcher::OutputTable &table, |
no test coverage detected