Skip to content
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

Make sideband port configurable via json file. #1126

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions 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,21 @@ int ServerConfigurationParser::parse_max_message_size() const
return UNLIMITED_MAX_MESSAGE_SIZE;
}

int ServerConfigurationParser::parse_sideband_port() const
{
auto sideband_port = config_file_.find(kSidebandPortJsonKey);
if (sideband_port != config_file_.end()) {
try {
return sideband_port->get<int>();
}
catch (const nlohmann::json::type_error& ex) {
throw InvalidMaxMessageSizeException(ex.what());
amehra-ni marked this conversation as resolved.
Show resolved Hide resolved
}
}

return DEFAULT_SIDEBAND_PORT;
}

FeatureToggles ServerConfigurationParser::parse_feature_toggles() const
{
FeatureToggleConfigurationMap map;
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 @@ -23,6 +23,7 @@ static const char* kInvalidFeatureToggleMessage = "Feature Toggles must be speci
static const char* kInvalidCodeReadinessMessage = "code_readiness must be a string in [Release, RestrictedRelease, NextRelease, RestrictedNextRelease, Incomplete, Prototype].\n\n";
static const char* kDefaultAddress = "[::]";
constexpr int UNLIMITED_MAX_MESSAGE_SIZE = -1;
constexpr int DEFAULT_SIDEBAND_PORT = 50055;

class ServerConfigurationParser {
public:
Expand All @@ -41,6 +42,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