OnixS C++ CME MDP Premium Market Data Handler 5.9.0
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
29#include <OnixS/CME/MDH/Time.h>
30
35
37
38// A bit of forward declarations.
40
42typedef std::vector<std::string> FileList;
43
49void gatherLogFiles(FileList&, ChannelId, const std::string&);
50
58void gatherLogFiles(FileList&, ChannelId, const std::string&, const std::string&);
59
68void gatherFiles(FileList&, const std::string&, const std::string&);
69
70#if !defined(ONIXS_CMEMDH_NO_DEPRECATED)
71
77inline void gatherPcapFiles(FileList& files, const std::string& location, const std::string& ext)
78{
79 gatherFiles(files, location, ext);
80}
81
82#endif // !ONIXS_CMEMDH_NO_DEPRECATED
83
103
106{
107public:
110 : begin_()
111 , end_()
112 {
113 }
114
118 : begin_(begin)
119 , end_(end)
120 {
121 }
122
125 ReplaySpan(const ReplaySpan& other)
126 : begin_(other.begin_)
127 , end_(other.end_)
128 {
129 }
130
132 bool empty() const
133 {
134 return (begin_ >= end_);
135 }
136
139 bool contain(const Timestamp& timestamp) const
140 {
141 return (begin_ <= timestamp && timestamp < end_);
142 }
143
145 const Timestamp& begin() const
146 {
147 return begin_;
148 }
149
151 void begin(const Timestamp& value)
152 {
153 begin_ = value;
154 }
155
157 const Timestamp& end() const
158 {
159 return end_;
160 }
161
163 void end(const Timestamp& value)
164 {
165 end_ = value;
166 }
167
170 {
171 begin_ = other.begin_;
172 end_ = other.end_;
173
174 return *this;
175 }
176
177private:
178 Timestamp begin_;
179 Timestamp end_;
180};
181
184{
186 enum Enum
187 {
190
193
197 X2 = 2
198 };
199};
200
203{
205 virtual void onDelay(const TimeSpan& delay) = 0;
206};
207
217
227
230template <class DataSource, class DataSourceLess = std::less<DataSource> >
232{
233public:
235 typedef std::map<DataSource, DataSource, DataSourceLess> Aliases;
236
239 : delayer_(&SleepReplayDelayer::service())
240 , settingsUse_(HandlerSettingsUse::Suggested)
241 , aliases_()
242 , timeSpan_()
243 , speed_(ReplaySpeed::NoDelay)
244 {
245 }
246
249 : delayer_(other.delayer_)
250 , settingsUse_(other.settingsUse_)
251 , aliases_(other.aliases_)
252 , timeSpan_(other.timeSpan_)
253 , speed_(other.speed_)
254 {
255 }
256
259 {
260 return settingsUse_;
261 }
262
265 {
266 settingsUse_ = policy;
267 }
268
274 const Aliases& aliases() const
275 {
276 return aliases_;
277 }
278
285 {
286 return aliases_;
287 }
288
290 const ReplaySpan& timeSpan() const
291 {
292 return timeSpan_;
293 }
294
297 {
298 return timeSpan_;
299 }
300
303 {
304 return speed_;
305 }
306
309 {
310 speed_ = policy;
311 }
312
315 {
316 delayer_ = &delayer;
317 }
318
321 {
322 assert(delayer_);
323 return *delayer_;
324 }
325
328 {
329 delayer_ = other.delayer_;
330
331 settingsUse_ = other.settingsUse_;
332
333 aliases_ = other.aliases_;
334
335 timeSpan_ = other.timeSpan_;
336
337 speed_ = other.speed_;
338
339 return *this;
340 }
341
342private:
343 ReplayDelayer* delayer_;
344 HandlerSettingsUse::Enum settingsUse_;
345 Aliases aliases_;
346
347 ReplaySpan timeSpan_;
348 ReplaySpeed::Enum speed_;
349};
350
353
359
361class ONIXS_CMEMDH_LTWT PcapReplaySettings : public ReplaySettings<NetFeedConnection, NetFeedConnectionLess>
362{
363public:
369
376
377private:
379
380 // Not applicable for the PCAP replay as no
381 // parameters are stored in the captured files.
382 using Base::settingsUse;
383};
384
390
394{
395public:
401
408
409private:
411
412 // Not applicable for the Datamine replay as no
413 // parameters are stored in the captured files.
414 using Base::settingsUse;
415};
416
421
426void replayLogFiles(const FileList&, Handler**, size_t, const LogReplaySettings&);
427
431inline void replayLogFiles(const FileList& logs, Handler& handler, const LogReplaySettings& supplements)
432{
433 Handler* handlers[] = {&handler};
434
435 replayLogFiles(logs, handlers, 1, supplements);
436}
437
440inline void replayLogFiles(const FileList& logs, Handler** handlers, size_t handlerQty)
441{
442 replayLogFiles(logs, handlers, handlerQty, LogReplaySettings());
443}
444
447inline void replayLogFiles(const FileList& logs, Handler& handler)
448{
449 Handler* handlers[] = {&handler};
450
451 replayLogFiles(logs, handlers, 1);
452}
453
459
462inline void replayLogFiles(const FileList& logs, Handler** handlers, size_t handlerQty, const UseHandlerSettingsAsIs&)
463{
464 LogReplaySettings supplements;
465
467
468 replayLogFiles(logs, handlers, handlerQty, supplements);
469}
470
473inline void replayLogFiles(const FileList& logs, Handler& handler, const UseHandlerSettingsAsIs& marker)
474{
475 Handler* handlers[] = {&handler};
476
477 replayLogFiles(logs, handlers, 1, marker);
478}
479
483void replayPcapFiles(const FileList&, Handler**, size_t, const PcapReplaySettings&);
484
492 const FileList& snapshots,
493 MarketRecoveryOptions::Enum snapshotsApplyOptions,
494 const FileList& incrementals,
495 Handler** handlers,
496 size_t handlerQty,
497 const PcapReplaySettings& supplements
498);
499
505inline void replayPcapFiles(
506 const FileList& snapshots,
507 MarketRecoveryOptions::Enum snapshotsApplyOptions,
508 const FileList& incrementals,
509 Handler& handler,
510 const PcapReplaySettings& supplements = PcapReplaySettings()
511)
512{
513 Handler* handlers[] = {&handler};
514
515 replayPcapFiles(snapshots, snapshotsApplyOptions, incrementals, handlers, 1, supplements);
516}
517
520inline void replayPcapFiles(const FileList& logs, Handler& handler, const PcapReplaySettings& supplements)
521{
522 Handler* handlers[] = {&handler};
523
524 replayPcapFiles(logs, handlers, 1, supplements);
525}
526
529inline void replayPcapFiles(const FileList& logs, Handler& handler)
530{
531 replayPcapFiles(logs, handler, PcapReplaySettings());
532}
533
536void mergeDatamineFiles(const FileList& inFileNames, std::string outFileName, const ReplaySpan& timeSpan = ReplaySpan());
537
542
545inline void replayDatamineFiles(const FileList& logs, Handler& handler, const DatamineReplaySettings& supplements)
546{
547 Handler* handlers[] = {&handler};
548
549 replayDatamineFiles(logs, handlers, 1, supplements);
550}
551
554inline void replayDatamineFiles(const FileList& logs, Handler& handler)
555{
557}
558
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:35
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
#define ONIXS_CMEMDH_OVERRIDE
Definition Compiler.h:176
Replay supplements for the CME DataMine historical data replay functionality.
Definition Replay.h:394
DatamineReplaySettings()
Initializes settings with the default values.
Definition Replay.h:397
HandlerSettingsUse::Enum settingsUse() const
Settings aren't stored in Datamine thus constant value is returned.
Definition Replay.h:404
Encapsulates all the machinery related with market data processing from CME Market Data Platform.
Definition Handler.h:56
Replay supplements for the PCAP replay functionality.
Definition Replay.h:362
PcapReplaySettings()
Initializes settings with the default values.
Definition Replay.h:365
HandlerSettingsUse::Enum settingsUse() const
Settings aren't stored in PCAPs thus constant value is returned.
Definition Replay.h:372
Various supplemental settings affecting the way the logged data is replayed.
Definition Replay.h:232
ReplayDelayer & delayPolicy() const
Indicates policy for implementing replay delay.
Definition Replay.h:320
ReplaySpeed::Enum speed() const
Indicates processing speed policy.
Definition Replay.h:302
void delayPolicy(ReplayDelayer &delayer)
Sets a policy for implementing replay delay.
Definition Replay.h:314
const ReplaySpan & timeSpan() const
Time span for which entries are to be processed.
Definition Replay.h:290
ReplaySettings()
Initializes the settings with the default values.
Definition Replay.h:238
HandlerSettingsUse::Enum settingsUse() const
Handler settings use policy.
Definition Replay.h:258
void speed(ReplaySpeed::Enum policy)
Defines processing speed.
Definition Replay.h:308
Aliases & aliases()
Aliases to be used during the replay.
Definition Replay.h:284
const Aliases & aliases() const
Aliases to be used during the replay.
Definition Replay.h:274
ReplaySpan & timeSpan()
Time span for which entries are to be processed.
Definition Replay.h:296
void settingsUse(HandlerSettingsUse::Enum policy)
Defines handler settings use policy.
Definition Replay.h:264
ReplaySettings & operator=(const ReplaySettings &other)
Re-initializes as a copy of the other one.
Definition Replay.h:327
ReplaySettings(const ReplaySettings &other)
Initializes as a copy of the other one.
Definition Replay.h:248
std::map< DataSource, DataSource, DataSourceLess > Aliases
The table of data source aliases.
Definition Replay.h:235
Defines range of log entries to be replayed.
Definition Replay.h:106
const Timestamp & end() const
Indicates the end of the range.
Definition Replay.h:157
ReplaySpan & operator=(const ReplaySpan &other)
Re-initializes as a copy of the other one.
Definition Replay.h:169
bool empty() const
Indicates whether span is empty or not.
Definition Replay.h:132
void begin(const Timestamp &value)
Updates the beginning of the range.
Definition Replay.h:151
void end(const Timestamp &value)
Indicates the end of the range.
Definition Replay.h:163
ReplaySpan(const Timestamp &begin, const Timestamp &end)
Initializes the instance according to the given bounds.
Definition Replay.h:117
const Timestamp & begin() const
Indicates the beginning of the range.
Definition Replay.h:145
bool contain(const Timestamp &timestamp) const
Indicates whether the given timestamp belongs to the given time span.
Definition Replay.h:139
ReplaySpan(const ReplaySpan &other)
Initializes the instance as a copy of the other one.
Definition Replay.h:125
ReplaySpan()
Initializes empty span.
Definition Replay.h:109
Represents time interval.
Definition Time.h:105
Represents time point without time-zone information.
Definition Time.h:388
void gatherPcapFiles(FileList &files, const std::string &location, const std::string &ext)
Gathers files which are stored in the given folder with the given extension.
Definition Replay.h:77
void replayPcapFiles(const FileList &, Handler **, size_t, const PcapReplaySettings &)
Replays the given list of PCAP files for the given Handlers according to the given settings.
void gatherLogFiles(FileList &, ChannelId, const std::string &)
Gathers log files logs which are available for given channel and are stored in a given folder.
void replayDatamineFiles(const FileList &, Handler **, size_t, const DatamineReplaySettings &)
Replays the given list of Datamine files for the given Handlers according to the given settings.
void replayLogFiles(const FileList &, Handler **, size_t, const LogReplaySettings &)
Extracts market data stored in the given log files and pushes it to the given handlers for further pr...
ReplaySettings< NetFeedId > LogReplaySettings
Replay supplements for log replay functionality.
Definition Replay.h:352
DatamineReplaySettings::Aliases ChannelIdAliases
Collection of channels to be used by the CME Datamine historical file replay to replace captured sour...
Definition Replay.h:420
void gatherFiles(FileList &, const std::string &, const std::string &)
Gathers files which are stored in the given folder with the given extension.
LogReplaySettings::Aliases FeedIdAliases
Collection of logged data sources (feed identifiers) to be used by the Log Replay to replace logged s...
Definition Replay.h:358
std::vector< std::string > FileList
Ordered list of logs to be replayed.
Definition Replay.h:42
PcapReplaySettings::Aliases NetAddressAliases
Collection of data sources (feed identifiers) to be used by the PCAP file replay to replace captured ...
Definition Replay.h:389
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.
UInt32 ChannelId
Identifies CME channel.
Definition Domain.h:28
Defines whether processing and other settings must be extracted from logs and used during the replay,...
Definition Replay.h:89
@ Suggested
Settings affecting the way the data is processed must be extracted from the logs and applied to the H...
Definition Replay.h:100
@ AsIs
Handler settings aren't touched and used as they are during the replay.
Definition Replay.h:94
Implements the replay delay by polling in the userspace.
Definition Replay.h:220
static ReplayDelayer & service()
Returns the instance reference.
void onDelay(const TimeSpan &delay) override
Implements the delay between packets.
Controls the replay delay.
Definition Replay.h:203
virtual void onDelay(const TimeSpan &delay)=0
Implements the delay between packets.
Controls speed of market data replay.
Definition Replay.h:184
Enum
Controls speed of market data replay.
Definition Replay.h:187
@ X2
Data is replayed two times faster in compare to the original speed at which the Handler was receiving...
Definition Replay.h:197
@ NoDelay
Replays run at maximal speed.
Definition Replay.h:189
@ Original
Data is replayed with the original speed.
Definition Replay.h:192
Implements the replay delay using the sleep system call.
Definition Replay.h:210
static ReplayDelayer & service()
Returns the instance reference.
void onDelay(const TimeSpan &delay) override
Implements the delay between packets.
A Marker instructing the log replay procedure to use Handler settings as they are without applying an...
Definition Replay.h:458