OnixS C++ CME MDP Premium Market Data Handler  5.8.3
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 <OnixS/CME/MDH/Domain.h>
26 
28 
29 // A bit of forward declarations.
30 
32 
33 /// List of hosts as a setting.
35 
36 /// List of network interfaces as a setting.
38 
39 /// Deserializes host list setting from a string.
41 void fromStr(HostListSetting&, const std::string&);
42 
43 /// The collection of parameters defining feed connection.
45 {
46 public:
47  // Makes assignment more flexible.
48  template <class>
50 
51  /// Initializes as a blank instance.
53  : group_(group ? *group : SettingGroup::null())
54  , port_(0)
55  , hosts_(group)
56  , nifs_(group)
57  {
58  }
59 
60  /// Initializes the given instance
61  /// as a copy of the other one.
63  : group_(SettingGroup::null())
64  , port_(other.port_)
65  , ip_(other.ip_)
66  , hosts_(other.hosts_)
67  , nifs_(other.nifs_)
68  , id_(other.id_)
69  {
70  }
71 
72  /// Finalizes the instance.
74 
75  /// Port component of the given connection settings.
76  UInt32 port() const
77  {
78  return port_;
79  }
80 
81  /// Updates port number for the given connection settings.
83  {
84  group_.controlAssignment("Port", port_, port);
85 
86  return *this;
87  }
88 
89  /// Indicates address component of the given connection settings.
90  ///
91  /// For the multicast type of connection the given parameter indicates
92  /// a multicast group to join to. For the streamed/TCP connections the
93  /// given parameter indicates the remote host to connect to.
94  const std::string& ip() const
95  {
96  return ip_;
97  }
98 
99  /// Updates address component of the given connection settings.
100  ///
101  /// For the multicast type of connection the given parameter indicates
102  /// a multicast group to join to. For the streamed/TCP connections the
103  /// given parameter indicates the remote host to connect to.
104  FeedConnectionSettings& ip(const std::string& address)
105  {
106  group_.controlAssignment("IP Address", ip_, address);
107 
108  return *this;
109  }
110 
111  /// Indicates host list of the given connection settings.
112  ///
113  /// This component is the optional one and may be used to supply
114  /// additional information on the connection. For example, if the
115  /// connection is the multicast one, the given parameter represents
116  /// a list of remote hosts from which the multicast data is actually
117  /// transmitted. Also, CME doesn't use IP parameter while defining
118  /// connections for the TCP Recovery feeds in the connectivity
119  /// configuration file (config.xml). Instead, this one is used.
120  const HostListSetting& hosts() const
121  {
122  return hosts_;
123  }
124 
125  /// Updates list of hosts for the given connection settings.
126  ///
127  /// This component is the optional one and may be used to supply
128  /// additional information on the connection. For example, if the
129  /// connection is the multicast one, the given parameter represents
130  /// a list of remote hosts from which the multicast data is actually
131  /// transmitted. Also, CME doesn't use IP parameter while defining
132  /// connections for the TCP Recovery feeds in the connectivity
133  /// configuration file (config.xml). Instead, this one is used.
135  {
136  return hosts_;
137  }
138 
139  /// Updates list of hosts for the given connection settings from a
140  /// string representing comma or semi-colon separated list of hosts.
141  ///
142  /// This component is the optional one and may be used to supply
143  /// additional information on the connection. For example, if the
144  /// connection is the multicast one, the given parameter represents
145  /// a list of remote hosts from which the multicast data is actually
146  /// transmitted. Also, CME doesn't use IP parameter while defining
147  /// connections for the TCP Recovery feeds in the connectivity
148  /// configuration file (config.xml). Instead, this one is used.
149  FeedConnectionSettings& hosts(const std::string& hosts)
150  {
151  fromStr(hosts_, hosts);
152 
153  return *this;
154  }
155 
156  /// List of network interfaces for the given connection settings.
157  ///
158  /// If the settings refers to a multicast group, the given parameter
159  /// indicates a list of network interfaces on which the multicast
160  /// data must be listen to.
162  {
163  return nifs_;
164  }
165 
166  /// List of network interfaces for the given connection settings.
167  ///
168  /// If the settings refers to a multicast group, the given parameter
169  /// indicates a list of network interfaces on which the multicast
170  /// data must be listen to.
172  {
173  return nifs_;
174  }
175 
176  /// Specifies one or more network interfaces on which to join the
177  /// multicast group if the settings define multicast connection.
178  /// Use semi-colon delimited list to specify multiple interfaces.
179  ///
180  /// @note On Linux the network interface is specified by its name,
181  /// on Windows - by IP address.
182  FeedConnectionSettings& networkInterfaces(const std::string& interfaces)
183  {
184  fromStr(nifs_, interfaces);
185 
186  return *this;
187  }
188 
189  /// The unique connection/feed identifier.
190  const std::string& id() const
191  {
192  return id_;
193  }
194 
195  /// Updates the connection/feed identifier.
196  FeedConnectionSettings& id(const std::string& id)
197  {
198  group_.controlAssignment("Identifier", id_, id);
199 
200  return *this;
201  }
202 
203  /// Re-initializes the instance as a copy of the other one.
205  {
206  group_.controlChange("Feed Connection Settings", &FeedConnectionSettings::assignNoControl, *this, other);
207 
208  return *this;
209  }
210 
211 private:
212  const SettingGroup& group_;
213 
214  UInt32 port_;
215  std::string ip_;
216 
217  HostListSetting hosts_;
218  NifListSetting nifs_;
219 
220  std::string id_;
221 
222  // Non-guarded assignment.
223  void assignNoControl(const FeedConnectionSettings& other)
224  {
225  port_ = other.port_;
226  ip_ = other.ip_;
227 
228  hosts_.assignNoControl(other.hosts_);
229  nifs_.assignNoControl(other.nifs_);
230 
231  id_ = other.id_;
232  }
233 };
234 
235 /// Serializes feed connection parameters into a string.
237 void toStr(std::string&, const FeedConnectionSettings&);
238 
239 /// Serializes feed connection parameters into a string.
240 inline std::string toStr(const FeedConnectionSettings& settings)
241 {
242  std::string str;
243 
244  toStr(str, settings);
245 
246  return str;
247 }
248 
249 /// Collection of parameters which are common for all types of feeds.
250 template <typename Layout>
252 {
253 public:
254  /// Defines feed layout for a feed group.
255  Layout layout() const
256  {
257  return layout_;
258  }
259 
260  /// Defines feed layout for recovery feed group.
262  {
263  group_.controlAssignment("Layout", layout_, value);
264 
265  return *this;
266  }
267 
268  /// Specifies maximal time interval between two
269  /// network packets. If no data is received during
270  /// specified time frame, corresponding event is raised
271  /// and further behavior is defined by feed layout.
272  ///
273  /// Interval is measured in seconds.
275  {
276  return heartbeatInterval_;
277  }
278 
279  /// Specifies maximal time interval between two packets.
281  {
282  group_.controlAssignment("Heartbeat Interval", heartbeatInterval_, interval);
283 
284  return *this;
285  }
286 
287  /// Connection attributes for the primary (A) feed.
289  {
290  return A_;
291  }
292 
293  /// Connection attributes for the primary (A) feed.
294  const FeedConnectionSettings& A() const
295  {
296  return A_;
297  }
298 
299  /// Connection attributes for the secondary (B) feed.
301  {
302  return B_;
303  }
304 
305  /// Connection attributes for the secondary (B) feed.
306  const FeedConnectionSettings& B() const
307  {
308  return B_;
309  }
310 
311 #if !defined(ONIXS_CMEMDH_NO_DEPRECATED)
312 
313  /// Specifies one or more network interfaces to use for
314  /// primary (A) feeds while joining the multicast group.
315  /// Use semi-colon to delimit multiple interfaces.
316  ///
317  /// @note On Linux the network interface is specified
318  /// by its name, on Windows - by IP address.
319  ///
320  /// @warning The given member is deprecated.
321  /// Use feed connection settings instead.
322  FeedSettingsBase& feedANetworkInterfaces(const std::string& interfaces)
323  {
324  A_.networkInterfaces(interfaces);
325 
326  return *this;
327  }
328 
329  /// Specifies one or more network interfaces to use for
330  /// secondary (B) feeds while joining the multicast group.
331  /// Use semi-colon to delimit multiple interfaces.
332  ///
333  /// @note On Linux the network interface is specified
334  /// by its name, on Windows - by IP address.
335  ///
336  /// @warning The given member is deprecated.
337  /// Use feed connection settings instead.
338  FeedSettingsBase& feedBNetworkInterfaces(const std::string& interfaces)
339  {
340  B_.networkInterfaces(interfaces);
341 
342  return *this;
343  }
344 #endif // !ONIXS_CMEMDH_NO_DEPRECATED
345 
346 protected:
347  // Makes assignment more flexible.
349 
350  /// Initializes the instance with the
351  /// given values and optional grouping.
352  FeedSettingsBase(const SettingGroup* group, Layout layout, UInt32 heartbeat)
353  : group_(group ? *group : SettingGroup::null())
354  , layout_(layout)
355  , heartbeatInterval_(heartbeat)
356  , A_(group)
357  , B_(group)
358  {
359  }
360 
361  /// Initializes the instance
362  /// as a copy of the other one.
363  ///
364  /// Attributes controlling value
365  /// assignment aren't cloned and
366  /// thus only settings are copied.
368  : group_(SettingGroup::null())
369  , layout_(other.layout_)
370  , heartbeatInterval_(other.heartbeatInterval_)
371  , A_(other.A_)
372  , B_(other.B_)
373  {
374  }
375 
376  // Finalizes the instance.
378 
379  /// Instance of the group which
380  /// the given settings belong to.
381  const SettingGroup& group() const
382  {
383  return group_;
384  }
385 
386  /// Re-initializes the instance as a
387  /// copy of the other one without involving
388  /// assignment control services.
390  {
391  layout_ = other.layout_;
392 
393  heartbeatInterval_ = other.heartbeatInterval_;
394 
395  A_.assignNoControl(other.A_);
396  B_.assignNoControl(other.B_);
397  }
398 
399 private:
400  const SettingGroup& group_;
401 
402  Layout layout_;
403  UInt32 heartbeatInterval_;
404 
407 
408  FeedSettingsBase& operator=(const FeedSettingsBase& other);
409 };
410 
411 /// Defines feed layout alternates available for
412 /// recovery feeds like instrument and snapshot.
414 {
415  /// Integral type used as basement for constants.
416  typedef UInt32 Base;
417 
418  enum Enum
419  {
420  /// Indicates only feed A is used as source for market data.
422 
423  /// Indicates only feed B is used as source for market data.
425 
426  /// Feed A is used as primary source of market data. If Handler
427  /// detects absence of market data on feed A, it switches to
428  /// feed B to continue market data processing. Feed B is used
429  /// by Handler until market data absence is detected on it. In
430  /// that case Handler will switch back to feed A. In other words,
431  /// this layout instructs Handler to cycle between feeds if data
432  /// absence is detected starting from feed A.
434 
435  /// Feed B is used as primary source of market data. If Handler
436  /// detects absence of market data on feed B, it switches to
437  /// feed A to continue market data processing. Feed A is used
438  /// by Handler until market data absence is detected on it. In
439  /// that case Handler will switch back to feed B. In other words,
440  /// this layout instructs Handler to cycle between feeds if data
441  /// absence is detected starting from feed B.
442  FeedBWithFailoverToFeedA
443  };
444 };
445 
446 /// Appends string presentation of feed layout.
448 void toStr(std::string&, RecoveryFeedLayout::Enum);
449 
450 /// Returns string presentation of feed layout.
451 inline std::string toStr(RecoveryFeedLayout::Enum layout)
452 {
453  std::string str;
454 
455  toStr(str, layout);
456 
457  return str;
458 }
459 
460 /// Collection of parameters affecting recovery feeds behavior.
461 class ONIXS_CMEMDH_LTWT MulticastRecoveryFeedSettings : public FeedSettingsBase<RecoveryFeedLayout::Enum>
462 {
463 public:
464  /// Initializes instance with default values.
465  ///
466  /// By default, feed A is used as the primary source
467  /// of market recovery data with fail-over to the feed B.
468  /// Heartbeats are expected within 30 seconds periodicity.
470  : Base(group, RecoveryFeedLayout::FeedAWithFailoverToFeedB, 30)
471  {
472  }
473 
474  /// Initializes the instance as a copy of the other one.
476  : Base(static_cast<const Base&>(other))
477  {
478  }
479 
480  /// Finalizes the instance.
482 
483  /// Re-initializes the instance as a copy of the other one.
485  {
486  group().controlChange(
487  "Multicast Recovery Feed Settings", &MulticastRecoveryFeedSettings::assignNoControl, *this, other
488  );
489 
490  return *this;
491  }
492 
493 private:
495 
497 
498  void assignNoControl(const MulticastRecoveryFeedSettings& other)
499  {
500  Base::assignNoControl(other);
501  }
502 };
503 
504 /// Serializes feed settings into string.
506 void toStr(std::string&, const MulticastRecoveryFeedSettings&);
507 
508 /// Serializes feed settings into string.
509 inline std::string toStr(const MulticastRecoveryFeedSettings& settings)
510 {
511  std::string str;
512 
513  toStr(str, settings);
514 
515  return str;
516 }
517 
518 /// Collection of parameters affecting recovery feeds behavior.
519 class ONIXS_CMEMDH_LTWT TcpRecoveryFeedSettings : public FeedSettingsBase<RecoveryFeedLayout::Enum>
520 {
521 public:
522  /// Initializes instance with default values.
523  ///
524  /// By default, feed A is used as the primary source
525  /// of market recovery data with fail-over to the feed B.
526  /// Heartbeats are expected within 2 seconds periodicity.
528  : Base(group, RecoveryFeedLayout::FeedAOnly, 2)
529  , connectionAttempts_(3)
530  , connectionTimeout_(500)
531  , sendTimeout_(5000)
532  {
533  }
534 
535  /// Initializes the instance
536  /// as a copy of the other one.
538  : Base(static_cast<const Base&>(other))
539  , connectionAttempts_(other.connectionAttempts_)
540  , connectionTimeout_(other.connectionTimeout_)
541  , sendTimeout_(other.sendTimeout_)
542  {
543  }
544 
545  /// Finalizes the instance.
547 
548  /// Number of times the Handler must try
549  /// recovering from the other feed if it
550  /// fails to recover from the primary one.
551  ///
552  /// @note Default value is '3'.
554  {
555  return connectionAttempts_;
556  }
557 
558  /// Number of times the Handler must try
559  /// recovering from the other feed if it
560  /// fails to recover from the primary one.
562  {
563  group().controlAssignment("Connection Attempts", connectionAttempts_, attemptQty);
564 
565  return *this;
566  }
567 
568  /// Interval between the attempts to receive
569  /// missed packets via the TCP recovery feed if
570  /// previous attempt either failed or was rejected.
571  ///
572  /// Interval is measured in milliseconds.
573  ///
574  /// @note Default value is '500'.
576  {
577  return connectionTimeout_;
578  }
579 
580  /// Interval between the attempts to receive
581  /// missed packets via the TCP recovery feed if
582  /// previous attempt either failed or was rejected.
583  ///
584  /// Interval is measured in milliseconds.
586  {
587  group().controlAssignment("Connection Timeout", connectionTimeout_, connectionTimeout);
588 
589  return *this;
590  }
591 
592  /// Time limit for the send operation.
593  ///
594  /// Value is measured in milliseconds.
595  ///
596  /// @note Default value is '5000'.
598  {
599  return sendTimeout_;
600  }
601 
602  /// Time limit for the send operation.
603  ///
604  /// Value is measured in milliseconds.
606  {
607  group().controlAssignment("Send Timeout", sendTimeout_, sendTimeout);
608 
609  return *this;
610  }
611 
612  /// Re-initializes the instance
613  /// as a copy of the other one.
615  {
616  group().controlChange("TCP Recovery Feed Settings", &TcpRecoveryFeedSettings::assignNoControl, *this, other);
617 
618  return *this;
619  }
620 
621 private:
622  // Makes assignment more flexible.
624 
626 
627  UInt32 connectionAttempts_;
628  UInt32 connectionTimeout_;
629  UInt32 sendTimeout_;
630 
631  void assignNoControl(const TcpRecoveryFeedSettings& other)
632  {
633  Base::assignNoControl(other);
634 
635  connectionAttempts_ = other.connectionAttempts_;
636 
637  connectionTimeout_ = other.connectionTimeout_;
638 
639  sendTimeout_ = other.sendTimeout_;
640  }
641 };
642 
643 /// Serializes feed settings into string.
645 void toStr(std::string&, const TcpRecoveryFeedSettings&);
646 
647 /// Serializes feed settings into string.
648 inline std::string toStr(const TcpRecoveryFeedSettings& settings)
649 {
650  std::string str;
651 
652  toStr(str, settings);
653 
654  return str;
655 }
656 
657 /// Defines feed layout alternates available
658 /// for real-time feed like incremental one.
660 {
661  /// Integral type used as basement for constants.
662  typedef UInt32 Base;
663 
664  enum Enum
665  {
666  /// Indicates only feed A is used as source for market data.
668 
669  /// Indicates only feed B is used as source for market data.
671 
672  /// Feed A is used as primary source of market data. If Handler
673  /// detects absence of market data on feed A, it switches to
674  /// feed B to continue market data processing. Feed B is used
675  /// by Handler until market data absence is detected on it. In
676  /// that case Handler will switch back to feed A. In other words,
677  /// this layout instructs Handler to cycle between feeds if data
678  /// absence is detected starting from feed A.
680 
681  /// Feed B is used as primary source of market data. If Handler
682  /// detects absence of market data on feed B, it switches to
683  /// feed A to continue market data processing. Feed A is used
684  /// by Handler until market data absence is detected on it. In
685  /// that case Handler will switch back to feed B. In other words,
686  /// this layout instructs Handler to cycle between feeds if data
687  /// absence is detected starting from feed B.
689 
690  /// Handler arbitrates between both feeds A and B.
691  BothFeedsWithArbitrage
692  };
693 };
694 
695 /// Appends string presentation of feed layout.
697 void toStr(std::string&, RealtimeFeedLayout::Enum);
698 
699 /// Returns string presentation of feed layout.
700 inline std::string toStr(RealtimeFeedLayout::Enum layout)
701 {
702  std::string str;
703 
704  toStr(str, layout);
705 
706  return str;
707 }
708 
709 /// Collection of parameters affecting real-time feeds behavior.
710 class ONIXS_CMEMDH_LTWT RealtimeFeedSettings : public FeedSettingsBase<RealtimeFeedLayout::Enum>
711 {
712 public:
713  /// Initializes instance with default values.
714  ///
715  /// By default, arbitrage between feeds A and B is done.
716  /// Heartbeats are expected within 30 seconds periodicity.
718  : Base(group, RealtimeFeedLayout::BothFeedsWithArbitrage, 30)
719  , outOfOrderPacketMaxInterval_(3)
720  , lostPacketWaitTime_(100000)
721  {
722  }
723 
724  /// Initializes the instance
725  /// as a copy of the other one.
727  : Base(static_cast<const Base&>(other))
728  , outOfOrderPacketMaxInterval_(other.outOfOrderPacketMaxInterval_)
729  , lostPacketWaitTime_(other.lostPacketWaitTime_)
730  {
731  }
732 
733  /// Finalizes the instance.
735 
736  /// Defines a threshold used by the Handler
737  /// while handling out-of-order incoming packets.
738  ///
739  /// Due to the unreliable nature of multicast, packets may be missed
740  /// or received in an order different from the expected. The Handler
741  /// uses the given parameter to establish a threshold for incoming
742  /// packets whose sequence numbers are greater than expected unless
743  /// the expected packets are received or recognized as lost.
744  ///
745  /// When the Handler receives a packet with the sequence number higher
746  /// than expected, it considers the incoming packet as out-of-order. It
747  /// puts the packet into an internal queue if its sequence number does
748  /// not exceed the established threshold. The threshold represents the
749  /// sum of the last accepted packet's sequence number and the value of
750  /// the given parameter.
751  ///
752  /// Packets are queued unless the expected ones are received, or their
753  /// sequence numbers exceed the threshold, or the time limit is reached.
754  /// If the incoming packet's sequence number exceeds the established
755  /// threshold, the Handler raises the gap event.
756  ///
757  /// If arbitrage between primary and secondary feeds is enabled, the
758  /// Handler does not trigger the gap event until incoming packets from
759  /// both feeds exceed the established threshold.
760  ///
761  /// @see 'lostPacketWaitTime' parameter for more information.
762  ///
763  /// @note The default value is '3'.
765  {
766  return outOfOrderPacketMaxInterval_;
767  }
768 
769  /// Defines value of threshold used by the Handler
770  /// while handling out-of-order incoming packets.
772  {
773  group().controlAssignment("Out Of Order Packet Max Interval", outOfOrderPacketMaxInterval_, intervalLength);
774 
775  return *this;
776  }
777 
778  /// Indicates the time limit for the Handler while waiting
779  /// for expected packets before they are considered lost.
780  ///
781  /// When the Handler receives a packet with the sequence number greater
782  /// than expected, it considers the received data as out-of-order. The
783  /// Handler resumes normal data processing if it receives missing data
784  /// during the given time interval.
785  ///
786  /// However, if expected packets aren't received for a predefined time
787  /// frame, the Handler considers expected data as lost and raises the
788  /// gap event. The given parameter defines a time interval the Handler
789  /// waits for expected packets.
790  ///
791  /// @note The given parameter is used in combination with the
792  /// 'outOfOrderPacketMaxInterval' parameter.
793  ///
794  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
795  ///
796  /// The time interval is measured in microseconds (usec).
797  ///
798  /// @note The default value is '100000' (100 milliseconds).
800  {
801  return lostPacketWaitTime_;
802  }
803 
804  /// Defines the time limit for the Handler while waiting
805  /// for expected packets before they considered as lost.
807  {
808  group().controlAssignment("Lost Packet Wait Time", lostPacketWaitTime_, waitTime);
809 
810  return *this;
811  }
812 
813  /// Re-initializes the instance
814  /// as a copy of the other one.
816  {
817  group().controlChange("Realtime Feed Settings", &RealtimeFeedSettings::assignNoControl, *this, other);
818 
819  return *this;
820  }
821 
822 private:
824 
826 
827  UInt32 outOfOrderPacketMaxInterval_;
828  UInt32 lostPacketWaitTime_;
829 
830  void assignNoControl(const RealtimeFeedSettings& other)
831  {
832  Base::assignNoControl(other);
833 
834  outOfOrderPacketMaxInterval_ = other.outOfOrderPacketMaxInterval_;
835 
836  lostPacketWaitTime_ = other.lostPacketWaitTime_;
837  }
838 };
839 
840 /// Serializes feed settings into string.
842 void toStr(std::string&, const RealtimeFeedSettings&);
843 
844 /// Serializes feed settings into string.
845 inline std::string toStr(const RealtimeFeedSettings& settings)
846 {
847  std::string str;
848 
849  toStr(str, settings);
850 
851  return str;
852 }
853 
854 /// To optimally service customers and meet regulatory requirements for
855 /// out-of-region recovery capabilities and timelines, CME Group utilizes
856 /// a two data center model comprised of a Primary and a Disaster Recovery
857 /// (DR) data center. The given enumeration class defines available kinds
858 /// of the data centers.
860 {
861  /// Integral type used as basement for constants.
862  typedef UInt32 Base;
863 
864  /// To optimally service customers and meet regulatory requirements
865  /// for out-of-region recovery capabilities and timelines, CME Group
866  /// utilizes a two data center model comprised of a Primary and a
867  /// Disaster Recovery (DR) data center. The given enumeration class
868  /// defines available kinds of the data centers.
869  enum Enum
870  {
871  /// Indicates the primary data center,
872  /// which houses all CME applications.
874 
875  /// Indicates data center used in case of disaster.
876  DisasterRecovery
877  };
878 };
879 
880 /// Appends string presentation of the given data center.
882 void toStr(std::string&, DataCenter::Enum);
883 
884 /// Returns string presentation of feed layout.
885 inline std::string toStr(DataCenter::Enum layout)
886 {
887  std::string str;
888 
889  toStr(str, layout);
890 
891  return str;
892 }
893 
894 /// The parameters affecting all feeds
895 /// involved into market data processing.
897 {
898 public:
899  /// Initializes the instance with the default values.
901  : SettingGroup(controller)
902  , packetMaxSize_(1420)
903  , incrementalFeeds_(&group())
904  , instrumentFeeds_(&group())
905  , snapshotFeeds_(&group())
906  , mboSnapshotFeeds_(&group())
907  , historicalFeeds_(&group())
908  , engine_()
909  {
910  }
911 
912  /// Initializes the instance
913  /// as a copy of the other one.
915  : SettingGroup()
916  , packetMaxSize_(other.packetMaxSize_)
917  , incrementalFeeds_(other.incrementalFeeds_)
918  , instrumentFeeds_(other.instrumentFeeds_)
919  , snapshotFeeds_(other.snapshotFeeds_)
920  , mboSnapshotFeeds_(other.mboSnapshotFeeds_)
921  , historicalFeeds_(other.historicalFeeds_)
922  , engine_(other.engine_)
923  {
924  }
925 
926  /// Specifies one or more network interfaces on which to
927  /// join multicast groups referring to primary (A) feeds.
928  ///
929  /// Multiple interfaces can be specified using semi-colon
930  /// as a delimiter.
931  ///
932  /// The given member is kind of batch set-up. Manual
933  /// specification of network interfaces for a particular
934  /// feed is also possible through the corresponding
935  /// parameters.
936  FeedSettings& feedANetworkInterfaces(const std::string& interfaces)
937  {
938  group().controlChange(
939  "Feed A Network Interfaces for All Feeds", &FeedSettings::assignFeedAInterfaces, *this, interfaces
940  );
941 
942  return *this;
943  }
944 
945  /// Specifies one or more network interfaces on which to
946  /// join multicast groups referring to secondary (B) feeds.
947  ///
948  /// Multiple interfaces can be specified using semi-colon
949  /// as a delimiter.
950  ///
951  /// The given member is kind of batch set-up. Manual
952  /// specification of network interfaces for a particular
953  /// feed is also possible through the corresponding
954  /// parameters.
955  FeedSettings& feedBNetworkInterfaces(const std::string& interfaces)
956  {
957  group().controlChange(
958  "Feed B Network Interfaces for All Feeds", &FeedSettings::assignFeedBInterfaces, *this, interfaces
959  );
960 
961  return *this;
962  }
963 
964  /// Max size for network packet transmitted by MDP.
965  ///
966  /// @note Default value is '1420'.
968  {
969  return packetMaxSize_;
970  }
971 
972  /// Max size for network packet transmitted by MDP.
974  {
975  group().controlAssignment("Packet Max Size", packetMaxSize_, value);
976 
977  return *this;
978  }
979 
980  /// The settings related to incremental feeds.
982  {
983  return incrementalFeeds_;
984  }
985 
986  /// The settings related to incremental feeds.
988  {
989  return incrementalFeeds_;
990  }
991 
992  /// The settings related to instrument feeds.
994  {
995  return instrumentFeeds_;
996  }
997 
998  /// The settings related to instrument feeds.
1000  {
1001  return instrumentFeeds_;
1002  }
1003 
1004  /// The settings related to snapshot feeds.
1006  {
1007  return snapshotFeeds_;
1008  }
1009 
1010  /// The settings related to snapshot feeds.
1012  {
1013  return snapshotFeeds_;
1014  }
1015 
1016  /// The settings related to snapshot feeds.
1018  {
1019  return mboSnapshotFeeds_;
1020  }
1021 
1022  /// The settings related to snapshot feeds.
1024  {
1025  return mboSnapshotFeeds_;
1026  }
1027 
1028  /// The settings related to historical (TCP recovery) feeds.
1030  {
1031  return historicalFeeds_;
1032  }
1033 
1034  /// The settings related to historical (TCP Recovery) feeds.
1036  {
1037  return historicalFeeds_;
1038  }
1039 
1040  /// Instance of the Feed Engine to be used by the Handler.
1041  /// Null instance means no feed engine is yet defined.
1043  {
1044  return engine_.get();
1045  }
1046 
1047  /// Defines instance of the Feed Engine to be used by the Handler.
1049  {
1050  group().controlAssignment("Feed Engine", engine_, NetFeedEngineController(engine));
1051 
1052  return *this;
1053  }
1054 
1055  /// Re-initializes the instance
1056  /// as a copy of the other one.
1058  {
1059  group().controlChange("Feed Settings", &FeedSettings::assignNoControl, *this, other);
1060 
1061  return *this;
1062  }
1063 
1064 private:
1065  friend ONIXS_CMEMDH_LTWT_CLASS_DECL(PcapReplayHelper);
1066 
1067  // To let assignment be controlled
1068  // by the master container.
1070 
1071  /// Holds a reference to `NetFeedEngine`.
1072  /// \private
1073  class ONIXS_CMEMDH_EXPORTED NetFeedEngineController
1074  {
1075  public:
1076  ///
1077  NetFeedEngineController();
1078 
1079  ///
1080  explicit NetFeedEngineController(NetFeedEngine*);
1081 
1082  ///
1083  NetFeedEngineController(const NetFeedEngineController&);
1084 
1085  ///
1086  ~NetFeedEngineController();
1087 
1088  ///
1089  NetFeedEngineController& operator=(const NetFeedEngineController& other)
1090  {
1091  NetFeedEngineController tmp(other);
1092  tmp.swap(*this);
1093  return *this;
1094  }
1095 
1096  ///
1097  NetFeedEngine* get() const
1098  {
1099  return engine_;
1100  }
1101 
1102  ///
1103  void swap(NetFeedEngineController& other)
1104  {
1105  std::swap(engine_, other.engine_);
1106  std::swap(owned_, other.owned_);
1107  }
1108 
1109  private:
1110  NetFeedEngine* engine_;
1111  bool owned_;
1112  };
1113 
1114  PacketSize packetMaxSize_;
1115 
1116  RealtimeFeedSettings incrementalFeeds_;
1117 
1118  MulticastRecoveryFeedSettings instrumentFeeds_;
1119  MulticastRecoveryFeedSettings snapshotFeeds_;
1120  MulticastRecoveryFeedSettings mboSnapshotFeeds_;
1121 
1122  TcpRecoveryFeedSettings historicalFeeds_;
1123 
1124  NetFeedEngineController engine_;
1125 
1126  // Casts the given instance to an
1127  // instance of SettingGroup class.
1128  const SettingGroup& group() const
1129  {
1130  return *this;
1131  }
1132 
1133  // Re-initializes the given instance
1134  // as a copy of the other one without
1135  // involving assignment control service.
1136  void assignNoControl(const FeedSettings& other)
1137  {
1138  packetMaxSize_ = other.packetMaxSize_;
1139 
1140  incrementalFeeds_.assignNoControl(other.incrementalFeeds_);
1141 
1142  instrumentFeeds_.assignNoControl(other.instrumentFeeds_);
1143 
1144  snapshotFeeds_.assignNoControl(other.snapshotFeeds_);
1145 
1146  mboSnapshotFeeds_.assignNoControl(other.mboSnapshotFeeds_);
1147 
1148  historicalFeeds_.assignNoControl(other.historicalFeeds_);
1149 
1150  engine_ = other.engine_;
1151  }
1152 
1153  // Updates interfaces for all primary feeds
1154  // without involving assignment control services.
1155  void assignFeedAInterfaces(const std::string& interfaces)
1156  {
1157  NifListSetting nifs;
1158 
1159  fromStr(nifs, interfaces);
1160 
1161  incrementalFeeds_.A().networkInterfaces().assignNoControl(nifs);
1162 
1163  instrumentFeeds_.A().networkInterfaces().assignNoControl(nifs);
1164 
1165  snapshotFeeds_.A().networkInterfaces().assignNoControl(nifs);
1166 
1167  mboSnapshotFeeds_.A().networkInterfaces().assignNoControl(nifs);
1168 
1169  historicalFeeds_.A().networkInterfaces().assignNoControl(nifs);
1170  }
1171 
1172  // Updates interfaces for all primary feeds
1173  // without involving assignment control services.
1174  void assignFeedBInterfaces(const std::string& interfaces)
1175  {
1176  NifListSetting nifs;
1177 
1178  fromStr(nifs, interfaces);
1179 
1180  incrementalFeeds_.B().networkInterfaces().assignNoControl(nifs);
1181 
1182  instrumentFeeds_.B().networkInterfaces().assignNoControl(nifs);
1183 
1184  snapshotFeeds_.B().networkInterfaces().assignNoControl(nifs);
1185 
1186  mboSnapshotFeeds_.B().networkInterfaces().assignNoControl(nifs);
1187 
1188  historicalFeeds_.B().networkInterfaces().assignNoControl(nifs);
1189  }
1190 };
1191 
1192 /// Serializes feed settings into string.
1194 void toStr(std::string&, const FeedSettings&);
1195 
1196 /// Serializes feed settings into string.
1197 inline std::string toStr(const FeedSettings& settings)
1198 {
1199  std::string str;
1200 
1201  toStr(str, settings);
1202 
1203  return str;
1204 }
1205 
1206 /// Retrieves connection settings from the given connectivity
1207 /// configuration file for the given channel and fills correspondent
1208 /// parameters in the given FeedSettings instance.
1209 ///
1210 /// If the configuration file includes connectivity settings for
1211 /// both primary and disaster recovery data centers, the additional
1212 /// parameter allows to control which settings are to be extracted.
1215  FeedSettings&,
1216  const std::string&,
1217  ChannelId,
1218  DataCenter::Enum = DataCenter::Primary
1219 );
1220 
Feed B is used as primary source of market data.
Definition: FeedSettings.h:688
FeedSettings & operator=(const FeedSettings &other)
Re-initializes the instance as a copy of the other one.
FeedConnectionSettings & hosts(const std::string &hosts)
Updates list of hosts for the given connection settings from a string representing comma or semi-colo...
Definition: FeedSettings.h:149
~FeedConnectionSettings()
Finalizes the instance.
Definition: FeedSettings.h:73
Handler&#39;s configuration settings.
FeedSettings & feedBNetworkInterfaces(const std::string &interfaces)
Specifies one or more network interfaces on which to join multicast groups referring to secondary (B)...
Definition: FeedSettings.h:955
FeedConnectionSettings & id(const std::string &id)
Updates the connection/feed identifier.
Definition: FeedSettings.h:196
HostListSetting & hosts()
Updates list of hosts for the given connection settings.
Definition: FeedSettings.h:134
UInt32 connectionAttempts() const
Number of times the Handler must try recovering from the other feed if it fails to recover from the p...
Definition: FeedSettings.h:553
MulticastRecoveryFeedSettings & operator=(const MulticastRecoveryFeedSettings &other)
Re-initializes the instance as a copy of the other one.
Definition: FeedSettings.h:484
const TcpRecoveryFeedSettings & historicalFeeds() const
The settings related to historical (TCP recovery) feeds.
FeedSettings & feedANetworkInterfaces(const std::string &interfaces)
Specifies one or more network interfaces on which to join multicast groups referring to primary (A) f...
Definition: FeedSettings.h:936
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:416
To optimally service customers and meet regulatory requirements for out-of-region recovery capabiliti...
Definition: FeedSettings.h:859
const FeedConnectionSettings & A() const
Connection attributes for the primary (A) feed.
Definition: FeedSettings.h:294
const NifListSetting & networkInterfaces() const
List of network interfaces for the given connection settings.
Definition: FeedSettings.h:161
FeedConnectionSettings & networkInterfaces(const std::string &interfaces)
Specifies one or more network interfaces on which to join the multicast group if the settings define ...
Definition: FeedSettings.h:182
MulticastRecoveryFeedSettings(const MulticastRecoveryFeedSettings &other)
Initializes the instance as a copy of the other one.
Definition: FeedSettings.h:475
ListSetting< std::string > HostListSetting
List of hosts as a setting.
Definition: FeedSettings.h:31
TcpRecoveryFeedSettings & connectionTimeout(UInt32 connectionTimeout)
Interval between the attempts to receive missed packets via the TCP recovery feed if previous attempt...
Definition: FeedSettings.h:585
UInt32 UInt32
uInt32.
Definition: Fields.h:192
const HostListSetting & hosts() const
Indicates host list of the given connection settings.
Definition: FeedSettings.h:120
#define ONIXS_CMEMDH_NULLPTR
Definition: Compiler.h:145
UInt32 ChannelId
Identifies CME channel.
Definition: Domain.h:28
Layout layout() const
Defines feed layout for a feed group.
Definition: FeedSettings.h:255
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:862
UInt32 port() const
Port component of the given connection settings.
Definition: FeedSettings.h:76
FeedSettings(const FeedSettings &other)
Initializes the instance as a copy of the other one.
Definition: FeedSettings.h:914
const RealtimeFeedSettings & incrementalFeeds() const
The settings related to incremental feeds.
Definition: FeedSettings.h:981
Collection of parameters which are common for all types of feeds.
Definition: FeedSettings.h:251
TcpRecoveryFeedSettings(const SettingGroup *group=nullptr)
Initializes instance with default values.
Definition: FeedSettings.h:527
FeedConnectionSettings & ip(const std::string &address)
Updates address component of the given connection settings.
Definition: FeedSettings.h:104
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:424
UInt32 connectionTimeout() const
Interval between the attempts to receive missed packets via the TCP recovery feed if previous attempt...
Definition: FeedSettings.h:575
TcpRecoveryFeedSettings & historicalFeeds()
The settings related to historical (TCP Recovery) feeds.
RealtimeFeedSettings(const RealtimeFeedSettings &other)
Initializes the instance as a copy of the other one.
Definition: FeedSettings.h:726
Indicates the primary data center, which houses all CME applications.
Definition: FeedSettings.h:873
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition: Bootstrap.h:35
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
const std::string & id() const
The unique connection/feed identifier.
Definition: FeedSettings.h:190
UInt32 outOfOrderPacketMaxInterval() const
Defines a threshold used by the Handler while handling out-of-order incoming packets.
Definition: FeedSettings.h:764
RealtimeFeedSettings & operator=(const RealtimeFeedSettings &other)
Re-initializes the instance as a copy of the other one.
Definition: FeedSettings.h:815
Abstraction for the Feed Engine machinery.
Definition: FeedEngine.h:101
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:421
void controlAssignment(const Char *description, Assignee &assignee, Value value) const
Guarded assignment of the given value to the given variable.
Definition: SettingGroup.h:107
FeedSettingsBase(const SettingGroup *group, Layout layout, UInt32 heartbeat)
Initializes the instance with the given values and optional grouping.
Definition: FeedSettings.h:352
NifListSetting & networkInterfaces()
List of network interfaces for the given connection settings.
Definition: FeedSettings.h:171
Defines feed layout alternates available for recovery feeds like instrument and snapshot.
Definition: FeedSettings.h:413
Collection of parameters affecting real-time feeds behavior.
Definition: FeedSettings.h:710
UInt32 lostPacketWaitTime() const
Indicates the time limit for the Handler while waiting for expected packets before they are considere...
Definition: FeedSettings.h:799
FeedConnectionSettings & A()
Connection attributes for the primary (A) feed.
Definition: FeedSettings.h:288
FeedConnectionSettings & port(UInt32 port)
Updates port number for the given connection settings.
Definition: FeedSettings.h:82
FeedSettingsBase(const FeedSettingsBase &other)
Initializes the instance as a copy of the other one.
Definition: FeedSettings.h:367
FeedSettingsBase & feedBNetworkInterfaces(const std::string &interfaces)
Specifies one or more network interfaces to use for secondary (B) feeds while joining the multicast g...
Definition: FeedSettings.h:338
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
TcpRecoveryFeedSettings & operator=(const TcpRecoveryFeedSettings &other)
Re-initializes the instance as a copy of the other one.
Definition: FeedSettings.h:614
MulticastRecoveryFeedSettings & snapshotFeeds()
The settings related to snapshot feeds.
FeedSettings(SettingChangeController *controller=nullptr)
Initializes the instance with the default values.
Definition: FeedSettings.h:900
void assignNoControl(const FeedSettingsBase &other)
Re-initializes the instance as a copy of the other one without involving assignment control services...
Definition: FeedSettings.h:389
std::string toStr(const FeedSettings &settings)
Serializes feed settings into string.
Enum
To optimally service customers and meet regulatory requirements for out-of-region recovery capabiliti...
Definition: FeedSettings.h:869
~RealtimeFeedSettings()
Finalizes the instance.
Definition: FeedSettings.h:734
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:667
RealtimeFeedSettings & lostPacketWaitTime(UInt32 waitTime)
Defines the time limit for the Handler while waiting for expected packets before they considered as l...
Definition: FeedSettings.h:806
HostListSetting NifListSetting
List of network interfaces as a setting.
Definition: FeedSettings.h:37
FeedSettings & engine(NetFeedEngine *engine)
Defines instance of the Feed Engine to be used by the Handler.
~TcpRecoveryFeedSettings()
Finalizes the instance.
Definition: FeedSettings.h:546
Feed A is used as primary source of market data.
Definition: FeedSettings.h:433
const std::string & ip() const
Indicates address component of the given connection settings.
Definition: FeedSettings.h:94
MulticastRecoveryFeedSettings(const SettingGroup *group=nullptr)
Initializes instance with default values.
Definition: FeedSettings.h:469
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:91
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:670
RealtimeFeedSettings & outOfOrderPacketMaxInterval(UInt32 intervalLength)
Defines value of threshold used by the Handler while handling out-of-order incoming packets...
Definition: FeedSettings.h:771
Collection of parameters affecting recovery feeds behavior.
Definition: FeedSettings.h:461
NetFeedEngine * engine() const
Instance of the Feed Engine to be used by the Handler.
~MulticastRecoveryFeedSettings()
Finalizes the instance.
Definition: FeedSettings.h:481
const SettingGroup & group() const
Instance of the group which the given settings belong to.
Definition: FeedSettings.h:381
const MulticastRecoveryFeedSettings & mboSnapshotFeeds() const
The settings related to snapshot feeds.
void connectivityFromConfiguration(FeedSettings &, const std::string &, ChannelId, DataCenter::Enum=DataCenter::Primary)
Retrieves connection settings from the given connectivity configuration file for the given channel an...
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:135
TcpRecoveryFeedSettings(const TcpRecoveryFeedSettings &other)
Initializes the instance as a copy of the other one.
Definition: FeedSettings.h:537
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:48
FeedConnectionSettings(const FeedConnectionSettings &other)
Initializes the given instance as a copy of the other one.
Definition: FeedSettings.h:62
PacketSize packetMaxSize() const
Max size for network packet transmitted by MDP.
Definition: FeedSettings.h:967
const MulticastRecoveryFeedSettings & snapshotFeeds() const
The settings related to snapshot feeds.
const FeedConnectionSettings & B() const
Connection attributes for the secondary (B) feed.
Definition: FeedSettings.h:306
ListSetting & assignNoControl(const ListSetting &other)
Unmanaged assignment of the list.
Definition: SettingGroup.h:301
const MulticastRecoveryFeedSettings & instrumentFeeds() const
The settings related to instrument feeds.
Definition: FeedSettings.h:993
void fromStr(HostListSetting &, const std::string &)
Deserializes host list setting from a string.
FeedConnectionSettings & operator=(const FeedConnectionSettings &other)
Re-initializes the instance as a copy of the other one.
Definition: FeedSettings.h:204
The parameters affecting all feeds involved into market data processing.
Definition: FeedSettings.h:896
Represents a service controlling change/update operations for the collections of settings.
Definition: SettingGroup.h:33
UInt32 sendTimeout() const
Time limit for the send operation.
Definition: FeedSettings.h:597
RealtimeFeedSettings(const SettingGroup *group=nullptr)
Initializes instance with default values.
Definition: FeedSettings.h:717
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:662
FeedConnectionSettings & B()
Connection attributes for the secondary (B) feed.
Definition: FeedSettings.h:300
Defines feed layout alternates available for real-time feed like incremental one. ...
Definition: FeedSettings.h:659
TcpRecoveryFeedSettings & sendTimeout(UInt32 sendTimeout)
Time limit for the send operation.
Definition: FeedSettings.h:605
FeedSettingsBase & feedANetworkInterfaces(const std::string &interfaces)
Specifies one or more network interfaces to use for primary (A) feeds while joining the multicast gro...
Definition: FeedSettings.h:322
FeedSettingsBase & layout(Layout value)
Defines feed layout for recovery feed group.
Definition: FeedSettings.h:261
MulticastRecoveryFeedSettings & instrumentFeeds()
The settings related to instrument feeds.
Definition: FeedSettings.h:999
Feed A is used as primary source of market data.
Definition: FeedSettings.h:679
FeedSettings & packetMaxSize(PacketSize value)
Max size for network packet transmitted by MDP.
Definition: FeedSettings.h:973
UInt16 PacketSize
Integral type for measuring packets.
Definition: PacketTraits.h:32
RealtimeFeedSettings & incrementalFeeds()
The settings related to incremental feeds.
Definition: FeedSettings.h:987
FeedConnectionSettings(const SettingGroup *group=nullptr)
Initializes as a blank instance.
Definition: FeedSettings.h:52
TcpRecoveryFeedSettings & connectionAttempts(UInt32 attemptQty)
Number of times the Handler must try recovering from the other feed if it fails to recover from the p...
Definition: FeedSettings.h:561
FeedSettingsBase & heartbeatInterval(UInt32 interval)
Specifies maximal time interval between two packets.
Definition: FeedSettings.h:280
UInt32 heartbeatInterval() const
Specifies maximal time interval between two network packets.
Definition: FeedSettings.h:274
MulticastRecoveryFeedSettings & mboSnapshotFeeds()
The settings related to snapshot feeds.
void controlChange(const Char *description, void(Changeable::*change)(), Changeable &changeable) const
Guarded invoke of the given routine which assumes complex change or update for the given object...
Definition: SettingGroup.h:118
Collection of parameters affecting recovery feeds behavior.
Definition: FeedSettings.h:519
The collection of parameters defining feed connection.
Definition: FeedSettings.h:44
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68