From f5741d80957e5db9bfe506ea10761221f6336b79 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 9 Feb 2023 10:30:36 -0500 Subject: [PATCH] refactor: Convert system/logging cfg to proto3 --- src/client/Directory.Build.Props | 107 +++++++++--------- src/client/spark/Daemons/AboutDaemon.cs | 5 +- src/client/spark/Daemons/OopsDaemon.cs | 2 +- .../spark/Daemons/ShellLatencyDaemon.cs | 4 +- src/client/spark/Init/ReleaseNotesParade.cs | 2 +- .../Modules/Support/Browser/BrowserWindow.cs | 6 +- .../NMSheets/Settings/NMSheetSettingGrid.cs | 3 +- .../UIComponents/MainSheet/NMSheetTheoGrid.cs | 5 +- .../spark/core/NativeMethods/NativeMethods.cs | 4 +- .../view/Extensions/HighDpiExtensions.cs | 2 +- src/client/spark/view/Shell/ShellModel.cs | 2 +- .../view/Shell/Workspaces/WorkspacesModel.cs | 4 +- .../spark/view/Utility/ScreenCapture.cs | 4 +- src/client/spark_api/spark_api.csproj | 9 +- src/client/spark_core/logging/LogUtil.cs | 5 +- src/client/spark_core/spark_core.csproj | 8 +- src/client/sparkcmd/Cmd/OrderStress.cs | 4 +- src/lib/api/core/ApiClientInterop.cpp | 4 +- .../api/service_helpers/AdminServiceUtils.cpp | 2 +- src/lib/config/ConfigurationState.cpp | 13 +-- .../defaults/{logging.conf => Logging.conf} | 4 + src/lib/config/defaults/MarketData.conf | 14 +-- src/lib/config/defaults/Symbols.conf | 4 +- src/lib/config/protos/logging.proto | 32 +++--- src/lib/config/protos/system.proto | 37 ------ src/lib/config/protos/system_config.proto | 40 +++++++ src/lib/config/tests/config_tests.cpp | 6 +- src/lib/logging/logging.cpp | 4 +- src/lib/md/Diag/MDPeriodicDumper.cpp | 6 +- src/lib/md/SecurityDB.cpp | 5 +- src/lib/md/SecurityIDRecorder.cpp | 5 +- src/lib/md/SettlementRecorder.cpp | 5 +- src/lib/md/cme/MDP3Utils.cpp | 4 +- src/lib/md/ice/ICEUtils.cpp | 4 +- src/lib/md/relay/QueryServer.cpp | 2 +- src/lib/md/relay/RelayClient.cpp | 4 +- src/lib/md/relay/RelayRecorder.cpp | 6 +- src/lib/metrics/system_metrics.cpp | 6 +- src/lib/plugin/plugin.cpp | 2 +- src/lib/tracing/PerfLog.cpp | 6 +- src/lib/utils/SecureLogon.cpp | 8 +- src/lib/utils/SharedList.h | 4 +- .../examples/algo_template/algo_template.cpp | 2 +- .../order_plugin_example.cpp | 2 +- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 2 +- .../md/platforms/mdp3_onixs/MDP3Main.cpp | 2 +- .../sparkd/support/ErrorReportService.cpp | 6 +- 47 files changed, 221 insertions(+), 196 deletions(-) rename src/lib/config/defaults/{logging.conf => Logging.conf} (83%) delete mode 100755 src/lib/config/protos/system.proto create mode 100644 src/lib/config/protos/system_config.proto diff --git a/src/client/Directory.Build.Props b/src/client/Directory.Build.Props index 47b823c6d..05190e58e 100644 --- a/src/client/Directory.Build.Props +++ b/src/client/Directory.Build.Props @@ -1,53 +1,54 @@ - - - - ..\..\tools\override\$(computername).props - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\..)) - $([System.IO.Path]::GetFullPath($(SparkRoot)\src)) - $(SparkRoot)\externals\windows - $([System.IO.Path]::GetFileName($([System.IO.Path]::GetFullPath($(SparkRoot))))) - None - False - true - False - false - Debug - true - - - - $(SparkRoot)\build\$(Configuration) - $(BaseOutputPath)\bin - $(BaseOutputPath)\obj\$(MSBuildProjectName) - $(BaseOutputPath)\obj\$(MSBuildProjectName) - $(BaseOutputPath)\gen\$(MSBuildProjectName) - - - - - - $(SparkRoot)\src\lib\api\service_compiler - $(Externals)\bin\protoc.exe - $(Externals)\bin\protogen.exe - - - - - - $(IntermediateOutputPath)\gen\%(relativedir) - %(OutBase)%(FileName).cs - %(OutBase)%(FileName).client.pb.cs - %(OutBase)%(FileName).server.pb.cs - %(OutBase)%(FileName).immutable.pb.cs - - - - $(IntermediateOutputPath)\gen\%(relativedir) - %(OutBase)%(FileName).excel.pb.cs - - - - - + + + + ..\..\tools\override\$(computername).props + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\..)) + $([System.IO.Path]::GetFullPath($(SparkRoot)\src)) + $(SparkRoot)\externals\windows + $([System.IO.Path]::GetFileName($([System.IO.Path]::GetFullPath($(SparkRoot))))) + None + False + true + False + false + Debug + true + + + + $(SparkRoot)\build\$(Configuration) + $(BaseOutputPath)\bin + $(BaseOutputPath)\obj\$(MSBuildProjectName) + $(BaseOutputPath)\obj\$(MSBuildProjectName) + $(BaseOutputPath)\obj\$(MSBuildProjectName) + $(BaseOutputPath)\gen\$(MSBuildProjectName) + + + + + + $(SparkRoot)\src\lib\api\service_compiler + $(Externals)\bin\protoc.exe + $(Externals)\bin\protogen.exe + + + + + + $(IntermediateOutputPath)\gen\%(relativedir) + %(OutBase)%(FileName).cs + %(OutBase)%(FileName).client.pb.cs + %(OutBase)%(FileName).server.pb.cs + %(OutBase)%(FileName).immutable.pb.cs + + + + $(IntermediateOutputPath)\gen\%(relativedir) + %(OutBase)%(FileName).excel.pb.cs + + + + + diff --git a/src/client/spark/Daemons/AboutDaemon.cs b/src/client/spark/Daemons/AboutDaemon.cs index 79b2d42c8..52107b439 100644 --- a/src/client/spark/Daemons/AboutDaemon.cs +++ b/src/client/spark/Daemons/AboutDaemon.cs @@ -38,7 +38,10 @@ namespace bts.ui { Window about = Application.LoadComponent(new Uri("/view/Shell/About.xaml", UriKind.Relative)) as Window; enable_crash_on_dblclick(about); if (about != null) { - about.DataContext = new { Version = Configuration.get().version, User = _user }; + about.DataContext = new { + Version = Configuration.get().Version, + User = _user + }; about.Topmost = true; about.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (a, b) => about.Close())); about.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, (arg, e) => { diff --git a/src/client/spark/Daemons/OopsDaemon.cs b/src/client/spark/Daemons/OopsDaemon.cs index 275d5f5a7..a87cfa47d 100644 --- a/src/client/spark/Daemons/OopsDaemon.cs +++ b/src/client/spark/Daemons/OopsDaemon.cs @@ -25,7 +25,7 @@ namespace bts.spark { void handle_unclean_shutdown(ErrorReporter e, int oldpid) { string extra = ""; try { - var conf = mbts.config.Configuration.get(); + var conf = mbts.config.Configuration.get(); extra = JsonConvert.SerializeObject(conf, Formatting.Indented); } catch { } Task.Run(() => e.report_silently( diff --git a/src/client/spark/Daemons/ShellLatencyDaemon.cs b/src/client/spark/Daemons/ShellLatencyDaemon.cs index 09b6e8ecf..195c4a19c 100644 --- a/src/client/spark/Daemons/ShellLatencyDaemon.cs +++ b/src/client/spark/Daemons/ShellLatencyDaemon.cs @@ -25,7 +25,7 @@ namespace bts.perf { [ImportingConstructor] public ShellLatencyDaemon(ShellLatencyService service, Lazy user) { _service = service; - _version = Configuration.get().version; + _version = Configuration.get().Version; _username = user.Value.name; _hostname = Environment.MachineName; @@ -50,7 +50,7 @@ namespace bts.perf { async void _forever_ping_host(Ping pinger) { var config = Configuration.get(); - string server_ip = Configuration.get().config_ip; + string server_ip = Configuration.get().ConfigIp; int delay = config.workloop_milliseconds_interval; int _current_missed_ping_count = 0; diff --git a/src/client/spark/Init/ReleaseNotesParade.cs b/src/client/spark/Init/ReleaseNotesParade.cs index c7c70c0a3..044b70fb4 100644 --- a/src/client/spark/Init/ReleaseNotesParade.cs +++ b/src/client/spark/Init/ReleaseNotesParade.cs @@ -28,7 +28,7 @@ namespace bts.shell { } } bool check_version() { - string current = Configuration.get().version; + string current = Configuration.get().Version; if (!string.IsNullOrWhiteSpace(current) && current != "private") { using (var key = Registry.CurrentUser.CreateSubKey(@"Software\BTS")) { var value = key.GetValue("version"); diff --git a/src/client/spark/Modules/Support/Browser/BrowserWindow.cs b/src/client/spark/Modules/Support/Browser/BrowserWindow.cs index 60fbc2732..2428ae762 100644 --- a/src/client/spark/Modules/Support/Browser/BrowserWindow.cs +++ b/src/client/spark/Modules/Support/Browser/BrowserWindow.cs @@ -44,8 +44,8 @@ namespace bts.shell { string uristr = uri.ToString(); string http_base = "http://{0}:{1}/".fmt( - Configuration.get().config_host, - Configuration.get().config_port); + Configuration.get().ConfigHost, + Configuration.get().ConfigPort); string temp = uristr; if (uristr.StartsWith("bts://m/")) { temp = uristr.Replace("bts://m/", http_base + "docs/"); @@ -94,7 +94,7 @@ namespace bts.shell { emulation_key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(ke_name); } - var process_name = Configuration.get().process_name; + var process_name = Configuration.get().ProcessName; emulation_key.SetValue(process_name, 11001); // IE11 } #endregion diff --git a/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs b/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs index ec26f3ccf..fd6eb4279 100644 --- a/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs +++ b/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs @@ -26,7 +26,8 @@ namespace BCG Right } - private readonly bool _is_remoted = mbts.config.Configuration.get().is_remote_app; + private readonly bool _is_remoted = + mbts.config.Configuration.get().IsRemoteApp; [Category("Grid Lines")] [DisplayName("Row Seperator Line Color")] diff --git a/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs b/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs index 163ae8057..f1c486aba 100644 --- a/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs +++ b/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs @@ -21,7 +21,8 @@ namespace BCG { Down } - private readonly bool _is_remoted = mbts.config.Configuration.get().is_remote_app; + private readonly bool _is_remoted = + mbts.config.Configuration.get().IsRemoteApp; private readonly PerfStatsLogger _recorder = new PerfStatsLogger(); private readonly HighPerformanceTimer _timer = new HighPerformanceTimer(); private System.ComponentModel.Container components = null; @@ -350,4 +351,4 @@ namespace BCG { } #endregion } -} \ No newline at end of file +} diff --git a/src/client/spark/core/NativeMethods/NativeMethods.cs b/src/client/spark/core/NativeMethods/NativeMethods.cs index 3ca81fe25..4efd440a3 100644 --- a/src/client/spark/core/NativeMethods/NativeMethods.cs +++ b/src/client/spark/core/NativeMethods/NativeMethods.cs @@ -202,7 +202,7 @@ namespace mbts.ui.native { private static extern bool SetWorkArea_SystemParametersInfo(SPI action, uint zero, Win32Rect param, uint winini); public static void SetWorkArea(Rect workarea) { - var dpi_ratio = config.Configuration.get().dpi_ratio; + var dpi_ratio = config.Configuration.get().DpiRatio; workarea = new Rect(workarea.Left * dpi_ratio, workarea.Top * dpi_ratio, (workarea.Right - workarea.Left) * dpi_ratio, (workarea.Bottom - workarea.Top) * dpi_ratio); //const uint SPIF_SENDWININICHANGE = 2; const uint SPIF_UPDATEINIFILE = 1; @@ -220,7 +220,7 @@ namespace mbts.ui.native { // Get the work area for monitor where the specified window is currently. // The work area is the area of the window not covered by the task bar or a docked shell public static Rect GetWorkArea(IntPtr window) { - var dpi_ratio = config.Configuration.get().dpi_ratio; + var dpi_ratio = config.Configuration.get().DpiRatio; IntPtr monitor = MonitorFromWindow(window, MONITOR_DEFAULTONNEAREST); MONITORINFO info = new MONITORINFO(); info.cbSize = Marshal.SizeOf(info); diff --git a/src/client/spark/view/Extensions/HighDpiExtensions.cs b/src/client/spark/view/Extensions/HighDpiExtensions.cs index 09c835ebc..9d14d3cbd 100644 --- a/src/client/spark/view/Extensions/HighDpiExtensions.cs +++ b/src/client/spark/view/Extensions/HighDpiExtensions.cs @@ -24,7 +24,7 @@ namespace mbts.ui.dpi { public static readonly float fdpi_ratio; static HighDpiExtensions() { - dpi_ratio = Configuration.get().dpi_ratio; + dpi_ratio = Configuration.get().DpiRatio; pixel_unit = 1.0 / dpi_ratio; fdpi_ratio = (float)dpi_ratio; } diff --git a/src/client/spark/view/Shell/ShellModel.cs b/src/client/spark/view/Shell/ShellModel.cs index 2035e5831..e25cd856a 100644 --- a/src/client/spark/view/Shell/ShellModel.cs +++ b/src/client/spark/view/Shell/ShellModel.cs @@ -78,7 +78,7 @@ .WithParts(types) .WithDefaultConventions(rules); - string plugin_path = Configuration.get().data_path + "/plugins/"; + string plugin_path = Configuration.get().DataPath + "/plugins/"; if (Directory.Exists(plugin_path)) { var assemblies = Directory.GetFiles(plugin_path, "*.dll") .Select(AssemblyLoadContext.Default.LoadFromAssemblyPath); diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs index 7e837372e..a9431c9ed 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs @@ -153,8 +153,8 @@ namespace mbts.ui.shell { #region Static local save methods private static string local_workspace_path() { - var system = Configuration.get(); - return @"{0}/{1}/{2}".fmt(system.data_path, WORKSPACE_NAMESPACE, "recover_workspace"); + var system = Configuration.get(); + return @"{0}/{1}/{2}".fmt(system.DataPath, WORKSPACE_NAMESPACE, "recover_workspace"); } private static void save_workspace_locally(WorkspaceDefinition workspace) { string path = local_workspace_path(); diff --git a/src/client/spark/view/Utility/ScreenCapture.cs b/src/client/spark/view/Utility/ScreenCapture.cs index e78b784f4..4ba380c33 100644 --- a/src/client/spark/view/Utility/ScreenCapture.cs +++ b/src/client/spark/view/Utility/ScreenCapture.cs @@ -46,8 +46,8 @@ namespace mbts.ui.utility { } static Int32Rect screen_size() { - var config = Configuration.get(); - var dpi = config.dpi_ratio; + var config = Configuration.get(); + var dpi = config.DpiRatio; return new Int32Rect( (int)(SystemParameters.VirtualScreenLeft * dpi), (int)(SystemParameters.VirtualScreenTop * dpi), diff --git a/src/client/spark_api/spark_api.csproj b/src/client/spark_api/spark_api.csproj index b2c84a020..7c5e2c5a7 100644 --- a/src/client/spark_api/spark_api.csproj +++ b/src/client/spark_api/spark_api.csproj @@ -38,8 +38,13 @@ + Include="../../lib/config/protos/*.proto"> + + + + + + diff --git a/src/client/spark_core/logging/LogUtil.cs b/src/client/spark_core/logging/LogUtil.cs index 7c7d569b8..65954ee6d 100644 --- a/src/client/spark_core/logging/LogUtil.cs +++ b/src/client/spark_core/logging/LogUtil.cs @@ -11,9 +11,8 @@ using bts.support; namespace mbts { public static class LogUtil { - private static string log_path = Path.Combine(Configuration.get().data_path, "logging", "log"); - - + static string log_path = Path.Combine( + Configuration.get().DataPath, "logging", "log"); public static ByteString read_logs_compressed() { return FileUtils.read_and_gzip(log_path); diff --git a/src/client/spark_core/spark_core.csproj b/src/client/spark_core/spark_core.csproj index bd2461b85..8880d9389 100644 --- a/src/client/spark_core/spark_core.csproj +++ b/src/client/spark_core/spark_core.csproj @@ -19,8 +19,12 @@ - - + + $(ProtoOutputPath)/lib/config/protos/Logging.cs + + + $(ProtoOutputPath)/lib/config/protos/SystemConfig.cs + diff --git a/src/client/sparkcmd/Cmd/OrderStress.cs b/src/client/sparkcmd/Cmd/OrderStress.cs index 1a0bd48a5..aeba18a7d 100644 --- a/src/client/sparkcmd/Cmd/OrderStress.cs +++ b/src/client/sparkcmd/Cmd/OrderStress.cs @@ -124,7 +124,7 @@ namespace bts { ConsoleEx.WriteLine("Invalid Credentials", ConsoleColor.Red); } - if (Configuration.get().type.ToUpper() == "PROD") { + if (Configuration.get().Type.ToUpper() == "PROD") { ConsoleEx.WriteLine("Refusing to run on production system", ConsoleColor.Red); return -1; } @@ -165,4 +165,4 @@ namespace bts { } } -} \ No newline at end of file +} diff --git a/src/lib/api/core/ApiClientInterop.cpp b/src/lib/api/core/ApiClientInterop.cpp index c7849f014..7ceef1bf2 100644 --- a/src/lib/api/core/ApiClientInterop.cpp +++ b/src/lib/api/core/ApiClientInterop.cpp @@ -11,7 +11,7 @@ #include "lib/api/apicore.pb.h" #include "lib/config/protos/ports.pb.h" #include "lib/config/protos/quickbus_cfg.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #ifdef WIN32 #include @@ -28,7 +28,7 @@ config::QuickbusNodeCfg get_client_node_cfg() { node_cfg.set_max_missed_hbs(cfg.max_missed_hbs()); node_cfg.set_parent_host( cfg.has_qbus_host() ? cfg.qbus_host() - : config::get().config_ip()); + : config::get().config_ip()); node_cfg.set_parent_port( cfg.has_qbus_port() ? cfg.qbus_port() : config::get().qbus_port()); diff --git a/src/lib/api/service_helpers/AdminServiceUtils.cpp b/src/lib/api/service_helpers/AdminServiceUtils.cpp index d4c03ad06..7e8ee16b8 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.cpp +++ b/src/lib/api/service_helpers/AdminServiceUtils.cpp @@ -3,7 +3,7 @@ #include "lib/config/config.h" #include "lib/config/protos/cme_reference_data.pb.h" #include "lib/config/protos/jetfix.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/domain_model/Security.pb.h" #include "lib/md/get_symbols.h" diff --git a/src/lib/config/ConfigurationState.cpp b/src/lib/config/ConfigurationState.cpp index 62baa41e1..f56603bae 100644 --- a/src/lib/config/ConfigurationState.cpp +++ b/src/lib/config/ConfigurationState.cpp @@ -12,7 +12,7 @@ #include "lib/utils/defer.h" #include "lib/utils/is_unittest_environment.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include // iequals #include @@ -137,7 +137,7 @@ void ConfigurationState::initialize_defaults( } void ConfigurationState::initialize_builtins() { - System sys; + SystemConfig sys; sys.set_host_name(os::host_name()); sys.set_process_name(os::get_application_name()); @@ -208,7 +208,7 @@ void ConfigurationState::initialize_builtins() { // // Add the System value to the defaults const proto::FieldDescriptor *field_desc = - _defaults->GetDescriptor()->FindFieldByName("System"); + _defaults->GetDescriptor()->FindFieldByName("SystemConfig"); const proto::Descriptor *message_desc = field_desc->message_type(); // Create a meta message @@ -234,7 +234,7 @@ void ConfigurationState::initialize_introspection() { const proto::FileDescriptor *file_desc = proto::DescriptorPool::generated_pool()->FindFileByName(proto_path); if (file_desc != nullptr) { - ConfigIntrospection::ConfigProto *config_proto = ci.add_config(); + ConfigProto *config_proto = ci.add_config(); bts_assert(config_proto); config_proto->set_name(file_desc->name()); for (int y = 0; y < file_desc->message_type_count(); y++) { @@ -861,10 +861,9 @@ int load_directory( for (const char *proto_file : config_proto_files) { std::string config_file(proto_file); - if (config_file == "system.proto") - continue; - if (config_file == "edge.proto") + if (config_file == "system_config.proto") { continue; + } const char proto_ext[] = ".proto"; const char conf_ext[] = ".conf"; diff --git a/src/lib/config/defaults/logging.conf b/src/lib/config/defaults/Logging.conf similarity index 83% rename from src/lib/config/defaults/logging.conf rename to src/lib/config/defaults/Logging.conf index f9684cd2f..067aaa6d4 100644 --- a/src/lib/config/defaults/logging.conf +++ b/src/lib/config/defaults/Logging.conf @@ -16,6 +16,8 @@ Logging { console { default_level: "Info" } syslog { default_level: "Info" } file { default_level: "Info" } + initial_queue_size: 120001 + max_queue_growth: 4 } } @@ -26,6 +28,8 @@ Logging console { default_level: "Error" } syslog { default_level: "Info" } file { default_level: "Info" } + initial_queue_size: 120001 + max_queue_growth: 4 } } diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index 5ff4b5df8..e8caa2df7 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -25,7 +25,7 @@ PlatformMap { PublisherNamespace { value { - shared_memory_namespace: @System.os_user + shared_memory_namespace: @SystemConfig.os_user } } @@ -45,12 +45,12 @@ CMEOptions { } } -ICEPublisherOptions { - value { - network_interface: "eth1" - } -} - +ICEPublisherOptions { + value { + network_interface: "eth1" + } +} + #to make this work in dev clone the operations repo #go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel> #modify the easyTunnelProxy.properties file to replace diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index 8cbc64c00..431b25c90 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -88,7 +88,7 @@ SymbolLists } Symbols { - rule: "DeploymentType.type == 'DEMO' and System.platform == 'windows'" + rule: "DeploymentType.type == 'DEMO' and SystemConfig.platform == 'windows'" value { sim { future: @SymbolLists.list[GLBX].symbol @@ -102,7 +102,7 @@ Symbols { } Symbols { - rule: "DeploymentType.type == 'PROD' and System.platform == 'windows'" + rule: "DeploymentType.type == 'PROD' and SystemConfig.platform == 'windows'" value { glbx { future: @SymbolLists.list[GLBX].symbol diff --git a/src/lib/config/protos/logging.proto b/src/lib/config/protos/logging.proto index 337a219a0..941dd1f8e 100644 --- a/src/lib/config/protos/logging.proto +++ b/src/lib/config/protos/logging.proto @@ -1,22 +1,24 @@ -syntax = 'proto2'; +syntax = "proto3"; package bts.config; -message Logging { - message SubsystemConfig { - required string name = 1; - required string level = 2; - } +option csharp_namespace = "bts.config"; - message SinkConfig { - optional string default_level = 2 [ default = "Info" ]; - repeated SubsystemConfig subsystem = 3; - } +message SubsystemConfig { + string name = 1; + string level = 2; +} - required SinkConfig console = 1; - required SinkConfig syslog = 2; - required SinkConfig file = 5; +message SinkConfig { + string default_level = 2; + repeated SubsystemConfig subsystem = 3; +} - optional uint32 initial_queue_size = 3 [ default = 120001 ]; - optional uint32 max_queue_growth = 4 [ default = 4 ]; +message Logging { + SinkConfig console = 1; + SinkConfig syslog = 2; + SinkConfig file = 5; + + uint32 initial_queue_size = 3; + uint32 max_queue_growth = 4; } diff --git a/src/lib/config/protos/system.proto b/src/lib/config/protos/system.proto deleted file mode 100755 index e9e3627bd..000000000 --- a/src/lib/config/protos/system.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = 'proto2'; - -package bts.config; - -message System { - required string host_name = 1; - required string process_name = 3; - required string directory = 4; - required string platform = 5; - required string qualifier = 6; - required bool unittest_environment = 7; - required string data_path = 8; - optional string version = 9 [ default = "private" ]; - repeated string cmd_args = 10; - // 11,12,13 - required string build_type = 14 [ default = "release" ]; - required string config_host = 15; - required string config_ip = 16 [ default = "127.0.0.1" ]; - optional bool is_remote_app = 17 [ default = false ]; - required string os_user = 18; - optional int32 dpi = 19 [ default = 96 ]; - optional double dpi_ratio = 20 [ default = 1.0 ]; - optional int32 num_cores = 21; - optional int32 config_port = 22 [ default = 80 ]; -} - -message ConfigIntrospection { - message ConfigProto { - required string name = 1; - repeated string type = 2; - } - repeated ConfigProto config = 1; -} - -message DeploymentType { - optional string type = 1 [ default = "dev" ]; -} diff --git a/src/lib/config/protos/system_config.proto b/src/lib/config/protos/system_config.proto new file mode 100644 index 000000000..94dd3e01a --- /dev/null +++ b/src/lib/config/protos/system_config.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package bts.config; + +option csharp_namespace = "bts.config"; + +message SystemConfig { + string host_name = 1; + string process_name = 3; + string directory = 4; + string platform = 5; + string qualifier = 6; + bool unittest_environment = 7; + string data_path = 8; + string version = 9; + repeated string cmd_args = 10; + // 11,12,13 + string build_type = 14; + string config_host = 15; + string config_ip = 16; + bool is_remote_app = 17; + string os_user = 18; + int32 dpi = 19; + double dpi_ratio = 20; + int32 num_cores = 21; + int32 config_port = 22; +} + +message ConfigProto { + string name = 1; + repeated string type = 2; +} + +message ConfigIntrospection { + repeated ConfigProto config = 1; +} + +message DeploymentType { + string type = 1; +} diff --git a/src/lib/config/tests/config_tests.cpp b/src/lib/config/tests/config_tests.cpp index 18a5632f3..27510bbe9 100644 --- a/src/lib/config/tests/config_tests.cpp +++ b/src/lib/config/tests/config_tests.cpp @@ -10,7 +10,7 @@ #include "HTTPServer.h" #include "lib/config/invalid/invalid.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/config/protos/testkeys.pb.h" #include @@ -175,7 +175,7 @@ TEST_CASE("Configuration Tests", "[config]") { REQUIRE(foogrp.group() == "http_group"); REQUIRE(foogrp.foo().name() == "http"); REQUIRE(foogrp.foo().id() == 80); - REQUIRE(get().config_host() == "127.0.0.1"); + REQUIRE(get().config_host() == "127.0.0.1"); } SECTION("http_folder_test") { @@ -332,7 +332,7 @@ TEST_CASE("Configuration Tests", "[config]") { SECTION("built_in_properties_test") { initialize_for_test("Foo { \n" - " rule: \"System.unittest_environment == true \"\n" + " rule: \"SystemConfig.unittest_environment == true \"\n" " value {\n" " name: \"unit tests\"\n" " }\n" diff --git a/src/lib/logging/logging.cpp b/src/lib/logging/logging.cpp index 4ba9c1cf6..cc8f88913 100644 --- a/src/lib/logging/logging.cpp +++ b/src/lib/logging/logging.cpp @@ -3,7 +3,7 @@ #include "LoggerHub.h" #include "lib/config/config.h" #include "lib/config/protos/logging.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/os/os.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/bts_assert.h" @@ -50,7 +50,7 @@ boost::filesystem::path log_path() { void start_default_logging_thread() { _default_logger_hub.start(); } -Filter get_filter(LoggingConfig &cfg, config::Logging::SinkConfig const &scfg) { +Filter get_filter(LoggingConfig &cfg, config::SinkConfig const &scfg) { Filter result; for (auto &l : result) l = Info; diff --git a/src/lib/md/Diag/MDPeriodicDumper.cpp b/src/lib/md/Diag/MDPeriodicDumper.cpp index 71386cf18..6d3720754 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.cpp +++ b/src/lib/md/Diag/MDPeriodicDumper.cpp @@ -1,5 +1,5 @@ #include "MDPeriodicDumper.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/md/MDConsumer.h" #include "lib/md/SecurityCache.h" #include "lib/utils/Dispatcher.h" @@ -170,7 +170,7 @@ void run_periodic_dumper( PrintFormat format, bool monitor_all) { - auto qualifier = config::get().qualifier(); + auto qualifier = config::get().qualifier(); auto thread_name = "tail-" + qualifier; threading::configure_current_thread(thread_name); @@ -216,4 +216,4 @@ void run_periodic_dumper( } } // namespace md -} // namespace bts \ No newline at end of file +} // namespace bts diff --git a/src/lib/md/SecurityDB.cpp b/src/lib/md/SecurityDB.cpp index b2c2e51d3..203e8df2e 100644 --- a/src/lib/md/SecurityDB.cpp +++ b/src/lib/md/SecurityDB.cpp @@ -7,7 +7,7 @@ #include "lib/config/config.h" #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/domain_model/Security.h" #include "lib/md/Shm/FixedSecurity.h" @@ -32,7 +32,8 @@ namespace db { std::unique_ptr open_db() { // Directory location on disk - auto db_dir = config::get().data_path() + "databases/md/"; + auto db_dir = + config::get().data_path() + "databases/md/"; auto db_path = db_dir + "/securities.sqlite"; if (!boost::filesystem::exists(db_dir)) { boost::filesystem::create_directories(db_dir); diff --git a/src/lib/md/SecurityIDRecorder.cpp b/src/lib/md/SecurityIDRecorder.cpp index 249551049..2a35c828c 100644 --- a/src/lib/md/SecurityIDRecorder.cpp +++ b/src/lib/md/SecurityIDRecorder.cpp @@ -9,7 +9,7 @@ #include #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include #include @@ -83,7 +83,8 @@ SecurityIDRecorder::~SecurityIDRecorder() {} void SecurityIDRecorder::init() { LOG(md, Info, "SecurityIDRecorder::init"); - string db_dir = config::get().data_path() + "databases/md/"; + string db_dir = + config::get().data_path() + "databases/md/"; string db_path = db_dir + "/security_keys.sqlite"; if (!boost::filesystem::exists(db_dir)) { diff --git a/src/lib/md/SettlementRecorder.cpp b/src/lib/md/SettlementRecorder.cpp index de61e98fa..541fee757 100644 --- a/src/lib/md/SettlementRecorder.cpp +++ b/src/lib/md/SettlementRecorder.cpp @@ -1,7 +1,7 @@ #ifndef WIN32 #include "SettlementRecorder.h" #include "lib/config/config.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/utils/Sqlite_utils.h" #include #include @@ -85,7 +85,8 @@ void apply_work(SettlementRecorderImpl &me, Work work) { SettlementRecorder::SettlementRecorder(Platform platform) : _self(new SettlementRecorderImpl()) { - string db_dir = config::get().data_path() + "databases/md/"; + string db_dir = + config::get().data_path() + "databases/md/"; string db_path = db_dir + "/settlements_" + Platform_Name(platform) + ".sqlite"; if (!boost::filesystem::exists(db_dir)) { diff --git a/src/lib/md/cme/MDP3Utils.cpp b/src/lib/md/cme/MDP3Utils.cpp index ff7ae4f39..9036e5faa 100644 --- a/src/lib/md/cme/MDP3Utils.cpp +++ b/src/lib/md/cme/MDP3Utils.cpp @@ -9,7 +9,7 @@ #include "lib/utils/download.h" #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include #include @@ -42,7 +42,7 @@ std::ostream &operator<<(std::ostream &out, md::CMEChannel const &ch) { } string data_path() { - auto p = config::get().data_path() + "cme_mdp3/"; + auto p = config::get().data_path() + "cme_mdp3/"; #ifdef _WIN32 // OnixS requires win32 paths to look like Win32 paths - everyone else in the // world is ok with '/' diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index aa1f0ba64..9a5154838 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -9,7 +9,7 @@ #include "lib/utils/download.h" #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include #include @@ -53,7 +53,7 @@ const vector parse_ice_channels(const vector &symbols) { } string ice_data_path() { - auto p = config::get().data_path() + "onixs_ice/"; + auto p = config::get().data_path() + "onixs_ice/"; #ifdef _WIN32 // OnixS requires win32 paths to look like Win32 paths - everyone else in the // world is ok with '/' diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index caeff66bb..5a5c8eff1 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -20,7 +20,7 @@ #include "lib/api/services/AdminService.client.pb.h" #include "lib/api/services/MarketDataRelay.server.pb.h" #include "lib/config/protos/cme_reference_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/md/SecurityCache.h" #include "lib/md/protos/co2.pb.h" #include "lib/utils/ConcurrentAppendCollection.h" diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 7efb50500..4ec52211b 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -13,7 +13,7 @@ #include "lib/api/public/ServiceContext.h" #include "lib/api/services/MarketDataRelay.client.pb.h" #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/md/protos/co2.pb.h" #include "lib/utils/base64.hpp" @@ -200,7 +200,7 @@ class RelayClient { : _request(), _rpc(rpc), _pconsumer(pconsumer), _writer(writer), _request_log(utils::TimeStamp::now()) { ostringstream fmt; - fmt << config::get().host_name() << "(" + fmt << config::get().host_name() << "(" << os::process_id() << ")"; _request.set_host(fmt.str()); for (const auto &s : symbols) { diff --git a/src/lib/md/relay/RelayRecorder.cpp b/src/lib/md/relay/RelayRecorder.cpp index 2ecfea27b..8403fb0e4 100644 --- a/src/lib/md/relay/RelayRecorder.cpp +++ b/src/lib/md/relay/RelayRecorder.cpp @@ -8,7 +8,7 @@ #include "lib/utils/datetime.h" #include "lib/config/protos/market_data.pb.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include "lib/md/SecurityIDRecorder.h" #include "lib/md/common.h" #include "lib/md/protos/co2.pb.h" @@ -62,7 +62,7 @@ RelayRecorder::RelayRecorder( header.set_magic(magic); header.set_version(recorder_version); header.set_timestamp(datetime::ll_now()); - header.set_host(config::get().config_host()); + header.set_host(config::get().config_host()); header.set_naggle_ms(naggle); writebuf(_file, header); } @@ -293,7 +293,7 @@ void unprint_recording(const std::string &src, const std::string &dest) { header.set_magic(magic); header.set_version(recorder_version); header.set_timestamp(datetime::ll_now()); - header.set_host(config::get().host_name()); + header.set_host(config::get().host_name()); writebuf(out, header); int index = 0; diff --git a/src/lib/metrics/system_metrics.cpp b/src/lib/metrics/system_metrics.cpp index c6f953c5d..b89878093 100644 --- a/src/lib/metrics/system_metrics.cpp +++ b/src/lib/metrics/system_metrics.cpp @@ -1,7 +1,7 @@ #include "system_metrics.h" #include "lib/config/config.h" -#include "lib/config/protos/system.pb.h" +#include "lib/config/protos/system_config.pb.h" #include #include @@ -55,7 +55,7 @@ void publish_system_metrics(MetricsContainer &stats) { auto version = std::make_shared>( "spark_version", std::vector