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