OnixS C++ CME Market Data Handler  4.8.0.10
API documentation
FeedSettings.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 
25 #include <OnixS/CME/MDH/Integral.h>
26 
28 
29 /// Collection of parameters common for all types of feeds.
30 template
31 <
32  typename Layout
33 >
35 {
36  Layout layout_;
37  UInt32 heartbeatInterval_;
38 
39  std::string feedANetworkInterfaces_;
40  std::string feedBNetworkInterfaces_;
41 
42 protected:
43  /// Initializes instance with default values.
45  Layout layout,
46  UInt32 heartbeat)
47  : layout_(layout)
48  , heartbeatInterval_(heartbeat)
49  {
50  }
51 
52 public:
53  /// Defines feed layout for a feed group.
54  Layout layout() const
55  {
56  return layout_;
57  }
58 
59  /// Defines feed layout for recovery feed group.
60  void layout(Layout value)
61  {
62  layout_ = value;
63  }
64 
65  /// Specifies maximal time interval between two
66  /// network packets. If no data is received during
67  /// specified time frame, corresponding event is raised
68  /// and further behavior is defined by feed layout.
69  ///
70  /// Interval is measured in seconds.
72  {
73  return heartbeatInterval_;
74  }
75 
76  /// Specifies maximal time interval between two packets.
78  {
79  heartbeatInterval_ = value;
80  }
81 
82  /// Specifies one or more network interfaces to use for
83  /// "A" feeds while joining the multicast group; use
84  /// semi-colon delimited list if more than one.
85  ///
86  /// @note On Linux the network interface is specified
87  /// by its name, on Windows - by IP address.
88  ///
89  /// @note If the value is empty or absent then the
90  /// Settings::networkInterface value is used.
91  const
92  std::string&
94  {
95  return feedANetworkInterfaces_;
96  }
97 
98  /// Specifies one or more network interfaces to use for
99  /// "A" feeds while joining the multicast group; use
100  /// semi-colon delimited list if more than one.
101  void
103  const std::string& interfaces)
104  {
105  feedANetworkInterfaces_ = interfaces;
106  }
107 
108  /// Specifies one or more network interfaces to use for "B"
109  /// feeds while joining the multicast group; use semi-colon
110  /// delimited list if more than one.
111  ///
112  /// @note On Linux the network interface is specified by
113  /// its name, on Windows - by IP address.
114  ///
115  /// @note If the value is empty or absent then the
116  /// Settings::networkInterface value is used.
117  const
118  std::string&
120  {
121  return feedBNetworkInterfaces_;
122  }
123 
124  /// Specifies one or more network interfaces to use for
125  /// "B" feeds while joining the multicast group; use
126  /// semi-colon delimited list if more than one.
127  void
129  const std::string& interfaces)
130  {
131  feedBNetworkInterfaces_ = interfaces;
132  }
133 };
134 
135 /// Defines feed layout alternates available for
136 /// recovery feeds like instrument and snapshot.
138 {
139  /// Integral type used as basement for constants.
140  typedef UInt32 Base;
141 
142  enum Enum
143  {
144  /// Indicates only feed A is used as source for market data.
146 
147  /// Indicates only feed B is used as source for market data.
149 
150  /// Feed A is used as primary source of market data. If Handler
151  /// detects absence of market data on feed A, it switches to
152  /// feed B to continue market data processing. Feed B is used
153  /// by Handler until market data absence is detected on it. In
154  /// that case Handler will switch back to feed A. In other words,
155  /// this layout instructs Handler to cycle between feeds if data
156  /// absence is detected starting from feed A.
158 
159  /// Feed B is used as primary source of market data. If Handler
160  /// detects absence of market data on feed B, it switches to
161  /// feed A to continue market data processing. Feed A is used
162  /// by Handler until market data absence is detected on it. In
163  /// that case Handler will switch back to feed B. In other words,
164  /// this layout instructs Handler to cycle between feeds if data
165  /// absence is detected starting from feed B.
166  FeedBWithFailoverToFeedA
167  };
168 };
169 
170 /// Appends string presentation of feed layout.
171 ONIXS_CMEMDH_EXPORTED
172 void
173 toStr(
174  std::string&,
176 
177 /// Returns string presentation of feed layout.
178 inline
179 std::string
182 {
183  std::string str;
184 
185  toStr(str, layout);
186 
187  return str;
188 }
189 
190 /// Collection of parameters affecting recovery feeds behavior.
193 : public FeedSettingsBase
194  <
196  >
197 {
198 public:
199  /// Initializes instance with default values.
200  ///
201  /// By default, feed A is used as the primary source
202  /// of market recovery data with fail-over to the feed B.
203  /// Heartbeats are expected within 30 seconds periodicy.
207  FeedAWithFailoverToFeedB,
208  30)
209  {
210  }
211 };
212 
213 /// Serializes feed settings into string.
214 ONIXS_CMEMDH_EXPORTED
215 void
216 toStr(
217  std::string&,
218  const RecoveryFeedSettings&);
219 
220 /// Serializes feed settings into string.
221 inline
222 std::string
224  const RecoveryFeedSettings& settings)
225 {
226  std::string str;
227 
228  toStr(str, settings);
229 
230  return str;
231 }
232 
233 /// Defines feed layout alternates available
234 /// for real-time feed like incremental one.
236 {
237  /// Integral type used as basement for constants.
238  typedef UInt32 Base;
239 
240  enum Enum
241  {
242  /// Indicates only feed A is used as source for market data.
244 
245  /// Indicates only feed B is used as source for market data.
247 
248  /// Feed A is used as primary source of market data. If Handler
249  /// detects absence of market data on feed A, it switches to
250  /// feed B to continue market data processing. Feed B is used
251  /// by Handler until market data absence is detected on it. In
252  /// that case Handler will switch back to feed A. In other words,
253  /// this layout instructs Handler to cycle between feeds if data
254  /// absence is detected starting from feed A.
256 
257  /// Feed B is used as primary source of market data. If Handler
258  /// detects absence of market data on feed B, it switches to
259  /// feed A to continue market data processing. Feed A is used
260  /// by Handler until market data absence is detected on it. In
261  /// that case Handler will switch back to feed B. In other words,
262  /// this layout instructs Handler to cycle between feeds if data
263  /// absence is detected starting from feed B.
265 
266  /// Handler arbitrates between both feeds A and B.
267  BothFeedsWithArbitrage
268  };
269 };
270 
271 /// Appends string presentation of feed layout.
272 ONIXS_CMEMDH_EXPORTED
273 void
274 toStr(
275  std::string&,
277 
278 /// Returns string presentation of feed layout.
279 inline
280 std::string
283 {
284  std::string str;
285 
286  toStr(str, layout);
287 
288  return str;
289 }
290 
291 /// Collection of parameters affecting real-time feeds behavior.
294 : public FeedSettingsBase
295  <
297  >
298 {
299  UInt32 outOfOrderPacketMaxInterval_;
300  UInt32 lostPacketWaitTime_;
301 
302 public:
303  /// Initializes instance with default values.
304  ///
305  /// By default, arbitrage between feeds A and B is done.
306  /// Heartbeats are expected within 30 seconds periodicy.
310  BothFeedsWithArbitrage,
311  30)
312  , outOfOrderPacketMaxInterval_(3)
313  , lostPacketWaitTime_(100000)
314  {
315  }
316 
317  /// Defines value of threshold used by Handler to differ
318  /// out-of-order packets from gaps.
319  ///
320  /// Due to unreliable nature of multicast, packets transmitted by MDP
321  /// may be received in the order different to original. To differ the
322  /// case when Handler received out-of-order packets from the case when
323  /// some of packets were completely lost, Handler uses given parameter.
324  /// It defines size of interval for incoming packets starting from the
325  /// last received. Packet is considered as out-of-order if its sequence
326  /// number fits into interval [seqNumberOfLastReceivedPacket,
327  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
328  /// In that case Handler waits for other packets to fulfill the incoming
329  /// sequence. If received packet has greater sequence number than
330  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
331  /// then Handler makes a decision on packets lost and gap is reported.
332  ///
333  /// @note When out-of-order packet is received, Handler makes a decision
334  /// on data loss if either waiting time is over or if newly received packet
335  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
336  /// outOfOrderPacketMaxInterval'.
337  ///
338  /// @see 'lostPacketWaitTime' parameter for more information.
339  ///
340  /// @note The default value is '3'.
342  {
343  return outOfOrderPacketMaxInterval_;
344  }
345 
346  /// Defines value of threshold used by Handler
347  /// to differ out-of-order packets from gaps.
349  {
350  outOfOrderPacketMaxInterval_ = value;
351  }
352 
353  /// Indicates for how long Handler should wait for
354  /// the packet before it's considered as totally lost.
355  ///
356  /// Due to unreliable nature of multicast, data transmitted by MDP
357  /// may come in order other than original or be completely lost. When
358  /// Handler receives packet with sequence number greater than expected,
359  /// it considers received data as out-of-order. If for a certain time
360  /// interval Handler receives missing data, Handler resumes normal data
361  /// processing. However, if no data is received for predefined time frame,
362  /// Handler considers missing data as lost and raises packet gap event.
363  /// Given parameter defines size of time interval Handler waits for missing
364  /// data.
365  ///
366  /// @note When out-of-order packet is received, Handler makes a decision
367  /// on data loss if either waiting time is over or if newly received packet
368  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
369  /// outOfOrderPacketMaxInterval'.
370  ///
371  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
372  ///
373  /// Time interval is measured in microseconds (usec).
374  ///
375  /// @note The default value is '100000' (100 milliseconds).
377  {
378  return lostPacketWaitTime_;
379  }
380 
381  /// Indicates for how long Handler should wait for
382  /// the packet before it's considered as totally lost.
384  {
385  lostPacketWaitTime_ = value;
386  }
387 };
388 
389 /// Serializes feed settings into string.
390 ONIXS_CMEMDH_EXPORTED
391 void
392 toStr(
393  std::string&,
394  const RealtimeFeedSettings&);
395 
396 /// Serializes feed settings into string.
397 inline
398 std::string
400  const RealtimeFeedSettings& settings)
401 {
402  std::string str;
403 
404  toStr(str, settings);
405 
406  return str;
407 }
408 
409 // Parameters affecting all feeds involved into market data processing.
411 {
412  std::string connectivityConfigurationFile_;
413 
414  UInt16 maxPacketSize_;
415 
416  RecoveryFeedSettings instrumentFeeds_;
417  RealtimeFeedSettings incrementalFeeds_;
418 
419  RecoveryFeedSettings snapshotFeeds_;
420  RecoveryFeedSettings mboSnapshotFeeds_;
421 
422 public:
423  /// Initializes instance with default values.
425  : maxPacketSize_(1420)
426  {
427  }
428 
429  /// Path to the connectivity configuration file.
430  const
431  std::string&
433  {
434  return connectivityConfigurationFile_;
435  }
436 
437  /// Sets path to the connectivity configuration file.
438  void
440  const std::string& configurationFile)
441  {
442  connectivityConfigurationFile_ = configurationFile;
443  }
444 
445  /// Specifies one or more network interfaces to use for
446  /// "A" feeds while joining the multicast group; use
447  /// semi-colon delimited list if more than one.
448  void
450  const std::string& interfaces)
451  {
452  instrumentFeeds_.
453  feedANetworkInterfaces
454  (interfaces);
455 
456  incrementalFeeds_.
457  feedANetworkInterfaces
458  (interfaces);
459 
460  snapshotFeeds_.
461  feedANetworkInterfaces
462  (interfaces);
463 
464  mboSnapshotFeeds_.
465  feedANetworkInterfaces
466  (interfaces);
467  }
468 
469  /// Specifies one or more network interfaces to use for
470  /// "B" feeds while joining the multicast group; use
471  /// semi-colon delimited list if more than one.
472  void
474  const std::string& interfaces)
475  {
476  instrumentFeeds_.
477  feedBNetworkInterfaces
478  (interfaces);
479 
480  incrementalFeeds_.
481  feedBNetworkInterfaces
482  (interfaces);
483 
484  snapshotFeeds_.
485  feedBNetworkInterfaces
486  (interfaces);
487 
488  mboSnapshotFeeds_.
489  feedBNetworkInterfaces
490  (interfaces);
491  }
492 
493  /// Max size for network packet transmitted by MDP.
494  ///
495  /// @note Default value is '1420'.
496  UInt16 maxPacketSize() const
497  {
498  return maxPacketSize_;
499  }
500 
501  /// Max size for network packet transmitted by MDP.
502  void maxPacketSize(UInt16 value)
503  {
504  maxPacketSize_ = value;
505  }
506 
507  /// Reference to parameters affecting instrument feeds.
509  {
510  return instrumentFeeds_;
511  }
512 
513  /// Reference to parameters affecting instrument feeds.
515  {
516  return instrumentFeeds_;
517  }
518 
519  /// Reference to parameters affecting incremental feeds.
521  {
522  return incrementalFeeds_;
523  }
524 
525  /// Reference to parameters affecting incremental feeds.
527  {
528  return incrementalFeeds_;
529  }
530 
531  /// Reference to parameters affecting snapshot feeds.
533  {
534  return snapshotFeeds_;
535  }
536 
537  /// Reference to parameters affecting snapshot feeds.
539  {
540  return snapshotFeeds_;
541  }
542 
543  /// Reference to parameters affecting snapshot feeds.
545  {
546  return mboSnapshotFeeds_;
547  }
548 
549  /// Reference to parameters affecting snapshot feeds.
551  {
552  return mboSnapshotFeeds_;
553  }
554 };
555 
556 /// Serializes feed settings into string.
557 ONIXS_CMEMDH_EXPORTED
558 void
559 toStr(
560  std::string&,
561  const FeedSettings&);
562 
563 /// Serializes feed settings into string.
564 inline
565 std::string
567  const FeedSettings& settings)
568 {
569  std::string str;
570 
571  toStr(str, settings);
572 
573  return str;
574 }
575 
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:110
const std::string & feedBNetworkInterfaces() const
Definition: FeedSettings.h:119
void layout(Layout value)
Defines feed layout for recovery feed group.
Definition: FeedSettings.h:60
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:140
const std::string & connectivityConfigurationFile() const
Path to the connectivity configuration file.
Definition: FeedSettings.h:432
UInt32 UInt32
uInt32.
Definition: Fields.h:189
FeedSettings()
Initializes instance with default values.
Definition: FeedSettings.h:424
Layout layout() const
Defines feed layout for a feed group.
Definition: FeedSettings.h:54
FeedSettingsBase(Layout layout, UInt32 heartbeat)
Initializes instance with default values.
Definition: FeedSettings.h:44
const RealtimeFeedSettings & incrementalFeeds() const
Reference to parameters affecting incremental feeds.
Definition: FeedSettings.h:520
void heartbeatInterval(UInt32 value)
Specifies maximal time interval between two packets.
Definition: FeedSettings.h:77
Collection of parameters common for all types of feeds.
Definition: FeedSettings.h:34
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:148
const RecoveryFeedSettings & mboSnapshotFeeds() const
Reference to parameters affecting snapshot feeds.
Definition: FeedSettings.h:544
const std::string & feedANetworkInterfaces() const
Definition: FeedSettings.h:93
void maxPacketSize(UInt16 value)
Max size for network packet transmitted by MDP.
Definition: FeedSettings.h:502
void feedANetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:102
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:145
void connectivityConfigurationFile(const std::string &configurationFile)
Sets path to the connectivity configuration file.
Definition: FeedSettings.h:439
RecoveryFeedSettings & mboSnapshotFeeds()
Reference to parameters affecting snapshot feeds.
Definition: FeedSettings.h:550
Collection of parameters affecting real-time feeds behavior.
Definition: FeedSettings.h:292
std::string toStr(const FeedSettings &settings)
Serializes feed settings into string.
Definition: FeedSettings.h:566
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:243
#define ONIXS_CMEMDH_LTWT_STRUCT
Definition: Bootstrap.h:114
const RecoveryFeedSettings & snapshotFeeds() const
Reference to parameters affecting snapshot feeds.
Definition: FeedSettings.h:532
Collection of parameters affecting recovery feeds behavior.
Definition: FeedSettings.h:191
const RecoveryFeedSettings & instrumentFeeds() const
Reference to parameters affecting instrument feeds.
Definition: FeedSettings.h:508
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168
void feedBNetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:128
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:246
RecoveryFeedSettings & snapshotFeeds()
Reference to parameters affecting snapshot feeds.
Definition: FeedSettings.h:538
void feedANetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:449
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:238
void outOfOrderPacketMaxInterval(UInt32 value)
Definition: FeedSettings.h:348
void feedBNetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:473
RealtimeFeedSettings & incrementalFeeds()
Reference to parameters affecting incremental feeds.
Definition: FeedSettings.h:526
RecoveryFeedSettings & instrumentFeeds()
Reference to parameters affecting instrument feeds.
Definition: FeedSettings.h:514
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:172