From 72243210e0cee32b1891f3df57e681afe4a69fa7 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Sat, 16 Sep 2017 23:35:01 +0000 Subject: [PATCH] Changed build to automatically determine sources from disk. --- src/lib/CMakeDeps.cmake | 2 + src/lib/CMakeLists.txt | 207 +--- .../tests/expression_parser_tests.cpp | 308 ++--- src/lib/md/protos/coconut.proto | 334 ------ src/lib/order_man/protos/OrderMan.proto | 1 - src/lib/os/tests/os_tests.cpp | 56 +- src/server/sparkd/CMakeDeps.cmake | 2 + src/server/sparkd/CMakeLists.txt | 91 +- .../md/platforms/mdp3_onixs/MDP3Listener.cpp | 1022 ++++++++--------- .../md/platforms/mdp3_onixs/MDP3Main.cpp | 536 ++++----- .../md/platforms/mdp3_onixs/MDP3Utils.cpp | 214 ++-- .../platforms/mdp3_onixs/tests/mdp3_tests.cpp | 354 +++--- src/server/sparkd/order_man/order_man_utils.h | 1 + tools/safe_dep_glob.cmake | 29 + 14 files changed, 1330 insertions(+), 1827 deletions(-) create mode 100644 src/lib/CMakeDeps.cmake delete mode 100755 src/lib/md/protos/coconut.proto create mode 100644 src/server/sparkd/CMakeDeps.cmake create mode 100644 tools/safe_dep_glob.cmake diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake new file mode 100644 index 000000000..bc9b53101 --- /dev/null +++ b/src/lib/CMakeDeps.cmake @@ -0,0 +1,2 @@ +# generated by make process +set(sources api/apicore.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/services/ApiUnitTestService.proto;api/services/HelloService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/Executor.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Securities.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/User.proto;config/protos/environment.proto;config/protos/expiration_display_offset.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/quickbus_cfg.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.proto;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPriceLantencyTester.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Structure/FixedSecurity.cpp;md/Structure/PriceSize.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;order_man/protos/OrderMan.proto;os/Win32Exception.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;security_model/SecurityHelper.cpp;security_model/old_security.proto;sparkproto/SparkProtos.proto;testing/windows_test_driver.cpp;utils/Dispatcher.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 4f2338da0..68bbf4e00 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,160 +1,32 @@ cmake_minimum_required(VERSION 3.5) project(spark_lib) -# config protos -set (Config_Protos - config/protos/system.proto - config/protos/testkeys.proto - config/protos/logging.proto - config/protos/quickbus_cfg.proto - config/protos/jetfix.proto - config/protos/MarketData.proto - config/protos/Symbols.proto - config/protos/Ports.proto - config/protos/Executor.proto - config/protos/User.proto - config/protos/UI.proto - config/protos/toggles.proto - config/protos/environment.proto - ) - -# non config/non service protos -set (NonConfig_Protos - config/invalid/invalid.proto - config/extensions/extensions.proto - quickbus/network/quickbus_msgs.proto - security_model/old_security.proto - domain_model/Security.proto - api/apicore.proto - api/apioptions.proto - sparkproto/SparkProtos.proto - md/protos/co2.proto - ) - -# service protos -set (Service_Protos - api/services/ApiUnitTestService.proto - api/services/HelloService.proto - api/services/PersistenceService.proto - api/services/UserService.proto - api/services/MarketDataRelay.proto - api/services/OrderService.proto - ) - +include(${CMAKE_SOURCE_DIR}/tools/safe_dep_glob.cmake) include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake) + +# DEPENDENCIES + # config protos + file(GLOB_RECURSE Config_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} config/protos/*.proto) + + # service protos + file (GLOB_RECURSE Service_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/services/*.proto) + + # non config/non service protos + file(GLOB_RECURSE NonConfig_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.proto) + list(REMOVE_ITEM NonConfig_Protos ${Service_Protos} ${Config_Protos}) + + # normal cpps + file(GLOB_RECURSE SparkLib_Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) + + # this is used to communicate to other repositories that the build + # needs to happen again (because a file was added) + update_deps_file("${SparkLib_Sources};${Config_Protos};${Service_Protos};${NonConfig_Protos}") +# END DEPENDENCIES + + protobuf_generate_cpp( PROTO_SRCS PROTO_HDRS ${NonConfig_Protos} ${Config_Protos}) service_compiler_generate_cpp(SERVICE_COMPILER_SRCS SERVICE_COMPILER_HDRS ${Service_Protos}) -# srcs for sparkd -set (SparkLib_Sources - - # api - api/core/ApiClientInterop.cpp - api/core/ApiServerInterop.cpp - api/public/ApiServer.cpp - api/public/ClientChannel.cpp - api/public/QuickbusClientChannel.cpp - api/public/ServerChannel.cpp - api/public/ServiceContext.cpp - api/test/ApiTests.cpp - api/test/HelloServiceServer.cpp - - # expression - expression/BooleanGrammar.cpp - expression/ExpressionEvaluator.cpp - expression/ParserExceptions.cpp - expression/Value.cpp - - # config - config/config.cpp - config/ConfigDownloader.cpp - config/ConfigErrorCollector.cpp - config/ConfigLog.cpp - config/ConfigPropertyEvaluator.cpp - config/ConfigurationException.cpp - config/ConfigurationState.cpp - config/ConfigValueQueue.cpp - config/PreprocessInputStream.cpp - config/ConfigCheck.cpp - config/text_format/text_format.cpp - config/tests/config_ref_tests.cpp - config/tests/HTTPServer.cpp - config/tests/config_tests.cpp - - # quickbus - quickbus/core/LocalNode.cpp - quickbus/core/Quickbus.cpp - quickbus/core/SubscriptionID.cpp - quickbus/core/TableID.cpp - quickbus/message_model/Update.cpp - quickbus/message_model/merge_updates.cpp - quickbus/network/QBConnection.cpp - quickbus/network/QBConnectionManager.cpp - quickbus/network/endpoint_description.cpp - quickbus/pubsub/TablePublisher.cpp - quickbus/pubsub/TableSubscriber.cpp - quickbus/pubsub/tests/qb_pubsub_tests.cpp - quickbus/routing/INode.cpp - quickbus/routing/NodeID.cpp - quickbus/routing/Router.cpp - quickbus/rpc/RPCClient.cpp - quickbus/rpc/RPCServer.cpp - quickbus/rpc/RPCSessionID.cpp - quickbus/rpc/rpc_utils.cpp - quickbus/rpc/tests/qb_rpc_tests.cpp - quickbus/tests/quickbus_tests.cpp - - # md - md/MDConsumer.cpp - md/MDConsumerHandle.cpp - md/MDConsumerInterop.cpp - md/MDProducer.cpp - md/MDProducerHandle.cpp - md/MDRecoverableConsumer.cpp - md/MemorySegmentUtils.cpp - md/PlatformLoader.cpp - md/SecurityIDRecorder.cpp - md/SettlementRecorder.cpp - md/common.cpp - md/relay/QueryServer.cpp - md/relay/RelayClient.cpp - md/relay/RelayRecorder.cpp - md/Structure/FixedSecurity.cpp - md/Structure/PriceSize.cpp - md/Diag/MDPriceLantencyTester.cpp - md/Diag/ShmDumper.cpp - md/test/Co2TestInstrument.cpp - md/test/md2_tests.cpp - - # OS - os/os.cpp - - #logging - logging/logging.cpp - logging/tests/logging_tests.cpp - logging/LoggerHub.cpp - logging/Sink.cpp - - # misc utils - utils/is_unittest_environment.cpp - utils/datetime.cpp - utils/PBUtils.cpp - utils/Uuid.cpp - utils/file_utils.cpp - utils/HTTPStream.cpp - utils/SharedMemory.cpp - utils/Dispatcher.cpp - utils/Sqlite_utils.cpp - utils/init_spark_lib.cpp - utils/Puid.cpp - - # security model - security_model/SecurityHelper.cpp - - # testing - testing/windows_test_driver.cpp - ) - # generate list of config protos set(config_proto_file ${CMAKE_CURRENT_BINARY_DIR}/config_proto_files.h) file(REMOVE ${config_proto_file}) @@ -166,28 +38,24 @@ foreach(protopath ${Config_Protos}) endforeach(protopath) file(APPEND ${config_proto_file} "};\n") - # spark_lib if (WIN32) -add_library(spark_lib SHARED - ${SparkLib_Sources} - ${PROTO_SRCS} - ${SERVICE_COMPILER_SRCS} - ) + include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake) + add_library(spark_lib SHARED + ${SparkLib_Sources} + ${PROTO_SRCS} + ${SERVICE_COMPILER_SRCS} + ) else () -add_library(spark_lib STATIC - ${SparkLib_Sources} - ${PROTO_SRCS} - ${SERVICE_COMPILER_SRCS} - ) + add_library(spark_lib STATIC + ${SparkLib_Sources} + ${PROTO_SRCS} + ${SERVICE_COMPILER_SRCS} + ) endif() - #include paths -target_include_directories( spark_lib PUBLIC - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_BINARY_DIR}/src - ) +target_include_directories( spark_lib PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) if (WIN32) target_link_libraries( spark_lib @@ -224,9 +92,4 @@ else () -static-libstdc++ -pthread) endif() - -if (WIN32) -include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake) -endif() - - + diff --git a/src/lib/expression/tests/expression_parser_tests.cpp b/src/lib/expression/tests/expression_parser_tests.cpp index 3d9f08ded..55c87286f 100755 --- a/src/lib/expression/tests/expression_parser_tests.cpp +++ b/src/lib/expression/tests/expression_parser_tests.cpp @@ -1,179 +1,179 @@ -#include "core/bts_core/utest/utest.h" +// #include "core/bts_core/utest/utest.h" -#include "../IPropertyEvaluator.h" -#include "../ExpressionEvaluator.h" -#include "../ParserExceptions.h" +// #include "../IPropertyEvaluator.h" +// #include "../ExpressionEvaluator.h" +// #include "../ParserExceptions.h" -#include "core/bts_core/utils/BTS_SharedPtr.h" -#include +// #include "core/bts_core/utils/BTS_SharedPtr.h" +// #include -using namespace bts::expression; +// using namespace bts::expression; -namespace bts { +// namespace bts { - // Simple property evaluator for testing - class EvaluatesToFoo : public IPropertyEvaluator - { - public: - EvaluatesToFoo() - { } - ~EvaluatesToFoo() - { } - BTS_NO_COPY(EvaluatesToFoo); +// // Simple property evaluator for testing +// class EvaluatesToFoo : public IPropertyEvaluator +// { +// public: +// EvaluatesToFoo() +// { } +// ~EvaluatesToFoo() +// { } +// BTS_NO_COPY(EvaluatesToFoo); - bool get_value(const std::string& prop, Value* out_value) OVERRIDE - { - bool valid = prop.substr(0,3) == "Foo"; - if (valid && out_value != nullptr) - { - if (prop == "Foo.number") - { - *out_value = Value(42.0); - } - else if (prop == "Foo.list") - { - std::vector values; - values.push_back(Value(std::string("foo"))); - values.push_back(Value(std::string("bar"))); - values.push_back(Value(std::string("baz"))); - *out_value = Value(values); - } - else if (prop == "Foo.bool") - { - *out_value = Value(true); - } - else - { - // Foo.* - *out_value = Value(std::string("Foo")); - } - } +// bool get_value(const std::string& prop, Value* out_value) OVERRIDE +// { +// bool valid = prop.substr(0,3) == "Foo"; +// if (valid && out_value != nullptr) +// { +// if (prop == "Foo.number") +// { +// *out_value = Value(42.0); +// } +// else if (prop == "Foo.list") +// { +// std::vector values; +// values.push_back(Value(std::string("foo"))); +// values.push_back(Value(std::string("bar"))); +// values.push_back(Value(std::string("baz"))); +// *out_value = Value(values); +// } +// else if (prop == "Foo.bool") +// { +// *out_value = Value(true); +// } +// else +// { +// // Foo.* +// *out_value = Value(std::string("Foo")); +// } +// } - return valid; - } - }; +// return valid; +// } +// }; - class EvaluatesRecursively : public IPropertyEvaluator - { - public: - EvaluatesRecursively() - : _e(nullptr) - { } - ~EvaluatesRecursively() - { } - BTS_NO_COPY(EvaluatesRecursively); +// class EvaluatesRecursively : public IPropertyEvaluator +// { +// public: +// EvaluatesRecursively() +// : _e(nullptr) +// { } +// ~EvaluatesRecursively() +// { } +// BTS_NO_COPY(EvaluatesRecursively); - void set_evaluator(ExpressionEvaluator* e) - { - _e = e; - } +// void set_evaluator(ExpressionEvaluator* e) +// { +// _e = e; +// } - bool get_value(const std::string& prop, Value* out_value) OVERRIDE - { - std::string recur = "42 == " + prop; - if (out_value) - { - *out_value = Value(_e->eval(recur)); - } - return true; - } +// bool get_value(const std::string& prop, Value* out_value) OVERRIDE +// { +// std::string recur = "42 == " + prop; +// if (out_value) +// { +// *out_value = Value(_e->eval(recur)); +// } +// return true; +// } - ExpressionEvaluator* _e; - }; +// ExpressionEvaluator* _e; +// }; - struct expression_tests : public TestSuite - { - expression_tests() { } - ~expression_tests() { } - BTS_NO_COPY(expression_tests); +// struct expression_tests : public TestSuite +// { +// expression_tests() { } +// ~expression_tests() { } +// BTS_NO_COPY(expression_tests); - void setup() - { - } +// void setup() +// { +// } - void teardown() - { - } +// void teardown() +// { +// } - void simple_operator_test() - { - ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); - test_assert(e.eval("!!true")); - test_assert(e.eval("3 == 3")); - test_assert(e.eval("4 > 3")); - test_assert(e.eval("3 < 6")); - test_assert(e.eval("3 <= 3.5")); - test_assert(e.eval("3 in [1,2,3]")); - test_assert(!e.eval("3 in [1,2,4]")); - test_assert(e.eval("'oo' in Foo.foo")); - test_assert(e.eval("'oo' == 'oo'")); - test_assert(e.eval("'afoobar' ~= 'foo.*'")); - test_assert(!e.eval("'afoobar' ~= '^foo.*'")); - } +// void simple_operator_test() +// { +// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); +// test_assert(e.eval("!!true")); +// test_assert(e.eval("3 == 3")); +// test_assert(e.eval("4 > 3")); +// test_assert(e.eval("3 < 6")); +// test_assert(e.eval("3 <= 3.5")); +// test_assert(e.eval("3 in [1,2,3]")); +// test_assert(!e.eval("3 in [1,2,4]")); +// test_assert(e.eval("'oo' in Foo.foo")); +// test_assert(e.eval("'oo' == 'oo'")); +// test_assert(e.eval("'afoobar' ~= 'foo.*'")); +// test_assert(!e.eval("'afoobar' ~= '^foo.*'")); +// } - void test_bool_conversion() - { - ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); - test_assert(e.eval("true")); - test_assert(e.eval("1")); - test_assert(e.eval("1.5")); - test_assert(e.eval("'true string'")); - //test_assert(e.eval("[1,2,3]")); // list not valid here - only after "in" - test_assert(e.eval("Foo.x")); - test_assert(e.eval("Foo.list")); - test_assert(!e.eval("''")); - } +// void test_bool_conversion() +// { +// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); +// test_assert(e.eval("true")); +// test_assert(e.eval("1")); +// test_assert(e.eval("1.5")); +// test_assert(e.eval("'true string'")); +// //test_assert(e.eval("[1,2,3]")); // list not valid here - only after "in" +// test_assert(e.eval("Foo.x")); +// test_assert(e.eval("Foo.list")); +// test_assert(!e.eval("''")); +// } - void property_validator_test() - { - ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); - test_assert(e.check_valid("Foo.bar == 'Foo' or 'x' in [Foo.x, Foo.y, 'z']", nullptr)); - std::string bad_property; - test_assert(!e.check_valid("Foo.bar == 'Foo' or 'x' in [Fuu.x, Foo.y, 'z']", &bad_property)); - test_assert(bad_property == "Fuu.x"); - } +// void property_validator_test() +// { +// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); +// test_assert(e.check_valid("Foo.bar == 'Foo' or 'x' in [Foo.x, Foo.y, 'z']", nullptr)); +// std::string bad_property; +// test_assert(!e.check_valid("Foo.bar == 'Foo' or 'x' in [Fuu.x, Foo.y, 'z']", &bad_property)); +// test_assert(bad_property == "Fuu.x"); +// } - void more_complex_test() - { - ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); +// void more_complex_test() +// { +// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); - test_assert(e.eval("Foo.bar == 'Foo' and 'b' in ['a', 'b', 'c', Foo.bar]")); - test_assert(e.eval("Foo.number > 2 or (3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); - test_assert(!e.eval("(3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); - test_assert(e.eval("'foo' in Foo.list and Foo.number == 42.0")); - test_assert(e.eval("!!('oo' in Foo.foo)")); - test_assert(e.eval("!('ooo' in Foo.foo)")); - test_assert(e.eval("!false in [false, false, false, false, true, Foo.bool]")); - } +// test_assert(e.eval("Foo.bar == 'Foo' and 'b' in ['a', 'b', 'c', Foo.bar]")); +// test_assert(e.eval("Foo.number > 2 or (3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); +// test_assert(!e.eval("(3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); +// test_assert(e.eval("'foo' in Foo.list and Foo.number == 42.0")); +// test_assert(e.eval("!!('oo' in Foo.foo)")); +// test_assert(e.eval("!('ooo' in Foo.foo)")); +// test_assert(e.eval("!false in [false, false, false, false, true, Foo.bool]")); +// } - void recursive_test() - { - BTS_SharedPtr badprops (new EvaluatesRecursively()); - ExpressionEvaluator e(badprops); - badprops->set_evaluator(&e); +// void recursive_test() +// { +// BTS_SharedPtr badprops (new EvaluatesRecursively()); +// ExpressionEvaluator e(badprops); +// badprops->set_evaluator(&e); - // Try to get the 'fuzzy'property recursively - bool success = false; - try - { - test_assert(e.eval("fuzzy == 42")); - } - catch(RecursivePropertyGetException) - { - success = true; - } - test_assert(success); - } +// // Try to get the 'fuzzy'property recursively +// bool success = false; +// try +// { +// test_assert(e.eval("fuzzy == 42")); +// } +// catch(RecursivePropertyGetException) +// { +// success = true; +// } +// test_assert(success); +// } - }; +// }; - BEGIN_TEST_SUITE(expression_tests) - ADD_TEST(simple_operator_test); - ADD_TEST(test_bool_conversion); - ADD_TEST(property_validator_test); - ADD_TEST(more_complex_test); - ADD_TEST(recursive_test); - END_TEST_SUITE +// BEGIN_TEST_SUITE(expression_tests) +// ADD_TEST(simple_operator_test); +// ADD_TEST(test_bool_conversion); +// ADD_TEST(property_validator_test); +// ADD_TEST(more_complex_test); +// ADD_TEST(recursive_test); +// END_TEST_SUITE -} +// } diff --git a/src/lib/md/protos/coconut.proto b/src/lib/md/protos/coconut.proto deleted file mode 100755 index e933915ee..000000000 --- a/src/lib/md/protos/coconut.proto +++ /dev/null @@ -1,334 +0,0 @@ -syntax='proto2'; -package bts.md; -// option cc_enable_arenas = true; - -// -// Notes -// -// When you update this file you also need to update the coconut system to handle the new message type. -// -// Use this handy checklist -// -// [ ] SubscriptionBuilder -// [ ] SubscriptionEx -// [ ] // Remember to increase the size of PublishOptions._flags -// [ ] MDRecorder -// [ ] ReplaySubscription -// [ ] Any market data provider which should produce the message (duh) - -import "lib/security_model/security.proto"; - -// -// Enums -// - -message Platform -{ - enum type - { - UNSET = 0; - SIM = 1; - SRLABS = 2; - SPRYWARE = 3; - CSM = 4; - CME = 5; - STREAM = 6; - ICE = 7; - REPLAY = 8; - ACTIV = 9; - MDP3ONIXS = 10; - CSM_ONIXS = 11; - BLUE = 12; - } -} - -message BidOrAsk -{ - enum type - { - BID = 1; - ASK = 2; - } -} - -message CBOEVolumeType -{ - enum type - { - TOTAL = 1; - CUSTOMER = 2; - ALL_OR_NONE = 3; - CUSTOMER_ALL_OR_NONE = 4; - } -} - -message TradingStatus -{ - enum type - { - UNKNOWN = 1; - NORMAL = 2; - CLOSED = 3; - PRE_OPEN = 4; - OPENING_ROTATION = 5; - FAST_MARKET = 6; // CBOE - SUSPENDED = 7; - HALTED = 8; - PRICE_INDICATION = 9; // CME - PRE_CROSS = 10; // CME - CROSS = 11; // CME - NO_CANCEL = 12; // CME - } -} - -message CoconutSecurityStatus -{ - enum type - { - OK = 0; - PACKET_LOSS = 2; - } -} - -// Instrument definition (Security) from exchange_messages.proto - -message BookMessage -{ - optional int64 time = 1; - required BidOrAsk.type side = 2; - optional double price = 3; - optional uint32 size = 4; - - // No longer needed since 1.111 as customer bbo has a dedicated channel - //optional CBOEVolumeType.type volume_type = 5 [default = TOTAL]; - - // Performance - optional uint64 server_arrival_time = 6; - optional uint64 client_arrival_time = 7; - - // Price now integer 3.0 - // optional int64 mantissa = 8; - // optional int32 exponent = 9; -} - -message TradeMessage -{ - optional int64 time = 1; - optional double price = 2; - optional uint32 size = 3; - optional uint32 total_volume = 4; - //optional string trade_condition = 5; - - // Added for Co2 to avoid heap - optional uint32 security_key = 6; -} - -message MiscMessage { - optional double settlement_price = 1; - optional uint64 settlement_timestamp = 2; - - optional double opening_price = 3; - optional uint32 opening_size = 4; - - optional double closing_price = 5; - //optional uint32 closing_size = 6; - - optional double session_high = 7; - optional double session_low = 8; - optional double open_interest = 9; - optional double prior = 10; - optional double session_high_bid = 11; - optional double session_low_offer = 12; - optional double fixing_price = 13; - - //optional double reference_price = 14; - //optional int64 reference_date = 15; -} - -message QuoteRequestMessage { - optional int64 time = 1; - optional string request_id = 2; - - optional double price = 10; - optional int32 size = 11; - enum Side { - UNDEFINED = 0; - // match o2 Side - BUY = 49; - SELL = 50; - CROSS = 99; - } - optional Side side = 12 [default = UNDEFINED]; - optional int64 transact_time = 13; - optional uint32 quote_type = 14; - - // Co2 - optional uint32 security_key = 15; - optional uint32 sequence = 16; - -} - -// -// Wire messages (Coconut 1) -// - -message SecurityRow -{ - optional uint64 security_id = 1; - required bts.security_model.Security security = 2; -} - -message ExchangeStatusRow -{ - optional uint64 security_id = 1; - required TradingStatus.type status = 2; -} - -message CoconutStatusRow -{ - optional uint64 security_id = 1; - required CoconutSecurityStatus.type status = 2; -} - - -message BBORow -{ - optional uint64 security_id = 1; - optional BookMessage bid = 2; - optional BookMessage ask = 3; -} - -message CustomerBBORow -{ - optional uint64 security_id = 1; - optional BookMessage bid = 2; - optional BookMessage ask = 3; -} - -message BookRow -{ - optional uint64 security_id = 1; - optional uint32 depth = 2; - required BookMessage book = 3; -} - -message TradeRow -{ - optional uint64 security_id = 1; - optional TradeMessage trade = 2; -} - -message MiscRow { - optional uint64 security_id = 1; - optional MiscMessage misc = 2; - optional bts.security_model.Security security = 3; -} - -message QuoteRequestRow { - // Optional for backwards compat with the replayer - optional uint64 security_id = 1; - required QuoteRequestMessage request = 2; -} - -// -// Status / Metadata messages -// - -message CoconutStatus -{ - optional string symbol = 1; - optional bts.security_model.SecurityType.type type = 2 [default = UNSET]; - optional bts.security_model.Exchange.type exchange = 3 [default = TESTEXCHANGE]; - //optional string status = 4; - - optional uint32 security_count = 10; - optional uint32 bbo_count = 11; - optional uint32 trade_count = 12; - optional uint32 estatus_count = 13; - optional uint32 rfq_count = 14; - optional uint32 depth_count = 15; - optional uint32 cstatus_count = 16; - optional uint32 custbbo_count = 17; - - //optional string last_error = 20; - //optional string last_warning = 21; - - optional uint32 bbo1 = 30; - optional uint32 bbo5 = 31; - optional uint32 bbo15 = 32; - optional uint32 bbo_burst = 33; - optional string bbo_burst_when = 34; - optional uint32 trade1 = 35; - optional uint32 trade5 = 36; - optional uint32 trade15 = 37; - optional uint32 trade_burst = 38; - optional string trade_burst_when = 39; - optional uint32 depth1 = 40; - optional uint32 depth5 = 41; - optional uint32 depth15 = 42; - optional uint32 depth_burst = 43; - optional string depth_burst_when = 44; - optional uint32 custbbo1 = 45; - optional uint32 custbbo5 = 46; - optional uint32 custbbo15 = 47; -} - -message Co2Status { - optional string symbol = 1; - optional bts.security_model.SecurityType.type type = 2 [default = UNSET]; - optional bts.security_model.Exchange.type exchange = 3 [default = TESTEXCHANGE]; - optional Platform.type platform = 4 [default = UNSET]; - - optional uint32 security_count_in = 10; - optional uint32 security_count_out = 11; - - optional uint32 bbo_count_in = 20; - optional uint32 bbo_count_out = 21; - - optional uint32 trade_count_in = 30; - optional uint32 trade_count_out = 31; - - optional uint32 rfq_count_in = 40; - optional uint32 rfq_count_out = 41; - - optional uint32 depth_count_in = 50; - optional uint32 depth_count_out = 51; - - optional uint32 custbbo_count_in = 60; - optional uint32 custbbo_count_out = 61; - -} - - -// -// Replayer messages -// - - -// Replay file format -// [uin16_t length] [byte HEADER] [uint16_t unused] CoconutReplayHeader - [uint16_t length] [byte CoconutRowType] [uint16_t delta seconds] [Row type] - -message CoconutRowType { - enum type { - HEADER = 1; - SECURITY = 2; - EXCHANGE_STATUS = 3; - BBO = 4; - BOOK = 5; - TRADE = 6; - MISC = 7; - RFQ = 8; - CUSTOMER_BBO = 9; - } -} - -message CoconutReplayHeader { - required string magic = 1; - required uint32 version = 2; - required int64 timestamp = 3; - optional string host = 4; - - optional int32 naggle_ms = 5; -} - - diff --git a/src/lib/order_man/protos/OrderMan.proto b/src/lib/order_man/protos/OrderMan.proto index 5a97518f8..74c8b7691 100644 --- a/src/lib/order_man/protos/OrderMan.proto +++ b/src/lib/order_man/protos/OrderMan.proto @@ -1,4 +1,3 @@ syntax='proto3' ; package bts.orderman ; -import "lib/domain_model/Security.proto"; diff --git a/src/lib/os/tests/os_tests.cpp b/src/lib/os/tests/os_tests.cpp index 423abef7e..51dc176c3 100755 --- a/src/lib/os/tests/os_tests.cpp +++ b/src/lib/os/tests/os_tests.cpp @@ -1,37 +1,37 @@ -#include "core/bts_core/utest/utest.h" -#include "core/bts_core/utest/TempFile.h" +// #include "core/bts_core/utest/utest.h" +// #include "core/bts_core/utest/TempFile.h" -#include "../os.h" +// #include "../os.h" -namespace bts { -namespace os { +// namespace bts { +// namespace os { - class FileNameSanitization : public TestSuite - { - public: - void empty_file_name_works () - { - test_equal (sanitize_file_name (""),""); - } +// class FileNameSanitization : public TestSuite +// { +// public: +// void empty_file_name_works () +// { +// test_equal (sanitize_file_name (""),""); +// } - void legal_file_name_passes_through () - { - test_equal (sanitize_file_name ("bts_shell"),"bts_shell"); - } +// void legal_file_name_passes_through () +// { +// test_equal (sanitize_file_name ("bts_shell"),"bts_shell"); +// } - void bad_file_name_is_fixed () - { - test_equal (sanitize_file_name ("bts_shell -configserver http://edge-qa/config/"), - "bts_shell -configserver http___edge-qa_config_"); - } - }; +// void bad_file_name_is_fixed () +// { +// test_equal (sanitize_file_name ("bts_shell -configserver http://edge-qa/config/"), +// "bts_shell -configserver http___edge-qa_config_"); +// } +// }; -BEGIN_TEST_SUITE(FileNameSanitization) -ADD_TEST (bad_file_name_is_fixed) -ADD_TEST (legal_file_name_passes_through) -ADD_TEST (bad_file_name_is_fixed) -END_TEST_SUITE -}} +// BEGIN_TEST_SUITE(FileNameSanitization) +// ADD_TEST (bad_file_name_is_fixed) +// ADD_TEST (legal_file_name_passes_through) +// ADD_TEST (bad_file_name_is_fixed) +// END_TEST_SUITE +// }} diff --git a/src/server/sparkd/CMakeDeps.cmake b/src/server/sparkd/CMakeDeps.cmake new file mode 100644 index 000000000..8ca1c48d1 --- /dev/null +++ b/src/server/sparkd/CMakeDeps.cmake @@ -0,0 +1,2 @@ +# generated by make process +set(sources ;fabric/Actor.cpp;fabric/Domain.cpp;fabric/Executor.cpp;fabric/IActor.cpp;fabric/IDomain.cpp;fabric/TopicDirectory.cpp;fabric/tests/baseline_perf_fabric_test.cpp;fabric/tests/fabric_test.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/store_tests.cpp;main.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;order_man/IFIXGateway.cpp;order_man/IOrderObserver.cpp;order_man/OldOrderMan.cpp;order_man/OrderMan.cpp;order_man/OrderState.cpp;order_man/OrderStore.cpp;order_man/WorkingOrder.cpp;order_man/fix_order_codec.cpp;order_man/order_man_common.cpp;order_man/order_man_utils.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;setup/BootstrapActor.cpp;setup/ServiceHostActor.cpp;spreader/SpreaderBase.cpp;testing/catch_test_runner.cpp;user/UserServiceServer.cpp) diff --git a/src/server/sparkd/CMakeLists.txt b/src/server/sparkd/CMakeLists.txt index 28c01395d..fb6850321 100644 --- a/src/server/sparkd/CMakeLists.txt +++ b/src/server/sparkd/CMakeLists.txt @@ -2,82 +2,24 @@ cmake_minimum_required(VERSION 3.5) project(sparkd) # proto sources -set (Protos - ) +set (Protos) + +include(${CMAKE_SOURCE_DIR}/tools/safe_dep_glob.cmake) include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake) + +# DEPENDENCIES + # protos + file(GLOB_RECURSE Proto_Srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.proto) + + # normal cpps + file(GLOB_RECURSE Sparkd_Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) + + # this is used to communicate to other repositories that the build + # needs to happen again (because a file was added) + update_deps_file("${Proto_Srcs};${Sparkd_Sources}") +# END DEPENDENCIES + protobuf_generate_cpp( Proto_Srcs PROTO_HDRS ${Protos} ) - -# cpp sources -set (Sparkd_Sources - main.cpp - - # fabric - fabric/Actor.cpp - fabric/Executor.cpp - fabric/Domain.cpp - fabric/IActor.cpp - fabric/IDomain.cpp - fabric/TopicDirectory.cpp - fabric/tests/fabric_test.cpp - fabric/tests/baseline_perf_fabric_test.cpp - - # jetfix - jetfix/codec/FIXArray.cpp - jetfix/common/OutFIX.cpp - jetfix/connection/AsyncReader.cpp - jetfix/connection/IConnection.cpp - jetfix/connection/SocketConnection.cpp - jetfix/gateway/CoreGateway.cpp - jetfix/gateway/JetFIXGateway.cpp - jetfix/gateway/Session.cpp - jetfix/store/FIXFileStore.cpp - jetfix/store/session_name.cpp - jetfix/tests/async_reader_tests.cpp - jetfix/tests/decoding_tests.cpp - jetfix/tests/fix_encoding_stream_tests.cpp - jetfix/tests/fix_fragment_tests.cpp - jetfix/tests/jetfix_performance_tests.cpp - jetfix/tests/store_tests.cpp - - # persistence - persistence/PersistenceServiceServer.cpp - persistence/tests/PersistenceServiceTests.cpp - persistence/IStore.cpp - persistence/SqliteStore.cpp - - # testing utilities - testing/catch_test_runner.cpp - - # setup - setup/BootstrapActor.cpp - setup/ServiceHostActor.cpp - - # user - user/UserServiceServer.cpp - - # orderman - order_man/OldOrderMan.cpp - order_man/OrderMan.cpp - order_man/IOrderObserver.cpp - order_man/WorkingOrder.cpp - order_man/IFIXGateway.cpp - order_man/OrderStore.cpp - order_man/OrderState.cpp - order_man/order_man_common.cpp - order_man/fix_order_codec.cpp - - # spreader - spreader/SpreaderBase.cpp - - # md, mdp3 onixs platform - # md/platforms/mdp3_onixs/MDP3Listener.cpp - # md/platforms/mdp3_onixs/MDP3Main.cpp - # md/platforms/mdp3_onixs/MDP3Utils.cpp - # md/platforms/mdp3_onixs/tests/mdp3_tests.cpp - md/run_md.cpp - ) - -# sparkd add_executable(sparkd ${Sparkd_Sources} ${Proto_Srcs}) #include paths @@ -89,7 +31,6 @@ target_link_libraries( sparkd tbb double-conversion pugixml - # -lOnixS.CmeMdp3HandlerCpp -static-libgcc -static-libstdc++ -pthread) diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp index 33f905787..37a09db50 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Listener.cpp @@ -1,596 +1,596 @@ -#ifndef NO_CPP0X +// #ifndef NO_CPP0X -#include "MDP3Listener.h" -#include "lib/utils/defer.h" -#include "lib/utils/CallTimer.h" -#include "lib/utils/helper_macros.h" -#include +// #include "MDP3Listener.h" +// #include "lib/utils/defer.h" +// #include "lib/utils/CallTimer.h" +// #include "lib/utils/helper_macros.h" +// #include -using namespace OnixS::CME::MDP3; -using namespace std; -using namespace bts::md2; +// using namespace OnixS::CME::MDP3; +// using namespace std; +// using namespace bts::md2; -namespace bts { -namespace md { +// namespace bts { +// namespace md { -MDP3Listener::MDP3Listener(CMESecurityIndex& index, md2::MDProducer& producer, md2::SecurityIDRecorder& recorder, co2::SettlementRecorder& settles, std::vector channels, utils::Dispatcher& disp) : - _index(index), - _producer(producer), - _packet_arrived(), - _latest_sequence(0), - _security_recorder(recorder), - _settlement_recorder(settles), - _symbol_filter_storage(), - _symbol_filter(), - _channels(channels), - _background(disp), - _security_recorder_input_timer(disp, 900, [&]() { dequeue_securities(); }), - _security_recorder_input(), - _concurrency_monitor(0), - _book_updates() -{ - _book_updates.reserve(32); - _security_recorder_input_timer.start(); -} +// MDP3Listener::MDP3Listener(CMESecurityIndex& index, md2::MDProducer& producer, md2::SecurityIDRecorder& recorder, co2::SettlementRecorder& settles, std::vector channels, utils::Dispatcher& disp) : +// _index(index), +// _producer(producer), +// _packet_arrived(), +// _latest_sequence(0), +// _security_recorder(recorder), +// _settlement_recorder(settles), +// _symbol_filter_storage(), +// _symbol_filter(), +// _channels(channels), +// _background(disp), +// _security_recorder_input_timer(disp, 900, [&]() { dequeue_securities(); }), +// _security_recorder_input(), +// _concurrency_monitor(0), +// _book_updates() +// { +// _book_updates.reserve(32); +// _security_recorder_input_timer.start(); +// } -MDP3Listener::~MDP3Listener() { - _security_recorder_input_timer.stop(); -} +// MDP3Listener::~MDP3Listener() { +// _security_recorder_input_timer.stop(); +// } -void MDP3Listener::add_filter_symbol(const std::string& symbol) { - _symbol_filter_storage.push_back(symbol); - _symbol_filter.clear(); - for (const auto& str : _symbol_filter_storage) { - _symbol_filter.insert(onixs::StringRef(str)); - } -} +// void MDP3Listener::add_filter_symbol(const std::string& symbol) { +// _symbol_filter_storage.push_back(symbol); +// _symbol_filter.clear(); +// for (const auto& str : _symbol_filter_storage) { +// _symbol_filter.insert(onixs::StringRef(str)); +// } +// } -bool MDP3Listener::filter_security(onixs::StringRef val) { - return _symbol_filter.count(val) == 0; -} +// bool MDP3Listener::filter_security(onixs::StringRef val) { +// return _symbol_filter.count(val) == 0; +// } -// -// MessageProcessingListener -void MDP3Listener::onProcessingBegin(const Message& msg, const ChannelId&) { +// // +// // MessageProcessingListener +// void MDP3Listener::onProcessingBegin(const Message& msg, const ChannelId&) { - // Mark the arrival of the packet - _packet_arrived = TimeStamp::now();// - TimeStamp::Interval::from_microseconds((onixs::Timestamp::utcNow() - msg.receiveTime()).microseconds()); +// // Mark the arrival of the packet +// _packet_arrived = TimeStamp::now();// - TimeStamp::Interval::from_microseconds((onixs::Timestamp::utcNow() - msg.receiveTime()).microseconds()); - // If we haven't flushed we must still be working on the same packet (and therefore the same sequence number) - if (!_book_updates.empty()) { - if (_latest_sequence != msg.sequenceNumber()) { - LOG(MarketData,Error, "expected sequence: {} got {} book updates:{}", - _latest_sequence,msg.sequenceNumber(), _book_updates.size()); - bts_assert(_latest_sequence == msg.sequenceNumber()); - } - } - _latest_sequence = msg.sequenceNumber(); -} +// // If we haven't flushed we must still be working on the same packet (and therefore the same sequence number) +// if (!_book_updates.empty()) { +// if (_latest_sequence != msg.sequenceNumber()) { +// LOG(MarketData,Error, "expected sequence: {} got {} book updates:{}", +// _latest_sequence,msg.sequenceNumber(), _book_updates.size()); +// bts_assert(_latest_sequence == msg.sequenceNumber()); +// } +// } +// _latest_sequence = msg.sequenceNumber(); +// } -void MDP3Listener::onProcessingEnd(const Message& msg, const ChannelId&) { - char msg_type; - // Market data snapshot messages do not include the 'lastInPacket' flag so we always flush when we finish processing a snapshot (35=W) message - if (msg.lastInPacket() || (msg.type().toChar(msg_type) && msg_type == 'W')) { - flush_books(); - } -} +// void MDP3Listener::onProcessingEnd(const Message& msg, const ChannelId&) { +// char msg_type; +// // Market data snapshot messages do not include the 'lastInPacket' flag so we always flush when we finish processing a snapshot (35=W) message +// if (msg.lastInPacket() || (msg.type().toChar(msg_type) && msg_type == 'W')) { +// flush_books(); +// } +// } -void MDP3Listener::onProcessingSuspended(const ChannelId&) { - // TODO: Mark this channel as out of date -} +// void MDP3Listener::onProcessingSuspended(const ChannelId&) { +// // TODO: Mark this channel as out of date +// } -SecurityType::type type_from_cfi(const StringRef& cfi_code) { +// SecurityType::type type_from_cfi(const StringRef& cfi_code) { - // - // Got an MRXXX which fell into spread but is actually invalid +// // +// // Got an MRXXX which fell into spread but is actually invalid - bts_assert(!cfi_code.empty() && cfi_code.size() > 2); - if (cfi_code[1] == 'M') return SecurityType::SPREAD; - switch (cfi_code[0]) { - case 'O': - return SecurityType::OPTION; - case 'F': - return SecurityType::FUTURE; - case 'M': - return SecurityType::SPREAD; // covered - default: - // string message = "Invalid or confusing CFI code: " + (string)cfi_code; - // bts_assert_msg(false, message.c_str()); - return SecurityType::UNSET; - } -} +// bts_assert(!cfi_code.empty() && cfi_code.size() > 2); +// if (cfi_code[1] == 'M') return SecurityType::SPREAD; +// switch (cfi_code[0]) { +// case 'O': +// return SecurityType::OPTION; +// case 'F': +// return SecurityType::FUTURE; +// case 'M': +// return SecurityType::SPREAD; // covered +// default: +// // string message = "Invalid or confusing CFI code: " + (string)cfi_code; +// // bts_assert_msg(false, message.c_str()); +// return SecurityType::UNSET; +// } +// } -PutOrCall::type call_put(const StringRef& cfi_code) { - bts_assert_msg(cfi_code[0] == 'O', cfi_code); - return cfi_code[1] == 'C' ? PutOrCall::CALL : PutOrCall::PUT; -} +// PutOrCall::type call_put(const StringRef& cfi_code) { +// bts_assert_msg(cfi_code[0] == 'O', cfi_code); +// return cfi_code[1] == 'C' ? PutOrCall::CALL : PutOrCall::PUT; +// } -int floorlog10(onixs::DecimalMantissa m) { - bts_assert(m >= 0); - if (m < 10) return 0; - if (m < 100) return 1; - if (m < 1000) return 2; - if (m < 10000) return 3; - if (m < 100000) return 4; - if (m < 1000000) return 5; - if (m < 10000000) return 6; - if (m < 100000000) return 7; - if (m < 1000000000) return 8; - if (m < 10000000000) return 9; - if (m < 100000000000) return 10; - if (m < 1000000000000) return 11; - if (m < 10000000000000) return 12; - if (m < 100000000000000) return 13; - if (m < 1000000000000000) return 14; - if (m < 10000000000000000) return 15; - if (m < 100000000000000000) return 16; - if (m < 1000000000000000000) return 17; - return 19; -} +// int floorlog10(onixs::DecimalMantissa m) { +// bts_assert(m >= 0); +// if (m < 10) return 0; +// if (m < 100) return 1; +// if (m < 1000) return 2; +// if (m < 10000) return 3; +// if (m < 100000) return 4; +// if (m < 1000000) return 5; +// if (m < 10000000) return 6; +// if (m < 100000000) return 7; +// if (m < 1000000000) return 8; +// if (m < 10000000000) return 9; +// if (m < 100000000000) return 10; +// if (m < 1000000000000) return 11; +// if (m < 10000000000000) return 12; +// if (m < 100000000000000) return 13; +// if (m < 1000000000000000) return 14; +// if (m < 10000000000000000) return 15; +// if (m < 100000000000000000) return 16; +// if (m < 1000000000000000000) return 17; +// return 19; +// } -template -void set_security_common(const onixs::SecurityDefinition& def, TSecurityType& security, uint32_t exchange_id) { - security.numeric_id = exchange_id; - security.symbol(def.asset().data(), def.asset().size()); // 1151-SecurityGroup changed to 6937-Asset in MDP3 - security.cfi_code(def.CFICode().data(), def.CFICode().size()); - security.alt_symbol(def.securityGroup().data(), def.securityGroup().size()); - security.security_desc(def.symbol().data(), def.symbol().size()); - security.exchange = Exchange::GLBX; - def.tickRule(security.cme_vtt); +// template +// void set_security_common(const onixs::SecurityDefinition& def, TSecurityType& security, uint32_t exchange_id) { +// security.numeric_id = exchange_id; +// security.symbol(def.asset().data(), def.asset().size()); // 1151-SecurityGroup changed to 6937-Asset in MDP3 +// security.cfi_code(def.CFICode().data(), def.CFICode().size()); +// security.alt_symbol(def.securityGroup().data(), def.securityGroup().size()); +// security.security_desc(def.symbol().data(), def.symbol().size()); +// security.exchange = Exchange::GLBX; +// def.tickRule(security.cme_vtt); - onixs::FloatQuantity unit_qty; - if (def.unitOfMeasureQty(unit_qty)) { - security.cme_unit_of_measure_qty = unit_qty; - } +// onixs::FloatQuantity unit_qty; +// if (def.unitOfMeasureQty(unit_qty)) { +// security.cme_unit_of_measure_qty = unit_qty; +// } - def.subFraction(security.cme_denominator_sub_fraction); - def.mainFraction(security.cme_display_decimals); - def.marketSegmentId(security.cme_market_segment_id); +// def.subFraction(security.cme_denominator_sub_fraction); +// def.mainFraction(security.cme_display_decimals); +// def.marketSegmentId(security.cme_market_segment_id); - onixs::PriceFactor display; - if (def.displayFactor(display)) { - auto exp = display.exponent(); - auto mant = floorlog10(display.mantissa()); - security.display_factor = exp + mant; - security.strike_display_factor = security.display_factor; - } - // mapping::display_factor((string)security.symbol(), &security.display_factor, security.type); - // bool should_multiply_strike = false; - // int8_t strike_factor = security.strike_display_factor; - // if (security.type == SecurityType::OPTION && - // mapping::strike_display_factor(security.symbol(), nullptr, &strike_factor, security.type, nullptr, nullptr, nullptr, &should_multiply_strike) && - // should_multiply_strike) { - // security.strike_display_factor = strike_factor; - // } +// onixs::PriceFactor display; +// if (def.displayFactor(display)) { +// auto exp = display.exponent(); +// auto mant = floorlog10(display.mantissa()); +// security.display_factor = exp + mant; +// security.strike_display_factor = security.display_factor; +// } +// // mapping::display_factor((string)security.symbol(), &security.display_factor, security.type); +// // bool should_multiply_strike = false; +// // int8_t strike_factor = security.strike_display_factor; +// // if (security.type == SecurityType::OPTION && +// // mapping::strike_display_factor(security.symbol(), nullptr, &strike_factor, security.type, nullptr, nullptr, nullptr, &should_multiply_strike) && +// // should_multiply_strike) { +// // security.strike_display_factor = strike_factor; +// // } - onixs::Price min_price_increment; - def.minPriceIncrement(min_price_increment); - security.cme_min_price_increment = min_price_increment; -} +// onixs::Price min_price_increment; +// def.minPriceIncrement(min_price_increment); +// security.cme_min_price_increment = min_price_increment; +// } -datetime::Date get_expiration(const SecurityDefinition& def) { - datetime::Date result; - size_t size = def.events().size(); - for (size_t index = 0; index < size; ++index) { - if (def.events()[index].type() == EventTypes::LastEligibleTradeDate) { - auto time = def.events()[index].time(); - result.year = time.year(); - result.month = time.month(); - result.day = time.day(); - break; - } - } - return result; -} +// datetime::Date get_expiration(const SecurityDefinition& def) { +// datetime::Date result; +// size_t size = def.events().size(); +// for (size_t index = 0; index < size; ++index) { +// if (def.events()[index].type() == EventTypes::LastEligibleTradeDate) { +// auto time = def.events()[index].time(); +// result.year = time.year(); +// result.month = time.month(); +// result.day = time.day(); +// break; +// } +// } +// return result; +// } -// -// SecurityDefinitionListener -void MDP3Listener::onSecurityDefinition(const SecurityDefinition& def, const ChannelId&) { - LOG_IF_SLOW - // - auto exchange_id = def.securityId(); +// // +// // SecurityDefinitionListener +// void MDP3Listener::onSecurityDefinition(const SecurityDefinition& def, const ChannelId&) { +// LOG_IF_SLOW +// // +// auto exchange_id = def.securityId(); - // Ignore duplicate security defs - if (_index.has_security(exchange_id)) return; - if (filter_security(def.asset())) return; +// // Ignore duplicate security defs +// if (_index.has_security(exchange_id)) return; +// if (filter_security(def.asset())) return; - // Also any securities which are not elligible for trading - if (def.tradingStatus() == SecurityTradingStatus::NotAvailableForTrading) return; +// // Also any securities which are not elligible for trading +// if (def.tradingStatus() == SecurityTradingStatus::NotAvailableForTrading) return; - StringRef cfi_code = def.CFICode(); - auto type = SecurityType::UNSET; - if (def.legs().size() > 0) { - type = SecurityType::SPREAD; - } - else { - type = type_from_cfi(cfi_code); - } +// StringRef cfi_code = def.CFICode(); +// auto type = SecurityType::UNSET; +// if (def.legs().size() > 0) { +// type = SecurityType::SPREAD; +// } +// else { +// type = type_from_cfi(cfi_code); +// } - switch (type) { - // - // Option - case SecurityType::OPTION: { - FixedOptionSecurity security; - set_security_common(def, security, exchange_id); - onixs::Price price; - bts_assert(def.strikePrice(price)); - security.strike = (double)price * pow10(security.strike_display_factor); - security.call_put = call_put(cfi_code); - auto date = get_expiration(def); - security.expiration_year = date.year; - security.expiration_month = date.month; - security.expiration_day = date.day; - add_security(security); - } break; - // - // Future - case SecurityType::FUTURE: { - FixedFutureSecurity security; - set_security_common(def, security, exchange_id); - auto date = get_expiration(def); - security.expiration_year = date.year; - security.expiration_month = date.month; - security.expiration_day = date.day; - add_security(security); - } break; - // - // Spread - case SecurityType::SPREAD: { - // Sometimes our CFI parsing isn't correct. There's a MRRXXX on the 6E channel for example - if (def.legs().size() == 0) return; +// switch (type) { +// // +// // Option +// case SecurityType::OPTION: { +// FixedOptionSecurity security; +// set_security_common(def, security, exchange_id); +// onixs::Price price; +// bts_assert(def.strikePrice(price)); +// security.strike = (double)price * pow10(security.strike_display_factor); +// security.call_put = call_put(cfi_code); +// auto date = get_expiration(def); +// security.expiration_year = date.year; +// security.expiration_month = date.month; +// security.expiration_day = date.day; +// add_security(security); +// } break; +// // +// // Future +// case SecurityType::FUTURE: { +// FixedFutureSecurity security; +// set_security_common(def, security, exchange_id); +// auto date = get_expiration(def); +// security.expiration_year = date.year; +// security.expiration_month = date.month; +// security.expiration_day = date.day; +// add_security(security); +// } break; +// // +// // Spread +// case SecurityType::SPREAD: { +// // Sometimes our CFI parsing isn't correct. There's a MRRXXX on the 6E channel for example +// if (def.legs().size() == 0) return; - // Filter out any already expired spreads - auto date = get_expiration(def); - if (date < datetime::today()) return; +// // Filter out any already expired spreads +// auto date = get_expiration(def); +// if (date < datetime::today()) return; - // Start simple - FixedSpreadSecurityL security; - vector leg_exchange_ids; - leg_exchange_ids.reserve(def.legs().size()); // TODOPERF: heap - set_security_common(def, security, exchange_id); +// // Start simple +// FixedSpreadSecurityL security; +// vector leg_exchange_ids; +// leg_exchange_ids.reserve(def.legs().size()); // TODOPERF: heap +// set_security_common(def, security, exchange_id); - security.set_leg_count(def.legs().size()); - for (size_t x = 0; x < security.leg_count(); ++x) { - const auto& leg = def.legs()[x]; - FloatQuantity f; - if (leg.optionDelta(f)) { - security.legs[x].leg_delta = f; - } - onixs::Price temp_price; - leg.price(temp_price); - security.legs[x].leg_price = (double)temp_price * pow10(security.display_factor); - security.legs[x].leg_quantity = leg.ratioQty(); - security.legs[x].leg_side = leg.side() == LegSides::Buy ? Side::BUY : Side::SELL; - if (leg.side() == LegSides::Undefined) return; // Do not add invalid spreads - leg_exchange_ids.push_back(leg.getUInt32(onixs::Tags::LegSecurityID)); - //leg_exchange_ids.push_back(leg.securityId()); - } - add_security(security); - _index.add_spread_legs(security.numeric_id, leg_exchange_ids); - } break; - default: - return; - } -} +// security.set_leg_count(def.legs().size()); +// for (size_t x = 0; x < security.leg_count(); ++x) { +// const auto& leg = def.legs()[x]; +// FloatQuantity f; +// if (leg.optionDelta(f)) { +// security.legs[x].leg_delta = f; +// } +// onixs::Price temp_price; +// leg.price(temp_price); +// security.legs[x].leg_price = (double)temp_price * pow10(security.display_factor); +// security.legs[x].leg_quantity = leg.ratioQty(); +// security.legs[x].leg_side = leg.side() == LegSides::Buy ? Side::BUY : Side::SELL; +// if (leg.side() == LegSides::Undefined) return; // Do not add invalid spreads +// leg_exchange_ids.push_back(leg.getUInt32(onixs::Tags::LegSecurityID)); +// //leg_exchange_ids.push_back(leg.securityId()); +// } +// add_security(security); +// _index.add_spread_legs(security.numeric_id, leg_exchange_ids); +// } break; +// default: +// return; +// } +// } -void MDP3Listener::onSecurityDefinitionDeleted(SecurityId id, const ChannelId&) { - auto* data = _index.get_security(id); - if (data != nullptr) { - data->handle.mark_deleted(); - } -} +// void MDP3Listener::onSecurityDefinitionDeleted(SecurityId id, const ChannelId&) { +// auto* data = _index.get_security(id); +// if (data != nullptr) { +// data->handle.mark_deleted(); +// } +// } -void MDP3Listener::onSecurityDefinitionsRecoveryStarted(const ChannelId& ch) { - LOG(MarketData,Info,"Security definition recovery started on channel {}",ch); -} -void MDP3Listener::onSecurityDefinitionsRecoveryFinished(const ChannelId& chan) { - LOG(MarketData,Info, "Security definition recovery finished on channel {}", chan); -} +// void MDP3Listener::onSecurityDefinitionsRecoveryStarted(const ChannelId& ch) { +// LOG(MarketData,Info,"Security definition recovery started on channel {}",ch); +// } +// void MDP3Listener::onSecurityDefinitionsRecoveryFinished(const ChannelId& chan) { +// LOG(MarketData,Info, "Security definition recovery finished on channel {}", chan); +// } -// -// SecurityStatusListener -void MDP3Listener::onSecurityStatus(const SecurityStatus&, const ChannelId&) { -} +// // +// // SecurityStatusListener +// void MDP3Listener::onSecurityStatus(const SecurityStatus&, const ChannelId&) { +// } -inline PriceSize convert(const onixs::Price price, int8_t display_factor, Size size) { - PriceSize result = PriceSize(price.mantissa(), price.exponent() + display_factor, size); - return result; -} -inline double convert(const onixs::Price price, int8_t display_factor) { - return (double)price * pow10(display_factor); -} +// inline PriceSize convert(const onixs::Price price, int8_t display_factor, Size size) { +// PriceSize result = PriceSize(price.mantissa(), price.exponent() + display_factor, size); +// return result; +// } +// inline double convert(const onixs::Price price, int8_t display_factor) { +// return (double)price * pow10(display_factor); +// } -inline datetime::LLDateTime convert_time(const onixs::Timestamp& timestamp) { - return datetime::ll_from_parts(timestamp.year(), timestamp.month(), timestamp.day(), timestamp.hour(), timestamp.minute(), timestamp.second(), timestamp.millisecond()); -} +// inline datetime::LLDateTime convert_time(const onixs::Timestamp& timestamp) { +// return datetime::ll_from_parts(timestamp.year(), timestamp.month(), timestamp.day(), timestamp.hour(), timestamp.minute(), timestamp.second(), timestamp.millisecond()); +// } -datetime::Date convert(const onixs::Timestamp& transactTime) { - datetime::Date date; - date.year = transactTime.year(); - date.month = transactTime.month(); - date.day = transactTime.day(); - return date; -} +// datetime::Date convert(const onixs::Timestamp& transactTime) { +// datetime::Date date; +// date.year = transactTime.year(); +// date.month = transactTime.month(); +// date.day = transactTime.day(); +// return date; +// } -// -// ConsolidatedBookUpdateListener -void MDP3Listener::onConsolidatedBookUpdated(const ConsolidatedBook& book, const ChannelId&) { - LOG_IF_SLOW +// // +// // ConsolidatedBookUpdateListener +// void MDP3Listener::onConsolidatedBookUpdated(const ConsolidatedBook& book, const ChannelId&) { +// LOG_IF_SLOW - // Validate our assumptions that only one packet is processed at a time inside this class - _concurrency_monitor++; - DEFER(_concurrency_monitor--); - if (_concurrency_monitor != 1) { - LOG(MarketData,Error, - "ERROR: Concurrent calls to onConsolidatedBookUpdated may result in corrupted book data." - "Please let Eric know about this."); - } +// // Validate our assumptions that only one packet is processed at a time inside this class +// _concurrency_monitor++; +// DEFER(_concurrency_monitor--); +// if (_concurrency_monitor != 1) { +// LOG(MarketData,Error, +// "ERROR: Concurrent calls to onConsolidatedBookUpdated may result in corrupted book data." +// "Please let Eric know about this."); +// } - auto data = _index.get_security(book.securityId()); - if (data == nullptr) return; - bts_assert((uint32_t)book.securityId() == data->id); +// auto data = _index.get_security(book.securityId()); +// if (data == nullptr) return; +// bts_assert((uint32_t)book.securityId() == data->id); - auto display_factor = data->handle.security().display_factor; - // Push the data into the cache - flush at the the end of the packet - // Linear search through the other updates in this packet - auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [&data](const BookData& entry) { - return data->handle.key() == entry.handle.key(); - }); - bool found = find_iter != _book_updates.end(); - if (!found) { - _book_updates.emplace_back(data->handle); - } - BookData& cache = found ? *find_iter : _book_updates.back(); +// auto display_factor = data->handle.security().display_factor; +// // Push the data into the cache - flush at the the end of the packet +// // Linear search through the other updates in this packet +// auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [&data](const BookData& entry) { +// return data->handle.key() == entry.handle.key(); +// }); +// bool found = find_iter != _book_updates.end(); +// if (!found) { +// _book_updates.emplace_back(data->handle); +// } +// BookData& cache = found ? *find_iter : _book_updates.back(); - // Overwrite all entries every time - size_t bids_size = data->handle.has_depth() ? book.bids().size() : min((size_t)book.bids().size(), (size_t)1); - size_t asks_size = data->handle.has_depth() ? book.asks().size() : min((size_t)book.asks().size(), (size_t)1); - for (size_t x = 0; x < bids_size; ++x) { - cache.bids[x] = convert(book.bids()[x].price(), display_factor, book.bids()[x].quantity()); - } - for (size_t x = 0; x < asks_size; ++x) { - cache.asks[x] = convert(book.asks()[x].price(), display_factor, book.asks()[x].quantity()); - } - // NaN out the remaining depth - for (size_t x = bids_size; x < COCONUT_MAX_DEPTH; ++x) { - cache.bids[x] = PriceSize::NO_MARKET; - } - for (size_t x = asks_size; x < COCONUT_MAX_DEPTH; ++x) { - cache.asks[x] = PriceSize::NO_MARKET; - } -} +// // Overwrite all entries every time +// size_t bids_size = data->handle.has_depth() ? book.bids().size() : min((size_t)book.bids().size(), (size_t)1); +// size_t asks_size = data->handle.has_depth() ? book.asks().size() : min((size_t)book.asks().size(), (size_t)1); +// for (size_t x = 0; x < bids_size; ++x) { +// cache.bids[x] = convert(book.bids()[x].price(), display_factor, book.bids()[x].quantity()); +// } +// for (size_t x = 0; x < asks_size; ++x) { +// cache.asks[x] = convert(book.asks()[x].price(), display_factor, book.asks()[x].quantity()); +// } +// // NaN out the remaining depth +// for (size_t x = bids_size; x < COCONUT_MAX_DEPTH; ++x) { +// cache.bids[x] = PriceSize::NO_MARKET; +// } +// for (size_t x = asks_size; x < COCONUT_MAX_DEPTH; ++x) { +// cache.asks[x] = PriceSize::NO_MARKET; +// } +// } -// -// HandlerStateChangeListener -void MDP3Listener::onHandlerStateChange(const HandlerStateChange& change, const ChannelId& ch) { - LOG(MarketData,Info,"Channel {} changed state from {} to {}", - ch, onixs::HandlerStates::toString(change.oldState()), - onixs::HandlerStates::toString(change.newState())); - if (change.newState() == HandlerState::BookRecoveryFinished) { - _index.walk_security_list([](SecurityData& data) { - data.handle.set_status(CoconutSecurityStatus::OK); - }); - } -} +// // +// // HandlerStateChangeListener +// void MDP3Listener::onHandlerStateChange(const HandlerStateChange& change, const ChannelId& ch) { +// LOG(MarketData,Info,"Channel {} changed state from {} to {}", +// ch, onixs::HandlerStates::toString(change.oldState()), +// onixs::HandlerStates::toString(change.newState())); +// if (change.newState() == HandlerState::BookRecoveryFinished) { +// _index.walk_security_list([](SecurityData& data) { +// data.handle.set_status(CoconutSecurityStatus::OK); +// }); +// } +// } -// -// TradeListener -void MDP3Listener::onTrade(const Trade& trade, const ChannelId&) { - LOG_IF_SLOW - utils::TimeStamp ts = utils::TimeStamp::now(); - auto data = _index.get_security(trade.securityId()); - if (data == nullptr) return; +// // +// // TradeListener +// void MDP3Listener::onTrade(const Trade& trade, const ChannelId&) { +// LOG_IF_SLOW +// utils::TimeStamp ts = utils::TimeStamp::now(); +// auto data = _index.get_security(trade.securityId()); +// if (data == nullptr) return; - onixs::SignedQuantity size = trade.quantity(); +// onixs::SignedQuantity size = trade.quantity(); - auto time = convert_time(trade.transactTime()); - data->handle.add_trade(ts, convert(trade.price(), data->handle.security().display_factor, size), time, data->electronic_volume + size); -} +// auto time = convert_time(trade.transactTime()); +// data->handle.add_trade(ts, convert(trade.price(), data->handle.security().display_factor, size), time, data->electronic_volume + size); +// } -void MDP3Listener::onElectronicVolume(const ElectronicVolume& volume, const ChannelId&) { - auto data = _index.get_security(volume.securityId()); - if (data == nullptr) return; - data->electronic_volume = volume.quantity(); -} +// void MDP3Listener::onElectronicVolume(const ElectronicVolume& volume, const ChannelId&) { +// auto data = _index.get_security(volume.securityId()); +// if (data == nullptr) return; +// data->electronic_volume = volume.quantity(); +// } -// -// RequestForQuoteListener -void MDP3Listener::onRequestForQuote(const RequestForQuote& quote, const ChannelId&) { - auto ts = utils::TimeStamp::now(); - // Note: Here we're throwing out the RFQ if we don't have a security defined - // It might make more sense to send it along and let the receiver try to match up the security key - auto data = _index.get_security(quote.securityId()); - if (!data) return; +// // +// // RequestForQuoteListener +// void MDP3Listener::onRequestForQuote(const RequestForQuote& quote, const ChannelId&) { +// auto ts = utils::TimeStamp::now(); +// // Note: Here we're throwing out the RFQ if we don't have a security defined +// // It might make more sense to send it along and let the receiver try to match up the security key +// auto data = _index.get_security(quote.securityId()); +// if (!data) return; - auto time = convert_time(quote.transactTime()); - onixs::QuoteReqId id; - if (!quote.quoteReqId(id)) return; +// auto time = convert_time(quote.transactTime()); +// onixs::QuoteReqId id; +// if (!quote.quoteReqId(id)) return; - co2::QuoteRequestMessage message; - message.set_time(time); - message.set_key(data->handle.key()); - id.toString(*message.mutable_request_id()); +// co2::QuoteRequestMessage message; +// message.set_time(time); +// message.set_key(data->handle.key()); +// id.toString(*message.mutable_request_id()); - switch (quote.side()) { - case RequestedSides::Undefined: message.set_side(co2::QuoteRequestMessage::UNDEFINED); break; - case RequestedSides::Buy: message.set_side(co2::QuoteRequestMessage::BUY); break; - case RequestedSides::Sell: message.set_side(co2::QuoteRequestMessage::SELL); break; - case RequestedSides::Cross: message.set_side(co2::QuoteRequestMessage::CROSS); break; - } - message.set_tradable(quote.quoteType() == RequestedQuoteType::Tradable ? 1 : 0); - SignedQuantity q; - if (quote.orderQty(q)) { - message.set_size(q); - } +// switch (quote.side()) { +// case RequestedSides::Undefined: message.set_side(co2::QuoteRequestMessage::UNDEFINED); break; +// case RequestedSides::Buy: message.set_side(co2::QuoteRequestMessage::BUY); break; +// case RequestedSides::Sell: message.set_side(co2::QuoteRequestMessage::SELL); break; +// case RequestedSides::Cross: message.set_side(co2::QuoteRequestMessage::CROSS); break; +// } +// message.set_tradable(quote.quoteType() == RequestedQuoteType::Tradable ? 1 : 0); +// SignedQuantity q; +// if (quote.orderQty(q)) { +// message.set_size(q); +// } - data->handle.add_rfq(ts, message); -} +// data->handle.add_rfq(ts, message); +// } -// -// StatisticsListener -void MDP3Listener::onStatisticsReset(SecurityId securityId,const ChannelId&) { - UNUSED(securityId); -} +// // +// // StatisticsListener +// void MDP3Listener::onStatisticsReset(SecurityId securityId,const ChannelId&) { +// UNUSED(securityId); +// } -void MDP3Listener::onStatisticsReset(const StringRef&,const ChannelId&) { -} +// void MDP3Listener::onStatisticsReset(const StringRef&,const ChannelId&) { +// } -void MDP3Listener::onStatistics(const OpeningPrice& openingPrice,const ChannelId&) { - auto data = _index.get_security(openingPrice.securityId()); - if (data == nullptr) return; - data->handle.update_opening(utils::TimeStamp::now(), convert(openingPrice.value(), data->handle.security().display_factor), convert(openingPrice.transactTime())); -} +// void MDP3Listener::onStatistics(const OpeningPrice& openingPrice,const ChannelId&) { +// auto data = _index.get_security(openingPrice.securityId()); +// if (data == nullptr) return; +// data->handle.update_opening(utils::TimeStamp::now(), convert(openingPrice.value(), data->handle.security().display_factor), convert(openingPrice.transactTime())); +// } -void MDP3Listener::onStatistics(const SettlementPrice& settlementPrice,const ChannelId&) { - auto data = _index.get_security(settlementPrice.securityId()); - if (data == nullptr) return; - auto price = convert(settlementPrice.value(), data->handle.security().display_factor); - //data->handle.update_settlement(utils::TimeStamp::now(), price, convert(settlementPrice.transactTime())); - _settlement_recorder.add_settlement(data->handle, price, convert(settlementPrice.transactTime())); -} +// void MDP3Listener::onStatistics(const SettlementPrice& settlementPrice,const ChannelId&) { +// auto data = _index.get_security(settlementPrice.securityId()); +// if (data == nullptr) return; +// auto price = convert(settlementPrice.value(), data->handle.security().display_factor); +// //data->handle.update_settlement(utils::TimeStamp::now(), price, convert(settlementPrice.transactTime())); +// _settlement_recorder.add_settlement(data->handle, price, convert(settlementPrice.transactTime())); +// } -void MDP3Listener::onStatistics(const TradingSessionHighPrice& highPrice,const ChannelId&) { - auto data = _index.get_security(highPrice.securityId()); - if (data == nullptr) return; - data->handle.update_session_high(utils::TimeStamp::now(), convert(highPrice.value(), data->handle.security().display_factor)); -} +// void MDP3Listener::onStatistics(const TradingSessionHighPrice& highPrice,const ChannelId&) { +// auto data = _index.get_security(highPrice.securityId()); +// if (data == nullptr) return; +// data->handle.update_session_high(utils::TimeStamp::now(), convert(highPrice.value(), data->handle.security().display_factor)); +// } -void MDP3Listener::onStatistics(const TradingSessionLowPrice& lowPrice,const ChannelId&) { - auto data = _index.get_security(lowPrice.securityId()); - if (data == nullptr) return; - data->handle.update_session_low(utils::TimeStamp::now(), convert(lowPrice.value(), data->handle.security().display_factor)); -} +// void MDP3Listener::onStatistics(const TradingSessionLowPrice& lowPrice,const ChannelId&) { +// auto data = _index.get_security(lowPrice.securityId()); +// if (data == nullptr) return; +// data->handle.update_session_low(utils::TimeStamp::now(), convert(lowPrice.value(), data->handle.security().display_factor)); +// } -void MDP3Listener::onStatistics(const SessionHighBid& highBid,const ChannelId&) { - auto data = _index.get_security(highBid.securityId()); - if (data == nullptr) return; - data->handle.update_session_high_bid(utils::TimeStamp::now(), convert(highBid.value(), data->handle.security().display_factor)); -} +// void MDP3Listener::onStatistics(const SessionHighBid& highBid,const ChannelId&) { +// auto data = _index.get_security(highBid.securityId()); +// if (data == nullptr) return; +// data->handle.update_session_high_bid(utils::TimeStamp::now(), convert(highBid.value(), data->handle.security().display_factor)); +// } -void MDP3Listener::onStatistics(const SessionLowOffer& lowOffer,const ChannelId&) { - auto data = _index.get_security(lowOffer.securityId()); - if (data == nullptr) return; - data->handle.update_session_low_offer(utils::TimeStamp::now(), convert(lowOffer.value(), data->handle.security().display_factor)); -} +// void MDP3Listener::onStatistics(const SessionLowOffer& lowOffer,const ChannelId&) { +// auto data = _index.get_security(lowOffer.securityId()); +// if (data == nullptr) return; +// data->handle.update_session_low_offer(utils::TimeStamp::now(), convert(lowOffer.value(), data->handle.security().display_factor)); +// } -void MDP3Listener::onStatistics(const TradeVolume&,const ChannelId&) { - // This is the total volume from yesterday -} +// void MDP3Listener::onStatistics(const TradeVolume&,const ChannelId&) { +// // This is the total volume from yesterday +// } -void MDP3Listener::onStatistics(const OpenInterest& interest,const ChannelId&) { - auto data = _index.get_security(interest.securityId()); - if (data == nullptr) return; - data->handle.update_open_interest(utils::TimeStamp::now(), interest.value()); -} +// void MDP3Listener::onStatistics(const OpenInterest& interest,const ChannelId&) { +// auto data = _index.get_security(interest.securityId()); +// if (data == nullptr) return; +// data->handle.update_open_interest(utils::TimeStamp::now(), interest.value()); +// } -void MDP3Listener::onStatistics(const FixingPrice& fixingPrice,const ChannelId&) { - auto data = _index.get_security(fixingPrice.securityId()); - if (data == nullptr) return; - data->handle.update_fixing_price(utils::TimeStamp::now(), convert(fixingPrice.value(), data->handle.security().display_factor)); -} +// void MDP3Listener::onStatistics(const FixingPrice& fixingPrice,const ChannelId&) { +// auto data = _index.get_security(fixingPrice.securityId()); +// if (data == nullptr) return; +// data->handle.update_fixing_price(utils::TimeStamp::now(), convert(fixingPrice.value(), data->handle.security().display_factor)); +// } -void MDP3Listener::onStatistics(const ThresholdLimits& ,const ChannelId&) { - // noop -} +// void MDP3Listener::onStatistics(const ThresholdLimits& ,const ChannelId&) { +// // noop +// } -// -// WarningListener -void MDP3Listener::onWarning(const Warning& warning,const ChannelId& ch) { - LOG_IF_SLOW - if (warning.code() == KnownWarnings::PacketGap) { - // Mark all securities on this channel as bad - // This is probably not fast but should be faster than creating a security I think - _index.walk_security_list([](SecurityData& data) { - data.handle.set_status(CoconutSecurityStatus::PACKET_LOSS); - }); - } - // Logging to the console can be very expensive - LOG(MarketData,Warn, "{} (Chanel {}) {}", - warning.description(),ch ,warning.source()); -} +// // +// // WarningListener +// void MDP3Listener::onWarning(const Warning& warning,const ChannelId& ch) { +// LOG_IF_SLOW +// if (warning.code() == KnownWarnings::PacketGap) { +// // Mark all securities on this channel as bad +// // This is probably not fast but should be faster than creating a security I think +// _index.walk_security_list([](SecurityData& data) { +// data.handle.set_status(CoconutSecurityStatus::PACKET_LOSS); +// }); +// } +// // Logging to the console can be very expensive +// LOG(MarketData,Warn, "{} (Chanel {}) {}", +// warning.description(),ch ,warning.source()); +// } -// -// ErrorListener -void MDP3Listener::onError(const onixs::Error& error, const ChannelId& ch) { - LOG(MarketData,Warn, "{} (Channel {}) {}", - error.description(), ch ,error.source()); -} +// // +// // ErrorListener +// void MDP3Listener::onError(const onixs::Error& error, const ChannelId& ch) { +// LOG(MarketData,Warn, "{} (Channel {}) {}", +// error.description(), ch ,error.source()); +// } -// -// Private Functions -// +// // +// // Private Functions +// // -void MDP3Listener::heartbeat() { - for (auto& c : _channels) { c.heartbeat(); } -} +// void MDP3Listener::heartbeat() { +// for (auto& c : _channels) { c.heartbeat(); } +// } -void MDP3Listener::add_security(const FixedSecurity& security) { - // Set up the shared memory for this security - auto handle = _producer.add_security(security); - bts_assert(security.numeric_id != 0); - // Add it to the index so it can receive messages - SecurityData* data = _index.add_security(security.numeric_id, handle); +// void MDP3Listener::add_security(const FixedSecurity& security) { +// // Set up the shared memory for this security +// auto handle = _producer.add_security(security); +// bts_assert(security.numeric_id != 0); +// // Add it to the index so it can receive messages +// SecurityData* data = _index.add_security(security.numeric_id, handle); - // Computing the descriptor may be expensive so defer that processing to the background worker thread (see dequeue_securities) - _security_recorder_input.push(data); -} +// // Computing the descriptor may be expensive so defer that processing to the background worker thread (see dequeue_securities) +// _security_recorder_input.push(data); +// } -void MDP3Listener::dequeue_securities() { - // already running on '_background' thread - vector defer; +// void MDP3Listener::dequeue_securities() { +// // already running on '_background' thread +// vector defer; - SecurityData* data = nullptr; - while (_security_recorder_input.try_pop(data)) { - bts_assert(data->handle.security().key == invalid_security_key); +// SecurityData* data = nullptr; +// while (_security_recorder_input.try_pop(data)) { +// bts_assert(data->handle.security().key == invalid_security_key); - string descriptor = security_descriptor(data->handle.security()); - if (descriptor.empty()) { - defer.push_back(data); - } - else { - _security_recorder.get_key(descriptor, data->handle.security().type, [](void* pv_handle, security_key key) { - SecurityData* pdata = (SecurityData*)pv_handle; - pdata->handle.set_key(key); - }, data); - // Restore saved settlements - _settlement_recorder.restore_settlement(data->handle); - } - } +// string descriptor = security_descriptor(data->handle.security()); +// if (descriptor.empty()) { +// defer.push_back(data); +// } +// else { +// _security_recorder.get_key(descriptor, data->handle.security().type, [](void* pv_handle, security_key key) { +// SecurityData* pdata = (SecurityData*)pv_handle; +// pdata->handle.set_key(key); +// }, data); +// // Restore saved settlements +// _settlement_recorder.restore_settlement(data->handle); +// } +// } - // try again later (when spread legs have resolved) - for (auto* retry : defer) { - _security_recorder_input.push(retry); - } +// // try again later (when spread legs have resolved) +// for (auto* retry : defer) { +// _security_recorder_input.push(retry); +// } -} +// } -void MDP3Listener::flush_books() { - // This is called at the end of the packet - // Write all book updates to shared memory and reset for the next packet - for (auto& entry : _book_updates) { - // bbo first - uint16_t sequence = (_latest_sequence & 0xFFFF); - entry.handle.update_bbo(_packet_arrived, entry.bids[0], entry.asks[0], sequence); +// void MDP3Listener::flush_books() { +// // This is called at the end of the packet +// // Write all book updates to shared memory and reset for the next packet +// for (auto& entry : _book_updates) { +// // bbo first +// uint16_t sequence = (_latest_sequence & 0xFFFF); +// entry.handle.update_bbo(_packet_arrived, entry.bids[0], entry.asks[0], sequence); - // Perf Note: the remainder of the book update could be done (carefully) with a memcpy - for (size_t x = 1; x < COCONUT_MAX_DEPTH; ++x) { - entry.handle.update_bid(_packet_arrived, entry.bids[x], x); - entry.handle.update_ask(_packet_arrived, entry.asks[x], x); - } - } - // Reset pending updates - _book_updates.clear(); -} +// // Perf Note: the remainder of the book update could be done (carefully) with a memcpy +// for (size_t x = 1; x < COCONUT_MAX_DEPTH; ++x) { +// entry.handle.update_bid(_packet_arrived, entry.bids[x], x); +// entry.handle.update_ask(_packet_arrived, entry.asks[x], x); +// } +// } +// // Reset pending updates +// _book_updates.clear(); +// } -} -md::MDP3Listener::BookData::BookData(md2::MDProducerHandle & handle) : handle(handle), bids(), asks() -{ } -}//namespace -#endif +// } +// md::MDP3Listener::BookData::BookData(md2::MDProducerHandle & handle) : handle(handle), bids(), asks() +// { } +// }//namespace +// #endif diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp index 69bec8e1a..ebd53dcf2 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp @@ -1,318 +1,318 @@ -#ifndef NO_CPP0X -#include "MDP3Main.h" +// #ifndef NO_CPP0X +// #include "MDP3Main.h" -#include "MDP3Utils.h" -#include "lib/config/config.h" -#include "lib/md/coconut2.h" -#include "lib/os/os.h" -#include "lib/utils/Dispatcher.h" -#include "lib/utils/proto_helper.h" +// #include "MDP3Utils.h" +// #include "lib/config/config.h" +// #include "lib/md/coconut2.h" +// #include "lib/os/os.h" +// #include "lib/utils/Dispatcher.h" +// #include "lib/utils/proto_helper.h" -#include "lib/config/protos/MarketData.pb.h" -#include "lib/config/protos/system.pb.h" +// #include "lib/config/protos/MarketData.pb.h" +// #include "lib/config/protos/system.pb.h" -#include -#include +// #include +// #include -using namespace std; -using namespace bts::md2; -// using namespace OnixS::CME::MDP3; +// using namespace std; +// using namespace bts::md2; +// // using namespace OnixS::CME::MDP3; -namespace bts { -namespace md { +// namespace bts { +// namespace md { -void run_onixs_mdp3_server(UserSymbol* psyms, size_t symcount) { - MDP3Main main; - vector symbols; - for (size_t x = 0; x < symcount; ++x) { - symbols.push_back(psyms[x]); - } - main.run(symbols); -} +// void run_onixs_mdp3_server(UserSymbol* psyms, size_t symcount) { +// MDP3Main main; +// vector symbols; +// for (size_t x = 0; x < symcount; ++x) { +// symbols.push_back(psyms[x]); +// } +// main.run(symbols); +// } -MDP3Main::MDP3Main() : - _producer(Platform::MDP3ONIXS), - _security_recorder(), - _settlement_recorder(Platform::MDP3ONIXS), - _engines(), - _handlers(), - _listeners() -{ -} +// MDP3Main::MDP3Main() : +// _producer(Platform::MDP3ONIXS), +// _security_recorder(), +// _settlement_recorder(Platform::MDP3ONIXS), +// _engines(), +// _handlers(), +// _listeners() +// { +// } -MDP3Main::~MDP3Main() {} +// MDP3Main::~MDP3Main() {} -const CMEOptions::CMEChannel channel_settings_for(const string& id) { - const auto& config = config::get(); - for (const auto& ch : config.channel()) { - bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); - if (found) { - return ch; - } - } - return CMEOptions::CMEChannel(); -} -bool feed_engine_exists(const string& name) { - const auto& config = config::get(); - for (const auto& feed : config.feed_engine()) { - if (feed.name() == name) return true; - } - return false; -} +// const CMEOptions::CMEChannel channel_settings_for(const string& id) { +// const auto& config = config::get(); +// for (const auto& ch : config.channel()) { +// bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); +// if (found) { +// return ch; +// } +// } +// return CMEOptions::CMEChannel(); +// } +// bool feed_engine_exists(const string& name) { +// const auto& config = config::get(); +// for (const auto& feed : config.feed_engine()) { +// if (feed.name() == name) return true; +// } +// return false; +// } -const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOptions::FeedEngineSettings& settings, int feed_count) { - onixs::FeedEngineSettings result; - if (settings.has_data_wait()) result.dataWaitTime(settings.data_wait()); - if (settings.has_spin_time()) result.redundancySpinTime(settings.spin_time()); - for (auto& core : settings.affinity()) { - result.threadsAffinity().insert(core); - } +// const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOptions::FeedEngineSettings& settings, int feed_count) { +// onixs::FeedEngineSettings result; +// if (settings.has_data_wait()) result.dataWaitTime(settings.data_wait()); +// if (settings.has_spin_time()) result.redundancySpinTime(settings.spin_time()); +// for (auto& core : settings.affinity()) { +// result.threadsAffinity().insert(core); +// } - // num_threads() overrides anything else - if (settings.has_num_threads()) { - result.threadsCount(settings.num_threads()); - } - else { - // If num_threads is absent determine thread count based on #channels - result.threadsCount((feed_count / settings.channels_per_thread()) + 1); - } - return result; -} +// // num_threads() overrides anything else +// if (settings.has_num_threads()) { +// result.threadsCount(settings.num_threads()); +// } +// else { +// // If num_threads is absent determine thread count based on #channels +// result.threadsCount((feed_count / settings.channels_per_thread()) + 1); +// } +// return result; +// } -size_t count_engine_uses(const vector& channels, const string& feed_name) { - return count_if(channels.begin(), channels.end(), [&](const CMEChannel& ch) { - const auto& settings = channel_settings_for(ch.id); - return settings.has_feed_engine() && settings.feed_engine() == feed_name; - }); -} +// size_t count_engine_uses(const vector& channels, const string& feed_name) { +// return count_if(channels.begin(), channels.end(), [&](const CMEChannel& ch) { +// const auto& settings = channel_settings_for(ch.id); +// return settings.has_feed_engine() && settings.feed_engine() == feed_name; +// }); +// } -map create_feed_engine_settings(const std::vector& channels) { - map settings; - const auto& config = config::get(); +// map create_feed_engine_settings(const std::vector& channels) { +// map settings; +// const auto& config = config::get(); - // For each feed engine in feed_engine - for (const auto& feed : config.feed_engine()) { - // - see if it is in use - size_t use_count = count_engine_uses(channels, feed.name()); - // - Only create if this feed engine is in use - if (use_count > 0) { - settings[feed.name()] = feed_engine_settings_from_config(feed, use_count); - } - } +// // For each feed engine in feed_engine +// for (const auto& feed : config.feed_engine()) { +// // - see if it is in use +// size_t use_count = count_engine_uses(channels, feed.name()); +// // - Only create if this feed engine is in use +// if (use_count > 0) { +// settings[feed.name()] = feed_engine_settings_from_config(feed, use_count); +// } +// } - // If a channel asks for defaults ensure it exists. - if (settings.count("default") == 0) { - size_t channels_using_default = count_engine_uses(channels, "default"); - if (channels_using_default > 0) { - settings["default"] = feed_engine_settings_from_config(CMEOptions::FeedEngineSettings(), channels_using_default); - } - } +// // If a channel asks for defaults ensure it exists. +// if (settings.count("default") == 0) { +// size_t channels_using_default = count_engine_uses(channels, "default"); +// if (channels_using_default > 0) { +// settings["default"] = feed_engine_settings_from_config(CMEOptions::FeedEngineSettings(), channels_using_default); +// } +// } - return settings; -} +// return settings; +// } -map> create_feed_engines(const vector& channels) { - map> result; - auto settings = create_feed_engine_settings(channels); - // Loop through settings and instantiate feed engines - for (const auto& s : settings) { - unique_ptr temp(new onixs::FeedEngine(s.second)); - result.insert(make_pair(s.first, move(temp))); - } +// map> create_feed_engines(const vector& channels) { +// map> result; +// auto settings = create_feed_engine_settings(channels); +// // Loop through settings and instantiate feed engines +// for (const auto& s : settings) { +// unique_ptr temp(new onixs::FeedEngine(s.second)); +// result.insert(make_pair(s.first, move(temp))); +// } - return result; -} +// return result; +// } -void MDP3Main::run(std::vector& symbols) { - await_cme_config(); - initialize(); - const auto& channels = parse_channels(symbols); - _engines = create_feed_engines(channels); - for (const auto& channel : channels) { - _handlers.push_back(prepare_handler(channel.id)); - _listeners.push_back(prepare_listener(*_handlers.back(), channel)); - std::stringstream symstr; - for (const auto& sym : channel.symbols) { symstr << sym.symbol() << "-" << SecurityType::type_Name(sym.type()) << " "; } - LOG(MarketData,Info, "CME: Initialized channel {} ({})",channel.id,symstr.str()); - } - for (auto& p_handler : _handlers) { - p_handler->start(); - } +// void MDP3Main::run(std::vector& symbols) { +// await_cme_config(); +// initialize(); +// const auto& channels = parse_channels(symbols); +// _engines = create_feed_engines(channels); +// for (const auto& channel : channels) { +// _handlers.push_back(prepare_handler(channel.id)); +// _listeners.push_back(prepare_listener(*_handlers.back(), channel)); +// std::stringstream symstr; +// for (const auto& sym : channel.symbols) { symstr << sym.symbol() << "-" << SecurityType::type_Name(sym.type()) << " "; } +// LOG(MarketData,Info, "CME: Initialized channel {} ({})",channel.id,symstr.str()); +// } +// for (auto& p_handler : _handlers) { +// p_handler->start(); +// } - // - // Work timer - auto& disp = utils::Dispatcher::current(); - utils::DispatcherTimer security_timer(disp, 500, [&]() { - _security_recorder.do_work(); - }); - security_timer.start(); +// // +// // Work timer +// auto& disp = utils::Dispatcher::current(); +// utils::DispatcherTimer security_timer(disp, 500, [&]() { +// _security_recorder.do_work(); +// }); +// security_timer.start(); - utils::DispatcherTimer spread_resolve_timer(disp, 1000, [&]() { - _index.resolve_spreads(); - }); - spread_resolve_timer.start(); +// utils::DispatcherTimer spread_resolve_timer(disp, 1000, [&]() { +// _index.resolve_spreads(); +// }); +// spread_resolve_timer.start(); - utils::DispatcherTimer settlement_timer(disp, 100, [&]() { - _settlement_recorder.do_work(); - }); - settlement_timer.start(); +// utils::DispatcherTimer settlement_timer(disp, 100, [&]() { +// _settlement_recorder.do_work(); +// }); +// settlement_timer.start(); - utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { - for (const auto& listener: _listeners) { - listener->heartbeat(); - } - }); - heartbeat_timer.start(); +// utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { +// for (const auto& listener: _listeners) { +// listener->heartbeat(); +// } +// }); +// heartbeat_timer.start(); - LOG(MarketData,Info, "** CME MDP3 Publisher started **"); +// LOG(MarketData,Info, "** CME MDP3 Publisher started **"); - disp.run(); -} +// disp.run(); +// } -void MDP3Main::initialize() { - const auto& options = config::get(); +// void MDP3Main::initialize() { +// const auto& options = config::get(); - // - // License path - onixs::InitializationSettings init_settings; - auto license = options.onixs_license(); - init_settings.licenseStore(license); - if (license == "{default}") { - init_settings.licenseStore(os::get_cwd() + "/licenses/"); - } - LOG(MarketData,Info,"Loading onixs license from {}", init_settings.licenseStore()); - onixs::initialize(init_settings); -} +// // +// // License path +// onixs::InitializationSettings init_settings; +// auto license = options.onixs_license(); +// init_settings.licenseStore(license); +// if (license == "{default}") { +// init_settings.licenseStore(os::get_cwd() + "/licenses/"); +// } +// LOG(MarketData,Info,"Loading onixs license from {}", init_settings.licenseStore()); +// onixs::initialize(init_settings); +// } -// -// Initialize HandlerSettings and allocate the channel Handler -unique_ptr MDP3Main::prepare_handler(const string& channel_id) { - const auto& pub_options = config::get(); - const auto& options = channel_settings_for(channel_id); - LOG(MarketData,Info,"Loaded channel options for channel {}:\n{}",channel_id ,options.DebugString()); - onixs::HandlerSettings settings; - settings.channelId(channel_id); - settings.channelsConfigurationFile(config_path()); - settings.codingTemplatesFile(template_path()); +// // +// // Initialize HandlerSettings and allocate the channel Handler +// unique_ptr MDP3Main::prepare_handler(const string& channel_id) { +// const auto& pub_options = config::get(); +// const auto& options = channel_settings_for(channel_id); +// LOG(MarketData,Info,"Loaded channel options for channel {}:\n{}",channel_id ,options.DebugString()); +// onixs::HandlerSettings settings; +// settings.channelId(channel_id); +// settings.channelsConfigurationFile(config_path()); +// settings.codingTemplatesFile(template_path()); - // - // Tcp Replay options +// // +// // Tcp Replay options - if (options.use_tcp_replay()) LOG(MarketData,Info,"CME: Enabled TCP replay"); - if (options.use_tcp_replay()) { - settings.tcpRecoveryUsername(options.tcp_replay_username()); - settings.tcpRecoveryPassword(options.tcp_replay_password()); - settings.tcpRecoveryReconnectAttempts(options.tcp_replay_connect_attempts()); - settings.tcpRecoveryReconnectInterval(options.tcp_replay_reconnect_interval_ms()); - } +// if (options.use_tcp_replay()) LOG(MarketData,Info,"CME: Enabled TCP replay"); +// if (options.use_tcp_replay()) { +// settings.tcpRecoveryUsername(options.tcp_replay_username()); +// settings.tcpRecoveryPassword(options.tcp_replay_password()); +// settings.tcpRecoveryReconnectAttempts(options.tcp_replay_connect_attempts()); +// settings.tcpRecoveryReconnectInterval(options.tcp_replay_reconnect_interval_ms()); +// } - // - // Network settings +// // +// // Network settings - settings.udpSocketBufferSize(options.udp_socket_buffer_size()); - if (options.has_lost_packet_wait_timeout_ms()) { - settings.lostPacketWaitTime((size_t)options.lost_packet_wait_timeout_ms() * 1000); - } - if (pub_options.has_network_interface()) { - settings.networkInterface(pub_options.network_interface()); - } - else { - if (pub_options.has_network_interface_a()) { - settings.networkInterfaceA(pub_options.network_interface_a()); - } - if (pub_options.has_network_interface_b()) { - settings.networkInterfaceB(pub_options.network_interface_b()); - } - } +// settings.udpSocketBufferSize(options.udp_socket_buffer_size()); +// if (options.has_lost_packet_wait_timeout_ms()) { +// settings.lostPacketWaitTime((size_t)options.lost_packet_wait_timeout_ms() * 1000); +// } +// if (pub_options.has_network_interface()) { +// settings.networkInterface(pub_options.network_interface()); +// } +// else { +// if (pub_options.has_network_interface_a()) { +// settings.networkInterfaceA(pub_options.network_interface_a()); +// } +// if (pub_options.has_network_interface_b()) { +// settings.networkInterfaceB(pub_options.network_interface_b()); +// } +// } - if (pub_options.has_network_interface() || - (pub_options.has_network_interface_a() && - pub_options.has_network_interface_b()) ) { - if (options.prefer_backup_feeds()) { - settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); - settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); - } - else { - settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB); - settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB); - } - } - else if (pub_options.has_network_interface_a()) { - settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedAOnly); - settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedAOnly); - } - else if (pub_options.has_network_interface_b()) { - settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedBOnly); - settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedBOnly); - } +// if (pub_options.has_network_interface() || +// (pub_options.has_network_interface_a() && +// pub_options.has_network_interface_b()) ) { +// if (options.prefer_backup_feeds()) { +// settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); +// settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); +// } +// else { +// settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB); +// settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB); +// } +// } +// else if (pub_options.has_network_interface_a()) { +// settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedAOnly); +// settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedAOnly); +// } +// else if (pub_options.has_network_interface_b()) { +// settings.instrumentFeedLayout(onixs::RecoveryFeedLayout::FeedBOnly); +// settings.snapshotFeedLayout(onixs::RecoveryFeedLayout::FeedBOnly); +// } - // - // Misc settings +// // +// // Misc settings - settings.recoverSecurityDefinitionsOnGap(false); - settings.bookUpdateNotificationStrategy(onixs::BookUpdateNotificationStrategies::OnEndOfEvent); +// settings.recoverSecurityDefinitionsOnGap(false); +// settings.bookUpdateNotificationStrategy(onixs::BookUpdateNotificationStrategies::OnEndOfEvent); - // - // Logging +// // +// // Logging - settings.logDirectory(config::get().onixs_log_path()); - settings.logMode((onixs::LogModes::Enum)options.onixs_log_mode()); - settings.advancedLogOptions((onixs::AdvancedLogOptions::Enum)options.onixs_log_advanced()); - settings.logFileNamePrefix(channel_id + "_"); +// settings.logDirectory(config::get().onixs_log_path()); +// settings.logMode((onixs::LogModes::Enum)options.onixs_log_mode()); +// settings.advancedLogOptions((onixs::AdvancedLogOptions::Enum)options.onixs_log_advanced()); +// settings.logFileNamePrefix(channel_id + "_"); - // - // Associate with feed handler +// // +// // Associate with feed handler - try { - auto temp = unique_ptr(new onixs::Handler(settings)); - if (options.has_feed_engine()) { - temp->bindToFeedEngine(_engines[options.feed_engine()].get()); - } - return temp; - } - catch (std::exception& e) { - LOG(MarketData,Error,"{}", e.what()); - throw; - } -} +// try { +// auto temp = unique_ptr(new onixs::Handler(settings)); +// if (options.has_feed_engine()) { +// temp->bindToFeedEngine(_engines[options.feed_engine()].get()); +// } +// return temp; +// } +// catch (std::exception& e) { +// LOG(MarketData,Error,"{}", e.what()); +// throw; +// } +// } -// -// Create a listener for this channel and register callbacks -unique_ptr MDP3Main::prepare_listener(onixs::Handler& handler, const CMEChannel& channel) { - // We need to get a handler to the producer channels so we can produce heartbeats - vector producer_channels; - for (auto& symbol : channel.symbols) { - producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); - //handler.addSecurityAssetFilter(symbol.symbol()); - } +// // +// // Create a listener for this channel and register callbacks +// unique_ptr MDP3Main::prepare_listener(onixs::Handler& handler, const CMEChannel& channel) { +// // We need to get a handler to the producer channels so we can produce heartbeats +// vector producer_channels; +// for (auto& symbol : channel.symbols) { +// producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); +// //handler.addSecurityAssetFilter(symbol.symbol()); +// } - unique_ptr listener(new MDP3Listener(_index, _producer, _security_recorder, _settlement_recorder, producer_channels, utils::Dispatcher::current())); - for (auto& symbol : channel.symbols) { - listener->add_filter_symbol(symbol.symbol()); - } +// unique_ptr listener(new MDP3Listener(_index, _producer, _security_recorder, _settlement_recorder, producer_channels, utils::Dispatcher::current())); +// for (auto& symbol : channel.symbols) { +// listener->add_filter_symbol(symbol.symbol()); +// } - handler.registerMessageProcessingListener(listener.get()); - handler.registerSecurityDefinitionListener(listener.get()); - handler.registerSecurityStatusListener(listener.get()); - handler.registerConsolidatedBookUpdateListener(listener.get()); - handler.registerStateChangeListener(listener.get()); +// handler.registerMessageProcessingListener(listener.get()); +// handler.registerSecurityDefinitionListener(listener.get()); +// handler.registerSecurityStatusListener(listener.get()); +// handler.registerConsolidatedBookUpdateListener(listener.get()); +// handler.registerStateChangeListener(listener.get()); - if (!config::get().quoter_mode()) { - handler.registerTradeListener(listener.get()); - handler.registerElectronicVolumeListener(listener.get()); - handler.registerRequestForQuoteListener(listener.get()); - handler.registerStatisticsListener(listener.get()); - } +// if (!config::get().quoter_mode()) { +// handler.registerTradeListener(listener.get()); +// handler.registerElectronicVolumeListener(listener.get()); +// handler.registerRequestForQuoteListener(listener.get()); +// handler.registerStatisticsListener(listener.get()); +// } - handler.registerWarningListener(listener.get()); - handler.registerErrorListener(listener.get()); +// handler.registerWarningListener(listener.get()); +// handler.registerErrorListener(listener.get()); - return listener; -} +// return listener; +// } -}}//namespace -#endif +// }}//namespace +// #endif diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Utils.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Utils.cpp index 4034af62f..90221c25d 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Utils.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Utils.cpp @@ -1,128 +1,128 @@ -#ifndef NO_CPP0X -#include "MDP3Utils.h" -#include "onixs.h" +// #ifndef NO_CPP0X +// #include "MDP3Utils.h" +// #include "onixs.h" -#include "lib/config/config.h" -#include "lib/utils/datetime.h" -#include "lib/utils/bts_chrono.h" +// #include "lib/config/config.h" +// #include "lib/utils/datetime.h" +// #include "lib/utils/bts_chrono.h" -#include "lib/config/protos/MarketData.pb.h" -#include "lib/config/protos/system.pb.h" +// #include "lib/config/protos/MarketData.pb.h" +// #include "lib/config/protos/system.pb.h" -#include -#include +// #include +// #include -using namespace std; -using namespace bts::md2; +// using namespace std; +// using namespace bts::md2; -namespace bts { -namespace md { +// namespace bts { +// namespace md { -string data_path() { - 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 '/' - os::normalize_path(p, '\\'); -#else - os::normalize_path(p); -#endif - return p; -} -const string config_path() { return data_path() + "config.xml"; } -const string template_path() { return data_path() + "templates.xml"; } +// string data_path() { +// 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 '/' +// os::normalize_path(p, '\\'); +// #else +// os::normalize_path(p); +// #endif +// return p; +// } +// const string config_path() { return data_path() + "config.xml"; } +// const string template_path() { return data_path() + "templates.xml"; } -bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { - if (!boost::filesystem::exists(filename)) { - if (log) { - LOG(MarketData,Error, - "File {} is not present on this system. " - "Please download it from the CME ftp site. " - "I will wait until the file is present.\n$ curl {} > {} ", - filename, url, filename); - } - return false; - } - return true; -} +// bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { +// if (!boost::filesystem::exists(filename)) { +// if (log) { +// LOG(MarketData,Error, +// "File {} is not present on this system. " +// "Please download it from the CME ftp site. " +// "I will wait until the file is present.\n$ curl {} > {} ", +// filename, url, filename); +// } +// return false; +// } +// return true; +// } -// For exponential backoff on logging this return true if x is a power of 2 or 0 -bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } +// // For exponential backoff on logging this return true if x is a power of 2 or 0 +// bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } -void await_cme_config() { - const auto config_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; - const auto templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml"; +// void await_cme_config() { +// const auto config_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; +// const auto templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml"; - boost::filesystem::create_directories(data_path()); +// boost::filesystem::create_directories(data_path()); - // Check config is present and give instructions for downloading it if not - // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. - uint32_t count = 0; - while(!check_file_exists_with_instructions(config_path(), config_url, is_pow_two_or_0(count))) { - ++count; - std::this_thread::sleep_for(1s); - } - count = 0; - while(!check_file_exists_with_instructions(template_path(), templates_url, is_pow_two_or_0(count))) { - ++count; - std::this_thread::sleep_for(1s); - } +// // Check config is present and give instructions for downloading it if not +// // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. +// uint32_t count = 0; +// while(!check_file_exists_with_instructions(config_path(), config_url, is_pow_two_or_0(count))) { +// ++count; +// std::this_thread::sleep_for(1s); +// } +// count = 0; +// while(!check_file_exists_with_instructions(template_path(), templates_url, is_pow_two_or_0(count))) { +// ++count; +// std::this_thread::sleep_for(1s); +// } - // If we waited for someone to download the file give it a second to be finished downloading - if (count > 0) { - std::this_thread::sleep_for(1s); - } -} +// // If we waited for someone to download the file give it a second to be finished downloading +// if (count > 0) { +// std::this_thread::sleep_for(1s); +// } +// } -SecurityType::type infer_security_type(const string& label) { - if (label.find("Option") != std::string::npos) { - return SecurityType::OPTION; - } +// SecurityType::type infer_security_type(const string& label) { +// if (label.find("Option") != std::string::npos) { +// return SecurityType::OPTION; +// } - if (label.find("Future") != std::string::npos) { - return SecurityType::FUTURE; - } +// if (label.find("Future") != std::string::npos) { +// return SecurityType::FUTURE; +// } - // TODO: Allow configuration to override this? - LOG(MarketData,Warn,"Unable to guess security type from label: '{}" - "' Treating as OPTION.",label); - return SecurityType::OPTION; -} +// // TODO: Allow configuration to override this? +// LOG(MarketData,Warn,"Unable to guess security type from label: '{}" +// "' Treating as OPTION.",label); +// return SecurityType::OPTION; +// } -const vector parse_channels(const vector& symbols) { - vector result; +// const vector parse_channels(const vector& symbols) { +// vector result; - pugi::xml_document doc; - bts_assert_msg(doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); +// pugi::xml_document doc; +// bts_assert_msg(doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); - auto configuration = doc.root().child("configuration"); - bts_assert(configuration); +// auto configuration = doc.root().child("configuration"); +// bts_assert(configuration); - LOG(MarketData,Info,"CME: Loaded '{}' config. Last updated: {}" , - configuration.attribute("environment").as_string(), - configuration.attribute("updated").as_string()); - auto channels = configuration.children("channel"); - for (const auto& chan : channels) { - CMEChannel channel; - channel.id = chan.attribute("id").as_string(); - auto type = infer_security_type(chan.attribute("label").as_string()); - if (!(channel.id.empty())) { - auto product_list = chan.child("products").children("product"); - for (const auto& product : product_list) { - auto symbol = product.attribute("code").as_string(); - for (auto s : symbols) { - if ((s.type() == type || s.type() == SecurityType::SPREAD) && s.symbol() == symbol) { - channel.symbols.insert(s); - } - } - } - if (!channel.symbols.empty()) { - result.push_back(channel); - } - } - } +// LOG(MarketData,Info,"CME: Loaded '{}' config. Last updated: {}" , +// configuration.attribute("environment").as_string(), +// configuration.attribute("updated").as_string()); +// auto channels = configuration.children("channel"); +// for (const auto& chan : channels) { +// CMEChannel channel; +// channel.id = chan.attribute("id").as_string(); +// auto type = infer_security_type(chan.attribute("label").as_string()); +// if (!(channel.id.empty())) { +// auto product_list = chan.child("products").children("product"); +// for (const auto& product : product_list) { +// auto symbol = product.attribute("code").as_string(); +// for (auto s : symbols) { +// if ((s.type() == type || s.type() == SecurityType::SPREAD) && s.symbol() == symbol) { +// channel.symbols.insert(s); +// } +// } +// } +// if (!channel.symbols.empty()) { +// result.push_back(channel); +// } +// } +// } - return result; -} +// return result; +// } -}}//namespace -#endif +// }}//namespace +// #endif diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/tests/mdp3_tests.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/tests/mdp3_tests.cpp index e7fe25a52..0358d1741 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/tests/mdp3_tests.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/tests/mdp3_tests.cpp @@ -1,210 +1,210 @@ -#include "catch/catch.hpp" +// #include "catch/catch.hpp" -#include "lib/config/config.h" -#include "lib/config/protos/MarketData.pb.h" +// #include "lib/config/config.h" +// #include "lib/config/protos/MarketData.pb.h" -#include -#include -#include -#include +// #include +// #include +// #include +// #include -#include "../MDP3Utils.h" -#include "../onixs.h" +// #include "../MDP3Utils.h" +// #include "../onixs.h" -using namespace bts::md; -using namespace std; +// using namespace bts::md; +// using namespace std; -namespace bts { -namespace md { +// namespace bts { +// namespace md { -map create_feed_engine_settings(const std::vector& channels); -const CMEOptions::CMEChannel channel_settings_for(const string& id); +// map create_feed_engine_settings(const std::vector& channels); +// const CMEOptions::CMEChannel channel_settings_for(const string& id); -namespace test { +// namespace test { -vector test_channels(int count, ...) { - // Doing this the C way because I still haven't updated VS - vector result; - va_list ap; - va_start(ap, count); - for (int x = 0; x < count; ++x) { - const char* val = va_arg(ap, char*); - CMEChannel temp; - temp.id = val; - result.push_back(temp); - } - va_end(ap); - return result; -} +// vector test_channels(int count, ...) { +// // Doing this the C way because I still haven't updated VS +// vector result; +// va_list ap; +// va_start(ap, count); +// for (int x = 0; x < count; ++x) { +// const char* val = va_arg(ap, char*); +// CMEChannel temp; +// temp.id = val; +// result.push_back(temp); +// } +// va_end(ap); +// return result; +// } -TEST_CASE("mdp3_tests","[md]") { - SECTION("test_defaults") { - config::internal::initialize_for_test("CMEOptions {}"); +// TEST_CASE("mdp3_tests","[md]") { +// SECTION("test_defaults") { +// config::internal::initialize_for_test("CMEOptions {}"); - vector channels = test_channels(1, "310"); - auto result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); - channels = test_channels(2, "310", "311"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); +// channels = test_channels(2, "310", "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); - channels = test_channels(4, "310", "311", "400", "412"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); +// channels = test_channels(4, "310", "311", "400", "412"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); - REQUIRE(!channel_settings_for("310").has_feed_engine()); - REQUIRE(!channel_settings_for("311").has_feed_engine()); - REQUIRE(!channel_settings_for("315").has_feed_engine()); - } +// REQUIRE(!channel_settings_for("310").has_feed_engine()); +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(!channel_settings_for("315").has_feed_engine()); +// } - SECTION("test_segregate_futures") { - config::internal::initialize_for_test( - "CMEOptions {\n" - " value {\n" - " feed_engine {\n" - " name: 'default'\n" - " }\n" - " feed_engine {\n" - " name: 'futures'\n" - " num_threads: 4\n" - " }\n" - " # Futures\n" - " channel {\n" - " id: '310'\n" - " id: '312'\n" - " feed_engine: 'futures'\n" - " }\n" - " # Options\n" - " channel {\n" - " id: '311'\n" - " id: '313'\n" - " id: '315'\n" - " feed_engine: 'default'\n" - " }\n" - " }\n" - "}"); +// SECTION("test_segregate_futures") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'default'\n" +// " }\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " feed_engine: 'default'\n" +// " }\n" +// " }\n" +// "}"); - vector channels = test_channels(1, "310"); - auto result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 1); - REQUIRE(result.begin()->first == "futures"); - REQUIRE(result.begin()->second.threadsCount() == 4); +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); - channels = test_channels(1, "311"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 1); - REQUIRE(result.begin()->first == "default"); - REQUIRE(result.begin()->second.threadsCount() == 1); +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "default"); +// REQUIRE(result.begin()->second.threadsCount() == 1); - channels = test_channels(2, "311", "310"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 2); - REQUIRE(result["default"].threadsCount() == 1); - REQUIRE(result["futures"].threadsCount() == 4); +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 2); +// REQUIRE(result["default"].threadsCount() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); - // Test channels not listed in config - channels = test_channels(2, "317", "318"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); - } +// // Test channels not listed in config +// channels = test_channels(2, "317", "318"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); +// } - SECTION("test_no_default") { - config::internal::initialize_for_test( - "CMEOptions {\n" - " value {\n" - " feed_engine {\n" - " name: 'futures'\n" - " num_threads: 4\n" - " }\n" - " # any channel not listed will use the default feed engine\n" - " # Futures\n" - " channel {\n" - " id: '310'\n" - " id: '312'\n" - " feed_engine: 'futures'\n" - " }\n" - " # Options\n" - " channel {\n" - " id: '311'\n" - " id: '313'\n" - " id: '315'\n" - " use_tcp_replay: false\n" - " }\n" - " }\n" - "}"); +// SECTION("test_no_default") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # any channel not listed will use the default feed engine\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " use_tcp_replay: false\n" +// " }\n" +// " }\n" +// "}"); - vector channels = test_channels(1, "310"); - auto result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 1); - REQUIRE(result.begin()->first == "futures"); - REQUIRE(result.begin()->second.threadsCount() == 4); +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); - channels = test_channels(1, "311"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); - channels = test_channels(2, "311", "310"); - result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 1); - REQUIRE(result["futures"].threadsCount() == 4); +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); - REQUIRE(channel_settings_for("310").use_tcp_replay() == true); - REQUIRE(channel_settings_for("311").use_tcp_replay() == false); - REQUIRE(channel_settings_for("315").use_tcp_replay() == false); - } +// REQUIRE(channel_settings_for("310").use_tcp_replay() == true); +// REQUIRE(channel_settings_for("311").use_tcp_replay() == false); +// REQUIRE(channel_settings_for("315").use_tcp_replay() == false); +// } - SECTION("test_one_thread_each") { - config::internal::initialize_for_test( - "CMEOptions {\n" - " value {\n" - " channel {\n" - " id: '*'\n" - " }\n" - " }\n" - "}\n"); +// SECTION("test_one_thread_each") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); - vector channels = test_channels(1, "310", "311"); - auto result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 0); +// vector channels = test_channels(1, "310", "311"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); - const auto& settings = channel_settings_for("311"); - REQUIRE(!settings.has_feed_engine()); - } +// const auto& settings = channel_settings_for("311"); +// REQUIRE(!settings.has_feed_engine()); +// } - SECTION("test_common_futures_thread") { - config::internal::initialize_for_test( - "CMEOptions {\n" - " value {\n" - " feed_engine {\n" - " name: 'futures'\n" - " num_threads: 4\n" - " }\n" - " channel {\n" - " id: '310'\n" - " feed_engine: 'futures'\n" - " udp_socket_buffer_size: 1234\n" - " }\n" - " channel {\n" - " id: '*'\n" - " }\n" - " }\n" - "}\n"); +// SECTION("test_common_futures_thread") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " channel {\n" +// " id: '310'\n" +// " feed_engine: 'futures'\n" +// " udp_socket_buffer_size: 1234\n" +// " }\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); - vector channels = test_channels(6, "310", "311", "315", "100", "10", "42"); - auto result = create_feed_engine_settings(channels); - REQUIRE(result.size() == 1); - result = create_feed_engine_settings(test_channels(1, "315")); - REQUIRE(result.size() == 0); +// vector channels = test_channels(6, "310", "311", "315", "100", "10", "42"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// result = create_feed_engine_settings(test_channels(1, "315")); +// REQUIRE(result.size() == 0); - REQUIRE(!channel_settings_for("311").has_feed_engine()); - REQUIRE(channel_settings_for("310").has_feed_engine()); - REQUIRE(channel_settings_for("310").udp_socket_buffer_size() == 1234); - REQUIRE(channel_settings_for("311").has_udp_socket_buffer_size() == false); - } -} +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(channel_settings_for("310").has_feed_engine()); +// REQUIRE(channel_settings_for("310").udp_socket_buffer_size() == 1234); +// REQUIRE(channel_settings_for("311").has_udp_socket_buffer_size() == false); +// } +// } -}}}//namespace +// }}}//namespace diff --git a/src/server/sparkd/order_man/order_man_utils.h b/src/server/sparkd/order_man/order_man_utils.h index 96bd4f26b..196095aa3 100644 --- a/src/server/sparkd/order_man/order_man_utils.h +++ b/src/server/sparkd/order_man/order_man_utils.h @@ -2,6 +2,7 @@ #include #include +#include #include "lib/utils/ValueWrapper.h" #include "lib/domain_model/common.h" diff --git a/tools/safe_dep_glob.cmake b/tools/safe_dep_glob.cmake new file mode 100644 index 000000000..da0cb9c45 --- /dev/null +++ b/tools/safe_dep_glob.cmake @@ -0,0 +1,29 @@ +# inspired by https://stackoverflow.com/questions/1027247/specify-source-files-globally-with-glob + +# Compare the new contents with the existing file, if it exists and is the +# same we don't want to trigger a make by changing its timestamp. +function(update_file path content) + set(old_content "") + if(EXISTS "${path}") + file(READ "${path}" old_content) + endif() + if(NOT old_content STREQUAL content) + file(WRITE "${path}" "${content}") + endif() +endfunction(update_file) + +# Creates a file called CMakeDeps.cmake next to your CMakeLists.txt with +# the list of dependencies in it - this file should be treated as part of +# CMakeLists.txt (source controlled, etc.). +function(update_deps_file deps) + set(deps_file "CMakeDeps.cmake") + # Normalize the list so it's the same on every machine + list(REMOVE_DUPLICATES deps) + list(SORT deps) + # Update the deps file + set(content "# generated by make process\nset(sources ${deps})\n") + update_file(${deps_file} "${content}") + # Include the file so it's tracked as a generation dependency we don't + # need the content. + include(${deps_file}) +endfunction(update_deps_file)