OnixS C++ EuroTLX GTP Market Data Handler  1.4.0
API documentation
HandlerSettings.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
25 
26 #include <sstream>
27 #include <string>
28 #include <set>
29 #include <vector>
30 
31 namespace OnixS
32 {
33  namespace EuroTLX
34  {
35  namespace MarketData
36  {
37  namespace GTP
38  {
39  /// Service endpoint description
41  {
42  ///
44  : port (0)
45  {}
46 
47  ///
48  ServiceDescriptor (const std::string& a, unsigned int port)
49  : address (a)
50  , port (port)
51  {}
52 
53  ///
55  : address (descriptor.address), port (descriptor.port)
56  {}
57 
58  /// Ip address
59  std::string address;
60 
61  /// Port number
62  unsigned port;
63 
64  /// Compares with another instance.
65  bool operator == (const ServiceDescriptor& other) const
66  {
67  return address == other.address && port == other.port;
68  }
69 
70  /// Compares with another instance.
71  bool operator != (const ServiceDescriptor& other) const
72  {
73  return !operator==(other);
74  }
75 
76  /// Returns true if the descriptor points to valid ip address
77  bool valid() const
78  {
79  return !address.empty() && port > 0;
80  }
81  };
82 
83  ONIXS_EUROTLX_GTP_API std::ostream& operator << (std::ostream& stream, const ServiceDescriptor& descriptor);
84 
85  /// Feed descriptor
87  {
88  /// Service A
90 
91  /// Service B
93 
94  /// Compares with another instance.
95  bool operator == (const FeedDescriptor& other) const
96  {
97  return serviceA == other.serviceA && serviceB == other.serviceB;
98  }
99 
100  /// Compares with another instance.
101  bool operator != (const FeedDescriptor& other) const
102  {
103  return !operator==(other);
104  }
105  };
106 
107  ONIXS_EUROTLX_GTP_API std::ostream& operator << (std::ostream& stream, const FeedDescriptor& descriptor);
108 
109  /// Describse GTP services such as replay or recovery
111  {
112  ///
114 
115  ///
117  const std::string& addr, unsigned int port, const std::string& ssn)
118  : ServiceDescriptor(addr, port)
119  , session(ssn)
120  {}
121 
122  ///
124  : ServiceDescriptor(other)
125  , session(other.session)
126  {}
127 
128  /// Returns true if the descriptor is valid
129  bool valid() const
130  {
131  return
132  ServiceDescriptor::valid() && !session.empty();
133  }
134 
135  /// Compares with another instance.
136  bool operator == (const TcpServiceDescriptor& other) const
137  {
138  return
139  ServiceDescriptor::operator==(other) && session == other.session;
140  }
141 
142  /// Compares with another instance.
143  bool operator != (const TcpServiceDescriptor& other) const
144  {
145  return !operator==(other);
146  }
147 
148  /// Session supplied by LSEG
149  std::string session;
150  };
151 
152  ///
153  ONIXS_EUROTLX_GTP_API std::ostream& operator << (std::ostream& stream, const TcpServiceDescriptor& descriptor);
154 
155 
156  ///
158  {
159  /// Service A
161 
162  /// Service B
164  };
165 
166  ///
167  ONIXS_EUROTLX_GTP_API std::ostream& operator << (std::ostream& stream, const TcpFeedDescriptor& descriptor);
168 
169 
170  /// Alias for symbol list
171  typedef std::set<std::string> Symbols;
172 
173  struct HandlerSettings;
174 
175  ONIXS_EUROTLX_GTP_API std::ostream& operator << (std::ostream& stream, const HandlerSettings& settings);
176 
177  /// Handler configuration settings.
179  {
180  /// Constructor.
182  : licenseDirectory("")
183  , logDirectory("logs")
184  , logFileNamePrefix("EuroTlxGtp")
185  , logSettings(LogSettings::Default)
186  , logLevel(LogLevel::Info)
187  , logFilePermissions(LogFilePermission::Default)
188  , heartbeatInterval(3)
189  , outOfOrderPacketMaxInterval(3)
190  , lostPacketWaitTime(100000)
191  , useFeedA(true)
192  , useFeedB(true)
193  , maxPacketSize(1500)
194  , maxConnectingAttempts(3)
195  , minReconnectingTimeout(3)
196  , receivingTimeout(10)
197  , sendingTimeout(10)
198  , replayMaxPacketsNumber(65000)
199  , sequenceResetThreshold(5000)
200  {}
201 
202  /// Path to the license directory.
203  std::string licenseDirectory;
204 
205  /// Log files are stored in this directory.
206  std::string logDirectory;
207 
208  /// Template of log file name without extension.
209  std::string logFileNamePrefix ;
210 
211  /// Combine LogSettings enum values to configure the logger.
213 
214  /// Log verbosity.
215  ///
216  /// @note The default value is LogLevel::Info
218 
219  /// Log file permissions.
220  ///
221  /// @note The default value is ReadAll | WriteOwnerOnly
223 
224  /**
225  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
226  *
227  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
228  *
229  * @note If the value is empty or absent then the default networking interface is used.
230  */
231  std::string networkInterface;
232 
233  /**
234  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
235  *
236  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
237  *
238  * @note If the value is empty or absent then the networkInterface_ filled value is used.
239  */
240  std::string networkInterfaceA;
241 
242  /**
243  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
244  *
245  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
246  *
247  * @note If the value is empty or absent then the networkInterface_ filled value is used.
248  */
249  std::string networkInterfaceB;
250 
251  /// Specifies maximal time interval between two
252  /// network packets. If no data is received during
253  /// specified time frame, corresponding warning is raised.
254  ///
255  /// Interval is measured in seconds.
256  ///
257  /// @note The default value is '3'.
259 
260  /// Defines value of threshold used by Handler to differ
261  /// out-of-order packets from gaps.
262  ///
263  /// Due to unreliable nature of multicast, packets transmitted by exchange
264  /// may be received in the order different to original. To differ the
265  /// case when Handler received out-of-order packets from the case when
266  /// some of packets were completely lost, Handler uses given parameter.
267  /// It defines size of interval for incoming packets starting from the
268  /// last received. Packet is considered as out-of-order if its sequence
269  /// number fits into interval [seqNumberOfLastReceivedPacket,
270  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
271  /// In that case Handler waits for other packets to fulfill the incoming
272  /// sequence. If received packet has greater sequence number than
273  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
274  /// then Handler makes a decision on packets lost and gap is reported.
275  ///
276  /// @note When out-of-order packet is received, Handler makes a decision
277  /// on data loss if either waiting time is over or if newly received packet
278  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
279  /// outOfOrderPacketMaxInterval'.
280  ///
281  /// @see 'lostPacketWaitTime' parameter for more information.
282  ///
283  /// @note The default value is '3'.
285 
286  /// Indicates for how long Handler should wait for
287  /// the packet before it's considered as totally lost.
288  ///
289  /// Due to unreliable nature of multicast, data transmitted by MDP
290  /// may come in order other than original or be completely lost. When
291  /// Handler receives packet with sequence number greater than expected,
292  /// it considers received data as out-of-order. If for a certain time
293  /// interval Handler receives missing data, Handler resumes normal data
294  /// processing. However, if no data is received for predefined time frame,
295  /// Handler considers missing data as lost and raises packet gap event.
296  /// Given parameter defines size of time interval Handler waits for missing
297  /// data.
298  ///
299  /// @note When out-of-order packet is received, Handler makes a decision
300  /// on data loss if either waiting time is over or if newly received packet
301  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
302  /// outOfOrderPacketMaxInterval'.
303  ///
304  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
305  ///
306  /// Time interval is measured in microseconds (uSec).
307  ///
308  /// @note The default value is '100000' (100 milliseconds).
310 
311  /// Option to use feed A.
312  ///
313  /// @note The default value is 'true'.
314  bool useFeedA;
315 
316  /// Option to use feed B.
317  ///
318  /// @note The default value is 'true'.
319  bool useFeedB;
320 
321  /// Realtime feed
323 
324  /// Replay TCP service credentials
326 
327  /// Recovery TCP service credentials
329 
330  /**
331  * Specifies network interfaces to use while establishing tcp connection.
332  *
333  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
334  *
335  * @note If the value is empty or absent then the default networking interface is used.
336  */
338 
339  /// Max size for network packet transmitted by GTP.
340  unsigned short maxPacketSize;
341 
342  /// Max number of attempts to connect replay and recovery services, default value is 3
343  unsigned int maxConnectingAttempts;
344 
345  /// Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
347 
348  /// Minimum timeout value to wait for a response from replay and recovery services (sec), default value is 10 sec.
349  unsigned int receivingTimeout;
350 
351  /// Heartbeat interval for sending packets to replay and recovery services (sec), default value is 10 sec.
352  unsigned int sendingTimeout;
353 
354  /// Lost packets threshold when the Handler prefers replay, must not exceed 65000
356 
357  /// Threshold to detect sequence reset
359 
360  /// Returns the string representation.
361  std::string toString() const
362  {
363  std::ostringstream out;
364  out << *this;
365  return out.str();
366  }
367  };
368 
369  }
370  }
371  }
372 }
373 
374 
375 
FeedDescriptor realtimeMulticastFeed
Realtime feed.
std::string session
Session supplied by LSEG.
TcpFeedDescriptor recoveryTcpService
Recovery TCP service credentials.
bool operator==(const ServiceDescriptor &other) const
Compares with another instance.
ServiceDescriptor(const ServiceDescriptor &descriptor)
unsigned int receivingTimeout
Minimum timeout value to wait for a response from replay and recovery services (sec), default value is 10 sec.
std::string licenseDirectory
Path to the license directory.
bool operator!=(const ServiceDescriptor &other) const
Compares with another instance.
TcpFeedDescriptor replayTcpService
Replay TCP service credentials.
bool valid() const
Returns true if the descriptor points to valid ip address.
TcpServiceDescriptor(const TcpServiceDescriptor &other)
std::string logFileNamePrefix
Template of log file name without extension.
unsigned int minReconnectingTimeout
Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
unsigned int maxConnectingAttempts
Max number of attempts to connect replay and recovery services, default value is 3.
TcpServiceDescriptor(const std::string &addr, unsigned int port, const std::string &ssn)
unsigned int sequenceResetThreshold
Threshold to detect sequence reset.
unsigned int replayMaxPacketsNumber
Lost packets threshold when the Handler prefers replay, must not exceed 65000.
ServiceDescriptor(const std::string &a, unsigned int port)
std::set< std::string > Symbols
Alias for symbol list.
std::string logDirectory
Log files are stored in this directory.
Describse GTP services such as replay or recovery.
std::string toString() const
Returns the string representation.
ONIXS_EUROTLX_GTP_API std::ostream & operator<<(std::ostream &stream, const ServiceDescriptor &descriptor)
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
bool valid() const
Returns true if the descriptor is valid.
unsigned short maxPacketSize
Max size for network packet transmitted by GTP.
unsigned int sendingTimeout
Heartbeat interval for sending packets to replay and recovery services (sec), default value is 10 sec...