OnixS C++ CME MDP Conflated TCP Handler 1.3.6
API Documentation
Loading...
Searching...
No Matches
SessionSettings.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 <climits>
27#include <set>
28#include <string>
29#include <vector>
30
31namespace OnixS {
32namespace CME {
33namespace ConflatedTCP {
34
39{
40public:
43
48 const std::string & sessionId() const {
49 return sessionId_;
50 }
51
54 SessionSettings& sessionId(const std::string & value);
55
60 const std::string & firmId() const {
61 return firmId_;
62 }
63
66 SessionSettings& firmId(const std::string & value);
67
72 const std::string & accessKey() const {
73 return accessKey_;
74 }
75
78 SessionSettings& accessKey(const std::string & value);
79
84 const std::string & secretKey() const {
85 return secretKey_;
86 }
87
90 SessionSettings& secretKey(const std::string & value);
91
97 return threadingModel_;
98 }
99
103
105 static const unsigned MaxSpinningTimeoutUsec = 1000000; //1 sec
106
111 unsigned receiveSpinningTimeout() const {
112 return receiveSpinningTimeout_;
113 }
114
118
123 unsigned sendSpinningTimeout() const
124 {
125 return sendSpinningTimeout_;
126 }
127
130 SessionSettings& sendSpinningTimeout(unsigned usecTimeout);
131
140 unsigned messageGrouping() const {
141 return messageGrouping_;
142 }
143
147
150
153 SessionSettings& addLicenseStore(const std::string& value);
154
157 SessionSettings& licenseStore(const std::string & value);
158
160 typedef std::vector<std::string> LicenseStores;
161
167 {
168 return licenseStores_;
169 }
170
176 return licenseAlertingDaysBeforeExpiration_;
177 }
178
187 licenseAlertingDaysBeforeExpiration_ = days;
188 return *this;
189 }
190
195 const std::string & localNetworkInterface() const {
196 return localNetworkInterface_;
197 }
198
204 SessionSettings& localNetworkInterface(const std::string & value);
205
210 const std::string & logFileName() const {
211 return logFileName_;
212 }
213
216 SessionSettings& logFileName(const std::string & value);
217
224 const std::string & storageDirectory() const {
225 return storageDirectory_;
226 }
227
232 SessionSettings& storageDirectory(const std::string & value);
233
238 bool localTimeUsage() const {
239 return localTimeUsage_;
240 }
241
247
253 return fileBasedStorageSegmentSize_;
254 }
255
259
265 return asyncFileBasedStorageQueueMaxSize_;
266 }
267
271
277 return asyncFileBasedStorageThreadAffinity_;
278 }
279
283
292 return ignoreFileBasedStorageIntegrityErrors_;
293 }
294
298
303 bool logBeforeSending() const {
304 return logBeforeSending_;
305 }
306
312
317 unsigned reconnectAttempts() const {
318 return reconnectAttempts_;
319 }
320
324
329 unsigned reconnectInterval() const {
330 return reconnectInterval_;
331 }
332
336
338 static const int UseOsDefaultSocketBufferSize = -1;
339
345 return socketReceiveBufferSize_;
346 }
347
354
359 unsigned reasonableTransmissionTime() const {
360 return reasonableTransmissionTime_;
361 }
362
366
372 return socketSendBufferSize_;
373 }
374
381
385 return threadPoolAffinity_;
386 }
387
391
394 int threadPoolPriority() const {
395 return threadPoolPriority_;
396 }
397
401
404 int threadPoolPolicy() const {
405 return threadPoolPolicy_;
406 }
407
411
416 bool tcpNoDelayOption() const {
417 return tcpNoDelayOption_;
418 }
419
423
428 unsigned threadPoolSize() const {
429 return threadPoolSize_;
430 }
431
434 SessionSettings& threadPoolSize(unsigned numberOfThreads);
435
440 unsigned keepAliveInterval() const
441 {
442 return keepAliveInterval_;
443 }
444
450 SessionSettings& keepAliveInterval(unsigned milliseconds);
451
456 SessionSettings& load(const std::string& configFile);
457
460 std::string toString() const;
461
465 static const bool CreateLogFile = true;
466 static const int KeepAliveInterval = 30000;
467 static const bool LogBeforeSending = true;
470 static const bool TcpNoDelayOption = true;
471 static const int ReceiveSpinningTimeout = 0;
472 static const int SendSpinningTimeout = 0;
473 static const char LicenseStore[] ;
474 static const unsigned LicenseAlertingDaysBeforeExpiration = 0;
475 static const char LogDir[];
476 static const char LogFileName[];
477 static const bool LocalTimeUsage = false;
478 static const unsigned MessageGrouping = 0;
479 static const int ReasonableTransmissionTime = 20;
480 static const int ReconnectAttempts = 3;
481 static const int ReconnectInterval = 180;
482 static const unsigned long long FileBasedStorageSegmentSize = 0;
483 static const bool IgnoreFileBasedStorageIntegrityErrors = false;
484 static const int ThreadPoolSize = 0;
485 static const unsigned AsyncFileBasedStorageQueueMaxSize = UINT_MAX;
486 };
487
490 static const char * SessionId;
491 static const char * FirmId;
492 static const char * AccessKey;
493 static const char * SecretKey;
494
497 static const char * ThreadingModel;
498 static const char * TcpNoDelayOption;
499 static const char * MessageGrouping;
500 static const char * FileBasedStorageSegmentSize;
502 static const char * KeepAliveInterval;
503 static const char * LicenseFile;
504 static const char * LicenseStore;
506 static const char * LocalNetworkInterface;
507 static const char * LogFileName;
508 static const char * LocalTimeUsage;
509 static const char * LogBeforeSending;
510 static const char * ReasonableTransmissionTime;
511 static const char * ReceiveSpinningTimeout;
512 static const char * ReconnectAttempts;
513 static const char * ReconnectInterval;
514 static const char * SendSpinningTimeout;
515 static const char * ThreadPoolAffinity;
516 static const char * ThreadPoolSize;
517 static const char * ThreadPoolPriority;
518 static const char * ThreadPoolPolicy;
519 static const char * SocketReceiveBufferSize;
520 static const char * SocketSendBufferSize;
521 static const char * StorageDirectory;
522 };
523
524private:
525 void processLicenseStores(const std::string& licenseStore);
526
527 std::string accessKey_;
528
529 unsigned asyncFileBasedStorageQueueMaxSize_;
530
531 CpuIndexes asyncFileBasedStorageThreadAffinity_;
532
533 bool createEngineLogFile_;
534
535 Messaging::UInt64 fileBasedStorageSegmentSize_;
536
537 std::string firmId_;
538
539 bool ignoreFileBasedStorageIntegrityErrors_;
540
541 unsigned keepAliveInterval_;
542
543 unsigned licenseAlertingDaysBeforeExpiration_;
544
545 std::string licenseFilePath_;
546
547 LicenseStores licenseStores_;
548
549 std::string localNetworkInterface_;
550
551 bool localTimeUsage_;
552
553 bool logBeforeSending_;
554
555 std::string logFileName_;
556
557 unsigned messageGrouping_;
558
559 unsigned reasonableTransmissionTime_;
560
561 int receiveSpinningTimeout_;
562
563 unsigned reconnectAttempts_;
564
565 unsigned reconnectInterval_;
566
567 std::string secretKey_;
568
569 int sendSpinningTimeout_;
570
571 std::string sessionId_;
572
573 int socketReceiveBufferSize_;
574
575 int socketSendBufferSize_;
576
577 std::string storageDirectory_;
578
579 bool tcpNoDelayOption_;
580
581 ThreadingModel::Enum threadingModel_;
582
583 CpuIndexes threadPoolAffinity_;
584
585 int threadPoolPolicy_;
586
587 int threadPoolPriority_;
588
589 unsigned threadPoolSize_;
590};
591
592}
593}
594}
#define ONIXS_CONFLATEDTCP_EXPORTED
Definition Compiler.h:175
#define ONIXS_CONFLATEDTCP_NODISCARD
Definition Compiler.h:185
const std::string & localNetworkInterface() const
SessionSettings & threadPoolSize(unsigned numberOfThreads)
Sets the size of the shared thread pool.
const std::string & accessKey() const
SessionSettings & resetToDefaults()
Resets the settings to the default values.
SessionSettings & ignoreFileBasedStorageIntegrityErrors(bool)
Sets the file-based storage integrity errors checking mode.
SessionSettings & asyncFileBasedStorageQueueMaxSize(unsigned value)
Sets the maximum size of the asynchronous session storage queue.
SessionSettings & reconnectAttempts(unsigned reconnectAttempts)
Sets the maximum number of tries to restore the telecommunications link.
SessionSettings & threadingModel(ThreadingModel::Enum value)
Sets the threading model.
SessionSettings & localTimeUsage(bool)
Specifies the usage of the local time in Handler events and log files.
SessionSettings & sendSpinningTimeout(unsigned usecTimeout)
Sets the send spinning timeout (microseconds).
SessionSettings & keepAliveInterval(unsigned milliseconds)
Sets the longest time in milliseconds the client system can remain silent before sending a message.
SessionSettings & threadPoolPriority(int priority)
Sets the thread pool priority.
SessionSettings & socketSendBufferSize(int bufferSize)
Sets the size of the socket send buffer size.
SessionSettings & threadPoolAffinity(const CpuIndexes &cpuIndexes)
Sets the thread pool affinity.
SessionSettings & secretKey(const std::string &value)
Sets the secret key that was assigned by the exchange.
SessionSettings & messageGrouping(unsigned value)
Sets the message grouping mode.
SessionSettings & reconnectInterval(unsigned value)
Sets the time interval between retries to restore the telecommunications link (seconds).
const CpuIndexes & asyncFileBasedStorageThreadAffinity() const
SessionSettings & asyncFileBasedStorageThreadAffinity(const CpuIndexes &cpuIndexes)
Specifies the CPU index(es) for affinity of the asynchronous session storage threads.
SessionSettings & socketReceiveBufferSize(int bufferSize)
Sets the socket receive buffer size.
SessionSettings & localNetworkInterface(const std::string &value)
Specifies the local interface from which the Handler connects to the counterparty.
const std::string & storageDirectory() const
const CpuIndexes & threadPoolAffinity() const
SessionSettings & sessionId(const std::string &value)
Sets the session id that was assigned by the exchange.
SessionSettings & fileBasedStorageSegmentSize(Messaging::UInt64 value)
Sets the segment size for file-based session storage.
const std::string & secretKey() const
SessionSettings & reasonableTransmissionTime(unsigned percentage)
Sets the reasonable transmission time - as the percentage from the KeepAliveInterval value.
static const unsigned MaxSpinningTimeoutUsec
The maximum spinning timeout (microseconds).
SessionSettings & load(const std::string &configFile)
Loads the settings from the given configuration file.
SessionSettings & logBeforeSending(bool before)
Controls the order of logging and sending outbound messages.
SessionSettings & storageDirectory(const std::string &value)
Sets the Session Storage directory.
ThreadingModel::Enum threadingModel() const
const std::string & logFileName() const
SessionSettings & logFileName(const std::string &value)
Specifies the Handler log file name.
Messaging::UInt64 fileBasedStorageSegmentSize() const
SessionSettings & accessKey(const std::string &value)
Sets the access key that was assigned by the exchange.
SessionSettings & receiveSpinningTimeout(unsigned usecTimeout)
Sets the receive spinning timeout (microseconds).
SessionSettings & addLicenseStore(const std::string &value)
Adds the path to the folder that contains license file(s).
SessionSettings & tcpNoDelayOption(bool value)
Sets the value of the option to improve latency at the expense of message throughput (the TCP_NODELAY...
const std::string & sessionId() const
SessionSettings & licenseStore(const std::string &value)
Sets the path to the folder that contains license file(s).
SessionSettings & threadPoolPolicy(int policy)
Sets the thread pool policy.
SessionSettings & firmId(const std::string &value)
Sets the firm id that was assigned by the exchange.
SessionSettings & licenseAlertingDaysBeforeExpiration(unsigned days)
Sets the number of days to alert before the license expiration.
const LicenseStores & licenseStores() const
static const int UseOsDefaultSocketBufferSize
Specifies the usage of the operating system default socket buffer size.
std::vector< std::string > LicenseStores
Folders that contain license file(s).
std::set< CpuIndex > CpuIndexes
Definition Defines.h:74
static const unsigned long long FileBasedStorageSegmentSize
static const ThreadingModel::Enum ThreadingModelValue
The keys that are used to load settings from the configuration file.
static const char * AsyncFileBasedStorageThreadAffinity
= "AsyncFileBasedStorage.ThreadAffinity"
static const char * ReconnectAttempts
= "Reconnect.Attempts"
static const char * SocketReceiveBufferSize
= "Socket.ReceiveBufferSize"
static const char * LicenseStore
= "LicenseStore"
static const char * ThreadPoolAffinity
= "ThreadPool.Affinity"
static const char * ReasonableTransmissionTime
= "ReasonableTransmissionTime"
static const char * AsyncFileBasedStorageQueueMaxSize
= "AsyncFileBasedStorage.QueueMaxSize"
static const char * SendSpinningTimeout
= "SendSpinningTimeout"
static const char * LicenseFile
= "LicenseFile"
static const char * ThreadingModel
= "ThreadingModel"
static const char * MessageGrouping
= "MessageGrouping"
static const char * LogBeforeSending
= "Log.BeforeSending"
static const char * TcpNoDelayOption
= "TcpNoDelayOption"
static const char * KeepAliveInterval
= "KeepAliveInterval"
static const char * IgnoreFileBasedStorageIntegrityErrors
= "IgnoreFileBasedStorageIntegrityErrors"
static const char * LocalTimeUsage
= "LocalTimeUsage"
static const char * SessionId
= "SessionId"
static const char * ThreadPoolPolicy
= "ThreadPool.Policy"
static const char * SocketSendBufferSize
= "Socket.SendBufferSize"
static const char * ThreadPoolPriority
= "ThreadPool.Priority"
static const char * FileBasedStorageSegmentSize
= "FileBasedStorageSegmentSize"
static const char * LicenseAlertingDaysBeforeExpiration
= "LicenseAlertingDaysBeforeExpiration"
static const char * LocalNetworkInterface
= "LocalNetworkInterface"
static const char * LogFileName
= "Log.FileName"
static const char * SecretKey
= "SecretKey"
static const char * ReconnectInterval
= "Reconnect.Interval"
static const char * StorageDirectory
= "Log.Directory"
static const char * AccessKey
= "AccessKey"
static const char * ThreadPoolSize
= "ThreadPool.Size"
static const char * ReceiveSpinningTimeout
= "ReceiveSpinningTimeout"
@ DedicatedThreads
Each session has a sender thread and a receiving thread.