OnixS C++ CME MDP Premium Market Data Handler  5.8.3
API Documentation
SolarflareFeedEngine.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 <OnixS/CME/MDH/Watch.h>
26 
28 
29 /// Defines modes in with the Solarflare Feed Engine can operate.
31 {
32  /// Underlying integral type for the enum.
33  typedef UInt32 Base;
34 
35  /// Defines modes in with the Solarflare Feed Engine can operate.
36  enum Enum
37  {
38  /// The conventional mode supposes use of the ef_vi
39  /// services only while working with multicast feeds.
40  ///
41  /// Thus attempt to establish multicast data reception
42  /// on non-Solarflare network interfaces while using the
43  /// Solarflare Feed Engine will lead to a failure.
45 
46  /// In the given mode the Solarflare Feed Engine mixes
47  /// ef_vi services with the traditional network sockets.
48  ///
49  /// The Solarflare Feed Engine uses ordinary network
50  /// sockets to receive multicast data on the non-Solarflare
51  /// network interfaces instead of giving up on operating.
52  /// The given mode offers more flexibility for the cases
53  /// when the operating environment is configured in such
54  /// a way that real-time incremental data arrives via a
55  /// Solarflare network interface, while recovery data via
56  /// a non-Solarflare network interface.
57  Mixed
58  };
59 };
60 
61 /// Serializes the Solarflare Feed Engine
62 /// operational mode into a string.
65 
66 /// Serializes the Solarflare Feed Engine
67 /// operational mode into a string.
69 {
70  std::string str;
71 
72  toStr(str, mode);
73 
74  return str;
75 }
76 
77 /// Represents a collection of settings affecting
78 /// the behavior of the Feed Engine while working
79 /// with virtual interfaces.
81 {
82 public:
83  /// Initializes the given instance of the
84  /// network settings with the default values.
86  : mode_(SolarflareFeedEngineOperatingMode::Conventional)
87  , receiveRingSize_(static_cast<UInt32>(-1))
88  , cacheSize_(1024)
89  , socketBufferSize_(8 * 1024 * 1024)
90  , watch_(&UtcWatch::service())
91  {
92  }
93 
94  /// Cleans everything up.
96 
97  /// The operational mode for the Feed Engine.
99  {
100  return mode_;
101  }
102 
103  /// Defines the operational mode for the Feed Engine.
105  {
106  mode_ = mode;
107  }
108 
109  /// Number of buffers in a virtual interface receive ring.
110  ///
111  /// Single buffer is used for a single network packet.
112  /// Thus the receive ring must be capacious enough to
113  /// place incoming packets during market data bursts.
114  ///
115  /// By default, the parameter is set to '-1' which means
116  /// receive ring will be constructed of the default capacity.
118  {
119  return receiveRingSize_;
120  }
121 
122  /// Number of buffers in a virtual interface receive ring.
123  ///
124  /// Single buffer is used for a single network packet.
125  /// Thus the receive ring must be capacious enough to
126  /// place incoming packets during market data bursts.
127  ///
128  /// By default, the parameter is set to '-1' which means
129  /// receive ring will be constructed of the default capacity.
130  void receiveRingSize(UInt32 ringSize)
131  {
132  receiveRingSize_ = ringSize;
133  }
134 
135  /// Size of a pool of buffers used to
136  /// receive and manipulate incoming data.
137  ///
138  /// The Feed Engine puts incoming packets into buffers
139  /// and keeps buffers busy until received data is processed
140  /// by handlers. In case of rapid transmission, buffers may
141  /// be allocated quicker than they are processed and released
142  /// back to pool. Therefore, the pool must be capacious enough
143  /// to avoid data losses.
145  {
146  return cacheSize_;
147  }
148 
149  /// Size of pool of buffers used to
150  /// receive and manipulate incoming data.
151  void cacheSize(UInt32 cacheSize)
152  {
153  cacheSize_ = cacheSize;
154  }
155 
156  /// Socket buffer size.
157  ///
158  /// When the Solarflare Feed Engine operates in mixed mode,
159  /// ordinary sockets are used to receive multicast data on
160  /// non-Solarflare network interfaces. The given parameter
161  /// defines size of a buffer used by socket to store incoming
162  /// data before it's retrieved by the Solarflare Feed Engine.
164  {
165  return socketBufferSize_;
166  }
167 
168  /// Specifies socket buffer size.
169  ///
170  /// When the Solarflare Feed Engine operates in mixed mode,
171  /// ordinary sockets are used to receive multicast data on
172  /// non-Solarflare network interfaces. The given parameter
173  /// defines size of a buffer used by socket to store incoming
174  /// data before it's retrieved by the Solarflare Feed Engine.
175  void socketBufferSize(UInt32 bufferSize)
176  {
177  socketBufferSize_ = bufferSize;
178  }
179 
180  /// Watch service to be used by the Solarlfare Feed Engine.
181  ///
182  /// Watch is used by the Solarlfare Feed Engine to assign
183  /// time stamps to incoming packets (received from feeds).
184  ///
185  /// @note By default, the TC watch service is used.
187  {
188  return *watch_;
189  }
190 
191  /// Watch service to be used by Feed Engine.
192  ///
193  /// If no instance is associated, the UTC watch is used.
194  void watch(WatchService& watch)
195  {
196  watch_ = &watch;
197  }
198 
199 private:
201 
202  UInt32 receiveRingSize_;
203  UInt32 cacheSize_;
204 
205  UInt32 socketBufferSize_;
206 
207  WatchService* watch_;
208 };
209 
210 /// Serializes the Solarflare Feed Engine settings into a string.
212 void toStr(std::string&, const SolarflareFeedEngineSettings&);
213 
214 /// Serializes the Solarflare Feed Engine settings into a string.
215 inline std::string toStr(const SolarflareFeedEngineSettings& settings)
216 {
217  std::string str;
218 
219  toStr(str, settings);
220 
221  return str;
222 }
223 
224 /// The given class implements the Feed Engine
225 /// concept using the Solarlfare ef_vi SDK.
226 ///
227 /// The ef_vi SDK is for high performance raw Ethernet
228 /// networking. It bypasses kernel and uses zero-copying
229 /// techniques while manipulating data.
231 {
232 public:
233  /// Initializes the engine according to the given configuration.
235 
236  /// Destructs the given instance.
238 
239  /// Appends information on the given
240  /// implementation to the given string.
241  void info(std::string&) ONIXS_CMEMDH_OVERRIDE;
242 
243  /// Allocates a link for the given feed.
244  NetFeedLink& allocate(const NetFeed&) ONIXS_CMEMDH_OVERRIDE;
245 
246  /// Exposes an instance of the watch service
247  /// used while manipulating the feed links.
249 
250  /// Carries out pending actions like
251  /// data retrieval and event dispatching.
253 
254 private:
255  // The workhorse for the feed engine.
256  class Workhorse;
257 
258  Workhorse* workhorse_;
259 };
260 
Enum
Defines modes in with the Solarflare Feed Engine can operate.
Designed to reflect various aspects of feed engine processing flow.
Definition: FeedEngine.h:35
The given class implements the Feed Engine concept using the Solarlfare ef_vi SDK.
#define ONIXS_CMEMDH_OVERRIDE
Definition: Compiler.h:143
UInt32 receiveRingSize() const
Number of buffers in a virtual interface receive ring.
Represents a collection of settings affecting the behavior of the Feed Engine while working with virt...
UInt32 UInt32
uInt32.
Definition: Fields.h:192
SolarflareFeedEngineSettings()
Initializes the given instance of the network settings with the default values.
UInt32 socketBufferSize() const
Socket buffer size.
Abstract watch service.
Definition: Watch.h:29
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
Defines modes in with the Solarflare Feed Engine can operate.
Abstraction for the Feed Engine machinery.
Definition: FeedEngine.h:101
bool process(NetFeedEngine &engine)
Carries out pending actions like data retrieval and event dispatching.
Definition: FeedEngine.h:146
SolarflareFeedEngineOperatingMode::Enum mode() const
The operational mode for the Feed Engine.
Base attributes of market data feed.
Definition: Feed.h:54
WatchService & watch() const
Watch service to be used by the Solarlfare Feed Engine.
void receiveRingSize(UInt32 ringSize)
Number of buffers in a virtual interface receive ring.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
void mode(SolarflareFeedEngineOperatingMode::Enum mode)
Defines the operational mode for the Feed Engine.
void watch(WatchService &watch)
Watch service to be used by Feed Engine.
std::string toStr(const SolarflareFeedEngineSettings &settings)
Serializes the Solarflare Feed Engine settings into a string.
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:135
void cacheSize(UInt32 cacheSize)
Size of pool of buffers used to receive and manipulate incoming data.
UInt32 cacheSize() const
Size of a pool of buffers used to receive and manipulate incoming data.
UInt32 Base
Underlying integral type for the enum.
The conventional mode supposes use of the ef_vi services only while working with multicast feeds...
void socketBufferSize(UInt32 bufferSize)
Specifies socket buffer size.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68