OnixS C++ CME Market Data Handler  5.7.0
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  NetFeedEngine
34 );
35 
36 /// List of hosts as a setting.
37 typedef
40 
41 /// List of network interfaces as a setting.
42 typedef
45 
46 /// Deserializes host list setting from a string.
47 ONIXS_CMEMDH_EXPORTED
48 void
49 fromStr(
51  const std::string&);
52 
53 /// The collection of parameters defining feed connection.
56 {
57  const SettingGroup& group_;
58 
59  UInt32 port_;
60  std::string ip_;
61 
62  HostListSetting hosts_;
63  NifListSetting nifs_;
64 
65  std::string id_;
66 
67  // Non-guarded assignment.
68  void
69  assignNoControl(
70  const
72  {
73  port_ = other.port_;
74  ip_ = other.ip_;
75 
76  hosts_.assignNoControl(other.hosts_);
77  nifs_.assignNoControl(other.nifs_);
78 
79  id_ = other.id_;
80  }
81 
82 public:
83  // Makes assignment more flexible.
84  template
85  <
86  class
87  >
88  friend
90  (
92  );
93 
94  /// Initializes as a blank instance.
96  const SettingGroup* group = NULL)
97  : group_(
98  group
99  ? *group
100  : SettingGroup::null())
101  , port_(0)
102  , hosts_(group)
103  , nifs_(group)
104  {
105  }
106 
107  /// Initializes the given instance
108  /// as a copy of the other one.
110  const FeedConnectionSettings& other)
111  : group_(SettingGroup::null())
112  , port_(other.port_)
113  , ip_(other.ip_)
114  , hosts_(other.hosts_)
115  , nifs_(other.nifs_)
116  , id_(other.id_)
117  {
118  }
119 
120  /// Finalizes the instance.
122  {
123  }
124 
125  /// Port component of the given connection settings.
126  UInt32 port() const
127  {
128  return port_;
129  }
130 
131  /// Updates port number for the given connection settings.
133  port(
134  UInt32 port)
135  {
136  group_.
137  controlAssignment
138  (
139  "Port",
140  port_,
141  port
142  );
143 
144  return *this;
145  }
146 
147  /// Indicates address component of the given connection settings.
148  ///
149  /// For the multicast type of connection the given parameter indicates
150  /// a multicast group to join to. For the streamed/TCP connections the
151  /// given parameter indicates the remote host to connect to.
152  const
153  std::string&
154  ip() const
155  {
156  return ip_;
157  }
158 
159  /// Updates address component of the given connection settings.
160  ///
161  /// For the multicast type of connection the given parameter indicates
162  /// a multicast group to join to. For the streamed/TCP connections the
163  /// given parameter indicates the remote host to connect to.
165  ip(
166  const std::string& address)
167  {
168  group_.
169  controlAssignment
170  (
171  "IP Address",
172  ip_,
173  address
174  );
175 
176  return *this;
177  }
178 
179  /// Indicates host list of the given connection settings.
180  ///
181  /// This component is the optional one and may be used to supply
182  /// additional information on the connection. For example, if the
183  /// connection is the multicast one, the given parameter represents
184  /// a list of remote hosts from which the multicast data is actually
185  /// transmitted. Also, CME doesn't use IP parameter while defining
186  /// connections for the TCP Recovery feeds in the connectivity
187  /// configuration file (config.xml). Instead, this one is used.
188  const
190  hosts() const
191  {
192  return hosts_;
193  }
194 
195  /// Updates list of hosts for the given connection settings.
196  ///
197  /// This component is the optional one and may be used to supply
198  /// additional information on the connection. For example, if the
199  /// connection is the multicast one, the given parameter represents
200  /// a list of remote hosts from which the multicast data is actually
201  /// transmitted. Also, CME doesn't use IP parameter while defining
202  /// connections for the TCP Recovery feeds in the connectivity
203  /// configuration file (config.xml). Instead, this one is used.
205  hosts()
206  {
207  return hosts_;
208  }
209 
210  /// Updates list of hosts for the given connection settings from a
211  /// string representing comma or semi-colon separated list of hosts.
212  ///
213  /// This component is the optional one and may be used to supply
214  /// additional information on the connection. For example, if the
215  /// connection is the multicast one, the given parameter represents
216  /// a list of remote hosts from which the multicast data is actually
217  /// transmitted. Also, CME doesn't use IP parameter while defining
218  /// connections for the TCP Recovery feeds in the connectivity
219  /// configuration file (config.xml). Instead, this one is used.
221  hosts(
222  const std::string& hosts)
223  {
224  fromStr(hosts_, hosts);
225 
226  return *this;
227  }
228 
229  /// List of network interfaces for the given connection settings.
230  ///
231  /// If the settings refers to a multicast group, the given parameter
232  /// indicates a list of network interfaces on which the multicast
233  /// data must be listen to.
234  const
236  networkInterfaces() const
237  {
238  return nifs_;
239  }
240 
241  /// List of network interfaces for the given connection settings.
242  ///
243  /// If the settings refers to a multicast group, the given parameter
244  /// indicates a list of network interfaces on which the multicast
245  /// data must be listen to.
247  networkInterfaces()
248  {
249  return nifs_;
250  }
251 
252  /// Specifies one or more network interfaces on which to join the
253  /// multicast group if the settings define multicast connection.
254  /// Use semi-colon delimited list to specify multiple interfaces.
255  ///
256  /// @note On Linux the network interface is specified by its name,
257  /// on Windows - by IP address.
259  networkInterfaces(
260  const std::string& interfaces)
261  {
262  fromStr(nifs_, interfaces);
263 
264  return *this;
265  }
267  /// The unique connection/feed identifier.
268  const
269  std::string&
270  id() const
271  {
272  return id_;
273  }
274 
275  /// Updates the connection/feed identifier.
277  id(
278  const
279  std::string& id)
280  {
281  group_.
282  controlAssignment
283  (
284  "Identifier",
285  id_,
286  id
287  );
288 
289  return *this;
290  }
291 
292  /// Re-initializes the instance as a copy of the other one.
294  operator =(
295  const
296  FeedConnectionSettings& other)
297  {
298  group_.
299  controlChange
300  (
301  "Feed Connection Settings",
302  &FeedConnectionSettings::assignNoControl,
303  *this,
304  other
305  );
306 
307  return *this;
308  }
309 };
310 
311 /// Serializes feed connection parameters into a string.
312 ONIXS_CMEMDH_EXPORTED
313 void
314 toStr(
315  std::string&,
316  const FeedConnectionSettings&);
317 
318 /// Serializes feed connection parameters into a string.
319 inline
320 std::string
322  const
323  FeedConnectionSettings& settings)
324 {
325  std::string str;
326 
327  toStr(str, settings);
328 
329  return str;
330 }
331 
332 /// Collection of parameters which are common for all types of feeds.
333 template
334 <
335  typename Layout
336 >
337 class
339 {
340  const SettingGroup& group_;
341 
342  Layout layout_;
343  UInt32 heartbeatInterval_;
344 
347 
349  operator =(
350  const
351  FeedSettingsBase& other);
352 
353 protected:
354  // Makes assignment more flexible.
355  friend
357  (
359  );
360 
361  /// Initializes the instance with the
362  /// given values and optional grouping.
364  const SettingGroup* group,
365  Layout layout, UInt32 heartbeat)
366  : group_(
367  group
368  ? *group
369  : SettingGroup::null())
370  , layout_(layout)
371  , heartbeatInterval_(heartbeat)
372  , A_(group)
373  , B_(group)
374  {
375  }
376 
377  /// Initializes the instance
378  /// as a copy of the other one.
379  ///
380  /// Attributes controlling value
381  /// assignment aren't cloned and
382  /// thus only settings are copied.
384  const
385  FeedSettingsBase& other)
386  : group_(SettingGroup::null())
387  , layout_(other.layout_)
388  , heartbeatInterval_(
389  other.heartbeatInterval_)
390  , A_(other.A_)
391  , B_(other.B_)
392  {
393  }
394 
395  // Finalizes the instance.
397  {
398  }
399 
400  /// Instance of the group which
401  /// the given settings belong to.
402  const
403  SettingGroup&
404  group() const
405  {
406  return group_;
407  }
408 
409  /// Re-initializes the instance as a
410  /// copy of the other one without involving
411  /// assignment control services.
412  void
413  assignNoControl(
414  const FeedSettingsBase& other)
415  {
416  layout_ =
417  other.layout_;
418 
419  heartbeatInterval_ =
420  other.heartbeatInterval_;
421 
422  A_.assignNoControl(other.A_);
423  B_.assignNoControl(other.B_);
424  }
425 
426 public:
427  /// Defines feed layout for a feed group.
428  Layout layout() const
429  {
430  return layout_;
431  }
432 
433  /// Defines feed layout for recovery feed group.
435  layout(
436  Layout value)
437  {
438  group_.
439  controlAssignment
440  (
441  "Layout",
442  layout_,
443  value
444  );
445 
446  return *this;
447  }
448 
449  /// Specifies maximal time interval between two
450  /// network packets. If no data is received during
451  /// specified time frame, corresponding event is raised
452  /// and further behavior is defined by feed layout.
453  ///
454  /// Interval is measured in seconds.
455  UInt32
456  heartbeatInterval() const
457  {
458  return heartbeatInterval_;
459  }
460 
461  /// Specifies maximal time interval between two packets.
463  heartbeatInterval(
464  UInt32 interval)
465  {
466  group_.
467  controlAssignment
468  (
469  "Heartbeat Interval",
470  heartbeatInterval_,
471  interval
472  );
473 
474  return *this;
475  }
476 
477  /// Connection attributes for the primary (A) feed.
479  A()
480  {
481  return A_;
482  }
484  /// Connection attributes for the primary (A) feed.
485  const
487  A() const
488  {
489  return A_;
490  }
491 
492  /// Connection attributes for the secondary (B) feed.
494  B()
495  {
496  return B_;
497  }
499  /// Connection attributes for the secondary (B) feed.
500  const
502  B() const
503  {
504  return B_;
505  }
506 
507 #if !defined (ONIXS_CMEMDH_NO_DEPRECATED)
508 
509  /// Specifies one or more network interfaces to use for
510  /// primary (A) feeds while joining the multicast group.
511  /// Use semi-colon to delimit multiple interfaces.
512  ///
513  /// @note On Linux the network interface is specified
514  /// by its name, on Windows - by IP address.
515  ///
516  /// @warning The given member is deprecated.
517  /// Use feed connection settings instead.
519  feedANetworkInterfaces(
520  const std::string& interfaces)
521  {
522  A_.networkInterfaces(interfaces);
523 
524  return *this;
525  }
526 
527  /// Specifies one or more network interfaces to use for
528  /// secondary (B) feeds while joining the multicast group.
529  /// Use semi-colon to delimit multiple interfaces.
530  ///
531  /// @note On Linux the network interface is specified
532  /// by its name, on Windows - by IP address.
533  ///
534  /// @warning The given member is deprecated.
535  /// Use feed connection settings instead.
537  feedBNetworkInterfaces(
538  const std::string& interfaces)
539  {
540  B_.networkInterfaces(interfaces);
541 
542  return *this;
543  }
544 
545 #endif // !ONIXS_CMEMDH_NO_DEPRECATED
546 };
547 
548 /// Defines feed layout alternates available for
549 /// recovery feeds like instrument and snapshot.
551 {
552  /// Integral type used as basement for constants.
553  typedef UInt32 Base;
554 
555  enum Enum
556  {
557  /// Indicates only feed A is used as source for market data.
559 
560  /// Indicates only feed B is used as source for market data.
562 
563  /// Feed A is used as primary source of market data. If Handler
564  /// detects absence of market data on feed A, it switches to
565  /// feed B to continue market data processing. Feed B is used
566  /// by Handler until market data absence is detected on it. In
567  /// that case Handler will switch back to feed A. In other words,
568  /// this layout instructs Handler to cycle between feeds if data
569  /// absence is detected starting from feed A.
571 
572  /// Feed B is used as primary source of market data. If Handler
573  /// detects absence of market data on feed B, it switches to
574  /// feed A to continue market data processing. Feed A is used
575  /// by Handler until market data absence is detected on it. In
576  /// that case Handler will switch back to feed B. In other words,
577  /// this layout instructs Handler to cycle between feeds if data
578  /// absence is detected starting from feed B.
579  FeedBWithFailoverToFeedA
580  };
581 };
582 
583 /// Appends string presentation of feed layout.
584 ONIXS_CMEMDH_EXPORTED
585 void
586 toStr(
587  std::string&,
589 
590 /// Returns string presentation of feed layout.
591 inline
592 std::string
595 {
596  std::string str;
597 
598  toStr(str, layout);
599 
600  return str;
601 }
602 
603 /// Collection of parameters affecting recovery feeds behavior.
606 : public FeedSettingsBase
607  <
609  >
610 {
611  friend
613  (
615  );
616 
617  typedef
619  <
621  >
622  Base;
623 
624  void
625  assignNoControl(
626  const
628  {
629  Base::assignNoControl(other);
630  }
631 
632 public:
633  /// Initializes instance with default values.
634  ///
635  /// By default, feed A is used as the primary source
636  /// of market recovery data with fail-over to the feed B.
637  /// Heartbeats are expected within 30 seconds periodicity.
639  const SettingGroup* group = NULL)
640  : Base(
641  group,
643  FeedAWithFailoverToFeedB,
644  30)
645  {
646  }
647 
648  /// Initializes the instance as a copy of the other one.
650  const MulticastRecoveryFeedSettings& other)
651  : Base(static_cast<const Base&>(other))
652  {
653  }
654 
655  /// Finalizes the instance.
657  {
658  }
659 
660  /// Re-initializes the instance as a copy of the other one.
662  operator =(
663  const
665  {
666  group().
667  controlChange
668  (
669  "Multicast Recovery Feed Settings",
670  &MulticastRecoveryFeedSettings::assignNoControl,
671  *this,
672  other
673  );
674 
675  return *this;
676  }
677 };
678 
679 /// Serializes feed settings into string.
680 ONIXS_CMEMDH_EXPORTED
681 void
682 toStr(
683  std::string&,
685 
686 /// Serializes feed settings into string.
687 inline
688 std::string
690  const
692 {
693  std::string str;
694 
695  toStr(str, settings);
696 
697  return str;
698 }
699 
700 /// Collection of parameters affecting recovery feeds behavior.
703 : public FeedSettingsBase
704  <
706  >
707 {
708  // Makes assignment more flexible.
709  friend
711  (
713  );
714 
715  typedef
717  <
719  >
720  Base;
721 
722  UInt32 connectionAttempts_;
723  UInt32 connectionTimeout_;
724  UInt32 sendTimeout_;
725 
726  void
727  assignNoControl(
728  const TcpRecoveryFeedSettings& other)
729  {
730  Base::assignNoControl(other);
731 
732  connectionAttempts_ =
733  other.connectionAttempts_;
734 
735  connectionTimeout_ =
736  other.connectionTimeout_;
737 
738  sendTimeout_ =
739  other.sendTimeout_;
740  }
741 
742 public:
743  /// Initializes instance with default values.
744  ///
745  /// By default, feed A is used as the primary source
746  /// of market recovery data with fail-over to the feed B.
747  /// Heartbeats are expected within 2 seconds periodicity.
749  const SettingGroup* group = NULL)
750  : Base(
751  group,
753  FeedAOnly,
754  2)
755  , connectionAttempts_(3)
756  , connectionTimeout_(500)
757  , sendTimeout_(5000)
758  {
759  }
760 
761  /// Initializes the instance
762  /// as a copy of the other one.
764  const
766  : Base(
767  static_cast
768  <const Base&>
769  (other))
770  , connectionAttempts_(
771  other.connectionAttempts_)
772  , connectionTimeout_(
773  other.connectionTimeout_)
774  , sendTimeout_(
775  other.sendTimeout_)
776  {
777  }
778 
779  /// Finalizes the instance.
781  {
782  }
783 
784  /// Number of times the Handler must try
785  /// recovering from the other feed if it
786  /// fails to recover from the primary one.
787  ///
788  /// @note Default value is '3'.
789  UInt32
790  connectionAttempts() const
791  {
792  return connectionAttempts_;
793  }
794 
795  /// Number of times the Handler must try
796  /// recovering from the other feed if it
797  /// fails to recover from the primary one.
799  connectionAttempts(
800  UInt32 attemptQty)
801  {
802  group().
803  controlAssignment
804  (
805  "Connection Attempts",
806  connectionAttempts_,
807  attemptQty
808  );
809 
810  return *this;
811  }
812 
813  /// Interval between the attempts to receive
814  /// missed packets via the TCP recovery feed if
815  /// previous attempt either failed or was rejected.
816  ///
817  /// Interval is measured in milliseconds.
818  ///
819  /// @note Default value is '500'.
820  UInt32
821  connectionTimeout() const
822  {
823  return connectionTimeout_;
824  }
825 
826  /// Interval between the attempts to receive
827  /// missed packets via the TCP recovery feed if
828  /// previous attempt either failed or was rejected.
829  ///
830  /// Interval is measured in milliseconds.
832  connectionTimeout(
833  UInt32 connectionTimeout)
834  {
835  group().
836  controlAssignment
837  (
838  "Connection Timeout",
839  connectionTimeout_,
840  connectionTimeout
841  );
842 
843  return *this;
844  }
845 
846  /// Time limit for the send operation.
847  ///
848  /// Value is measured in milliseconds.
849  ///
850  /// @note Default value is '5000'.
851  UInt32
852  sendTimeout() const
853  {
854  return sendTimeout_;
855  }
856 
857  /// Time limit for the send operation.
858  ///
859  /// Value is measured in milliseconds.
861  sendTimeout(
862  UInt32 sendTimeout)
863  {
864  group().
865  controlAssignment
866  (
867  "Send Timeout",
868  sendTimeout_,
869  sendTimeout
870  );
871 
872  return *this;
873  }
875  /// Re-initializes the instance
876  /// as a copy of the other one.
878  operator =(
879  const
881  {
882  group().
883  controlChange
884  (
885  "TCP Recovery Feed Settings",
886  &TcpRecoveryFeedSettings::assignNoControl,
887  *this,
888  other
889  );
890 
891  return *this;
892  }
893 };
894 
895 /// Serializes feed settings into string.
896 ONIXS_CMEMDH_EXPORTED
897 void
898 toStr(
899  std::string&,
900  const TcpRecoveryFeedSettings&);
901 
902 /// Serializes feed settings into string.
903 inline
904 std::string
906  const TcpRecoveryFeedSettings& settings)
907 {
908  std::string str;
909 
910  toStr(str, settings);
911 
912  return str;
913 }
914 
915 /// Defines feed layout alternates available
916 /// for real-time feed like incremental one.
918 {
919  /// Integral type used as basement for constants.
920  typedef UInt32 Base;
921 
922  enum Enum
923  {
924  /// Indicates only feed A is used as source for market data.
926 
927  /// Indicates only feed B is used as source for market data.
929 
930  /// Feed A is used as primary source of market data. If Handler
931  /// detects absence of market data on feed A, it switches to
932  /// feed B to continue market data processing. Feed B is used
933  /// by Handler until market data absence is detected on it. In
934  /// that case Handler will switch back to feed A. In other words,
935  /// this layout instructs Handler to cycle between feeds if data
936  /// absence is detected starting from feed A.
938 
939  /// Feed B is used as primary source of market data. If Handler
940  /// detects absence of market data on feed B, it switches to
941  /// feed A to continue market data processing. Feed A is used
942  /// by Handler until market data absence is detected on it. In
943  /// that case Handler will switch back to feed B. In other words,
944  /// this layout instructs Handler to cycle between feeds if data
945  /// absence is detected starting from feed B.
947 
948  /// Handler arbitrates between both feeds A and B.
949  BothFeedsWithArbitrage
950  };
951 };
952 
953 /// Appends string presentation of feed layout.
954 ONIXS_CMEMDH_EXPORTED
955 void
956 toStr(
957  std::string&,
959 
960 /// Returns string presentation of feed layout.
961 inline
962 std::string
965 {
966  std::string str;
967 
968  toStr(str, layout);
969 
970  return str;
971 }
972 
973 /// Collection of parameters affecting real-time feeds behavior.
976 : public FeedSettingsBase
977  <
979  >
980 {
981  friend
983  (
985  );
986 
987  typedef
989  <
991  >
992  Base;
993 
994  UInt32 outOfOrderPacketMaxInterval_;
995  UInt32 lostPacketWaitTime_;
996 
997  void
998  assignNoControl(
999  const RealtimeFeedSettings& other)
1000  {
1001  Base::assignNoControl(other);
1002 
1003  outOfOrderPacketMaxInterval_ =
1004  other.outOfOrderPacketMaxInterval_;
1005 
1006  lostPacketWaitTime_ =
1007  other.lostPacketWaitTime_;
1008  }
1009 
1010 public:
1011  /// Initializes instance with default values.
1012  ///
1013  /// By default, arbitrage between feeds A and B is done.
1014  /// Heartbeats are expected within 30 seconds periodicity.
1016  const SettingGroup* group = NULL)
1017  : Base(
1018  group,
1020  BothFeedsWithArbitrage,
1021  30)
1022  , outOfOrderPacketMaxInterval_(3)
1023  , lostPacketWaitTime_(100000)
1024  {
1025  }
1026 
1027  /// Initializes the instance
1028  /// as a copy of the other one.
1030  const
1031  RealtimeFeedSettings& other)
1032  : Base(
1033  static_cast
1034  <const Base&>
1035  (other))
1036  , outOfOrderPacketMaxInterval_(
1037  other.outOfOrderPacketMaxInterval_)
1038  , lostPacketWaitTime_(
1039  other.lostPacketWaitTime_)
1040  {
1041  }
1042 
1043  /// Finalizes the instance.
1045  {
1046  }
1047 
1048  /// Defines a threshold used by the Handler
1049  /// while handling out-of-order incoming packets.
1050  ///
1051  /// Due to the unreliable nature of multicast, packets may be missed
1052  /// or received in an order different from the expected. The Handler
1053  /// uses the given parameter to establish a threshold for incoming
1054  /// packets whose sequence numbers are greater than expected unless
1055  /// the expected packets are received or recognized as lost.
1056  ///
1057  /// When the Handler receives a packet with the sequence number higher
1058  /// than expected, it considers the incoming packet as out-of-order. It
1059  /// puts the packet into an internal queue if its sequence number does
1060  /// not exceed the established threshold. The threshold represents the
1061  /// sum of the last accepted packet's sequence number and the value of
1062  /// the given parameter.
1063  ///
1064  /// Packets are queued unless the expected ones are received, or their
1065  /// sequence numbers exceed the threshold, or the time limit is reached.
1066  /// If the incoming packet's sequence number exceeds the established
1067  /// threshold, the Handler raises the gap event.
1068  ///
1069  /// If arbitrage between primary and secondary feeds is enabled, the
1070  /// Handler does not trigger the gap event until incoming packets from
1071  /// both feeds exceed the established threshold.
1072  ///
1073  /// @see 'lostPacketWaitTime' parameter for more information.
1074  ///
1075  /// @note The default value is '3'.
1076  UInt32
1077  outOfOrderPacketMaxInterval() const
1078  {
1079  return outOfOrderPacketMaxInterval_;
1080  }
1082  /// Defines value of threshold used by the Handler
1083  /// while handling out-of-order incoming packets.
1085  outOfOrderPacketMaxInterval(
1086  UInt32 intervalLength)
1087  {
1088  group().
1089  controlAssignment
1090  (
1091  "Out Of Order Packet Max Interval",
1092  outOfOrderPacketMaxInterval_,
1093  intervalLength
1094  );
1095 
1096  return *this;
1097  }
1098 
1099  /// Indicates the time limit for the Handler while waiting
1100  /// for expected packets before they are considered lost.
1101  ///
1102  /// When the Handler receives a packet with the sequence number greater
1103  /// than expected, it considers the received data as out-of-order. The
1104  /// Handler resumes normal data processing if it receives missing data
1105  /// during the given time interval.
1106  ///
1107  /// However, if expected packets aren't received for a predefined time
1108  /// frame, the Handler considers expected data as lost and raises the
1109  /// gap event. The given parameter defines a time interval the Handler
1110  /// waits for expected packets.
1111  ///
1112  /// @note The given parameter is used in combination with the
1113  /// 'outOfOrderPacketMaxInterval' parameter.
1114  ///
1115  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
1116  ///
1117  /// The time interval is measured in microseconds (usec).
1118  ///
1119  /// @note The default value is '100000' (100 milliseconds).
1120  UInt32
1121  lostPacketWaitTime() const
1122  {
1123  return lostPacketWaitTime_;
1124  }
1126  /// Defines the time limit for the Handler while waiting
1127  /// for expected packets before they considered as lost.
1129  lostPacketWaitTime(
1130  UInt32 waitTime)
1131  {
1132  group().
1133  controlAssignment
1134  (
1135  "Lost Packet Wait Time",
1136  lostPacketWaitTime_,
1137  waitTime
1138  );
1139 
1140  return *this;
1141  }
1143  /// Re-initializes the instance
1144  /// as a copy of the other one.
1146  operator =(
1147  const
1148  RealtimeFeedSettings& other)
1149  {
1150  group().
1151  controlChange
1152  (
1153  "Realtime Feed Settings",
1154  &RealtimeFeedSettings::assignNoControl,
1155  *this,
1156  other
1157  );
1158 
1159  return *this;
1160  }
1161 };
1162 
1163 /// Serializes feed settings into string.
1164 ONIXS_CMEMDH_EXPORTED
1165 void
1166 toStr(
1167  std::string&,
1168  const RealtimeFeedSettings&);
1169 
1170 /// Serializes feed settings into string.
1171 inline
1172 std::string
1174  const RealtimeFeedSettings& settings)
1175 {
1176  std::string str;
1177 
1178  toStr(str, settings);
1179 
1180  return str;
1181 }
1182 
1183 /// To optimally service customers and meet regulatory requirements for
1184 /// out-of-region recovery capabilities and timelines, CME Group utilizes
1185 /// a two data center model comprised of a Primary and a Disaster Recovery
1186 /// (DR) data center. The given enumeration class defines available kinds
1187 /// of the data centers.
1189 {
1190  /// Integral type used as basement for constants.
1191  typedef UInt32 Base;
1192 
1193  /// To optimally service customers and meet regulatory requirements
1194  /// for out-of-region recovery capabilities and timelines, CME Group
1195  /// utilizes a two data center model comprised of a Primary and a
1196  /// Disaster Recovery (DR) data center. The given enumeration class
1197  /// defines available kinds of the data centers.
1198  enum Enum
1199  {
1200  /// Indicates the primary data center,
1201  /// which houses all CME applications.
1203 
1204  /// Indicates data center used in case of disaster.
1205  DisasterRecovery
1206  };
1207 };
1208 
1209 /// Appends string presentation of the given data center.
1210 ONIXS_CMEMDH_EXPORTED
1211 void
1212 toStr(
1213  std::string&,
1215 
1216 /// Returns string presentation of feed layout.
1217 inline
1218 std::string
1220  DataCenter::Enum layout)
1221 {
1222  std::string str;
1223 
1224  toStr(str, layout);
1225 
1226  return str;
1227 }
1228 
1229 /// The parameters affecting all feeds
1230 /// involved into market data processing.
1232 FeedSettings : public SettingGroup
1233 {
1234  // To let assignment be controlled
1235  // by the master container.
1236  friend
1238  (
1240  );
1241 
1242  std::string configurationFile_;
1243  DataCenter::Enum dataCenter_;
1244 
1245  PacketSize packetMaxSize_;
1246 
1247  RealtimeFeedSettings incrementalFeeds_;
1248 
1249  MulticastRecoveryFeedSettings instrumentFeeds_;
1250  MulticastRecoveryFeedSettings snapshotFeeds_;
1251  MulticastRecoveryFeedSettings mboSnapshotFeeds_;
1252 
1253  TcpRecoveryFeedSettings historicalFeeds_;
1254 
1255  NetFeedEngine* engine_;
1256 
1257  // Casts the given instance to an
1258  // instance of SettingGroup class.
1259  const
1260  SettingGroup&
1261  group() const
1262  {
1263  return *this;
1264  }
1265 
1266  // Re-initializes the given instance
1267  // as a copy of the other one without
1268  // involving assignment control service.
1269  void
1270  assignNoControl(
1271  const FeedSettings& other)
1272  {
1273  configurationFile_ =
1274  other.configurationFile_;
1275 
1276  dataCenter_ = other.dataCenter_;
1277 
1278  packetMaxSize_ =
1279  other.packetMaxSize_;
1280 
1281  incrementalFeeds_.
1282  assignNoControl(
1283  other.incrementalFeeds_);
1284 
1285  instrumentFeeds_.
1286  assignNoControl(
1287  other.instrumentFeeds_);
1288 
1289  snapshotFeeds_.
1290  assignNoControl(
1291  other.snapshotFeeds_);
1292 
1293  mboSnapshotFeeds_.
1294  assignNoControl(
1295  other.mboSnapshotFeeds_);
1296 
1297  historicalFeeds_.
1298  assignNoControl(
1299  other.historicalFeeds_);
1300 
1301  engine_ = other.engine_;
1302  }
1303 
1304  // Updates interfaces for all primary feeds
1305  // without involving assignment control services.
1306  void
1307  assignFeedAInterfaces(
1308  const std::string& interfaces)
1309  {
1310  NifListSetting nifs;
1311 
1312  fromStr(nifs, interfaces);
1313 
1314  incrementalFeeds_.
1315  A().
1316  networkInterfaces().
1317  assignNoControl(nifs);
1318 
1319  instrumentFeeds_.
1320  A().
1321  networkInterfaces().
1322  assignNoControl(nifs);
1323 
1324  snapshotFeeds_.
1325  A().
1326  networkInterfaces().
1327  assignNoControl(nifs);
1328 
1329  mboSnapshotFeeds_.
1330  A().
1331  networkInterfaces().
1332  assignNoControl(nifs);
1333 
1334  historicalFeeds_.
1335  A().
1336  networkInterfaces().
1337  assignNoControl(nifs);
1338  }
1339 
1340  // Updates interfaces for all primary feeds
1341  // without involving assignment control services.
1342  void
1343  assignFeedBInterfaces(
1344  const std::string& interfaces)
1345  {
1346  NifListSetting nifs;
1347 
1348  fromStr(nifs, interfaces);
1349 
1350  incrementalFeeds_.
1351  B().
1352  networkInterfaces().
1353  assignNoControl(nifs);
1354 
1355  instrumentFeeds_.
1356  B().
1357  networkInterfaces().
1358  assignNoControl(nifs);
1359 
1360  snapshotFeeds_.
1361  B().
1362  networkInterfaces().
1363  assignNoControl(nifs);
1364 
1365  mboSnapshotFeeds_.
1366  B().
1367  networkInterfaces().
1368  assignNoControl(nifs);
1369 
1370  historicalFeeds_.
1371  B().
1372  networkInterfaces().
1373  assignNoControl(nifs);
1374  }
1375 
1376  /// Loads connectivity parameters from the given configuration file.
1377  void
1378  assignConnectivityConfiguration(
1379  const std::string& configurationFile,
1380  DataCenter::Enum dataCenter)
1381  {
1382  configurationFile_ =
1383  configurationFile;
1384 
1385  dataCenter_ =
1386  dataCenter;
1387  }
1388 
1389 public:
1390  /// Initializes the instance with the default values.
1391  FeedSettings(
1393  controller = NULL)
1394  : SettingGroup(controller)
1395  , dataCenter_(DataCenter::Primary)
1396  , packetMaxSize_(1420)
1397  , incrementalFeeds_(&group())
1398  , instrumentFeeds_(&group())
1399  , snapshotFeeds_(&group())
1400  , mboSnapshotFeeds_(&group())
1401  , historicalFeeds_(&group())
1402  , engine_(NULL)
1403  {
1404  }
1405 
1406  /// Initializes the instance
1407  /// as a copy of the other one.
1408  FeedSettings(
1409  const FeedSettings& other)
1410  : SettingGroup()
1411  , configurationFile_(
1412  other.configurationFile_)
1413  , dataCenter_(
1414  other.dataCenter_)
1415  , packetMaxSize_(
1416  other.packetMaxSize_)
1417  , incrementalFeeds_(
1418  other.incrementalFeeds_)
1419  , instrumentFeeds_(
1420  other.instrumentFeeds_)
1421  , snapshotFeeds_(
1422  other.snapshotFeeds_)
1423  , mboSnapshotFeeds_(
1424  other.mboSnapshotFeeds_)
1425  , historicalFeeds_(
1426  other.historicalFeeds_)
1427  , engine_(
1428  other.engine_)
1429  {
1430  }
1432  /// Path to the connectivity configuration file.
1433  const
1434  std::string&
1435  connectivityConfigurationFile() const
1436  {
1437  return configurationFile_;
1438  }
1439 
1440  /// Identifies the data center whose parameters are to
1441  /// be extracted from the connectivity configuration file.
1442  ///
1443  /// The connectivity configuration file may not include
1444  /// attributes for all kinds of data centers.
1446  dataCenter() const
1447  {
1448  return dataCenter_;
1449  }
1450 
1451  /// Path to the connectivity configuration file from which
1452  /// to load feed connection settings.
1453  ///
1454  /// The given parameter allows retrieving connectivity settings
1455  /// from the connectivity configuration file published by CME
1456  /// instead of manual setup.
1457  ///
1458  /// \warning The given parameter has lower priority comparing
1459  /// to feed connection settings. E.g., if connection parameters
1460  /// are manually set up for any of feeds, the Handler will use
1461  /// those parameters to connect to or join multicast groups.
1462  /// The given parameter value is ignored in such a case and thus
1463  /// connectivity configuration is not loaded from the specified
1464  /// file.
1465  ///
1466  /// For certain environments CME provides additional data
1467  /// centers to be used in case of a disaster. The additional
1468  /// parameter allows specifing whether to load connection
1469  /// settings for either the primary or a disaster recovery
1470  /// data center.
1471  FeedSettings&
1472  connectivityConfigurationFile(
1473  const std::string& configurationFile,
1474  DataCenter::Enum dataCenter = DataCenter::Primary)
1475  {
1476  group().
1477  controlChange
1478  (
1479  "Connectivity Configuration File",
1480  &FeedSettings::assignConnectivityConfiguration,
1481  *this,
1482  configurationFile,
1483  dataCenter
1484  );
1485 
1486  return *this;
1487  }
1488 
1489  /// Specifies one or more network interfaces on which to
1490  /// join multicast groups referring to primary (A) feeds.
1491  ///
1492  /// Multiple interfaces can be specified using semi-colon
1493  /// as a delimiter.
1494  ///
1495  /// The given member is kind of batch set-up. Manual
1496  /// specification of network interfaces for a particular
1497  /// feed is also possible through the corresponding
1498  /// parameters.
1499  FeedSettings&
1500  feedANetworkInterfaces(
1501  const std::string& interfaces)
1502  {
1503  group().
1504  controlChange
1505  (
1506  "Feed A Network Interfaces for All Feeds",
1507  &FeedSettings::assignFeedAInterfaces,
1508  *this,
1509  interfaces
1510  );
1511 
1512  return *this;
1513  }
1514 
1515  /// Specifies one or more network interfaces on which to
1516  /// join multicast groups referring to secondary (B) feeds.
1517  ///
1518  /// Multiple interfaces can be specified using semi-colon
1519  /// as a delimiter.
1520  ///
1521  /// The given member is kind of batch set-up. Manual
1522  /// specification of network interfaces for a particular
1523  /// feed is also possible through the corresponding
1524  /// parameters.
1525  FeedSettings&
1526  feedBNetworkInterfaces(
1527  const std::string& interfaces)
1528  {
1529  group().
1530  controlChange
1531  (
1532  "Feed B Network Interfaces for All Feeds",
1533  &FeedSettings::assignFeedBInterfaces,
1534  *this,
1535  interfaces
1536  );
1537 
1538  return *this;
1539  }
1541  /// Max size for network packet transmitted by MDP.
1542  ///
1543  /// @note Default value is '1420'.
1544  PacketSize packetMaxSize() const
1545  {
1546  return packetMaxSize_;
1547  }
1548 
1549  /// Max size for network packet transmitted by MDP.
1550  FeedSettings&
1551  packetMaxSize(
1552  PacketSize value)
1553  {
1554  group().
1555  controlAssignment
1556  (
1557  "Packet Max Size",
1558  packetMaxSize_,
1559  value
1560  );
1561 
1562  return *this;
1563  }
1565  /// The settings related to incremental feeds.
1566  const
1568  incrementalFeeds() const
1569  {
1570  return incrementalFeeds_;
1571  }
1572 
1573  /// The settings related to incremental feeds.
1575  incrementalFeeds()
1576  {
1577  return incrementalFeeds_;
1578  }
1580  /// The settings related to instrument feeds.
1581  const
1583  instrumentFeeds() const
1584  {
1585  return instrumentFeeds_;
1586  }
1587 
1588  /// The settings related to instrument feeds.
1590  instrumentFeeds()
1591  {
1592  return instrumentFeeds_;
1593  }
1595  /// The settings related to snapshot feeds.
1596  const
1598  snapshotFeeds() const
1599  {
1600  return snapshotFeeds_;
1601  }
1602 
1603  /// The settings related to snapshot feeds.
1605  snapshotFeeds()
1606  {
1607  return snapshotFeeds_;
1608  }
1610  /// The settings related to snapshot feeds.
1611  const
1613  mboSnapshotFeeds() const
1614  {
1615  return mboSnapshotFeeds_;
1616  }
1617 
1618  /// The settings related to snapshot feeds.
1620  mboSnapshotFeeds()
1621  {
1622  return mboSnapshotFeeds_;
1623  }
1625  /// The settings related to historical (TCP recovery) feeds.
1626  const
1628  historicalFeeds() const
1629  {
1630  return historicalFeeds_;
1631  }
1632 
1633  /// The settings related to historical (TCP Recovery) feeds.
1635  historicalFeeds()
1636  {
1637  return historicalFeeds_;
1638  }
1639 
1640  /// Instance of the Feed Engine to be used by the Handler.
1641  /// Null instance means no feed engine is yet defined.
1642  NetFeedEngine* engine() const
1643  {
1644  return engine_;
1645  }
1646 
1647  /// Defines instance of the Feed Engine to be used by the Handler.
1648  FeedSettings&
1649  engine(
1650  NetFeedEngine* engine)
1651  {
1652  group().
1653  controlAssignment
1654  (
1655  "Feed Engine",
1656  engine_,
1657  engine
1658  );
1659 
1660  return *this;
1661  }
1663  /// Re-initializes the instance
1664  /// as a copy of the other one.
1665  FeedSettings&
1666  operator =(
1667  const FeedSettings& other)
1668  {
1669  group().
1670  controlChange
1671  (
1672  "Feed Settings",
1673  &FeedSettings::assignNoControl,
1674  *this,
1675  other
1676  );
1677 
1678  return *this;
1679  }
1680 };
1681 
1682 /// Serializes feed settings into string.
1683 ONIXS_CMEMDH_EXPORTED
1684 void
1685 toStr(
1686  std::string&,
1687  const FeedSettings&);
1688 
1689 /// Serializes feed settings into string.
1690 inline
1691 std::string
1693  const FeedSettings& settings)
1694 {
1695  std::string str;
1696 
1697  toStr(str, settings);
1698 
1699  return str;
1700 }
1701 
1702 /// Retrieves connection settings from the given connectivity
1703 /// configuration file for the given channel and fills correspondent
1704 /// parameters in the given FeedSettings instance.
1705 ///
1706 /// If the configuration file includes connectivity settings for
1707 /// both primary and disaster recovery data centers, the additional
1708 /// parameter allows to control which settings are to be extracted.
1709 ONIXS_CMEMDH_EXPORTED
1710 void
1712 (
1713  FeedSettings&,
1714  const std::string&,
1715  ChannelId,
1717  DataCenter::Primary
1718 );
1719 
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:94
Handler&#39;s configuration settings.
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:553
const NifListSetting & networkInterfaces() const
Definition: FeedSettings.h:232
ListSetting< std::string > HostListSetting
List of hosts as a setting.
Definition: FeedSettings.h:34
UInt32 UInt32
uInt32.
Definition: Fields.h:247
UInt32 ChannelId
Identifies CME channel.
Definition: Domain.h:28
UInt32 Base
Integral type used as basement for constants.
Collection of parameters which are common for all types of feeds.
Definition: FeedSettings.h:337
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:561
ONIXS_CMEMDH_EXPORTED void fromStr(HostListSetting &, const std::string &)
Deserializes host list setting from a string.
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition: Bootstrap.h:46
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:558
Collection of parameters affecting real-time feeds behavior.
Definition: FeedSettings.h:974
ONIXS_CMEMDH_EXPORTED void connectivityFromConfiguration(FeedSettings &, const std::string &, ChannelId, DataCenter::Enum=DataCenter::Primary)
bool value(Number &number, const MultiContainer &container, Tag tag)
std::string toStr(const FeedSettings &settings)
Serializes feed settings into string.
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:925
#define ONIXS_CMEMDH_LTWT_STRUCT
Definition: Bootstrap.h:98
HostListSetting NifListSetting
List of network interfaces as a setting.
Definition: FeedSettings.h:44
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:152
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:124
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:928
Collection of parameters affecting recovery feeds behavior.
Definition: FeedSettings.h:604
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:106
ListSetting & assignNoControl(const ListSetting &other)
Definition: SettingGroup.h:512
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:920
UInt16 PacketSize
Integral type for measuring packets.
Definition: PacketTraits.h:36
Collection of parameters affecting recovery feeds behavior.
Definition: FeedSettings.h:701
The collection of parameters defining feed connection.
Definition: FeedSettings.h:54
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:156