OnixS C++ CME MDP Premium Market Data Handler 5.10.3
Users' manual and API documentation
Loading...
Searching...
No Matches
Replay.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <string>
24#include <vector>
25#include <map>
26#include <functional>
27#include <limits>
28
31
32#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Disable.h>
34#include <OnixS/CME/MDH/Time.h>
35#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Restore.h>
36
42
44class ONIXS_CMEMDH_EXPORTED MulticastSender;
46
48
49// A bit of forward declarations.
51
53typedef std::vector<std::string> FileList;
54
60void gatherLogFiles(FileList&, ChannelId, const std::string&);
61
69void gatherLogFiles(FileList&, ChannelId, const std::string&, const std::string&);
70
79void gatherFiles(FileList&, const std::string&, const std::string&);
80
81#if !defined(ONIXS_CMEMDH_NO_DEPRECATED)
82
88inline void gatherPcapFiles(FileList& files, const std::string& location, const std::string& ext)
89{
90 gatherFiles(files, location, ext);
91}
92
93#endif // !ONIXS_CMEMDH_NO_DEPRECATED
94
100{
101 enum Enum
102 {
106
112 };
113};
114
117{
118public:
121 : begin_()
122 , end_()
123 {
124 }
125
129 : begin_(begin)
130 , end_(end)
131 {
132 }
133
136 ReplaySpan(const ReplaySpan& other)
137 : begin_(other.begin_)
138 , end_(other.end_)
139 {
140 }
141
143 bool empty() const
144 {
145 return (begin_ >= end_);
146 }
147
151 {
152 return (begin_ <= timestamp && timestamp < end_);
153 }
154
157 {
158 return begin_;
159 }
160
162 void begin(const Messaging::Timestamp& value)
163 {
164 begin_ = value;
165 }
166
169 {
170 return end_;
171 }
172
174 void end(const Messaging::Timestamp& value)
175 {
176 end_ = value;
177 }
178
181 {
182 begin_ = other.begin_;
183 end_ = other.end_;
184
185 return *this;
186 }
187
188private:
191};
192
195{
197 enum Enum
198 {
201
204
208 X2 = 2
209 };
210};
211
214template <class DataSource, class DataSourceLess = std::less<DataSource> >
216{
217public:
219 typedef std::map<DataSource, DataSource, DataSourceLess> Aliases;
220
223 : delayer_(&SleepReplayDelayer::service())
224 , settingsUse_(HandlerSettingsUse::Suggested)
225 , aliases_()
226 , timeSpan_()
227 , speed_(ReplaySpeed::NoDelay)
228 {
229 }
230
233 : delayer_(other.delayer_)
234 , settingsUse_(other.settingsUse_)
235 , aliases_(other.aliases_)
236 , timeSpan_(other.timeSpan_)
237 , speed_(other.speed_)
238 {
239 }
240
243 {
244 return settingsUse_;
245 }
246
249 {
250 settingsUse_ = policy;
251 }
252
258 const Aliases& aliases() const
259 {
260 return aliases_;
261 }
262
269 {
270 return aliases_;
271 }
272
274 const ReplaySpan& timeSpan() const
275 {
276 return timeSpan_;
277 }
278
281 {
282 return timeSpan_;
283 }
284
287 {
288 return speed_;
289 }
290
293 {
294 speed_ = policy;
295 }
296
299 {
300 delayer_ = &delayer;
301 }
302
305 {
306 assert(delayer_);
307 return *delayer_;
308 }
309
312 {
313 delayer_ = other.delayer_;
314
315 settingsUse_ = other.settingsUse_;
316
317 aliases_ = other.aliases_;
318
319 timeSpan_ = other.timeSpan_;
320
321 speed_ = other.speed_;
322
323 return *this;
324 }
325
326private:
327 ReplayDelayer* delayer_;
328 HandlerSettingsUse::Enum settingsUse_;
329 Aliases aliases_;
330
331 ReplaySpan timeSpan_;
332 ReplaySpeed::Enum speed_;
333};
334
337
343
345class ONIXS_CMEMDH_LTWT PcapReplaySettings : public ReplaySettings<NetFeedConnection, NetFeedConnectionLess>
346{
347public:
353
360
361private:
363
364 // Not applicable for the PCAP replay as no
365 // parameters are stored in the captured files.
366 using Base::settingsUse;
367};
368
374
378{
379public:
385
392
393private:
394 typedef ReplaySettings<ChannelId> Base;
395
396 // Not applicable for the Datamine replay as no
397 // parameters are stored in the captured files.
398 using Base::settingsUse;
399};
400
405
420void replayLogFiles(const FileList& logs, Handler** handlers, size_t handlerQty, const LogReplaySettings& supplements);
421
430inline void replayLogFiles(const FileList& logs, Handler& handler, const LogReplaySettings& supplements)
431{
432 Handler* handlers[] = {&handler};
433
434 replayLogFiles(logs, handlers, 1, supplements);
435}
436
446inline void replayLogFiles(const FileList& logs, Handler** handlers, size_t handlerQty)
447{
448 replayLogFiles(logs, handlers, handlerQty, LogReplaySettings());
449}
450
459inline void replayLogFiles(const FileList& logs, Handler& handler)
460{
461 Handler* handlers[] = {&handler};
462
463 replayLogFiles(logs, handlers, 1);
464}
465
472
480inline void replayLogFiles(const FileList& logs, Handler** handlers, size_t handlerQty, const UseHandlerSettingsAsIs&)
481{
482 LogReplaySettings supplements;
483
485
486 replayLogFiles(logs, handlers, handlerQty, supplements);
487}
488
497inline void replayLogFiles(const FileList& logs, Handler& handler, const UseHandlerSettingsAsIs& marker)
498{
499 Handler* handlers[] = {&handler};
500
501 replayLogFiles(logs, handlers, 1, marker);
502}
503
508void replayPcapFiles(const FileList&, Handler**, size_t, const PcapReplaySettings&);
509
517 const FileList& snapshots,
518 MarketRecoveryOptions::Enum snapshotsApplyOptions,
519 const FileList& incrementals,
520 Handler** handlers,
521 size_t handlerQty,
522 const PcapReplaySettings& supplements
523);
524
530inline void replayPcapFiles(
531 const FileList& snapshots,
532 MarketRecoveryOptions::Enum snapshotsApplyOptions,
533 const FileList& incrementals,
534 Handler& handler,
535 const PcapReplaySettings& supplements = PcapReplaySettings()
536)
537{
538 Handler* handlers[] = {&handler};
539
540 replayPcapFiles(snapshots, snapshotsApplyOptions, incrementals, handlers, 1, supplements);
541}
542
545inline void replayPcapFiles(const FileList& logs, Handler& handler, const PcapReplaySettings& supplements)
546{
547 Handler* handlers[] = {&handler};
548
549 replayPcapFiles(logs, handlers, 1, supplements);
550}
551
554inline void replayPcapFiles(const FileList& logs, Handler& handler)
555{
556 replayPcapFiles(logs, handler, PcapReplaySettings());
557}
558
561void mergeDatamineFiles(const FileList& inFileNames, std::string outFileName, const ReplaySpan& timeSpan = ReplaySpan());
562
567
570inline void replayDatamineFiles(const FileList& logs, Handler& handler, const DatamineReplaySettings& supplements)
571{
572 Handler* handlers[] = {&handler};
573
574 replayDatamineFiles(logs, handlers, 1, supplements);
575}
576
579inline void replayDatamineFiles(const FileList& logs, Handler& handler)
580{
582}
583
586{
587public:
593 : logs_(std::move(logs))
594 , channel_(channel)
595 {}
596
598 const FileList& logs() const noexcept
599 {
600 return logs_;
601 }
602
607 {
608 logs_ = std::move(logs);
609 return *this;
610 }
611
613 ChannelId channel() const noexcept
614 {
615 return channel_;
616 }
617
622 {
623 channel_ = value;
624 return *this;
625 }
626
635 {
636 return sendDelay_;
637 }
638
647 {
648 sendDelay_ = value;
649 return *this;
650 }
651
658 bool useNaturalSendDelays() const noexcept
659 {
660 return useNaturalSendDelays_;
661 }
662
668 {
669 useNaturalSendDelays_ = value;
670 return *this;
671 }
672
676 bool updateSendingTime() const noexcept
677 {
678 return updateSendingTime_;
679 }
680
685 {
686 updateSendingTime_ = value;
687 return *this;
688 }
689
696 {
697 return sourceSwitchDelay_;
698 }
699
706 {
707 sourceSwitchDelay_ = value;
708 return *this;
709 }
710
715 {
716 delayer_ = &delayer;
717 return *this;
718 }
719
721 ReplayDelayer& delayPolicy() const noexcept
722 {
723 assert(delayer_);
724 return *delayer_;
725 }
726
734 size_t incrementalPacketsCount() const noexcept
735 {
736 return incrementalPacketsCount_;
737 }
738
748 {
749 incrementalPacketsCount_ = value;
750 return *this;
751 }
752
753private:
754 FileList logs_;
755 ChannelId channel_ = 310;
757 bool useNaturalSendDelays_ = false;
758 bool updateSendingTime_ = false;
759 Messaging::TimeSpan sourceSwitchDelay_ = Messaging::MillisecondSpan(1);
760 size_t incrementalPacketsCount_ = (std::numeric_limits<size_t>::max)();
762};
763
771void replayLogFiles(const LogPlayerSettings& settings, Test::MulticastSender** targets, size_t targetsQty);
772
778inline void replayLogFiles(const LogPlayerSettings& settings, Test::MulticastSender& target)
779{
780 Test::MulticastSender* targets[] = {&target};
781 replayLogFiles(settings, targets, 1);
782}
783
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:54
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CME_MDH_TESTING_NAMESPACE_END
Definition Bootstrap.h:64
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:35
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:55
#define ONIXS_CME_MDH_TESTING_NAMESPACE_BEGIN
Definition Bootstrap.h:63
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:148
DatamineReplaySettings()
Initializes settings with the default values.
Definition Replay.h:381
HandlerSettingsUse::Enum settingsUse() const
Definition Replay.h:388
Settings for replaying Handler log files through multicast senders.
Definition Replay.h:586
LogPlayerSettings & sendDelay(Messaging::TimeSpan value) noexcept
Definition Replay.h:646
Messaging::TimeSpan sourceSwitchDelay() const noexcept
Definition Replay.h:695
ReplayDelayer & delayPolicy() const noexcept
Indicates policy for implementing replay delay.
Definition Replay.h:721
LogPlayerSettings & logs(FileList logs) noexcept
Definition Replay.h:606
LogPlayerSettings & useNaturalSendDelays(bool value) noexcept
Definition Replay.h:667
bool updateSendingTime() const noexcept
Definition Replay.h:676
LogPlayerSettings(ChannelId channel, FileList logs) noexcept
Definition Replay.h:592
LogPlayerSettings & incrementalPacketsCount(size_t value) noexcept
Definition Replay.h:747
Messaging::TimeSpan sendDelay() const noexcept
Definition Replay.h:634
LogPlayerSettings & sourceSwitchDelay(Messaging::TimeSpan value) noexcept
Definition Replay.h:705
LogPlayerSettings & delayPolicy(ReplayDelayer &delayer) noexcept
Definition Replay.h:714
size_t incrementalPacketsCount() const noexcept
Definition Replay.h:734
LogPlayerSettings & updateSendingTime(bool value) noexcept
Definition Replay.h:684
bool useNaturalSendDelays() const noexcept
Definition Replay.h:658
LogPlayerSettings & channel(ChannelId value) noexcept
Definition Replay.h:621
ChannelId channel() const noexcept
Returns the channel identifier used to extract feed settings from the logs.
Definition Replay.h:613
const FileList & logs() const noexcept
Returns the ordered list of Handler log files to replay.
Definition Replay.h:598
Time interval specified in microseconds.
Definition Time.h:325
Time interval specified in milliseconds.
Definition Time.h:315
The time point without the time-zone information.
Definition Time.h:455
Replay supplements for the PCAP replay functionality.
Definition Replay.h:346
PcapReplaySettings()
Initializes settings with the default values.
Definition Replay.h:349
HandlerSettingsUse::Enum settingsUse() const
Definition Replay.h:356
ReplayDelayer & delayPolicy() const
Indicates policy for implementing replay delay.
Definition Replay.h:304
ReplaySpeed::Enum speed() const
Indicates processing speed policy.
Definition Replay.h:286
void delayPolicy(ReplayDelayer &delayer)
Sets a policy for implementing replay delay.
Definition Replay.h:298
const ReplaySpan & timeSpan() const
Time span for which entries are to be processed.
Definition Replay.h:274
ReplaySettings()
Initializes the settings with the default values.
Definition Replay.h:222
HandlerSettingsUse::Enum settingsUse() const
Handler settings use policy.
Definition Replay.h:242
void speed(ReplaySpeed::Enum policy)
Defines processing speed.
Definition Replay.h:292
const Aliases & aliases() const
Definition Replay.h:258
ReplaySpan & timeSpan()
Time span for which entries are to be processed.
Definition Replay.h:280
void settingsUse(HandlerSettingsUse::Enum policy)
Defines handler settings use policy.
Definition Replay.h:248
ReplaySettings & operator=(const ReplaySettings &other)
Re-initializes as a copy of the other one.
Definition Replay.h:311
ReplaySettings(const ReplaySettings &other)
Initializes as a copy of the other one.
Definition Replay.h:232
std::map< DataSource, DataSource, DataSourceLess > Aliases
The table of data source aliases.
Definition Replay.h:219
Defines range of log entries to be replayed.
Definition Replay.h:117
void begin(const Messaging::Timestamp &value)
Updates the beginning of the range.
Definition Replay.h:162
const Messaging::Timestamp & begin() const
Indicates the beginning of the range.
Definition Replay.h:156
const Messaging::Timestamp & end() const
Indicates the end of the range.
Definition Replay.h:168
ReplaySpan & operator=(const ReplaySpan &other)
Re-initializes as a copy of the other one.
Definition Replay.h:180
bool empty() const
Indicates whether span is empty or not.
Definition Replay.h:143
bool contain(const Messaging::Timestamp &timestamp) const
Definition Replay.h:150
ReplaySpan(const Messaging::Timestamp &begin, const Messaging::Timestamp &end)
Definition Replay.h:128
void end(const Messaging::Timestamp &value)
Indicates the end of the range.
Definition Replay.h:174
ReplaySpan(const ReplaySpan &other)
Definition Replay.h:136
ReplaySpan()
Initializes empty span.
Definition Replay.h:120
Test helper that sends multicast datagrams to configured CME feed targets.
void replayPcapFiles(const FileList &, Handler **, size_t, const PcapReplaySettings &)
void gatherLogFiles(FileList &, ChannelId, const std::string &)
void replayDatamineFiles(const FileList &, Handler **, size_t, const DatamineReplaySettings &)
ReplaySettings< NetFeedId > LogReplaySettings
Replay supplements for log replay functionality.
Definition Replay.h:336
Messaging::Timestamp timestamp(const Messaging::FIX::MultiContainer &, Messaging::FIX::Tag)
Retrieves last update time field value.
Messaging::UInt32 ChannelId
Identifies CME channel.
Definition Domain.h:28
void replayLogFiles(const FileList &logs, Handler **handlers, size_t handlerQty, const LogReplaySettings &supplements)
DatamineReplaySettings::Aliases ChannelIdAliases
Definition Replay.h:404
void gatherFiles(FileList &, const std::string &, const std::string &)
LogReplaySettings::Aliases FeedIdAliases
Definition Replay.h:342
std::vector< std::string > FileList
Ordered list of logs to be replayed.
Definition Replay.h:53
PcapReplaySettings::Aliases NetAddressAliases
Definition Replay.h:373
void mergeDatamineFiles(const FileList &inFileNames, std::string outFileName, const ReplaySpan &timeSpan=ReplaySpan())
Merges the given Datamine files into a single one. The output file is gzipped.
Controls speed of market data replay.
Definition Replay.h:195
Enum
Controls speed of market data replay.
Definition Replay.h:198
@ NoDelay
Replays run at maximal speed.
Definition Replay.h:200
@ Original
Data is replayed with the original speed.
Definition Replay.h:203
Implements the replay delay using the sleep system call.
static ReplayDelayer & service()
Returns the instance reference.