MCPcopy Create free account
hub / github.com/ByConity/ByConity / parseAndRunInspectPartTask

Function parseAndRunInspectPartTask

programs/storage-tools/PartInspector.cpp:366–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366int parseAndRunInspectPartTask(const std::vector<String>& args) {
367 po::options_description desc("part inspector");
368
369 desc.add_options()
370 ("help", po::bool_switch()->default_value(false), "Help")
371 ("user", po::value<String>()->default_value("clickhouse"), "user when access hdfs")
372 ("prefix", po::value<String>()->required(), "file system prefix, supported are hdfs://nnip:nnport/, cfs://nnip:nnport, nnproxy or empty for local file system")
373 ("path", po::value<String>()->required(), "relative data path, can be a folder or just a file")
374 ("threads", po::value<size_t>()->default_value(1), "threads to use")
375 ("type", po::value<String>()->required(), "inspect type, can be brief, checksum, all, marks, check_files")
376 ("stream", po::value<String>()->default_value("")->implicit_value(""), "inspect stream's mark content");
377
378 po::variables_map options;
379 po::store(po::command_line_parser(args).options(desc).run(), options);
380 po::notify(options);
381
382 if (options["help"].as<bool>()) {
383 std::cout << desc << std::endl;
384 return 0;
385 }
386
387 std::vector<String> required_field = {"prefix", "path", "type"};
388 for (const String& field : required_field) {
389 if (options.count(field) == 0) {
390 std::cerr << "Missing required field " << field << "\n" << desc << std::endl;
391 return 1;
392 }
393 }
394
395 String prefix = options["prefix"].as<String>();
396 String user = options["user"].as<String>();
397 String path = options["path"].as<String>();
398 size_t threads = options["threads"].as<size_t>();
399 String task_type = options["type"].as<String>();
400 String stream_name = options["stream"].as<String>();
401 Poco::URI uri(prefix);
402
403 if (threads == 0) {
404 std::cerr << "Invalid thread num " << threads << std::endl;
405 return 1;
406 }
407
408 std::unique_ptr<FSOp> fs = nullptr;
409 if (prefix.empty()) {
410 fs = std::make_unique<LocalFSOp>();
411 } else {
412 HDFSConnectionParams hdfs_params;
413 String uri_scheme = Poco::toLower(uri.getScheme());
414 if (uri_scheme.empty()) {
415 hdfs_params = HDFSConnectionParams(HDFSConnectionParams::CONN_NNPROXY,
416 user, prefix);
417 } else {
418 HDFSConnectionParams::HDFSConnectionType type = HDFSConnectionParams::CONN_DUMMY;
419 if (uri_scheme == "cfs") {
420 type = HDFSConnectionParams::CONN_CFS;
421 } else if (uri_scheme == "hdfs") {
422 type = HDFSConnectionParams::CONN_HDFS;
423 } else {

Callers 1

mainEntryStorageToolsFunction · 0.85

Calls 8

storeFunction · 0.85
requiredMethod · 0.80
runMethod · 0.45
countMethod · 0.45
emptyMethod · 0.45
getPortMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected