OnixS C++ Tradeweb Approved Publication Arrangement (APA) Handler  1.2.2.18
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 Tradeweb
34  {
35  namespace MarketData
36  {
37  namespace Apa
38  {
39  /// Service endpoint description
41  {
43  : port (0)
44  {}
45 
46  ServiceDescriptor (const std::string& a, unsigned p)
47  : address (a), port (p)
48  {}
49 
51  : address (descriptor.address), port (descriptor.port)
52  {}
53 
54  /// Ip address
55  std::string address;
56 
57  /// Port number
58  unsigned port;
59 
60  /// Compares with another instance.
61  bool operator == (const ServiceDescriptor& other) const
62  {
63  return address == other.address && port == other.port;
64  }
65 
66  /// Compares with another instance.
67  bool operator != (const ServiceDescriptor& other) const
68  {
69  return address != other.address || port != other.port;
70  }
71 
72  /// Returns true if the descriptor points to valid ip address
73  bool valid() const
74  {
75  return !address.empty() && port > 0;
76  }
77  };
78 
79  ONIXS_TRADEWEB_APA_API std::ostream& operator << (std::ostream& stream, const ServiceDescriptor& descriptor);
80 
81  /// Feed descriptor
83  {
84  /// Service A
86 
87  /// Service B
89 
90  /// Compares with another instance.
91  bool operator == (const FeedDescriptor& other) const
92  {
93  return serviceA == other.serviceA && serviceB == other.serviceB;
94  }
95 
96  /// Compares with another instance.
97  bool operator != (const FeedDescriptor& other) const
98  {
99  return serviceA != other.serviceA || serviceB != other.serviceB;
100  }
101  };
102 
103  ONIXS_TRADEWEB_APA_API std::ostream& operator << (std::ostream& stream, const FeedDescriptor& descriptor);
104 
105  /// Alias for symbol list
106  typedef std::set<std::string> Symbols;
107 
108  struct HandlerSettings;
109 
110  ONIXS_TRADEWEB_APA_API std::ostream& operator << (std::ostream& stream, const HandlerSettings& settings);
111 
112  /// Handler configuration settings.
114  {
115  /// Constructor.
117  : licenseDirectory("")
118  , logDirectory("logs")
119  , logFileNamePrefix("TradewebApa")
120  , logSettings(LogSettings::Default)
121  , logLevel(LogLevel::Info)
122  , logFilePermissions(LogFilePermission::Default)
123  , heartbeatInterval(1)
124  , outOfOrderPacketMaxInterval(3)
125  , lostPacketWaitTime(100000)
126  , useFeedA(true)
127  , useFeedB(true)
128  , maxPacketSize(1500)
129  , maxConnectingAttempts(3)
130  , minReconnectingTimeout(3)
131  {}
132 
133  /// Path to the license directory.
134  std::string licenseDirectory;
135 
136  /// Log files are stored in this directory.
137  std::string logDirectory;
138 
139  /// Template of log file name without extension.
140  std::string logFileNamePrefix ;
141 
142  /// Combine LogSettings enum values to configure the logger.
144 
145  /// Log verbosity.
146  ///
147  /// @note The default value is LogLevel::Info
149 
150  /// Log file permissions.
151  ///
152  /// @note The default value is ReadAll | WriteOwnerOnly
154 
155  /**
156  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
157  *
158  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
159  *
160  * @note If the value is empty or absent then the default networking interface is used.
161  */
162  std::string networkInterface;
163 
164  /**
165  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
166  *
167  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
168  *
169  * @note If the value is empty or absent then the networkInterface_ filled value is used.
170  */
171  std::string networkInterfaceA;
172 
173  /**
174  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
175  *
176  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
177  *
178  * @note If the value is empty or absent then the networkInterface_ filled value is used.
179  */
180  std::string networkInterfaceB;
181 
182  /// Specifies maximal time interval between two
183  /// network packets. If no data is received during
184  /// specified time frame, corresponding warning is raised.
185  ///
186  /// Interval is measured in seconds.
187  ///
188  /// @note The default value is '1'.
190 
191  /// Defines value of threshold used by Handler to differ
192  /// out-of-order packets from gaps.
193  ///
194  /// Due to unreliable nature of multicast, packets transmitted by exchange
195  /// may be received in the order different to original. To differ the
196  /// case when Handler received out-of-order packets from the case when
197  /// some of packets were completely lost, Handler uses given parameter.
198  /// It defines size of interval for incoming packets starting from the
199  /// last received. Packet is considered as out-of-order if its sequence
200  /// number fits into interval [seqNumberOfLastReceivedPacket,
201  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
202  /// In that case Handler waits for other packets to fulfill the incoming
203  /// sequence. If received packet has greater sequence number than
204  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
205  /// then Handler makes a decision on packets lost and gap is reported.
206  ///
207  /// @note When out-of-order packet is received, Handler makes a decision
208  /// on data loss if either waiting time is over or if newly received packet
209  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
210  /// outOfOrderPacketMaxInterval'.
211  ///
212  /// @see 'lostPacketWaitTime' parameter for more information.
213  ///
214  /// @note The default value is '3'.
216 
217  /// Indicates for how long Handler should wait for
218  /// the packet before it's considered as totally lost.
219  ///
220  /// Due to unreliable nature of multicast, data transmitted by MDP
221  /// may come in order other than original or be completely lost. When
222  /// Handler receives packet with sequence number greater than expected,
223  /// it considers received data as out-of-order. If for a certain time
224  /// interval Handler receives missing data, Handler resumes normal data
225  /// processing. However, if no data is received for predefined time frame,
226  /// Handler considers missing data as lost and raises packet gap event.
227  /// Given parameter defines size of time interval Handler waits for missing
228  /// data.
229  ///
230  /// @note When out-of-order packet is received, Handler makes a decision
231  /// on data loss if either waiting time is over or if newly received packet
232  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
233  /// outOfOrderPacketMaxInterval'.
234  ///
235  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
236  ///
237  /// Time interval is measured in microseconds (usec).
238  ///
239  /// @note The default value is '100000' (100 milliseconds).
241 
242  /// Option to use feed A.
243  ///
244  /// @note The default value is 'true'.
245  bool useFeedA;
246 
247  /// Option to use feed B.
248  ///
249  /// @note The default value is 'true'.
250  bool useFeedB;
251 
252  /// Realtime feed
254 
255  /// Recovery TCP service A
257 
258  /// Recovery TCP service B
260 
261  /**
262  * Specifies network interfaces to use while establishing tcp connection.
263  *
264  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
265  *
266  * @note If the value is empty or absent then the default networking interface is used.
267  */
269 
270  /// Username assigned for Recovery Service
271  std::string recoveryUsername;
272 
273  /// Password assigned for Recovery Service
274  std::string recoveryPassword;
275 
276  /// Max size for network packet transmitted by Eurex.
277  unsigned short maxPacketSize;
278 
279  /// Max number of attempts to connect replay and recovery services, default value is 3
280  unsigned int maxConnectingAttempts;
281 
282  /// Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
284 
285  /// Returns the string representation.
286  std::string toString() const
287  {
288  std::ostringstream out;
289  out << *this;
290  return out.str();
291  }
292  };
293 
294  }
295  }
296  }
297 }
298 
299 
300 
std::set< std::string > Symbols
Alias for symbol list.
std::string recoveryUsername
Username assigned for Recovery Service.
ServiceDescriptor(const std::string &a, unsigned p)
bool operator==(const ServiceDescriptor &other) const
Compares with another instance.
unsigned short maxPacketSize
Max size for network packet transmitted by Eurex.
unsigned int maxConnectingAttempts
Max number of attempts to connect replay and recovery services, default value is 3.
ServiceDescriptor recoveryTcpServiceA
Recovery TCP service A.
std::string licenseDirectory
Path to the license directory.
bool valid() const
Returns true if the descriptor points to valid ip address.
FeedDescriptor realtimeMulticastFeed
Realtime feed.
std::string logDirectory
Log files are stored in this directory.
ServiceDescriptor(const ServiceDescriptor &descriptor)
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
ONIXS_TRADEWEB_APA_API std::ostream & operator<<(std::ostream &stream, const DataSource &ds)
bool operator!=(const ServiceDescriptor &other) const
Compares with another instance.
std::string logFileNamePrefix
Template of log file name without extension.
std::string toString() const
Returns the string representation.
ServiceDescriptor recoveryTcpServiceB
Recovery TCP service B.
std::string recoveryPassword
Password assigned for Recovery Service.
size_t minReconnectingTimeout
Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.