OnixS C++ B3 Binary UMDF Market Data Handler  1.3.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 B3
34  {
35  namespace MarketData
36  {
37  namespace UMDF
38  {
39  class FeedEngine;
40 
41  /// Multicast feed description
43  {
44  ///
46  : port (0)
47  {}
48 
49  ///
50  FeedDescriptor(const std::string& a, unsigned int port, const std::string& nif = "")
51  : address (a)
52  , port (port)
53  , networkInterface(nif)
54  {}
55 
56  /// Ip address
57  std::string address;
58 
59  /// Port number
60  unsigned port;
61 
62  /// Specifies one or more network interfaces to use while joining the multicast group;
63  /// use semi-colon delimited list if more than one.
64  /// This value overrides the default one.
65  std::string networkInterface;
66 
67  /// Returns true if the descriptor points to valid ip address
68  bool valid() const
69  {
70  return !address.empty() && port > 0;
71  }
72  };
73 
74  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const FeedDescriptor& descriptor);
75 
76  // A feed-related settings.
77  struct Feed
78  {
79  /// Feed descriptor.
81 
82  /// Feed descriptor.
84 
85  /// Feed engine to use on feed.
86  /// This value overrides the default one.
88 
89  ///
90  Feed()
91  : feedEngine(ONIXS_B3_UMDF_MD_NULLPTR)
92  {}
93 
94  ///
95  Feed(const FeedDescriptor& aFeed, const FeedDescriptor& bFeed, FeedEngine* engine = ONIXS_B3_UMDF_MD_NULLPTR)
96  : a(aFeed)
97  , b(bFeed)
98  , feedEngine(engine)
99  {}
100  };
101 
102  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const Feed& descriptor);
103 
104  struct HandlerSettings;
105 
106  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const HandlerSettings& settings);
107 
108  /// Handler configuration settings.
110  {
111  /// Constructor.
113  : licenseString("")
114  , licenseDirectory("")
115  , feedEngine()
116  , heartbeatInterval(3)
117  , outOfOrderPacketMaxInterval(3)
118  , lostPacketWaitTime(100000)
119  , maxPacketSize(1400)
120  , maxBooksObjectAmount(1000)
121  , buildInternalOrderBooks(false)
122  {}
123 
124  /// Logger settings.
126 
127  /// License string.
128  std::string licenseString;
129 
130  /// Path to the license directory.
131  std::string licenseDirectory;
132 
133  /// Feed engine.
135 
136  /**
137  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
138  *
139  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
140  *
141  * @note If the value is empty or absent then the default networking interface is used.
142  */
143  std::string networkInterface;
144 
145  /**
146  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
147  *
148  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
149  *
150  * @note If the value is empty or absent then the networkInterface_ filled value is used.
151  */
152  std::string networkInterfaceA;
153 
154  /**
155  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
156  *
157  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
158  *
159  * @note If the value is empty or absent then the networkInterface_ filled value is used.
160  */
161  std::string networkInterfaceB;
162 
163  /// Specifies maximal time interval between two
164  /// network packets. If no data is received during
165  /// specified time frame, corresponding warning is raised.
166  ///
167  /// Interval is measured in seconds.
168  ///
169  /// @note The default value is '3'.
171 
172  /// Defines value of threshold used by Handler to differ
173  /// out-of-order packets from gaps.
174  ///
175  /// Due to unreliable nature of multicast, packets transmitted by exchange
176  /// may be received in the order different to original. To differ the
177  /// case when Handler received out-of-order packets from the case when
178  /// some of packets were completely lost, Handler uses given parameter.
179  /// It defines size of interval for incoming packets starting from the
180  /// last received. Packet is considered as out-of-order if its sequence
181  /// number fits into interval [seqNumberOfLastReceivedPacket,
182  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
183  /// In that case Handler waits for other packets to fulfill the incoming
184  /// sequence. If received packet has greater sequence number than
185  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
186  /// then Handler makes a decision on packets lost and gap is reported.
187  ///
188  /// @note When out-of-order packet is received, Handler makes a decision
189  /// on data loss if either waiting time is over or if newly received packet
190  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
191  /// outOfOrderPacketMaxInterval'.
192  ///
193  /// @see 'lostPacketWaitTime' parameter for more information.
194  ///
195  /// @note The default value is '3'.
197 
198  /// Indicates for how long Handler should wait for
199  /// the packet before it's considered as totally lost.
200  ///
201  /// Due to unreliable nature of multicast, data transmitted by MDP
202  /// may come in order other than original or be completely lost. When
203  /// Handler receives packet with sequence number greater than expected,
204  /// it considers received data as out-of-order. If for a certain time
205  /// interval Handler receives missing data, Handler resumes normal data
206  /// processing. However, if no data is received for predefined time frame,
207  /// Handler considers missing data as lost and raises packet gap event.
208  /// Given parameter defines size of time interval Handler waits for missing
209  /// data.
210  ///
211  /// @note When out-of-order packet is received, Handler makes a decision
212  /// on data loss if either waiting time is over or if newly received packet
213  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
214  /// outOfOrderPacketMaxInterval'.
215  ///
216  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
217  ///
218  /// Time interval is measured in microseconds (uSec).
219  ///
220  /// @note The default value is '100000' (100 milliseconds).
222 
223  /// Instrument definition multicast feed
225 
226  /// Incremental multicast feed B
228 
229  /// Snapshot recovery multicast feed
231 
232  /// Max size for network packet transmitted by B3 UMDF.
233  ///
234  /// @note The default value is 1400 bytes.
235  unsigned short maxPacketSize;
236 
237  /// Defines size of pre-allocated memory for Order Book. Default value is 100
238  unsigned int maxBooksObjectAmount;
239 
240  /// Build internal books
242 
243  /// Returns the string representation.
244  std::string toString() const
245  {
246  std::ostringstream out;
247  out << *this;
248  return out.str();
249  }
250  };
251  }
252  }
253  }
254 }
Feed instrumentMulticastFeed
Instrument definition multicast feed.
Feed(const FeedDescriptor &aFeed, const FeedDescriptor &bFeed, FeedEngine *engine=0)
ONIXS_B3_UMDF_MD_API std::ostream & operator<<(std::ostream &stream, const LoggerSettings &settings)
Feed snapshotMulticastFeed
Snapshot recovery multicast feed.
FeedEngine * feedEngine
Feed engine to use on feed.
#define ONIXS_B3_UMDF_MD_NULLPTR
Definition: Compiler.h:128
Messaging::UInt32 UInt32
Definition: Integral.h:37
bool valid() const
Returns true if the descriptor points to valid ip address.
Feed incrementalMulticastFeed
Incremental multicast feed B.
UInt32 heartbeatInterval
Specifies maximal time interval between two network packets.
unsigned short maxPacketSize
Max size for network packet transmitted by B3 UMDF.
unsigned int maxBooksObjectAmount
Defines size of pre-allocated memory for Order Book. Default value is 100.
Definition: Handler.h:26
std::string networkInterface
Specifies one or more network interfaces to use while joining the multicast group; use semi-colon del...
UInt32 outOfOrderPacketMaxInterval
Defines value of threshold used by Handler to differ out-of-order packets from gaps.
std::string networkInterfaceB
Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon d...
std::string networkInterface
Specifies one or more network interfaces to use while joining the multicast group; use semi-colon del...
Handler configuration settings.
UInt32 lostPacketWaitTime
Indicates for how long Handler should wait for the packet before it&#39;s considered as totally lost...
FeedDescriptor b
Feed descriptor.
std::string networkInterfaceA
Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon d...
FeedDescriptor(const std::string &a, unsigned int port, const std::string &nif="")
std::string licenseDirectory
Path to the license directory.
bool buildInternalOrderBooks
Build internal books.
std::string toString() const
Returns the string representation.
The Feed Engine machinery.
Definition: FeedEngine.h:106
LoggerSettings loggerSettings
Logger settings.
FeedDescriptor a
Feed descriptor.