it builds, ship it

This commit is contained in:
Kevin Darby committed 2020-04-23 17:57:13 -04:00
1 parent 3193bc6467
commit e7b6bf40d9
25 files changed
+455 -479

No files matched your search

+1 -1
View File
@@ -1 +1 @@
set(sources api/apicore.proto;api/apigateway.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/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.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/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.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.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.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/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metricsLine truncated
set(sources api/apicore.proto;api/apigateway.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/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.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/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.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.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.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/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metricsLine truncated
+23 -25
View File
@@ -4,15 +4,20 @@ OrdermanCfg {
executor {
thread_name: "oman_orders"
poll: false
hosted_actor: "MDSource"
hosted_actor: "OrderManager"
hosted_actor: "ExecutionGateway"
hosted_actor: { type: "MDSource" }
hosted_actor: { type: "OrderManager" }
}
executor {
thread_name: "oman_gw"
poll: false
hosted_actor: { type: "Gateway" qualifier: "gw0" }
}
executor {
thread_name: "oman_slow"
poll: false
hosted_actor: "*"
hosted_actor: { type : "*" }
}
use_gateway: true
}
}
@@ -21,37 +26,30 @@ OrdermanCfg {
executor {
thread_name: "oman_orders"
poll: true
hosted_actor: "MDSource"
hosted_actor: "OrderManager"
hosted_actor: "ExecutionGateway"
hosted_actor: { type: "MDSource" }
hosted_actor: { type: "OrderManager" }
}
executor {
thread_name: "oman_gw"
poll: true
hosted_actor: { type: "Gateway" qualifier: "gw0" }
}
executor {
thread_name: "oman_slow"
poll: false
hosted_actor: "*"
hosted_actor: { type: "*" }
}
use_gateway: true
}
}
OrderServiceLoadBalancing {
value {
load_balancer {
qualfier: "LB1"
user_regex: "BTS"
}
load_balancer {
qualifier: ""
user_regex: "*"
}
use_load_balancing: true
}
}
GatewayCgf {
GatewayCfg {
value {
#note that multiple gws are possible but not well tested as of 4/23/2020
gateway {
qualifier: ""
connection_regex: "*"
}
qualifier: "gw0"
connection: "*"
}
}
}
+2 -1
View File
@@ -15,6 +15,7 @@ message OrdermanCfg {
repeated Executor executor = 1;
optional uint32 default_iceberg_pause_secs = 2 [default = 0];
optional string fallback_cust_order_handling_inst = 3 [default = "Y"];
optional bool use_gateway = 4 [default = true];
}
message OrderServiceLoadBalancing {
@@ -29,7 +30,7 @@ message OrderServiceLoadBalancing {
message GatewayCfg {
message Gateway {
required string qualifier = 1;
required string connection_regex = 2;
repeated string connection = 2;
}
repeated Gateway gateway = 1;
}
+81
View File
@@ -0,0 +1,81 @@
#include "ActorThread.h"
#include "lib/utils/thread_manager.h"
#include "lib/utils/type_name.h"
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
namespace bts {
namespace orderman {
ActorThread::ActorThread(const config::OrdermanCfg::Executor &cfg, metrics::MetricsContainer &stats)
: cfg(cfg), thread(), executor(), loop_metric(), done(false)
{
std::array<double, 30> buckets;
auto i = 0;
for (auto &b : buckets)
b = (i += 1000);
loop_metric = std::make_shared<metrics::HistogramMetric<30>>(
fmt::format("spark_metrics_{}_thread_loop_ns", cfg.thread_name()),
buckets);
stats.publish(loop_metric);
}
ActorThread::~ActorThread()
{
done = true;
thread.join();
}
void ActorThread::start(trace::PerfLog &log)
{
if (cfg.poll())
thread = threading::make_thread(cfg.thread_name(), [this, &log]()
{
for (;;)
executor.do_work(log);
});
else
{
thread = threading::make_thread(cfg.thread_name(), [this, &log]()
{
const auto inner_iter = 1000;
while (!done)
{
auto start = Timer::now();
for (auto i = 0; i < inner_iter; i++)
executor.do_work(log);
auto stop = Timer::now();
loop_metric->observe(ns_diff(stop, start) / inner_iter);
std::this_thread::sleep_for(10ms);
}
});
}
}
ActorThread* ActorThread::find_thread_for_actor(const std::string& actor_name,
const std::vector<std::unique_ptr<ActorThread>>& all_executors,
const std::string& qualifier)
{
for (auto const &ex : all_executors)
{
for (auto const &hosted : ex->cfg.hosted_actor())
{
if (hosted.type() == "*" || boost::algorithm::to_lower_copy(hosted.type()) ==
boost::algorithm::to_lower_copy(actor_name))
{
if(qualifier != "")
{
if(boost::algorithm::to_lower_copy(qualifier) == boost::algorithm::to_lower_copy(hosted.qualifier()))
return ex.get();
}
else
return ex.get();
}
}
}
return nullptr;
}
}}
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include "lib/mercury/executor/Executor.h"
#include "lib/metrics/metrics.h"
#include "lib/utils/thread_manager.h"
#include "lib/config/config.h"
#include "lib/config/protos/jetfix.pb.h"
#include "lib/config/protos/orderman_cfg.pb.h"
namespace bts {
namespace orderman {
struct ActorThread
{
ActorThread(const config::OrdermanCfg::Executor &cfg, metrics::MetricsContainer &stats);
void start(trace::PerfLog &log);
~ActorThread();
static ActorThread* find_thread_for_actor(const std::string&actor_name,
const std::vector<std::unique_ptr<ActorThread>>& all_executors,
const std::string& qualifier = "");
config::OrdermanCfg::Executor cfg;
std::thread thread;
mercury::Executor executor;
std::shared_ptr<metrics::HistogramMetric<30>> loop_metric;
std::atomic<bool> done;
};
}}
+3 -3
View File
@@ -25,8 +25,8 @@ struct FillStore::UnresolvedFills {
};
struct FillStore::PImpl {
PImpl(md::SecurityOracle &oracle, const std::string& qualifier)
: store(new persistence::SqliteStore(std::string("fills") + qualifier)), known_orders(),
PImpl(md::SecurityOracle &oracle)
: store(new persistence::SqliteStore("fills")), known_orders(),
fills_with_unresolved_accounts(), oracle(oracle) {}
std::unique_ptr<persistence::IStore> store;
@@ -37,7 +37,7 @@ struct FillStore::PImpl {
md::SecurityOracle oracle;
};
FillStore::FillStore(md::SecurityOracle o, const std::string& qualifier) : me(new PImpl(o, qualifier)) {}
FillStore::FillStore(md::SecurityOracle o) : me(new PImpl(o)) {}
void FillStore::init() {
+1 -1
View File
@@ -15,7 +15,7 @@ class OrderDefinitionUpdateEvent;
class FillStore : public mercury::Actor
{
public:
FillStore(md::SecurityOracle, const std::string& qualifier);
FillStore(md::SecurityOracle);
~FillStore();
void init() override;
@@ -18,7 +18,7 @@ ExecutionGatewayFactory::create_gateway(const config::JetFIX::Connection &conn,
trace::PerfLog &pl,
md::SecurityOracle o)
{
if(config::get<config::OrderServiceLoadBalancing>().use_load_balancing())
if(config::get<config::OrdermanCfg>().use_gateway())
return std::make_unique<GatewayProxy>(conn, pl, o);
else
return create_local_gateway(conn, pl, o);
+3 -3
View File
@@ -19,8 +19,8 @@ namespace orderman {
static auto const orders_ns = "orders";
struct OrderStore::PImpl {
PImpl(md::SecurityOracle o, const std::string& qualifier)
: known_orders(), store(new persistence::SqliteStore(std::string("orders_") + qualifier)),
PImpl(md::SecurityOracle o)
: known_orders(), store(new persistence::SqliteStore("orders")),
order_stream(),
soft_cleanup_enabled(
config::get<config::toggles::OrdersSoftCleanup>().enabled()),
@@ -39,7 +39,7 @@ struct OrderStore::PImpl {
timeval cutoff_time;
};
OrderStore::OrderStore(md::SecurityOracle o, const std::string& qualifier) : me(new PImpl(o, qualifier)) {}
OrderStore::OrderStore(md::SecurityOracle o) : me(new PImpl(o)) {}
OrderStore::~OrderStore() {}
void OrderStore::init() {
+1 -1
View File
@@ -17,7 +17,7 @@ class OrderDefinitionUpdateEvent;
class OrderStore : public mercury::Actor
{
public:
OrderStore(md::SecurityOracle, const std::string& qualifier);
OrderStore(md::SecurityOracle);
~OrderStore();
void init() override;
+103 -136
View File
@@ -1,183 +1,150 @@
#include "GatewayProxy.h"
#include "GatewayManager.h"
#include "Gateway.h"
#include "lib/mercury/executor/Executor.h"
#include "lib/mercury/events/Update.h"
#include "lib/mercury/events/Stream.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/events/NewAdminDataEvent.h"
#include "lib/orderman/events/SendFixEvent.h"
#include "lib/orderman/events/SendOrderMsgsEvent.h"
#include "lib/orderman/events/GatewayStatusChangeEvent.h"
#include "lib/orderman/events/CancelRejectEvent.h"
#include "lib/orderman/events/NewExecutionReportEvent.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/orderman/orderman_utils/ExecutionReport.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/jetfix/common/OutFIX.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/helper_macros.h"
#include "lib/utils/type_name.h"
#include "lib/utils/GrowableSPSCQueue.h"
#include "lib/metrics/metrics.h"
#include "lib/config/config.h"
#include "lib/config/protos/mercury_cfg.pb.h"
#include "lib/config/protos/jetfix.pb.h"
#include <boost/pool/object_pool.hpp>
#include <variant>
#include <tuple>
#include <map>
namespace bts {
namespace orderman {
enum class GatewayMsgType
void Gateway::spawn_gateways(const std::vector<std::unique_ptr<ActorThread>>& actor_threads,
trace::PerfLog& pl, md::SecurityOracle oracle)
{
CREATE,
START,
if(!config::get<config::OrdermanCfg>().use_gateway())
return;
bts_assert_msg(config::get<config::OrdermanCfg>().use_gateway(), "invalid gw config");
std::map<std::string, config::JetFIX::Connection> connections;
for(auto& conn : config::get<config::JetFIX>().connection())
connections[conn.name()] = conn;
ON_SECURITIES,
ON_ADMIN_DATA,
SEND_FIX,
SEND_MSGS,
std::set<std::string> dedicated;
for(auto& e : config::get<config::OrdermanCfg>().executor())
{
for(auto& h : e.hosted_actor())
{
if(h.type() == std::string(utils::type_name<Gateway>()))
{
auto thread = ActorThread::find_thread_for_actor(h.type(), actor_threads, h.qualifier());
for(auto& g : config::get<config::GatewayCfg>().gateway())
{
if(g.qualifier() == h.qualifier())
{
for(auto& cc : g.connection())
{
if(cc == "*")
{
for(auto& allconn : connections)
thread->executor.spawn<Gateway>(allconn.second, pl, oracle);
}
else
{
auto& conn = connections[cc];
thread->executor.spawn<Gateway>(conn, pl, oracle);
connections.erase(cc);
}
}
}
}
}
}
}
}
ON_EXEC,
ON_GW_STATUS,
ON_CANCEL_REJECT
};
using GWStatus = bool;
using GatewayMsgMsg = std::variant<
config::JetFIX::Connection,
mercury::Update<NewSecuritiesEvent>,
mercury::Update<NewAdminDataEvent>,
jetfix::OutFIX,
std::vector<OrderMsg>,
ExecutionReport,
GWStatus,
std::tuple<OrderKey, std::string>
>;
struct GatewayMsg
struct Gateway::PImpl
{
GatewayMsgType msg_type;
GatewayMsgMsg msg;
trace::CorID corid;
};
struct GatewayProxy::PImpl
{
PImpl(config::JetFIX::Connection const &cfg, trace::PerfLog &l, md::SecurityOracle o)
: cfg(cfg), perf_log(l), sec_oracle(o),
on_exe_report(),
on_gw_status_change(),
on_cancel_reject(),
out(config::get<config::Mercury>().queue_size()),
in(config::get<config::Mercury>().queue_size())
PImpl(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle orc)
: perf_log(pl), sec_oracle(orc), gw(ExecutionGatewayFactory::create_local_gateway(conn, pl, orc)),
gateway_name(GatewayName(conn.name()))
{
}
config::JetFIX::Connection cfg;
trace::PerfLog& perf_log;
md::SecurityOracle sec_oracle;
md::SecurityOracle sec_oracle;
std::unique_ptr<IExecutionGateway> gw;
GatewayName gateway_name;
OnExeReport on_exe_report;
OnGwStatusChange on_gw_status_change;
OnCancelReject on_cancel_reject;
utils::GrowableSPSCQueue<GatewayMsg*> out;
utils::GrowableSPSCQueue<GatewayMsg*> in;
boost::object_pool<GatewayMsg> action_pool;
mercury::Stream<NewExecutionReportEvent> new_executionreport_pub;
mercury::Stream<GatewayStatusChangeEvent> gatewaystatus_pub;
mercury::Stream<CancelRejectEvent> cancelreject_pub;
};
GatewayProxy::GatewayProxy(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle md)
: me(new PImpl(conn, pl, md))
Gateway::Gateway(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle orc)
: me(new PImpl(conn, pl, orc))
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::CREATE;
m->msg = false;
me->out.push(m);
}
GatewayProxy::~GatewayProxy() { }
void GatewayProxy::start()
Gateway::~Gateway()
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::START;
m->msg = false;
me->out.push(m);
}
void GatewayProxy::dispatch_incoming_fix_messages()
void Gateway::init()
{
me->in.consume_all([this](GatewayMsg *m)
me->gw->start();
subscribe<SendFixEvent>(me->gateway_name, [this](const mercury::Update<SendFixEvent>& update) //for GWNAME
{
switch(m->msg_type)
{
case GatewayMsgType::ON_EXEC:
{
auto&& val = std::get<ExecutionReport>(m->msg);
me->on_exe_report(val, m->corid);
}
break;
case GatewayMsgType::ON_GW_STATUS:
{
auto&& val = std::get<GWStatus>(m->msg);
me->on_gw_status_change(val);
}
break;
case GatewayMsgType::ON_CANCEL_REJECT:
{
auto&& tup = std::get<std::tuple<OrderKey, std::string>>(m->msg);
me->on_cancel_reject(std::get<0>(tup), std::get<1>(tup));
}
break;
default:
bts_assert_msg(false, "invalid GatewayMsgType");
break;
}
if(update.events)
for (const auto& ev : *update.events)
me->gw->send_fix(ev.fix, ev.corid);
});
subscribe<SendOrderMsgsEvent>(me->gateway_name, [this](const mercury::Update<SendOrderMsgsEvent>& update)
{
if(update.events)
for (const auto& ev : *update.events)
me->gw->send_msgs(*ev.msgs, ev.corid);
});
}
void GatewayProxy::on_securities(const mercury::Update<NewSecuritiesEvent>& secs)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::ON_SECURITIES;
m->msg = secs;
me->out.push(m);
}
void GatewayProxy::on_admin_data(const mercury::Update<NewAdminDataEvent>& admin)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::ON_ADMIN_DATA;
m->msg = admin;
me->out.push(m);
}
subscribe<NewAdminDataEvent>([this](const auto& admin_update)
{
me->gw->on_admin_data(admin_update);
});
subscribe<NewSecuritiesEvent>([this](const auto& secs)
{
me->gw->on_securities(secs);
});
void GatewayProxy::send_fix(const jetfix::OutFIXPtr& fixptr, trace::CorID corid)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::SEND_FIX;
m->msg = *fixptr;
m->corid = corid;
me->out.push(m);
me->new_executionreport_pub = make_stream<NewExecutionReportEvent>(me->gateway_name);
me->gw->on_exe_report() = [this](const auto& er, const auto& t)
{
publish(me->new_executionreport_pub, &er, t);
};
me->gatewaystatus_pub = make_stream<GatewayStatusChangeEvent>(me->gateway_name);
me->gw->on_gw_status_change() = [this](bool b)
{
publish(me->gatewaystatus_pub, me->gateway_name, b);
};
me->cancelreject_pub = make_stream<CancelRejectEvent>(me->gateway_name);
me->gw->on_cancel_reject() = [this](const auto& k,const auto& msg)
{
publish(me->cancelreject_pub, k, msg);
};
}
void GatewayProxy::send_msgs(const std::vector<OrderMsg>& msgs, trace::CorID corid)
void Gateway::on_poll(trace::PerfLog&)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::SEND_MSGS;
m->msg = msgs;
m->corid = corid;
me->out.push(m);
}
OnExeReport& GatewayProxy::on_exe_report()
{
return me->on_exe_report;
}
OnGwStatusChange& GatewayProxy::on_gw_status_change()
{
return me->on_gw_status_change;
}
OnCancelReject& GatewayProxy::on_cancel_reject()
{
return me->on_cancel_reject;
me->gw->dispatch_incoming_fix_messages();
}
+41 -38
View File
@@ -1,39 +1,42 @@
#pragma once
#include "lib/orderman/actors/IExecutionGateway.h"
#include "lib/config/config.h"
#include "lib/config/protos/jetfix.pb.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/md/SecurityOracle.h"
#include "lib/utils/bts_no_copy.h"
#include <memory>
namespace bts {
namespace trace {struct CorID;class PerfLog;}
namespace orderman {
class Gateway
{
public:
GatewayProxy(const config::JetFIX::Connection&, trace::PerfLog&, md::SecurityOracle);
virtual ~GatewayProxy();
virtual void start();
virtual void dispatch_incoming_fix_messages();
virtual void on_securities(const mercury::Update<NewSecuritiesEvent> &);
virtual void on_admin_data(const mercury::Update<NewAdminDataEvent> &);
virtual void send_fix(const jetfix::OutFIXPtr&, trace::CorID);
virtual void send_msgs(std::vector<OrderMsg> const&, trace::CorID);
virtual OnExeReport& on_exe_report();
virtual OnGwStatusChange& on_gw_status_change();
virtual OnCancelReject &on_cancel_reject();
private:
BTS_NO_COPY(GatewayProxy);
friend class Gateway;
struct PImpl;
std::unique_ptr<PImpl> me;
};
#pragma once
#include "lib/orderman/actors/IExecutionGateway.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/md/SecurityOracle.h"
#include "lib/utils/bts_no_copy.h"
#include "lib/mercury/actors/Actor.h"
#include "lib/mercury/actors/IPollableActor.h"
#include "lib/tracing/PerfLog.h"
#include "lib/tracing/bts_trace.h"
#include "lib/utils/TimeStamp.h"
#include "lib/orderman/actors/ActorThread.h"
#include <memory>
namespace bts {
namespace trace {struct CorID;class PerfLog;}
namespace orderman {
class GatewayManager;
class Gateway : public mercury::Actor, public mercury::IPollableActor
{
public:
static void spawn_gateways(const std::vector<std::unique_ptr<ActorThread>>& actor_threads,
trace::PerfLog&, md::SecurityOracle);
public:
Gateway(const config::JetFIX::Connection&, trace::PerfLog&, md::SecurityOracle);
virtual ~Gateway();
void init() override;
void on_poll(trace::PerfLog&) override;
private:
void on(const mercury::Update<NewSecuritiesEvent>&);
void on(const mercury::Update<NewAdminDataEvent>&);
private:
BTS_NO_COPY(Gateway);
struct PImpl;
std::unique_ptr<PImpl> me;
};
}}
@@ -1,9 +0,0 @@
#include "lib/orderman/actors/gateway/GatewayManager.h"
#include "lib/orderman/actors/gateway/GatewayProxy.h"
namespace bts {
namespace orderman {
}}
@@ -1,35 +0,0 @@
#pragma once
#include "lib/orderman/actors/IExecutionGateway.h"
#include "lib/config/config.h"
#include "lib/config/protos/orderman_cfg.pb.h"
#include "lib/logging/logging.h"
#include "lib/md/IntPrice.h"
#include "lib/md/MDConsumer.h"
#include "lib/md/MDConsumerHandle.h"
#include "lib/mercury/actors/Actor.h"
#include "lib/mercury/actors/IPollableActor.h"
#include "lib/tracing/PerfLog.h"
#include "lib/tracing/bts_trace.h"
#include "lib/utils/TimeStamp.h"
#include "lib/domain_model/Security.h"
#include <date/date.h>
#include <memory>
namespace bts {
namespace orderman {
class GatewayManager //: public mercury::Actor, public mercury::IPollableActor
{
public:
GatewayManager(const config::JetFIX::Connection&, trace::PerfLog&, md::SecurityOracle);
private:
struct PImpl;
std::unique_ptr<PImpl> me;
};
}}
+42 -114
View File
@@ -1,184 +1,112 @@
#include "GatewayProxy.h"
#include "GatewayManager.h"
#include "lib/mercury/broker/BrokerProxy.h"
#include "lib/mercury/events/Update.h"
#include "lib/mercury/events/Stream.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/events/NewAdminDataEvent.h"
#include "lib/orderman/events/SendFixEvent.h"
#include "lib/orderman/events/SendOrderMsgsEvent.h"
#include "lib/orderman/events/GatewayStatusChangeEvent.h"
#include "lib/orderman/events/CancelRejectEvent.h"
#include "lib/orderman/events/NewExecutionReportEvent.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/orderman/orderman_utils/ExecutionReport.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/jetfix/common/OutFIX.h"
#include "lib/utils/helper_macros.h"
#include "lib/utils/GrowableSPSCQueue.h"
#include "lib/utils/bts_assert.h"
#include "lib/config/config.h"
#include "lib/config/protos/mercury_cfg.pb.h"
#include <boost/pool/object_pool.hpp>
#include <variant>
#include <tuple>
namespace bts {
namespace orderman {
enum class GatewayMsgType
{
CREATE,
START,
ON_SECURITIES,
ON_ADMIN_DATA,
SEND_FIX,
SEND_MSGS,
ON_EXEC,
ON_GW_STATUS,
ON_CANCEL_REJECT
};
using GWStatus = bool;
using GatewayMsgMsg = std::variant<
config::JetFIX::Connection,
mercury::Update<NewSecuritiesEvent>,
mercury::Update<NewAdminDataEvent>,
jetfix::OutFIX,
std::vector<OrderMsg>,
ExecutionReport,
GWStatus,
std::tuple<OrderKey, std::string>
>;
struct GatewayMsg
{
GatewayMsgType msg_type;
GatewayMsgMsg msg;
trace::CorID corid;
};
struct GatewayProxy::PImpl
{
PImpl(config::JetFIX::Connection const &cfg, trace::PerfLog &l, md::SecurityOracle o)
: cfg(cfg), perf_log(l), sec_oracle(o),
on_exe_report(),
on_gw_status_change(),
on_cancel_reject(),
out(config::get<config::Mercury>().queue_size()),
in(config::get<config::Mercury>().queue_size())
PImpl(const config::JetFIX::Connection &cfg, trace::PerfLog &l, md::SecurityOracle o)
: cfg(cfg), perf_log(l), sec_oracle(o), gateway_name(cfg.name())
{
}
config::JetFIX::Connection cfg;
trace::PerfLog& perf_log;
md::SecurityOracle sec_oracle;
GatewayName gateway_name;
mercury::Stream<SendFixEvent> send_fix_pub;
mercury::Stream<SendOrderMsgsEvent> send_ordermsgs_pub;
OnExeReport on_exe_report;
OnGwStatusChange on_gw_status_change;
OnCancelReject on_cancel_reject;
utils::GrowableSPSCQueue<GatewayMsg*> out;
utils::GrowableSPSCQueue<GatewayMsg*> in;
boost::object_pool<GatewayMsg> action_pool;
};
GatewayProxy::GatewayProxy(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle md)
: me(new PImpl(conn, pl, md))
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::CREATE;
m->msg = false;
me->out.push(m);
}
GatewayProxy::~GatewayProxy() { }
void GatewayProxy::start()
//actor init
void GatewayProxy::init()
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::START;
m->msg = false;
me->out.push(m);
me->send_fix_pub = make_stream<SendFixEvent>(me->gateway_name);
me->send_ordermsgs_pub = make_stream<SendOrderMsgsEvent>(me->gateway_name);
}
void GatewayProxy::dispatch_incoming_fix_messages()
//start the gateway
void GatewayProxy::start()
{
me->in.consume_all([this](GatewayMsg *m)
{
switch(m->msg_type)
{
case GatewayMsgType::ON_EXEC:
{
auto&& val = std::get<ExecutionReport>(m->msg);
me->on_exe_report(val, m->corid);
}
break;
case GatewayMsgType::ON_GW_STATUS:
{
auto&& val = std::get<GWStatus>(m->msg);
me->on_gw_status_change(val);
}
break;
case GatewayMsgType::ON_CANCEL_REJECT:
{
auto&& tup = std::get<std::tuple<OrderKey, std::string>>(m->msg);
me->on_cancel_reject(std::get<0>(tup), std::get<1>(tup));
}
break;
default:
bts_assert_msg(false, "invalid GatewayMsgType");
break;
}
});
}
void GatewayProxy::on_securities(const mercury::Update<NewSecuritiesEvent>& secs)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::ON_SECURITIES;
m->msg = secs;
me->out.push(m);
}
void GatewayProxy::on_admin_data(const mercury::Update<NewAdminDataEvent>& admin)
void GatewayProxy::dispatch_incoming_fix_messages()
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::ON_ADMIN_DATA;
m->msg = admin;
me->out.push(m);
//called on GW thread and sent back through queue
}
void GatewayProxy::on_securities(const mercury::Update<NewSecuritiesEvent>& )
{
//the actual gateway subscribes to these, no-op here
}
void GatewayProxy::on_admin_data(const mercury::Update<NewAdminDataEvent>& )
{
//the actual gateway subscribes to these, no-op here
}
void GatewayProxy::send_fix(const jetfix::OutFIXPtr& fixptr, trace::CorID corid)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::SEND_FIX;
m->msg = *fixptr;
m->corid = corid;
me->out.push(m);
//jetfix::OutFIXPtr copy(new jetfix::OutFIX(*fixptr)); //copy not necessary see OrderManager::reload_fix_buffer
publish<SendFixEvent>(me->send_fix_pub, fixptr, corid);
}
void GatewayProxy::send_msgs(const std::vector<OrderMsg>& msgs, trace::CorID corid)
{
auto m = me->action_pool.construct();
m->msg_type = GatewayMsgType::SEND_MSGS;
m->msg = msgs;
m->corid = corid;
me->out.push(m);
SendOrderMsgsEvent::MsgsPtr copy(new SendOrderMsgsEvent::Msgs(msgs));
publish<SendOrderMsgsEvent>(me->send_ordermsgs_pub, copy, corid);
}
OnExeReport& GatewayProxy::on_exe_report()
OnExeReport& GatewayProxy::on_exe_report()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_exe_report;
}
OnGwStatusChange& GatewayProxy::on_gw_status_change()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_gw_status_change;
}
OnCancelReject& GatewayProxy::on_cancel_reject()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_cancel_reject;
}
}}
+13 -5
View File
@@ -1,9 +1,12 @@
#pragma once
#include "lib/orderman/actors/IExecutionGateway.h"
#include "lib/mercury/actors/Actor.h"
#include "lib/config/config.h"
#include "lib/config/protos/jetfix.pb.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/jetfix/common/OutFIX.h"
#include "lib/md/SecurityOracle.h"
#include "lib/utils/bts_no_copy.h"
@@ -12,28 +15,33 @@
namespace bts {
namespace trace {struct CorID;class PerfLog;}
namespace orderman {
class GatewayProxy : public IExecutionGateway
class GatewayProxy : public mercury::Actor, public IExecutionGateway
{
public:
GatewayProxy(const config::JetFIX::Connection&, trace::PerfLog&, md::SecurityOracle);
virtual ~GatewayProxy();
//Actor
virtual void init();
//IExecutionGateway
virtual void start();
virtual void dispatch_incoming_fix_messages();
virtual void on_securities(const mercury::Update<NewSecuritiesEvent> &);
virtual void on_admin_data(const mercury::Update<NewAdminDataEvent> &);
virtual void send_fix(const jetfix::OutFIXPtr&, trace::CorID);
virtual void send_msgs(std::vector<OrderMsg> const&, trace::CorID);
virtual OnExeReport& on_exe_report();
virtual OnGwStatusChange& on_gw_status_change();
virtual OnCancelReject &on_cancel_reject();
private:
BTS_NO_COPY(GatewayProxy);
friend class GatewayManager;
BTS_NO_COPY(GatewayProxy);
struct PImpl;
std::unique_ptr<PImpl> me;
std::unique_ptr<PImpl> me;
};
}}
@@ -16,6 +16,8 @@
#include "lib/orderman/securities/ISecurityDB.h"
#include "lib/utils/inplace_function.h"
#include "lib/utils/thread_manager.h"
#include "lib/config/config.h"
#include "lib/config/protos/orderman_cfg.pb.h"
#include <algorithm>
#include <boost/algorithm/string/trim.hpp>
@@ -457,20 +459,23 @@ void OrderManager::init_order_services() {
// publishers for execution reports, gateway status and cancel
// reject evets
auto s_ptr = s.get();
s->exe_report_pub = make_stream<NewExecutionReportEvent>(gw_name);
s->gw->on_exe_report() = [s_ptr, this](auto const &er, auto const &t) {
publish(s_ptr->exe_report_pub, &er, t);
};
s->gw_status_change_pub = make_stream<GatewayStatusChangeEvent>(gw_name);
s->gw->on_gw_status_change() = [s_ptr, this, gw_name](bool b) {
publish(s_ptr->gw_status_change_pub, gw_name, b);
};
s->cancel_reject_pub = make_stream<CancelRejectEvent>(gw_name);
s->gw->on_cancel_reject() = [s_ptr, this](auto const &k,
auto const &msg) {
publish(s_ptr->cancel_reject_pub, k, msg);
};
if(!config::get<config::OrdermanCfg>().use_gateway()) //if we are in gateway mode, the gw will publish these events
{
auto s_ptr = s.get();
s->exe_report_pub = make_stream<NewExecutionReportEvent>(gw_name);
s->gw->on_exe_report() = [s_ptr, this](auto const &er, auto const &t) {
publish(s_ptr->exe_report_pub, &er, t);
};
s->gw_status_change_pub = make_stream<GatewayStatusChangeEvent>(gw_name);
s->gw->on_gw_status_change() = [s_ptr, this, gw_name](bool b) {
publish(s_ptr->gw_status_change_pub, gw_name, b);
};
s->cancel_reject_pub = make_stream<CancelRejectEvent>(gw_name);
s->gw->on_cancel_reject() = [s_ptr, this](auto const &k,
auto const &msg) {
publish(s_ptr->cancel_reject_pub, k, msg);
};
}
// handlers are ready so we can start processing fix events
s->gw->start();
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include "lib/api/services/AdminService.pb.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/mercury/common/mercury_common.h"
#include "lib/mercury/events/Event.h"
#include "lib/mercury/synopsis/NoSynopsis.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/tracing/PerfLog.h"
#include <memory>
namespace bts {
namespace orderman {
class SendFixEvent : public mercury::Event<SendFixEvent>
{
public:
using Tag = GatewayName;
using SynopsisPolicy = mercury::NoSynopsis;
jetfix::OutFIXPtr fix;
trace::CorID corid;
SendFixEvent(const jetfix::OutFIXPtr& f, const trace::CorID& cid) : fix(f), corid(cid) {};
};
}}
@@ -0,0 +1,31 @@
#pragma once
#include "lib/api/services/AdminService.pb.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/mercury/common/mercury_common.h"
#include "lib/mercury/events/Event.h"
#include "lib/mercury/synopsis/NoSynopsis.h"
#include "lib/orderman/actors/IExecutionGateway.h"
#include "lib/tracing/PerfLog.h"
#include <memory>
namespace bts {
namespace orderman {
class SendOrderMsgsEvent : public mercury::Event<SendOrderMsgsEvent>
{
public:
using Tag = GatewayName;
using SynopsisPolicy = mercury::NoSynopsis;
using Msgs = std::vector<orderman::OrderMsg>;
using MsgsPtr = std::shared_ptr<Msgs>;
MsgsPtr msgs;
trace::CorID corid;
SendOrderMsgsEvent(const MsgsPtr& m, const trace::CorID& cid) : msgs(m), corid(cid) {};
};
}}
+19 -77
View File
@@ -11,6 +11,8 @@
#include "lib/mercury/actors/Timer.h"
#include "lib/mercury/executor/Executor.h"
#include "lib/metrics/metrics.h"
#include "lib/orderman/actors/ActorThread.h"
#include "lib/orderman/actors/gateway/Gateway.h"
#include "lib/orderman/actors/AsyncFactory.h"
#include "lib/orderman/actors/FillStore.h"
#include "lib/orderman/actors/MDSource.h"
@@ -32,69 +34,10 @@
namespace bts {
namespace orderman {
struct ActorThread {
ActorThread(const config::OrdermanCfg::Executor &cfg,
metrics::MetricsContainer &stats)
: cfg(cfg), thread(), executor(), loop_metric(), done(false) {
std::array<double, 30> buckets;
auto i = 0;
for (auto &b : buckets)
b = (i += 1000);
loop_metric = std::make_shared<metrics::HistogramMetric<30>>(
fmt::format("spark_metrics_{}_thread_loop_ns", cfg.thread_name()),
buckets);
stats.publish(loop_metric);
}
void start(trace::PerfLog &log) {
if (cfg.poll())
thread = threading::make_thread(cfg.thread_name(), [this, &log]() {
for (;;)
executor.do_work(log);
});
else {
thread = threading::make_thread(cfg.thread_name(), [this, &log]() {
const auto inner_iter = 1000;
while (!done) {
auto start = Timer::now();
for (auto i = 0; i < inner_iter; i++)
executor.do_work(log);
auto stop = Timer::now();
loop_metric->observe(ns_diff(stop, start) / inner_iter);
std::this_thread::sleep_for(10ms);
}
});
}
}
~ActorThread() {
done = true;
thread.join();
}
config::OrdermanCfg::Executor cfg;
std::thread thread;
mercury::Executor executor;
std::shared_ptr<metrics::HistogramMetric<30>> loop_metric;
std::atomic<bool> done;
};
ActorThread *find_thread_for_actor(
std::string const &actor_name,
std::vector<std::unique_ptr<ActorThread>> const &all_executors) {
for (auto const &ex : all_executors)
for (auto const &hosted : ex->cfg.hosted_actor())
if (hosted == "*" || boost::algorithm::to_lower_copy(hosted) ==
boost::algorithm::to_lower_copy(actor_name))
return ex.get();
return nullptr;
}
struct OrderServiceServer::PImpl {
PImpl(bts::api::ServiceContext &ctx, md::MDClient &mdc,
DynamicOrderRegistry const &d, metrics::MetricsContainer &stats,
trace::PerfLog &log, const std::string& lb_qual)
trace::PerfLog &log)
: service_bridge(), service_ready(false), known_orders(), known_fills(),
publish_orders(), publish_fills(),
admin_service(ctx.locate<api::admin::AdminService>()),
@@ -102,7 +45,7 @@ struct OrderServiceServer::PImpl {
margin_service(ctx.locate<api::position::MarginService>()),
md_consumer(mdc.current_consumer()), stats(stats),
dyn_order_registry(d), log(log), in_flight_order_ops(),
current_req_op_id(0), lb_qualifier(lb_qual) {}
current_req_op_id(0) {}
ServiceBridge *service_bridge;
@@ -124,16 +67,15 @@ struct OrderServiceServer::PImpl {
std::unordered_map<uint32_t, api::Response<api::orderman::Response>>
in_flight_order_ops;
uint32_t current_req_op_id;
std::string lb_qualifier;
};
OrderServiceServer::OrderServiceServer(bts::api::ServiceContext &ctx,
md::MDClient &mdc,
DynamicOrderRegistry const &d,
metrics::MetricsContainer &stats,
trace::PerfLog &log, const std::string& lb_qualifier)
: api::orderman::OrderServiceBase(ctx, lb_qualifier),
me(new PImpl(ctx, mdc, d, stats, log, lb_qualifier)) {
trace::PerfLog &log)
: api::orderman::OrderServiceBase(ctx),
me(new PImpl(ctx, mdc, d, stats, log)) {
me->publish_orders = make_orders_publisher();
me->publish_fills = make_fills_publisher();
@@ -143,12 +85,12 @@ OrderServiceServer::OrderServiceServer(bts::api::ServiceContext &ctx,
all_executors.push_back(&at->executor);
me->actor_threads.push_back(std::move(at));
}
Gateway::spawn_gateways(me->actor_threads, log, mdc.oracle());
for (auto &t : me->actor_threads)
t->executor.init_neighbours(all_executors);
// MDSource
auto thread = find_thread_for_actor("MDSource", me->actor_threads);
auto thread = ActorThread::find_thread_for_actor("MDSource", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for MDSource. See the "
"OrdermanCfg key");
@@ -156,49 +98,49 @@ OrderServiceServer::OrderServiceServer(bts::api::ServiceContext &ctx,
thread->executor.spawn<MDSource>(me->md_consumer, me->stats, log);
// OrderManager
thread = find_thread_for_actor("OrderManager", me->actor_threads);
thread = ActorThread::find_thread_for_actor("OrderManager", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for OrderManager. See "
"the OrdermanCfg key");
thread->executor.spawn<OrderManager>(d, me->log, mdc.oracle());
// Timer
thread = find_thread_for_actor("Timer", me->actor_threads);
thread = ActorThread::find_thread_for_actor("Timer", me->actor_threads);
bts_assert_msg(
thread,
"Could not find a configured thread for Timer. See the OrdermanCfg key");
thread->executor.spawn<mercury::Timer>();
// AsyncFactory
thread = find_thread_for_actor("AsyncFactory", me->actor_threads);
thread = ActorThread::find_thread_for_actor("AsyncFactory", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for AsyncFactory. See "
"the OrdermanCfg key");
thread->executor.spawn<AsyncFactory>(d, mdc.oracle());
// OrderStore
thread = find_thread_for_actor("OrderStore", me->actor_threads);
thread = ActorThread::find_thread_for_actor("OrderStore", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for OrderStore. See "
"the OrdermanCfg key");
thread->executor.spawn<OrderStore>(mdc.oracle(), me->lb_qualifier);
thread->executor.spawn<OrderStore>(mdc.oracle());
// FillStore
thread = find_thread_for_actor("FillStore", me->actor_threads);
thread = ActorThread::find_thread_for_actor("FillStore", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for FilllStore. See "
"the OrdermanCfg key");
thread->executor.spawn<FillStore>(mdc.oracle(), me->lb_qualifier);
thread->executor.spawn<FillStore>(mdc.oracle());
// SecuritySrc
thread = find_thread_for_actor("SecuritySrc", me->actor_threads);
thread = ActorThread::find_thread_for_actor("SecuritySrc", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for SecuritySrc. See "
"the OrdermanCfg key");
thread->executor.spawn<SecuritySrc>(me->md_consumer);
// MDSupplementarySource
thread = find_thread_for_actor("MDSupplementarySource", me->actor_threads);
thread = ActorThread::find_thread_for_actor("MDSupplementarySource", me->actor_threads);
bts_assert_msg(
thread,
"Could not find a configured thread for MDSupplementarySource. See "
@@ -206,7 +148,7 @@ OrderServiceServer::OrderServiceServer(bts::api::ServiceContext &ctx,
thread->executor.spawn<MDSupplementarySource>(me->md_consumer);
// ServiceBridge
thread = find_thread_for_actor("ServiceBridge", me->actor_threads);
thread = ActorThread::find_thread_for_actor("ServiceBridge", me->actor_threads);
bts_assert_msg(thread,
"Could not find a configured thread for ServiceBridge. See "
"the OrdermanCfg key");
+1 -2
View File
@@ -21,8 +21,7 @@ class OrderServiceServer : public api::orderman::OrderServiceBase {
md::MDClient&,
DynamicOrderRegistry const&,
metrics::MetricsContainer &,
trace::PerfLog &,
const std::string& lb_qualifier);
trace::PerfLog &);
~OrderServiceServer();
void create_order(const api::orderman::Create &,
+1 -8
View File
@@ -94,14 +94,7 @@ int Run::execute(std::vector<std::string> const &) {
plugin::init_plugins(plugin_services);
// finished initializing order plugins
auto& lbs = config::get<config::OrderServiceLoadBalancing>();
std::vector<std::shared_ptr<orderman::OrderServiceServer>> order_servers;
for(auto&& lb : lbs.load_balancer())
{
std::shared_ptr<orderman::OrderServiceServer> p(
new orderman::OrderServiceServer (sc, mdclient, dyn_order_registry, stats, perf_log, lb.qualifier()));
order_servers.push_back(p);
}
orderman::OrderServiceServer order_service(sc, mdclient, dyn_order_registry, stats, perf_log);
support::ErrorReportServer error_report_service(sc);
admin::AdminServiceServer admin_service(sc);
md::auxiliary::MarketDataAuxiliaryServiceServer md_aux_server(sc);
+1 -1
View File
@@ -1 +1 @@
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/object.assign/test.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs)
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/object.assign/test.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)
+2 -2
View File
@@ -61,7 +61,7 @@ $PROTOC --plugin=protoc-gen-service=../../lib/api/service_compiler/plugin.py \
# run typescript compiler to convert typescript to javascript
echo -e \* ${ORANGE} tsc ${NOCOLOR}
npx --no-install tsc -p tsconfig.$MODE.json
npx --no-install tsc -p tsconfig.$MODE.json --outDir $OUT/api
# cleanup
@@ -75,7 +75,7 @@ ts2fable() {
wait
}
echo -e \* ${ORANGE} ts2fable ${NOCOLOR}
echo -e \* ${ORANGE} ts2fable ${NOCOLOR} $OUT
ts2fable $OUT/api
# ts2fable $OUT/api/gen
+6 -2
View File
@@ -1,8 +1,12 @@
#/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SRC_ROOT=$DIR/../
mkdir -p $SRC_ROOT/build/
BUILD_ROOT=`readlink -f $SRC_ROOT/build`
#mkdir -p $SRC_ROOT/build/
#BUILD_ROOT=`readlink -f $SRC_ROOT/build`
cd $SRC_ROOT
mkdir -p ./build/
cd ./build
BUILD_ROOT=`pwd`
rm -rf $BUILD_ROOT/clang_debug
mkdir $BUILD_ROOT/clang_debug