I misunderstood how onixs wants to do the ice threading. fixed
This commit is contained in:
1 parent
6b6fd9c40a
commit
d488ff23ba
6 files changed
+70
-51
No files matched your search
@@ -41,11 +41,13 @@ CMEOptions {
|
||||
ICEOptions {
|
||||
value {
|
||||
channel {
|
||||
name: "oil"
|
||||
market_type: 5 #ICE Futures Brent, IPE Brent Futures
|
||||
market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures
|
||||
#udp_buffer_size: 67108864
|
||||
}
|
||||
channel {
|
||||
name: "juice"
|
||||
market_type: 23 #ICE Futures US Agricultures, FCOJ A
|
||||
}
|
||||
ice_config_file: "ConnectivityConfiguration.APITest.xml"
|
||||
|
||||
@@ -143,11 +143,12 @@ message ICEOptions
|
||||
|
||||
//A channel is one onixs-ice thread
|
||||
message ICEChannel {
|
||||
repeated uint32 market_type = 1;
|
||||
optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb
|
||||
optional uint32 heartbeat_interval = 3 [default = 36000];
|
||||
optional uint32 sequence_gap_margin = 4 [default = 10000];
|
||||
optional uint32 gap_timeout_in_ms = 5 [default = 10000];
|
||||
required string name = 1;
|
||||
repeated uint32 market_type = 2;
|
||||
optional uint32 udp_buffer_size = 3 [default = 33554432]; //32mb
|
||||
optional uint32 heartbeat_interval = 4 [default = 36000];
|
||||
optional uint32 sequence_gap_margin = 5 [default = 10000];
|
||||
optional uint32 gap_timeout_in_ms = 6 [default = 10000];
|
||||
|
||||
optional int32 snapshot_recovery_timeout_in_ms = 10 [default = -1];
|
||||
optional int32 maximum_number_of_snapshot_recovery_attempts = 11 [default = -1];
|
||||
|
||||
+29
-20
@@ -21,6 +21,35 @@ using namespace bts::api;
|
||||
namespace bts {
|
||||
namespace md {
|
||||
namespace ice {
|
||||
|
||||
std::string ICEChannel::to_string() const
|
||||
{
|
||||
std::string mt = name;
|
||||
for(const auto& x : market_types)
|
||||
mt += " " + x;
|
||||
return mt;
|
||||
}
|
||||
|
||||
//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice
|
||||
//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of
|
||||
//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol
|
||||
//but Eric says this is ok
|
||||
const vector<ICEChannel> parse_ice_channels(const vector<UserSymbol>& symbols)
|
||||
{
|
||||
vector<ICEChannel> result;
|
||||
const auto& ice_options = config::get<bts::md::ICEOptions>();
|
||||
for(const auto& x : ice_options.channel())
|
||||
{
|
||||
md::ice::ICEChannel chan;
|
||||
chan.name = x.name();
|
||||
chan.symbols.insert(symbols.begin(), symbols.end());
|
||||
for(const auto& xx : x.market_type())
|
||||
chan.market_types.push_back(xx);
|
||||
result.push_back(chan);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
string ice_data_path() {
|
||||
auto p = config::get<config::System>().data_path() + "onixs_ice/";
|
||||
@@ -106,26 +135,6 @@ const std::vector<ICEChannel> get_configured_ice_channels() {
|
||||
return parse_ice_channels(symbols);
|
||||
}
|
||||
|
||||
//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice
|
||||
//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of
|
||||
//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol
|
||||
//but Eric says this is ok
|
||||
const vector<ICEChannel> parse_ice_channels(const vector<UserSymbol>& symbols)
|
||||
{
|
||||
vector<ICEChannel> result;
|
||||
const auto& ice_options = config::get<bts::md::ICEOptions>();
|
||||
for(const auto& x : ice_options.channel())
|
||||
{
|
||||
for(const auto& xx : x.market_type())
|
||||
{
|
||||
md::ice::ICEChannel chan;
|
||||
chan.market_type = xx;
|
||||
chan.symbols.insert(symbols.begin(), symbols.end());
|
||||
result.push_back(chan);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}}} //namespace
|
||||
#endif
|
||||
@@ -11,8 +11,10 @@ namespace ice {
|
||||
|
||||
struct ICEChannel
|
||||
{
|
||||
uint32_t market_type;
|
||||
std::string name;
|
||||
std::vector<uint32_t> market_types;
|
||||
std::set<UserSymbol> symbols;
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
void await_ice_config();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "lib/utils/helper_macros.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/proto_helper.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "lib/md/protos/co2.pb.h"
|
||||
|
||||
#include "lib/config/protos/MarketData.pb.h"
|
||||
@@ -54,28 +55,29 @@ ICEMain::ICEMain() :
|
||||
|
||||
ICEMain::~ICEMain() {}
|
||||
|
||||
const ICEOptions::ICEChannel channel_settings_for(uint32_t id)
|
||||
const ICEOptions::ICEChannel channel_settings_for(const ICEChannel& channel)
|
||||
{
|
||||
const auto& config = config::get<ICEOptions>();
|
||||
for (const auto& ch : config.channel())
|
||||
{
|
||||
bool found = std::find_if(ch.market_type().begin(), ch.market_type().end(), [&](const uint32_t& chan_id) { return chan_id == id ; }) != ch.market_type().end();
|
||||
if(found)
|
||||
return ch;
|
||||
if(ch.name() == channel.name)
|
||||
return ch;
|
||||
}
|
||||
return ICEOptions::ICEChannel();
|
||||
}
|
||||
|
||||
|
||||
onixs_ice::MarketSubscriptions market_subcription_for_channel(uint32_t market_type)
|
||||
onixs_ice::MarketSubscriptions market_subcription_for_channel(const ICEChannel& chan)
|
||||
{
|
||||
const auto& options = channel_settings_for(market_type);
|
||||
onixs_ice::MarketSubscriptions subs;
|
||||
//onixs_ice::MarketSubType::NonImplied
|
||||
onixs_ice::MarketSubscription futures(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD);
|
||||
onixs_ice::MarketSubscription spreads(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD);
|
||||
subs.push_back(futures);
|
||||
subs.push_back(spreads);
|
||||
for(const auto& x : chan.market_types)
|
||||
{
|
||||
//onixs_ice::MarketSubType::NonImplied
|
||||
onixs_ice::MarketSubscription futures(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD);
|
||||
onixs_ice::MarketSubscription spreads(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD);
|
||||
subs.push_back(futures);
|
||||
subs.push_back(spreads);
|
||||
}
|
||||
return subs;
|
||||
}
|
||||
|
||||
@@ -101,19 +103,22 @@ void ICEMain::run(std::vector<UserSymbol>& symbols)
|
||||
const auto& channels = parse_ice_channels(symbols);
|
||||
for (const auto& channel : channels)
|
||||
{
|
||||
unique_ptr<onixs_ice::Handler> phandler = prepare_handler(channel.market_type);
|
||||
unique_ptr<onixs_ice::Handler> phandler = prepare_handler(channel);
|
||||
_listeners.push_back(prepare_listener(*phandler, channel));
|
||||
_handlers.insert(std::make_pair(channel.market_type, move(phandler)));
|
||||
std::stringstream symstr;
|
||||
_handlers.push_back(std::make_pair(channel, move(phandler)));
|
||||
|
||||
std::stringstream symstr;
|
||||
for (const auto& sym : channel.symbols)
|
||||
symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " ";
|
||||
LOG(md,Info, "ICE: Initialized channel {} ({})",channel.market_type,symstr.str());
|
||||
LOG(md,Info, "ICE: Initialized channel {} ({})", channel.to_string(), symstr.str());
|
||||
}
|
||||
|
||||
for (auto& pair : _handlers)
|
||||
{
|
||||
onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first);
|
||||
{
|
||||
LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string());
|
||||
onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first);
|
||||
pair.second->start(subs);
|
||||
sleep_for(16s);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -131,7 +136,7 @@ void ICEMain::run(std::vector<UserSymbol>& symbols)
|
||||
|
||||
// //
|
||||
// Initialize HandlerSettings and allocate the channel Handler
|
||||
unique_ptr<onixs_ice::Handler> ICEMain::prepare_handler(uint32_t market_type)
|
||||
unique_ptr<onixs_ice::Handler> ICEMain::prepare_handler(const ICEChannel& channel)
|
||||
{
|
||||
const auto& ice_options = config::get<ICEOptions>();
|
||||
auto license = ice_options.onixs_license();
|
||||
@@ -139,8 +144,8 @@ unique_ptr<onixs_ice::Handler> ICEMain::prepare_handler(uint32_t market_type)
|
||||
license = os::bts_data_path() + "/licenses/";
|
||||
|
||||
const auto& pub_options = config::get<PublisherOptions>();
|
||||
const auto& options = channel_settings_for(market_type);
|
||||
LOG(md,Info,"Loaded channel options for channel {}:\n{}",market_type,options.DebugString());
|
||||
const auto& options = channel_settings_for(channel);
|
||||
LOG(md,Info,"Loaded channel options for channel {}:\n{}", channel.to_string(), options.DebugString());
|
||||
|
||||
onixs_ice::HandlerSettings settings;
|
||||
settings.licenseDirectory = license;
|
||||
@@ -201,7 +206,7 @@ unique_ptr<onixs_ice::Handler> ICEMain::prepare_handler(uint32_t market_type)
|
||||
return handler;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
LOG(md,Error,"{}", std::string(e.what()));
|
||||
LOG(md,Error,"ONIXSERROR{}", std::string(e.what()));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -217,7 +222,7 @@ unique_ptr<ICEListener> ICEMain::prepare_listener(onixs_ice::Handler& handler, c
|
||||
producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange()));
|
||||
}
|
||||
|
||||
const auto& options = channel_settings_for(channel.market_type);
|
||||
const auto& options = channel_settings_for(channel);
|
||||
unique_ptr<ICEListener> listener(new ICEListener(_index, _producer, /*_settlement_recorder,*/ producer_channels));
|
||||
for (auto& symbol : channel.symbols)
|
||||
listener->add_filter_symbol(symbol.symbol());
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
void run(std::vector<UserSymbol>&);
|
||||
void initialize();
|
||||
std::unique_ptr<onixs_ice::Handler> prepare_handler(uint32_t channel);
|
||||
std::unique_ptr<onixs_ice::Handler> prepare_handler(const ICEChannel& channel);
|
||||
std::unique_ptr<ICEListener> prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel);
|
||||
|
||||
private:
|
||||
@@ -41,8 +41,8 @@ private:
|
||||
ICESecurityIndex _index;
|
||||
SecurityIDRecorder _recorder;
|
||||
MDProducer _producer;
|
||||
std::map<uint32_t, std::unique_ptr<onixs_ice::Handler>> _handlers;
|
||||
std::vector<std::unique_ptr<ICEListener>> _listeners;
|
||||
std::vector< std::pair<ICEChannel, std::unique_ptr<onixs_ice::Handler>> > _handlers;
|
||||
std::vector< std::unique_ptr<ICEListener> > _listeners;
|
||||
};
|
||||
|
||||
}}} //namespace
|
||||
|
||||
Reference in new issue
Block a user