Some refactoring in il3 store.
This commit is contained in:
1 parent
36da47f66e
commit
cda4c522fd
11 files changed
+240096
-35
No files matched your search
@@ -19,6 +19,13 @@ CME Globex will automatically terminate and close both the primary and backup po
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Session+Layer][Session Layer]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Binary+Order+Entry+-+Business+Layer][Business Layer]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+FIX+Tag+Library][Tag Library]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+New+Order+-+Single][NewOrderSingle]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Order+Cancel+Replace+Request][CancelReplace]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Order+Cancel+Request][Cancel]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Trade+Outright][ExecutionReport (Outright)]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Trade+Spread][ExecutionReport (Spread)]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Reject][Execution Report Reject]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Elimination][Execution Report Elimination]]
|
||||
** [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+-+Simple+Binary+Encoding][Encoding]]
|
||||
*** Structure
|
||||
- [[file:cme_notes.org_20210112_124836_Hgt1aF.png][Diagram]]
|
||||
@@ -46,20 +53,13 @@ CME Globex will automatically terminate and close both the primary and backup po
|
||||
- configuration:
|
||||
- get /MSGW/[NRCert|Cert|Production]/Configuration/MSGW_Config.xml
|
||||
** [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Binary+Order+Entry+-+Session+Layer][Session Protocol]]
|
||||
** Preregistration of party details
|
||||
** [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Binary+Order+Entry+-+Business+Layer#iLink3BinaryOrderEntryBusinessLayer-PartyDetails][Party Details]]
|
||||
- CME allows the registration of bundles of order properties so that orders can simply refer to a registration id rather than include every property on every order.
|
||||
- This is achieved through a separate iLink3 server, the [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Binary+Order+Entry+-+Business+Layer#iLink3BinaryOrderEntryBusinessLayer-OrderEntryServiceGateway][Order Entry Service Gateway]]
|
||||
- This gateway uses the same iLink3s session, meaning the same UUID and seq numbers as the main gateway
|
||||
** [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+Reject+Codes][Error codes]]
|
||||
** [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+Order+Cancel-Replace+and+In-Flight+Mitigation][In-Flight mitigation]]
|
||||
** Messages
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+New+Order+-+Single][NewOrderSingle]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Order+Cancel+Replace+Request][CancelReplace]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Order+Cancel+Request][Cancel]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Trade+Outright][ExecutionReport (Outright)]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Trade+Spread][ExecutionReport (Spread)]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Reject][Execution Report Reject]]
|
||||
- [[https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Execution+Report+-+Elimination][Execution Report Elimination]]
|
||||
** [[file:ilink3_log.json][Log example]]
|
||||
* SBE
|
||||
** Generators
|
||||
- Source be found on [[https://github.com/real-logic/simple-binary-encoding][RealLogic's GitHub]]
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include "execution/il3/common/IL3UUID.h"
|
||||
|
||||
namespace bts::spartan::il3 {
|
||||
|
||||
struct IL3GatewayCfg {
|
||||
const uint64_t uuid;
|
||||
const IL3UUID uuid;
|
||||
const size_t smp_id_2362;
|
||||
const std::string session_39006;
|
||||
const std::string firm_39007;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/utils/ValueWrapper.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace bts::spartan::il3 {
|
||||
|
||||
using IL3UUID = utils::ValueWrapper<struct IL3UUIDTag, uint64_t>;
|
||||
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void IL3InitHandler::send_negotiate() {
|
||||
|
||||
auto msg = me->sender.enqueue<::il3::Negotiate500>(
|
||||
::il3::Negotiate500::credentialsHeaderLength());
|
||||
msg.uUID(me->cfg.uuid);
|
||||
msg.uUID(me->cfg.uuid.value());
|
||||
msg.requestTimestamp(me->clock.now().value());
|
||||
msg.putSession(me->cfg.session_39006);
|
||||
msg.putCredentials("", 0);
|
||||
@@ -130,7 +130,7 @@ void IL3InitHandler::send_establish() {
|
||||
me->cfg.uuid, me->cfg.segment, me->cfg.from_cme, me->cfg.to_cme);
|
||||
|
||||
auto msg = me->sender.enqueue<::il3::Establish503>(2);
|
||||
msg.uUID(me->cfg.uuid);
|
||||
msg.uUID(me->cfg.uuid.value());
|
||||
msg.requestTimestamp(me->clock.now().value());
|
||||
msg.putSession(me->cfg.session_39006);
|
||||
msg.putCredentials("", 0);
|
||||
@@ -162,7 +162,7 @@ void IL3InitHandler::operator()(::il3::EstablishmentAck504 msg) {
|
||||
|
||||
auto cme_prev_uuid = msg.previousUUID();
|
||||
auto cme_prev_seq = msg.previousSeqNo();
|
||||
if (cme_prev_seq != 0 && cme_prev_uuid != me->cfg.uuid) {
|
||||
if (cme_prev_seq != 0 && cme_prev_uuid != me->cfg.uuid.value()) {
|
||||
|
||||
// There was a previous session and we need to replay messages from it
|
||||
|
||||
@@ -190,7 +190,8 @@ void IL3InitHandler::operator()(::il3::EstablishmentAck504 msg) {
|
||||
"Requesting replay from "
|
||||
"{} to {}",
|
||||
me->cfg.uuid, me->cfg.segment, me->cfg.from_cme + 1, cme_current_seq);
|
||||
enqueue_retransmit(me->cfg.from_cme + 1, cme_current_seq, me->cfg.uuid);
|
||||
enqueue_retransmit(
|
||||
me->cfg.from_cme + 1, cme_current_seq, me->cfg.uuid.value());
|
||||
}
|
||||
|
||||
me->init_rec.from_cme = cme_current_seq;
|
||||
@@ -245,7 +246,7 @@ void IL3InitHandler::send_retransmit_request(
|
||||
|
||||
bts_assert(from > 0);
|
||||
auto msg = me->sender.enqueue<::il3::RetransmitRequest508>();
|
||||
msg.uUID(me->cfg.uuid);
|
||||
msg.uUID(me->cfg.uuid.value());
|
||||
msg.lastUUID(uuid);
|
||||
msg.requestTimestamp(me->clock.now().value());
|
||||
msg.fromSeqNo(from);
|
||||
@@ -338,7 +339,7 @@ void IL3InitHandler::send_sequence() {
|
||||
bts_assert(
|
||||
me->state == State::ESTABLISHING || me->state == State::RETRANSMITTING);
|
||||
auto msg = me->sender.enqueue<::il3::Sequence506>();
|
||||
msg.uUID(me->cfg.uuid);
|
||||
msg.uUID(me->cfg.uuid.value());
|
||||
msg.nextSeqNo(me->init_rec.to_cme);
|
||||
msg.faultToleranceIndicator(::il3::FTI::NULL_VALUE);
|
||||
msg.keepAliveIntervalLapsed(::il3::KeepAliveLapsed::NotLapsed);
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ void IL3RealTimeHandler::send() { me->sender.flush(); }
|
||||
|
||||
void IL3RealTimeHandler::operator()(::il3::Sequence506) {
|
||||
auto msg = me->sender.enqueue<::il3::Sequence506>();
|
||||
msg.uUID(me->cfg.uuid);
|
||||
msg.uUID(me->cfg.uuid.value());
|
||||
msg.nextSeqNo(me->next_sn);
|
||||
msg.faultToleranceIndicator(::il3::FTI::NULL_VALUE);
|
||||
msg.keepAliveIntervalLapsed(::il3::KeepAliveLapsed::NotLapsed);
|
||||
|
||||
@@ -7,6 +7,11 @@ namespace bts::spartan::il3 {
|
||||
class IIL3SessionStore {
|
||||
public:
|
||||
virtual ~IIL3SessionStore() {};
|
||||
struct SeqNum {
|
||||
size_t to_cme;
|
||||
size_t from_cme;
|
||||
};
|
||||
virtual SeqNum starting_seq_num() = 0;
|
||||
virtual void store_incoming(std::string_view const&) = 0;
|
||||
virtual void store_outgoing(std::string_view const&) = 0;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "IL3SessionFileStore.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/file_utils.h"
|
||||
#include "lib/utils/type_name.h"
|
||||
#include "server/sparkd/cmds/spartan/execution/il3/common/IL3MsgFramer.h"
|
||||
#include "server/sparkd/cmds/spartan/execution/il3/parsing/IL3Parser.h"
|
||||
#include "lib/utils/type_name.h"
|
||||
#include <boost/date_time/posix_time/ptime.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -30,7 +30,7 @@ struct IL3SessionFileStore::PImpl {
|
||||
};
|
||||
|
||||
IL3SessionFileStore::IL3SessionFileStore(
|
||||
std::string const &session_kind, std::string const &path)
|
||||
std::string const &session_kind, std::string const &path, IL3UUID)
|
||||
: me(new PImpl()) {
|
||||
me->file_store.open(store_path(session_kind, path), std::ofstream::app);
|
||||
nlohmann::json j;
|
||||
@@ -55,7 +55,7 @@ struct Persister {
|
||||
nlohmann::json j;
|
||||
j["direction"] = direction;
|
||||
j["time"] = datetime::FIX_timestamp(datetime::now());
|
||||
j["type"] = utils::type_name<M>();
|
||||
j["type"] = utils::type_name<M>();
|
||||
std::stringstream buffer;
|
||||
buffer << m;
|
||||
try {
|
||||
@@ -63,7 +63,7 @@ struct Persister {
|
||||
} catch (...) {
|
||||
LOG(Spartan, Error, "Skipping troublesome json encoded message: {}",
|
||||
buffer.str());
|
||||
j["msg_json"] = {} ;
|
||||
j["msg_json"] = {};
|
||||
}
|
||||
stream << j << std::endl;
|
||||
stream.flush();
|
||||
@@ -91,7 +91,6 @@ struct Persister {
|
||||
stream << j << std::endl;
|
||||
stream.flush();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void IL3SessionFileStore::store(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "server/sparkd/cmds/spartan/execution/il3/store/IIL3SessionStore.h"
|
||||
#include "execution/il3/store/IIL3SessionStore.h"
|
||||
#include "execution/il3/common/IL3UUID.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -12,9 +13,12 @@ class IL3MsgFramer;
|
||||
class IL3SessionFileStore : public IIL3SessionStore {
|
||||
public:
|
||||
IL3SessionFileStore(
|
||||
std::string const &session_kind, std::string const &session_name);
|
||||
std::string const &session_kind,
|
||||
std::string const &session_name,
|
||||
IL3UUID uuid);
|
||||
~IL3SessionFileStore();
|
||||
|
||||
SeqNum starting_seq_num() override { return {}; }
|
||||
void store_incoming(std::string_view const &bytes) override;
|
||||
void store_outgoing(std::string_view const &bytes) override;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "execution/il3/common/PartyDetailsCfg.h"
|
||||
#include "execution/il3/handlers/init/IIL3InitObserver.h"
|
||||
#include "execution/il3/handlers/init/IL3InitHandler.h"
|
||||
#include "execution/il3/handlers/party_details/IPartyDetailsObserver.h"
|
||||
#include "execution/il3/handlers/party_details/IL3PartyDetailsHandler.h"
|
||||
#include "execution/il3/handlers/party_details/IPartyDetailsObserver.h"
|
||||
#include "execution/il3/parsing/IL3Parser.h"
|
||||
#include "execution/il3/store/IL3SessionFileStore.h"
|
||||
#include "system/Clock.h"
|
||||
@@ -55,7 +55,7 @@ static size_t set_party_details() {
|
||||
"M3V" // operator
|
||||
};
|
||||
|
||||
auto store = IL3SessionFileStore{"oesgw", "log"};
|
||||
auto store = IL3SessionFileStore{"oesgw", "log",IL3UUID{0}};
|
||||
auto connected = false;
|
||||
auto disconnected = false;
|
||||
|
||||
@@ -113,7 +113,7 @@ static size_t connect(IL3GatewayCfg const &gw_cfg) {
|
||||
auto gw_end_point = EndPoint{"10.3.10.16", 57630, EndPoint::TCP};
|
||||
|
||||
// Store
|
||||
auto store = IL3SessionFileStore{"gw", "52"};
|
||||
auto store = IL3SessionFileStore{"gw", "52", IL3UUID{0}};
|
||||
|
||||
// Setup connection observer
|
||||
auto c_obs = MyConnectionObs{};
|
||||
@@ -144,9 +144,7 @@ static size_t connect(IL3GatewayCfg const &gw_cfg) {
|
||||
struct MyObserver : IIL3InitObserver {
|
||||
std::function<void(IL3InitRec const &)> on_success;
|
||||
std::function<void(GatewayError const &)> on_failure;
|
||||
void on_init_success(IL3InitRec const &rec) override {
|
||||
on_success(rec);
|
||||
}
|
||||
void on_init_success(IL3InitRec const &rec) override { on_success(rec); }
|
||||
void on_init_failure(GatewayError const &e) override { on_failure(e); }
|
||||
} my_obs;
|
||||
my_obs.on_success = [&done](auto const &) { done = true; };
|
||||
@@ -165,12 +163,12 @@ static size_t connect(IL3GatewayCfg const &gw_cfg) {
|
||||
REQUIRE(!disconnected);
|
||||
}
|
||||
auto terminate = sender.enqueue<::il3::Terminate507>();
|
||||
terminate.uUID(gw_cfg.uuid);
|
||||
terminate.uUID(gw_cfg.uuid.value());
|
||||
terminate.requestTimestamp(clock.now().value());
|
||||
terminate.errorCodes(0);
|
||||
terminate.splitMsg(::il3::SplitMsg::NULL_VALUE);
|
||||
sender.flush();
|
||||
return gw_cfg.uuid;
|
||||
return gw_cfg.uuid.value();
|
||||
}
|
||||
|
||||
TEST_CASE("iLink3", "[spartan_cert") {
|
||||
@@ -178,7 +176,7 @@ TEST_CASE("iLink3", "[spartan_cert") {
|
||||
SECTION("set_party_details") { REQUIRE(set_party_details()); }
|
||||
|
||||
auto negotiate_cfg = IL3GatewayCfg{
|
||||
Clock{}.now().value(),
|
||||
IL3UUID{Clock{}.now().value()},
|
||||
1, // smp_id
|
||||
"M3V", // cme_session
|
||||
"498", // firm
|
||||
@@ -193,14 +191,14 @@ TEST_CASE("iLink3", "[spartan_cert") {
|
||||
0}; // to cme
|
||||
|
||||
SECTION("init_handler_negotiate") { REQUIRE(connect(negotiate_cfg)); }
|
||||
|
||||
|
||||
SECTION("init_handler_establish") {
|
||||
sleep_for(5s);
|
||||
auto uuid = connect(negotiate_cfg);
|
||||
REQUIRE(uuid);
|
||||
sleep_for(5s);
|
||||
auto establish_cfg = IL3GatewayCfg{
|
||||
uuid,
|
||||
IL3UUID{uuid},
|
||||
1, // smp_id
|
||||
"M3V", // cme_session
|
||||
"498", // firm
|
||||
|
||||
Reference in new issue
Block a user