OnixS C++ CME MDP Streamlined Market Data Handler  1.2.0
API Documentation
TcpRecovery.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 <string>
24 
26 
28 
29 /// TCP recovery service configuration settings.
32 {
33 public:
34  /// Initializes parameters with default values.
36  : username_()
37  , password_()
38  , reconnectAttempts_(3)
39  , reconnectInterval_(500)
40  , servingTimeout_(10)
41  , acquisitionTimeout_(500)
42  {
43  }
44 
45  /// Cleans everything up.
47  {
48  }
49 
50  /// Username to identify a requester while
51  /// logging on to a TCP Recovery service.
52  const std::string& username() const
53  {
54  return username_;
55  }
56 
57  /// Assigns username to identify a requester
58  /// while logging on to a TCP Recovery service.
59  void
61  const std::string& username)
62  {
63  username_ = username;
64  }
65 
66  /// Password to identify a requester while
67  /// logging on to TCP Recovery service.
68  const std::string& password() const
69  {
70  return password_;
71  }
72 
73  /// Assigns password to identify a requester
74  /// while logging on to TCP Recovery service.
75  void
77  const std::string& password)
78  {
79  password_ = password;
80  }
81 
82  /// Number of attempts to receive missed
83  /// messages via the TCP recovery feed.
84  ///
85  /// @note Default value is '3'.
87  {
88  return reconnectAttempts_;
89  }
90 
91  /// Number of attempts to receive missed
92  /// messages via the TCP recovery feed.
93  void
95  UInt32 reconnectAttempts)
96  {
97  reconnectAttempts_ =
98  reconnectAttempts;
99  }
100 
101  /// Interval between the attempts to receive
102  /// missed packets via the TCP recovery feed if
103  /// previous attempt either failed or was rejected.
104  ///
105  /// Interval is measured in milliseconds.
106  ///
107  /// @note Default value is '500'.
109  {
110  return reconnectInterval_;
111  }
112 
113  /// Interval between the attempts to receive
114  /// missed packets via the TCP recovery feed if
115  /// previous attempt either failed or was rejected.
116  ///
117  /// Interval is measured in milliseconds.
118  void
120  UInt32 reconnectInterval)
121  {
122  reconnectInterval_ =
123  reconnectInterval;
124  }
125 
126  /// Amount of time allocated to process a
127  /// recovery request. TCP recovery service
128  /// interrupts request processing if it can't
129  /// be accomplished within given time frame.
130  ///
131  /// Interval is measured in seconds.
132  ///
133  /// @note Default value is '10'.
135  {
136  return servingTimeout_;
137  }
138 
139  /// Amount of time allocated to process a
140  /// recovery request. TCP recovery service
141  /// interrupts request processing if it can't
142  /// be accomplished within given time frame.
143  ///
144  /// Interval is measured in seconds.
145  void
147  UInt32 servingTimeout)
148  {
149  servingTimeout_ =
150  servingTimeout;
151  }
152 
153  /// Timeout on a TCP recovery service acquisition.
154  ///
155  /// TCP recovery service may process only
156  /// single request at a time. If TCP recovery
157  /// service can't be acquired within time defined
158  /// by given parameter, recovery request will be
159  /// rejected.
160  ///
161  /// Timeout is measured in milliseconds.
162  ///
163  /// @note Default value is '500'.
165  {
166  return acquisitionTimeout_;
167  }
168 
169  /// Timeout of request for shared TCP recovery service.
170  /// If shared TCP recovery service is used and another Handler
171  /// instance owned it for processing, this Handler instance
172  /// will wait for specified timeout and cancel TCP recovery request
173  /// if TCP Recovery service still not released.
174  ///
175  /// Timeout is measured in milliseconds.
176  void
178  UInt32 acquisitionTimeout)
179  {
180  acquisitionTimeout_ =
181  acquisitionTimeout;
182  }
183 
184 
185 private:
186  std::string username_;
187  std::string password_;
188 
189  UInt32 reconnectAttempts_;
190  UInt32 reconnectInterval_;
191 
192  UInt32 servingTimeout_;
193  UInt32 acquisitionTimeout_;
194 };
195 
196 /// Serializes TCP recovery settings.
198 void
199 toStr(
200  std::string&,
201  const
203 
204 /// Serializes TCP recovery settings.
205 inline
206 std::string
208  const
209  TcpRecoverySettings& settings)
210 {
211  std::string str;
212 
213  toStr(str, settings);
214 
215  return str;
216 }
217 
219 (
220  TcpRecoverySession
221 );
222 
223 /// TCP Recovery Service.
226 {
227 public:
228  /// Initializes instance according to given settings.
230  const TcpRecoverySettings&);
231 
232  /// Finalizes instance and cleans everything up.
234 
235  /// Settings defining service behavior.
236  const
238  settings() const
239  {
240  return *settings_;
241  }
242 
243 private:
244  friend
246  (
247  TcpRecoverySession
248  );
249 
250  // Shared details.
251  void* resource_;
252 
253  // Settings of the service.
254  TcpRecoverySettings* settings_;
255 
256  // Copying is not assumed.
257 
259  const TcpRecoveryService&);
260 
262  operator =(
263  const TcpRecoveryService&);
264 };
265 
std::string toStr(const TcpRecoverySettings &settings)
Serializes TCP recovery settings.
Definition: TcpRecovery.h:207
void reconnectInterval(UInt32 reconnectInterval)
Interval between the attempts to receive missed packets via the TCP recovery feed if previous attempt...
Definition: TcpRecovery.h:119
void acquisitionTimeout(UInt32 acquisitionTimeout)
Timeout of request for shared TCP recovery service.
Definition: TcpRecovery.h:177
const TcpRecoverySettings & settings() const
Settings defining service behavior.
Definition: TcpRecovery.h:238
UInt32 reconnectInterval() const
Interval between the attempts to receive missed packets via the TCP recovery feed if previous attempt...
Definition: TcpRecovery.h:108
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:173
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition: Bootstrap.h:111
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED
Definition: Compiler.h:160
#define ONIXS_CMESTREAMLINEDMDH_INTERNAL_CLASS_DECL(typeName)
Definition: Bootstrap.h:71
TCP recovery service configuration settings.
Definition: TcpRecovery.h:30
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS
Definition: Bootstrap.h:63
void servingTimeout(UInt32 servingTimeout)
Amount of time allocated to process a recovery request.
Definition: TcpRecovery.h:146
UInt32 reconnectAttempts() const
Number of attempts to receive missed messages via the TCP recovery feed.
Definition: TcpRecovery.h:86
const std::string & password() const
Password to identify a requester while logging on to TCP Recovery service.
Definition: TcpRecovery.h:68
UInt32 servingTimeout() const
Amount of time allocated to process a recovery request.
Definition: TcpRecovery.h:134
const std::string & username() const
Username to identify a requester while logging on to a TCP Recovery service.
Definition: TcpRecovery.h:52
void reconnectAttempts(UInt32 reconnectAttempts)
Number of attempts to receive missed messages via the TCP recovery feed.
Definition: TcpRecovery.h:94
void username(const std::string &username)
Assigns username to identify a requester while logging on to a TCP Recovery service.
Definition: TcpRecovery.h:60
UInt32 acquisitionTimeout() const
Timeout on a TCP recovery service acquisition.
Definition: TcpRecovery.h:164
void password(const std::string &password)
Assigns password to identify a requester while logging on to TCP Recovery service.
Definition: TcpRecovery.h:76
TcpRecoverySettings()
Initializes parameters with default values.
Definition: TcpRecovery.h:35
UInt32 UInt32
uInt32.
Definition: Fields.h:183
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:169