OnixS C++ CME Streamlined Market Data Handler  1.1.0.5
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 
26 
28 
29 /// Defines feed layout alternates available
30 /// for real-time feed like incremental one.
32 {
33  /// Integral type used as basement for constants.
34  typedef UInt32 Base;
35 
36  enum Enum
37  {
38  /// Indicates only feed A is used as source for market data.
40 
41  /// Indicates only feed B is used as source for market data.
43 
44  /// Feed A is used as primary source of market data. If Handler
45  /// detects absence of market data on feed A, it switches to
46  /// feed B to continue market data processing. Feed B is used
47  /// by Handler until market data absence is detected on it. In
48  /// that case Handler will switch back to feed A. In other words,
49  /// this layout instructs Handler to cycle between feeds if data
50  /// absence is detected starting from feed A.
52 
53  /// Feed B is used as primary source of market data. If Handler
54  /// detects absence of market data on feed B, it switches to
55  /// feed A to continue market data processing. Feed A is used
56  /// by Handler until market data absence is detected on it. In
57  /// that case Handler will switch back to feed B. In other words,
58  /// this layout instructs Handler to cycle between feeds if data
59  /// absence is detected starting from feed B.
61 
62  /// Handler arbitrates between both feeds A and B.
63  BothFeedsWithArbitrage
64  };
65 };
66 
67 /// Appends string presentation of feed layout.
68 ONIXS_CMESTREAMLINEDMDH_EXPORTED
69 void
70 toStr(
71  std::string&,
73 
74 /// Returns string presentation of feed layout.
75 inline
76 std::string
79 {
80  std::string str;
81 
82  toStr(str, layout);
83 
84  return str;
85 }
86 
87 /// Collection of parameters affecting real-time feeds behavior.
89 {
91  UInt32 heartbeatInterval_;
92 
93  UInt32 outOfOrderPacketMaxInterval_;
94  UInt32 lostPacketWaitTime_;
95 
96 public:
97  /// Initializes instance with default values.
99  : layout_(
101  BothFeedsWithArbitrage)
102  , heartbeatInterval_(30)
103  , outOfOrderPacketMaxInterval_(3)
104  , lostPacketWaitTime_(100000)
105  {
106  }
107 
108  /// Defines feed layout for real-time feed group.
109  ///
110  /// @note By default, arbitrage between feeds A and B is done.
112  {
113  return layout_;
114  }
115 
116  /// Defines feed layout for real-time feed group.
118  {
119  layout_ = value;
120  }
121 
122  /// Specifies maximal time interval between two
123  /// network packets. If no data is received during
124  /// specified time frame, corresponding event is raised
125  /// and further behavior is defined by feed layout.
126  ///
127  /// Interval is measured in seconds.
128  ///
129  /// @note The default value is '30'.
131  {
132  return heartbeatInterval_;
133  }
134 
135  /// Specifies maximal time interval between two network packets.
137  {
138  heartbeatInterval_ = value;
139  }
140 
141  /// Defines value of threshold used by Handler to differ
142  /// out-of-order packets from gaps.
143  ///
144  /// Due to unreliable nature of multicast, packets transmitted by MDP
145  /// may be received in the order different to original. To differ the
146  /// case when Handler received out-of-order packets from the case when
147  /// some of packets were completely lost, Handler uses given parameter.
148  /// It defines size of interval for incoming packets starting from the
149  /// last received. Packet is considered as out-of-order if its sequence
150  /// number fits into interval [seqNumberOfLastReceivedPacket,
151  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
152  /// In that case Handler waits for other packets to fulfill the incoming
153  /// sequence. If received packet has greater sequence number than
154  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
155  /// then Handler makes a decision on packets lost and gap is reported.
156  ///
157  /// @note When out-of-order packet is received, Handler makes a decision
158  /// on data loss if either waiting time is over or if newly received packet
159  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
160  /// outOfOrderPacketMaxInterval'.
161  ///
162  /// @see 'lostPacketWaitTime' parameter for more information.
163  ///
164  /// @note The default value is '3'.
166  {
167  return outOfOrderPacketMaxInterval_;
168  }
169 
170  /// Defines value of threshold used by Handler
171  /// to differ out-of-order packets from gaps.
173  {
174  outOfOrderPacketMaxInterval_ = value;
175  }
176 
177  /// Indicates for how long Handler should wait for
178  /// the packet before it's considered as totally lost.
179  ///
180  /// Due to unreliable nature of multicast, data transmitted by MDP
181  /// may come in order other than original or be completely lost. When
182  /// Handler receives packet with sequence number greater than expected,
183  /// it considers received data as out-of-order. If for a certain time
184  /// interval Handler receives missing data, Handler resumes normal data
185  /// processing. However, if no data is received for predefined time frame,
186  /// Handler considers missing data as lost and raises packet gap event.
187  /// Given parameter defines size of time interval Handler waits for missing
188  /// data.
189  ///
190  /// @note When out-of-order packet is received, Handler makes a decision
191  /// on data loss if either waiting time is over or if newly received packet
192  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
193  /// outOfOrderPacketMaxInterval'.
194  ///
195  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
196  ///
197  /// Time interval is measured in microseconds (usec).
198  ///
199  /// @note The default value is '100000' (100 milliseconds).
201  {
202  return lostPacketWaitTime_;
203  }
204 
205  /// Indicates for how long Handler should wait for
206  /// the packet before it's considered as totally lost.
208  {
209  lostPacketWaitTime_ = value;
210  }
211 };
212 
213 /// Serializes feed settings into string.
214 ONIXS_CMESTREAMLINEDMDH_EXPORTED
215 void
216 toStr(
217  std::string&,
218  const RealtimeFeedSettings&);
219 
220 /// Serializes feed settings into string.
221 inline
222 std::string
224  const RealtimeFeedSettings& settings)
225 {
226  std::string str;
227 
228  toStr(str, settings);
229 
230  return str;
231 }
232 
233 // Parameters affecting all feeds involved into market data processing.
235 {
236  std::string connectivityConfigurationFile_;
237 
238  std::string feedANetworkInterfaces_;
239  std::string feedBNetworkInterfaces_;
240 
241  UInt16 maxPacketSize_;
242 
243  RealtimeFeedSettings incrementalFeeds_;
244 
245 public:
246  /// Initializes instance with default values.
248  : maxPacketSize_(1420)
249  {
250  }
251 
252  /// Path to the connectivity configuration file.
253  const
254  std::string&
256  {
257  return connectivityConfigurationFile_;
258  }
259 
260  /// Sets path to the connectivity configuration file.
261  void
263  const std::string& configurationFile)
264  {
265  connectivityConfigurationFile_ = configurationFile;
266  }
267 
268  /// Specifies one or more network interfaces to use for
269  /// "A" feeds while joining the multicast group; use
270  /// semi-colon delimited list if more than one.
271  ///
272  /// @note On Linux the network interface is specified
273  /// by its name, on Windows - by IP address.
274  ///
275  /// @note If the value is empty or absent then the
276  /// Settings::networkInterface value is used.
277  const
278  std::string&
280  {
281  return feedANetworkInterfaces_;
282  }
283 
284  /// Specifies one or more network interfaces to use for
285  /// "A" feeds while joining the multicast group; use
286  /// semi-colon delimited list if more than one.
287  void
289  const std::string& interfaces)
290  {
291  feedANetworkInterfaces_ = interfaces;
292  }
293 
294  /// Specifies one or more network interfaces to use for "B"
295  /// feeds while joining the multicast group; use semi-colon
296  /// delimited list if more than one.
297  ///
298  /// @note On Linux the network interface is specified by
299  /// its name, on Windows - by IP address.
300  ///
301  /// @note If the value is empty or absent then the
302  /// Settings::networkInterface value is used.
303  const
304  std::string&
306  {
307  return feedBNetworkInterfaces_;
308  }
309 
310  /// Specifies one or more network interfaces to use for
311  /// "B" feeds while joining the multicast group; use
312  /// semi-colon delimited list if more than one.
313  void
315  const std::string& interfaces)
316  {
317  feedBNetworkInterfaces_ = interfaces;
318  }
319 
320  /// Max size for network packet transmitted by MDP.
321  ///
322  /// @note Default value is '1420'.
324  {
325  return maxPacketSize_;
326  }
327 
328  /// Max size for network packet transmitted by MDP.
329  void maxPacketSize(UInt16 value)
330  {
331  maxPacketSize_ = value;
332  }
333 
334  /// Reference to parameters affecting incremental feeds.
336  {
337  return incrementalFeeds_;
338  }
339 
340  /// Reference to parameters affecting incremental feeds.
342  {
343  return incrementalFeeds_;
344  }
345 };
346 
347 /// Serializes feed settings into string.
348 ONIXS_CMESTREAMLINEDMDH_EXPORTED
349 void
350 toStr(
351  std::string&,
352  const FeedSettings&);
353 
354 /// Serializes feed settings into string.
355 inline
356 std::string
358  const FeedSettings& settings)
359 {
360  std::string str;
361 
362  toStr(str, settings);
363 
364  return str;
365 }
366 
FeedSettings()
Initializes instance with default values.
Definition: FeedSettings.h:247
Collection of parameters affecting real-time feeds behavior.
Definition: FeedSettings.h:88
const std::string & connectivityConfigurationFile() const
Path to the connectivity configuration file.
Definition: FeedSettings.h:255
UInt16 UInt16
uInt16.
Definition: Fields.h:179
void heartbeatInterval(UInt32 value)
Specifies maximal time interval between two network packets.
Definition: FeedSettings.h:136
const std::string & feedBNetworkInterfaces() const
Definition: FeedSettings.h:305
void layout(RealtimeFeedLayout::Enum value)
Defines feed layout for real-time feed group.
Definition: FeedSettings.h:117
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:172
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition: Bootstrap.h:110
RealtimeFeedSettings()
Initializes instance with default values.
Definition: FeedSettings.h:98
void connectivityConfigurationFile(const std::string &configurationFile)
Sets path to the connectivity configuration file.
Definition: FeedSettings.h:262
const RealtimeFeedSettings & incrementalFeeds() const
Reference to parameters affecting incremental feeds.
Definition: FeedSettings.h:335
RealtimeFeedLayout::Enum layout() const
Definition: FeedSettings.h:111
RealtimeFeedSettings & incrementalFeeds()
Reference to parameters affecting incremental feeds.
Definition: FeedSettings.h:341
void feedANetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:288
void maxPacketSize(UInt16 value)
Max size for network packet transmitted by MDP.
Definition: FeedSettings.h:329
UInt32 Base
Integral type used as basement for constants.
Definition: FeedSettings.h:34
Indicates only feed A is used as source for market data.
Definition: FeedSettings.h:39
void feedBNetworkInterfaces(const std::string &interfaces)
Definition: FeedSettings.h:314
Indicates only feed B is used as source for market data.
Definition: FeedSettings.h:42
#define ONIXS_CMESTREAMLINEDMDH_LTWT_STRUCT
Definition: Bootstrap.h:114
const std::string & feedANetworkInterfaces() const
Definition: FeedSettings.h:279
std::string toStr(const FeedSettings &settings)
Serializes feed settings into string.
Definition: FeedSettings.h:357
UInt32 UInt32
uInt32.
Definition: Fields.h:183
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168