From eb38b4f373b10efac6a924e599b6b716c8c664dc Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Sun, 8 Dec 2019 11:42:59 +0100 Subject: [PATCH] Rename Bolt flags Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2587 --- src/memgraph.cpp | 40 +++++++++++++--------- src/memgraph_ha.cpp | 40 +++++++++++++--------- tests/drivers/run.sh | 2 +- tests/feature_benchmark/ha/read/runner.sh | 2 +- tests/feature_benchmark/ha/write/runner.sh | 2 +- tests/integration/ha/ha_test.py | 2 +- tests/macro_benchmark/databases.py | 4 +-- tests/public_benchmark/ldbc/run_benchmark | 5 +-- tests/stress/continuous_integration | 4 +-- tests/stress/continuous_integration_ha | 2 +- tests/stress/durability | 2 +- tools/tests/test_mg_client | 2 +- 12 files changed, 60 insertions(+), 47 deletions(-) diff --git a/src/memgraph.cpp b/src/memgraph.cpp index 656ee92e8..b08c3b059 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -24,19 +24,25 @@ #include "query/procedure/module.hpp" // General purpose flags. -DEFINE_string(interface, "0.0.0.0", - "Communication interface on which to listen."); -DEFINE_VALIDATED_int32(port, 7687, "Communication port on which to listen.", +DEFINE_string(bolt_address, "0.0.0.0", + "IP address on which the Bolt server should listen."); +DEFINE_VALIDATED_int32(bolt_port, 7687, + "Port on which the Bolt server should listen.", FLAG_IN_RANGE(0, std::numeric_limits::max())); -DEFINE_VALIDATED_int32(num_workers, - std::max(std::thread::hardware_concurrency(), 1U), - "Number of workers (Bolt)", FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_VALIDATED_int32(session_inactivity_timeout, 1800, - "Time in seconds after which inactive sessions will be " - "closed.", - FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_string(cert_file, "", "Certificate file to use."); -DEFINE_string(key_file, "", "Key file to use."); +DEFINE_VALIDATED_int32( + bolt_num_workers, std::max(std::thread::hardware_concurrency(), 1U), + "Number of workers used by the Bolt server. By default, this will be the " + "number of processing units available on the machine.", + FLAG_IN_RANGE(1, INT32_MAX)); +DEFINE_VALIDATED_int32( + bolt_session_inactivity_timeout, 1800, + "Time in seconds after which inactive Bolt sessions will be " + "closed.", + FLAG_IN_RANGE(1, INT32_MAX)); +DEFINE_string(bolt_cert_file, "", + "Certificate file which should be used for the Bolt server."); +DEFINE_string(bolt_key_file, "", + "Key file which should be used for the Bolt server."); #ifdef MG_SINGLE_NODE_V2 // General purpose flags. @@ -202,14 +208,14 @@ void SingleNodeMain() { ServerContext context; std::string service_name = "Bolt"; - if (FLAGS_key_file != "" && FLAGS_cert_file != "") { - context = ServerContext(FLAGS_key_file, FLAGS_cert_file); + if (!FLAGS_bolt_key_file.empty() && !FLAGS_bolt_cert_file.empty()) { + context = ServerContext(FLAGS_bolt_key_file, FLAGS_bolt_cert_file); service_name = "BoltS"; } - ServerT server({FLAGS_interface, static_cast(FLAGS_port)}, - &session_data, &context, FLAGS_session_inactivity_timeout, - service_name, FLAGS_num_workers); + ServerT server({FLAGS_bolt_address, static_cast(FLAGS_bolt_port)}, + &session_data, &context, FLAGS_bolt_session_inactivity_timeout, + service_name, FLAGS_bolt_num_workers); // Setup telemetry std::optional telemetry; diff --git a/src/memgraph_ha.cpp b/src/memgraph_ha.cpp index aa6be558f..06aedc30b 100644 --- a/src/memgraph_ha.cpp +++ b/src/memgraph_ha.cpp @@ -16,19 +16,25 @@ #include "utils/flag_validation.hpp" // General purpose flags. -DEFINE_string(interface, "0.0.0.0", - "Communication interface on which to listen."); -DEFINE_VALIDATED_int32(port, 7687, "Communication port on which to listen.", +DEFINE_string(bolt_address, "0.0.0.0", + "IP address on which the Bolt server should listen."); +DEFINE_VALIDATED_int32(bolt_port, 7687, + "Port on which the Bolt server should listen.", FLAG_IN_RANGE(0, std::numeric_limits::max())); -DEFINE_VALIDATED_int32(num_workers, - std::max(std::thread::hardware_concurrency(), 1U), - "Number of workers (Bolt)", FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_VALIDATED_int32(session_inactivity_timeout, 1800, - "Time in seconds after which inactive sessions will be " - "closed.", - FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_string(cert_file, "", "Certificate file to use (Bolt)."); -DEFINE_string(key_file, "", "Key file to use (Bolt)."); +DEFINE_VALIDATED_int32( + bolt_num_workers, std::max(std::thread::hardware_concurrency(), 1U), + "Number of workers used by the Bolt server. By default, this will be the " + "number of processing units available on the machine.", + FLAG_IN_RANGE(1, INT32_MAX)); +DEFINE_VALIDATED_int32( + bolt_session_inactivity_timeout, 1800, + "Time in seconds after which inactive Bolt sessions will be " + "closed.", + FLAG_IN_RANGE(1, INT32_MAX)); +DEFINE_string(bolt_cert_file, "", + "Certificate file which should be used for the Bolt server."); +DEFINE_string(bolt_key_file, "", + "Key file which should be used for the Bolt server."); using ServerT = communication::Server; using communication::ServerContext; @@ -45,14 +51,14 @@ void SingleNodeHAMain() { ServerContext context; std::string service_name = "Bolt"; - if (FLAGS_key_file != "" && FLAGS_cert_file != "") { - context = ServerContext(FLAGS_key_file, FLAGS_cert_file); + if (!FLAGS_bolt_key_file.empty() && !FLAGS_bolt_cert_file.empty()) { + context = ServerContext(FLAGS_bolt_key_file, FLAGS_bolt_cert_file); service_name = "BoltS"; } - ServerT server({FLAGS_interface, static_cast(FLAGS_port)}, - &session_data, &context, FLAGS_session_inactivity_timeout, - service_name, FLAGS_num_workers); + ServerT server({FLAGS_bolt_address, static_cast(FLAGS_bolt_port)}, + &session_data, &context, FLAGS_bolt_session_inactivity_timeout, + service_name, FLAGS_bolt_num_workers); // Handler for regular termination signals auto shutdown = [&db] { db.Shutdown(); }; diff --git a/tests/drivers/run.sh b/tests/drivers/run.sh index 39444f7c2..c98799b0a 100755 --- a/tests/drivers/run.sh +++ b/tests/drivers/run.sh @@ -31,7 +31,7 @@ fi $binary_dir/memgraph \ --data-directory=$tmpdir \ --query-execution-timeout-sec=5 \ - --session-inactivity-timeout=10 & + --bolt-session-inactivity-timeout=10 & pid=$! wait_for_server 7687 diff --git a/tests/feature_benchmark/ha/read/runner.sh b/tests/feature_benchmark/ha/read/runner.sh index 4237aaa22..2b8bc3c58 100755 --- a/tests/feature_benchmark/ha/read/runner.sh +++ b/tests/feature_benchmark/ha/read/runner.sh @@ -41,7 +41,7 @@ do $binary_dir/memgraph_ha --server_id $server_id \ --coordination_config_file="coordination.json" \ --raft_config_file="raft.json" \ - --port $((7686 + $server_id)) \ + --bolt-port $((7686 + $server_id)) \ --db-recover-on-startup=false \ --durability_directory=dur$server_id & HA_PIDS[$server_id]=$! diff --git a/tests/feature_benchmark/ha/write/runner.sh b/tests/feature_benchmark/ha/write/runner.sh index b921902d2..81e49a9a3 100755 --- a/tests/feature_benchmark/ha/write/runner.sh +++ b/tests/feature_benchmark/ha/write/runner.sh @@ -41,7 +41,7 @@ do $binary_dir/memgraph_ha --server_id $server_id \ --coordination_config_file="coordination.json" \ --raft_config_file="raft.json" \ - --port $((7686 + $server_id)) \ + --bolt-port $((7686 + $server_id)) \ --db-recover-on-startup=false \ --durability_directory=dur$server_id & HA_PIDS[$server_id]=$! diff --git a/tests/integration/ha/ha_test.py b/tests/integration/ha/ha_test.py index 611b07ab0..72a084362 100644 --- a/tests/integration/ha/ha_test.py +++ b/tests/integration/ha/ha_test.py @@ -101,7 +101,7 @@ class HaTestBase: def _generate_args(self, worker_id): args = [self.memgraph_binary] args.extend(["--server_id", str(worker_id + 1)]) - args.extend(["--port", str(7687 + worker_id)]) + args.extend(["--bolt-port", str(7687 + worker_id)]) args.extend(["--raft_config_file", self.raft_config_file]) args.extend(["--coordination_config_file", self.coordination_config_file.name]) diff --git a/tests/macro_benchmark/databases.py b/tests/macro_benchmark/databases.py index 250d2c27f..8d3f1ebf5 100644 --- a/tests/macro_benchmark/databases.py +++ b/tests/macro_benchmark/databases.py @@ -44,10 +44,10 @@ class Memgraph: def start(self): self.log.info("start") - database_args = ["--port", self.args.port, + database_args = ["--bolt-port", self.args.port, "--query-execution-timeout-sec", "0"] if self.num_workers: - database_args += ["--num_workers", str(self.num_workers)] + database_args += ["--bolt-num-workers", str(self.num_workers)] if self.args.data_directory: database_args += ["--data-directory", self.args.data_directory] if self.args.storage_recover_on_startup: diff --git a/tests/public_benchmark/ldbc/run_benchmark b/tests/public_benchmark/ldbc/run_benchmark index a29c783c3..ce70559d9 100755 --- a/tests/public_benchmark/ldbc/run_benchmark +++ b/tests/public_benchmark/ldbc/run_benchmark @@ -40,11 +40,12 @@ class Memgraph: binary = os.path.join(BASE_DIR, "build_release", "memgraph") # database args - database_args = [binary, "--num-workers", self.num_workers, + database_args = [binary, + "--bolt-num-workers", self.num_workers, "--data-directory", os.path.join(self.dataset, "memgraph"), "--storage-recover-on-startup", "true", - "--port", self.port] + "--bolt-port", self.port] # database env env = {"MEMGRAPH_CONFIG": os.path.join(SCRIPT_DIR, "config", diff --git a/tests/stress/continuous_integration b/tests/stress/continuous_integration index f183a179f..319869fac 100755 --- a/tests/stress/continuous_integration +++ b/tests/stress/continuous_integration @@ -150,7 +150,7 @@ if args.use_ssl: # start memgraph cwd = os.path.dirname(args.memgraph) -cmd = [args.memgraph, "--num-workers=" + str(THREADS), +cmd = [args.memgraph, "--bolt-num-workers=" + str(THREADS), "--storage-properties-on-edges=true", "--storage-snapshot-on-exit=true", "--storage-snapshot-interval-sec=600", @@ -165,7 +165,7 @@ if args.log_file: if args.data_directory: cmd += ["--data-directory", args.data_directory] if args.use_ssl: - cmd += ["--cert-file", CERT_FILE, "--key-file", KEY_FILE] + cmd += ["--bolt-cert-file", CERT_FILE, "--bolt-key-file", KEY_FILE] proc_mg = subprocess.Popen(cmd, cwd = cwd) time.sleep(1.0) diff --git a/tests/stress/continuous_integration_ha b/tests/stress/continuous_integration_ha index ba3426338..02b8b071f 100755 --- a/tests/stress/continuous_integration_ha +++ b/tests/stress/continuous_integration_ha @@ -117,7 +117,7 @@ coordination_config_file = tempfile.NamedTemporaryFile(mode="w") def generate_cmd_args(worker_id): cmd = [args.memgraph] cmd.extend(["--server-id", str(worker_id + 1)]) - cmd.extend(["--port", str(PORT + worker_id)]) + cmd.extend(["--bolt-port", str(PORT + worker_id)]) cmd.extend(["--raft-config-file", RAFT_CONFIG_FILE]) cmd.extend(["--coordination-config-file", coordination_config_file.name]) diff --git a/tests/stress/durability b/tests/stress/durability index e43fe0e54..23925d17a 100755 --- a/tests/stress/durability +++ b/tests/stress/durability @@ -51,7 +51,7 @@ if not os.path.exists(args.memgraph): # Memgraph run command construction cwd = os.path.dirname(args.memgraph) -cmd = [args.memgraph, "--num-workers=" + str(DB_WORKERS), +cmd = [args.memgraph, "--bolt-num-workers=" + str(DB_WORKERS), "--storage-properties-on-edges=true", "--storage-snapshot-on-exit=false", "--storage-snapshot-interval-sec=5", diff --git a/tools/tests/test_mg_client b/tools/tests/test_mg_client index df21fcb12..73f84900e 100755 --- a/tools/tests/test_mg_client +++ b/tools/tests/test_mg_client @@ -72,7 +72,7 @@ fi # Start the memgraph process and wait for it to start. echo_info "Starting memgraph" -$memgraph_dir/memgraph --cert-file=$cert_file --key-file=$key_file & +$memgraph_dir/memgraph --bolt-cert-file=$cert_file --bolt-key-file=$key_file & pid=$! wait_for_server 7687 echo_success "Started memgraph"