tools: introduce scylla-nodetool
This patch only introuces the bare skeleton of the tool, plus the wiring into main. No operations are added yet, they will be added in later patches.
This commit is contained in:
@@ -1245,7 +1245,7 @@ scylla_tests_dependencies = scylla_core + alternator + idls + scylla_tests_gener
|
||||
|
||||
scylla_raft_dependencies = scylla_raft_core + ['utils/uuid.cc', 'utils/error_injection.cc']
|
||||
|
||||
scylla_tools = ['tools/scylla-types.cc', 'tools/scylla-sstable.cc', 'tools/schema_loader.cc', 'tools/utils.cc', 'tools/lua_sstable_consumer.cc']
|
||||
scylla_tools = ['tools/scylla-types.cc', 'tools/scylla-sstable.cc', 'tools/scylla-nodetool.cc', 'tools/schema_loader.cc', 'tools/utils.cc', 'tools/lua_sstable_consumer.cc']
|
||||
scylla_perfs = ['test/perf/perf_fast_forward.cc',
|
||||
'test/perf/perf_row_cache_update.cc',
|
||||
'test/perf/perf_simple_query.cc',
|
||||
|
||||
1
main.cc
1
main.cc
@@ -1944,6 +1944,7 @@ int main(int ac, char** av) {
|
||||
{"server", scylla_main, "the scylladb server"},
|
||||
{"types", tools::scylla_types_main, "a command-line tool to examine values belonging to scylla types"},
|
||||
{"sstable", tools::scylla_sstable_main, "a multifunctional command-line tool to examine the content of sstables"},
|
||||
{"nodetool", tools::scylla_nodetool_main, "a command-line tool to administer local or remote ScyllaDB nodes"},
|
||||
{"perf-fast-forward", perf::scylla_fast_forward_main, "run performance tests by fast forwarding the reader on this server"},
|
||||
{"perf-row-cache-update", perf::scylla_row_cache_update_main, "run performance tests by updating row cache on this server"},
|
||||
{"perf-tablets", perf::scylla_tablets_main, "run performance tests of tablet metadata management"},
|
||||
|
||||
@@ -3,6 +3,7 @@ target_sources(tools
|
||||
PRIVATE
|
||||
scylla-types.cc
|
||||
scylla-sstable.cc
|
||||
scylla-nodetool.cc
|
||||
schema_loader.cc
|
||||
utils.cc
|
||||
lua_sstable_consumer.cc)
|
||||
|
||||
@@ -10,5 +10,6 @@ namespace tools {
|
||||
|
||||
int scylla_types_main(int argc, char** argv);
|
||||
int scylla_sstable_main(int argc, char** argv);
|
||||
int scylla_nodetool_main(int argc, char** argv);
|
||||
|
||||
} // namespace tools
|
||||
|
||||
86
tools/scylla-nodetool.cc
Normal file
86
tools/scylla-nodetool.cc
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2023-present ScyllaDB
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <seastar/core/thread.hh>
|
||||
|
||||
#include "log.hh"
|
||||
#include "tools/utils.hh"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
using namespace tools::utils;
|
||||
|
||||
namespace {
|
||||
|
||||
const auto app_name = "scylla-nodetool";
|
||||
|
||||
logging::logger nlog(app_name);
|
||||
|
||||
class scylla_rest_client {
|
||||
};
|
||||
|
||||
using operation_func = void(*)(scylla_rest_client&, const bpo::variables_map&);
|
||||
|
||||
const std::vector<operation_option> global_options{
|
||||
};
|
||||
|
||||
const std::map<operation, operation_func> operations_with_func{
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace tools {
|
||||
|
||||
int scylla_nodetool_main(int argc, char** argv) {
|
||||
const auto description_template =
|
||||
R"(scylla-nodetool - a command-line tool to administer local or remote ScyllaDB nodes
|
||||
|
||||
# Operations
|
||||
|
||||
The operation to execute is the mandatory, first positional argument.
|
||||
Operations write their output to stdout. Logs are written to stderr,
|
||||
with a logger called {}.
|
||||
|
||||
Supported Nodetool operations:
|
||||
{}
|
||||
|
||||
For more information, see: https://opensource.docs.scylladb.com/stable/operating-scylla/nodetool.html
|
||||
)";
|
||||
|
||||
const auto operations = boost::copy_range<std::vector<operation>>(operations_with_func | boost::adaptors::map_keys);
|
||||
tool_app_template::config app_cfg{
|
||||
.name = app_name,
|
||||
.description = format(description_template, app_name, boost::algorithm::join(operations | boost::adaptors::transformed([] (const auto& op) {
|
||||
return format("* {}: {}", op.name(), op.summary());
|
||||
}), "\n")),
|
||||
.logger_name = app_name,
|
||||
.lsa_segment_pool_backend_size_mb = 1,
|
||||
.operations = std::move(operations),
|
||||
.global_options = &global_options};
|
||||
tool_app_template app(std::move(app_cfg));
|
||||
|
||||
return app.run_async(argc, argv, [] (const operation& operation, const bpo::variables_map& app_config) {
|
||||
scylla_rest_client client;
|
||||
|
||||
try {
|
||||
operations_with_func.at(operation)(client, app_config);
|
||||
} catch (std::invalid_argument& e) {
|
||||
fmt::print(std::cerr, "error processing arguments: {}\n", e.what());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fmt::print(std::cerr, "error running operation: {}\n", std::current_exception());
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
Reference in New Issue
Block a user