Skip to content

Make sideband port configurable via json file. #1126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/config/localhost_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"address": "[::1]",
"port": 31763,
"sideband_address": "[::1]",
"sideband_port": 50055,
"security" : {
"server_cert": "",
"server_key": "",
Expand Down
4 changes: 3 additions & 1 deletion source/server/core_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct ServerConfiguration {
std::string server_key;
std::string root_cert;
int max_message_size;
int sideband_port;
nidevice_grpc::FeatureToggles feature_toggles;
};

Expand All @@ -49,6 +50,7 @@ static ServerConfiguration GetConfiguration(const std::string& config_file_path)
config.config_file_path = server_config_parser.get_config_file_path();
config.server_address = server_config_parser.parse_address();
config.sideband_address = server_config_parser.parse_sideband_address();
config.sideband_port = server_config_parser.parse_sideband_port();
config.server_cert = server_config_parser.parse_server_cert();
config.server_key = server_config_parser.parse_server_key();
config.root_cert = server_config_parser.parse_root_cert();
Expand Down Expand Up @@ -110,7 +112,7 @@ static void RunServer(const ServerConfiguration& config)
}
server = builder.BuildAndStart();
if (ni::data_monikers::is_sideband_streaming_enabled(config.feature_toggles)) {
auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055);
auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), config.sideband_port);
// auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests);
// auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests);
}
Expand Down
13 changes: 12 additions & 1 deletion source/server/server_configuration_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const char* kDefaultFilename = "server_config.json";
static const char* kAddressJsonKey = "address";
static const char* kPortJsonKey = "port";
static const char* kSidebandAddressJsonKey = "sideband_address";
static const char* kSidebandPortJsonKey = "sideband_port";
static const char* kServerCertJsonKey = "server_cert";
static const char* kServerKeyJsonKey = "server_key";
static const char* kRootCertJsonKey = "root_cert";
Expand Down Expand Up @@ -141,6 +142,11 @@ int ServerConfigurationParser::parse_max_message_size() const
return UNLIMITED_MAX_MESSAGE_SIZE;
}

int ServerConfigurationParser::parse_sideband_port() const
{
return parse_port_with_key(kSidebandPortJsonKey);
}

FeatureToggles ServerConfigurationParser::parse_feature_toggles() const
{
FeatureToggleConfigurationMap map;
Expand Down Expand Up @@ -253,10 +259,15 @@ std::string ServerConfigurationParser::parse_bind_address() const
}

int ServerConfigurationParser::parse_port() const
{
return parse_port_with_key(kPortJsonKey);
}

int ServerConfigurationParser::parse_port_with_key(const std::string& key) const
{
int parsed_port = -1;

auto it = config_file_.find(kPortJsonKey);
auto it = config_file_.find(key);
if (it != config_file_.end()) {
try {
parsed_port = it->get<int>();
Expand Down
2 changes: 2 additions & 0 deletions source/server/server_configuration_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ServerConfigurationParser {
std::string parse_server_key() const;
std::string parse_root_cert() const;
int parse_max_message_size() const;
int parse_sideband_port() const;
FeatureToggles parse_feature_toggles() const;
FeatureToggles::CodeReadiness parse_code_readiness() const;

Expand Down Expand Up @@ -103,6 +104,7 @@ class ServerConfigurationParser {
std::string parse_key_from_security_section(const char* key) const;
std::string parse_bind_address() const;
int parse_port() const;
int parse_port_with_key(const std::string& key) const;

std::string config_file_path_;
nlohmann::json config_file_;
Expand Down