#include <OnixS/CME/iLink3/Session.h>
Public Member Functions | |
Session (const SessionSettings &settings, int marketSegmentId, SessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, SessionStorage *storage=nullptr, UInt64 uuid=UndefinedUuid, const std::string &customKey="") | |
Session (SessionReactor &stack, const SessionSettings &settings, int marketSegmentId, SessionListener *listener, SessionStorageType::Enum storageType=SessionStorageType::FileBased, SessionStorage *storage=nullptr, UInt64 uuid=UndefinedUuid, const std::string &customKey="") | |
~Session () | |
UInt64 | uuid () const noexcept |
std::string | id () const |
int | marketSegmentId () const noexcept |
std::string | customKey () const |
bool | negotiated () const |
Session & | negotiated (bool negotiated) |
Messaging::FTI::Enum | faultToleranceIndicator () const |
Session & | faultToleranceIndicator (Messaging::FTI::Enum value) |
Session & | connect (const std::string &host, Port port) |
Threading::SharedFuture< void > | connectAsync (const std::string &host, Port port) |
Session & | disconnect (const std::string &reason="") |
Threading::SharedFuture< void > | disconnectAsync (const std::string &reason="") |
Session & | breakConnection () |
Threading::SharedFuture< void > | breakConnectionAsync () |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Session & | send (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &msg, Messaging::Timestamp sendingTime=UtcWatch::now()) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Session & | send (Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > &&msg, Messaging::Timestamp sendingTime=UtcWatch::now()) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Session & | send (MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize) |
Session & | send (MessageBatchCombiner &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize) |
Session & | sendSequenceMessage (Messaging::KeepAliveLapsed::Enum keepAliveLapsed=Messaging::KeepAliveLapsed::Lapsed) |
template<typename SbeMessageType , size_t MaxMessageSize> | |
Session & | warmUp (Messaging::MessageHolder< SbeMessageType, MaxMessageSize > &msg, Messaging::Timestamp sendingTime=UtcWatch::now(), int warmupFlags=0) |
template<typename SbeMessageType , size_t MaxMessageSize, typename MessageInitializer > | |
Session & | warmUp (MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize, int warmupFlags=0) |
Session & | warmUp (MessageBatchCombiner &msgs, Messaging::Timestamp sendingTime=UtcWatch::now(), size_t maxPacketSize=CmeMaxPacketSize, int warmupFlags=0) |
Session & | throttle () |
size_t | tryThrottle () |
Session & | throttlingLimit (size_t messagesCount, size_t intervalInMs=1000) |
std::string | remoteHost () const |
std::string | remoteIpAddress () const |
Port | remotePort () const |
std::pair< Port, Port > | localPortRange () const noexcept |
Session & | localPortRange (std::pair< Port, Port > portRange) |
std::string | localNetworkInterface () const |
Session & | localNetworkInterface (const std::string &value) |
Port | localPort () const |
bool | tcpNoDelayOption () const |
Session & | tcpNoDelayOption (bool value) |
const SocketOptions & | socketOptions () const |
Session & | socketOptions (const SocketOptions &options) |
Session & | receivingThreadAffinity (CpuIndex cpuIndex) |
Session & | receivingThreadAffinity (const CpuIndexes &cpuIndexes) |
const CpuIndexes & | receivingThreadAffinity () const |
Session & | sendingThreadAffinity (CpuIndex cpuIndex) |
Session & | sendingThreadAffinity (const CpuIndexes &cpuIndexes) |
const CpuIndexes & | sendingThreadAffinity () const |
int | receivingThreadPriority () const |
Session & | receivingThreadPriority (int priority) |
int | sendingThreadPriority () const |
Session & | sendingThreadPriority (int priority) |
int | receivingThreadPolicy () const |
Session & | receivingThreadPolicy (int policy) |
int | sendingThreadPolicy () const |
Session & | sendingThreadPolicy (int policy) |
unsigned | receiveSpinningTimeout () const noexcept |
Session & | receiveSpinningTimeout (unsigned timeoutInUs) |
unsigned | sendSpinningTimeout () const noexcept |
Session & | sendSpinningTimeout (unsigned timeoutInUs) |
bool | reportNewMessagesWhileWaitingForMissedMessages () const |
Session & | reportNewMessagesWhileWaitingForMissedMessages (bool value) |
unsigned | messageGrouping () const noexcept |
Session & | messageGrouping (unsigned numberOfMessagesToGroup) |
SessionStorageType::Enum | storageType () const noexcept |
const std::string & | storageId () const noexcept |
SeqNumber | outSeqNum () const noexcept |
Session & | outSeqNum (SeqNumber nextOutSeqNum) |
SeqNumber | inSeqNum () const |
Session & | inSeqNum (SeqNumber nextExpectedInSeqNum) |
SeqNumber | previousSeqNo () const noexcept |
Session & | previousSeqNo (SeqNumber value) |
Messaging::UInt64 | previousUuid () const noexcept |
Session & | previousUuid (Messaging::UInt64 value) |
Session & | reset (bool startOfWeek=false) |
SessionStateId::Enum | state () const |
Messaging::Timestamp | creationTime () const noexcept |
void | flushSessionStorage () |
unsigned | reconnectAttempts () const |
Session & | reconnectAttempts (unsigned reconnectAttempts) |
unsigned | reconnectInterval () const |
Session & | reconnectInterval (unsigned seconds) |
bool | localTimeUsage () const |
Session & | localTimeUsage (bool useLocalTime) |
const std::string & | storageDirectory () const |
bool | logBeforeSending () const |
Session & | logBeforeSending (bool value) |
size_t | incomingMessageGapQueueMaximumSize () const |
Session & | incomingMessageGapQueueMaximumSize (size_t value) |
const Session & | log (const std::string &message) const |
std::string | toString () const |
Messaging::Timestamp | licenseExpirationDate () const |
Messaging::SchemaVersion | messagingVersion () const noexcept |
bool | detectMessageGapForPreviousUuid () const |
Session & | detectMessageGapForPreviousUuid (bool detectGap) |
Handle | socketHandle () |
size_t | outboundQueueBytes () |
bool | getTcpInfo (TcpInfo &) |
Static Public Member Functions | |
static const std::string & | version () noexcept |
Static Public Attributes | |
static const UInt64 | UndefinedUuid = 0 |
static const size_t | CmeMaxPacketSize = 1420 |
static const int | UndefinedAffinity = -1 |
static const Handle | InvalidSocketHandle |
Friends | |
struct | AdHoc::SessionHelper |
Session | ( | const SessionSettings & | settings, |
int | marketSegmentId, | ||
SessionListener * | listener, | ||
SessionStorageType::Enum | storageType = SessionStorageType::FileBased , |
||
SessionStorage * | storage = nullptr , |
||
UInt64 | uuid = UndefinedUuid , |
||
const std::string & | customKey = "" |
||
) |
Constructor.
settings | Session settings. |
marketSegmentId | Market segment ID. |
listener | Session listener. |
storageType | Session storage type. |
storage | Session storage. |
uuid | Universally Unique Identifier (UUID). |
customKey | Custom key that could be used to distinguish sessions with the same UUID, Session ID, FirmId, and Market Segment ID values. |
Session | ( | SessionReactor & | stack, |
const SessionSettings & | settings, | ||
int | marketSegmentId, | ||
SessionListener * | listener, | ||
SessionStorageType::Enum | storageType = SessionStorageType::FileBased , |
||
SessionStorage * | storage = nullptr , |
||
UInt64 | uuid = UndefinedUuid , |
||
const std::string & | customKey = "" |
||
) |
~Session | ( | ) |
Session& breakConnection | ( | ) |
Breaks the connection non-gracefully.
Threading::SharedFuture<void> breakConnectionAsync | ( | ) |
Breaks the connection non-gracefully asynchronously.
Establishes the connection.
host | Market Segment Gateway host. |
port | Market Segment Gateway port. |
Threading::SharedFuture<void> connectAsync | ( | const std::string & | host, |
Port | port | ||
) |
Establishes the connection asynchronously.
host | Market Segment Gateway host. |
port | Market Segment Gateway port. |
|
noexcept |
std::string customKey | ( | ) | const |
bool detectMessageGapForPreviousUuid | ( | ) | const |
Session& detectMessageGapForPreviousUuid | ( | bool | detectGap | ) |
Sets the value of the option to detect the message gap for the previous UUID.
Session& disconnect | ( | const std::string & | reason = "" | ) |
Terminates the connection.
reason | Terminate reason details. |
Threading::SharedFuture<void> disconnectAsync | ( | const std::string & | reason = "" | ) |
Terminates the connection asynchronously.
reason | Terminate reason details. |
Messaging::FTI::Enum faultToleranceIndicator | ( | ) | const |
Session& faultToleranceIndicator | ( | Messaging::FTI::Enum | value | ) |
Sets the Fault Tolerance Indicator (whether the connection is the primary or backup).
void flushSessionStorage | ( | ) |
Flushes all internal buffers of the session storage.
bool getTcpInfo | ( | TcpInfo & | ) |
Gets information about the underlying TCP connection.
true
when success; otherwise - false
. std::string id | ( | ) | const |
size_t incomingMessageGapQueueMaximumSize | ( | ) | const |
Session& incomingMessageGapQueueMaximumSize | ( | size_t | value | ) |
Sets the maximum size of the message queue used during message gap recovery.
SeqNumber inSeqNum | ( | ) | const |
Sets the expected sequence number of the next inbound message.
Messaging::Timestamp licenseExpirationDate | ( | ) | const |
std::string localNetworkInterface | ( | ) | const |
Session& localNetworkInterface | ( | const std::string & | value | ) |
Sets the IP Address or name of the local network interface.
Port localPort | ( | ) | const |
bool localTimeUsage | ( | ) | const |
Session& localTimeUsage | ( | bool | useLocalTime | ) |
Specifies the usage of local time in Handler events and logs files.
const Session& log | ( | const std::string & | message | ) | const |
Write the given user's message to the Handler's log file using the session formatted Id.
bool logBeforeSending | ( | ) | const |
true
if logging of an outgoing message to the session storage is performed before sending it to the wire; otherwise - false
. Session& logBeforeSending | ( | bool | value | ) |
Sets the option to log an outgoing message to the session storage before sending it to the wire.
|
noexcept |
|
noexcept |
Session& messageGrouping | ( | unsigned | numberOfMessagesToGroup | ) |
Sets the number of messages to be sent together.
numberOfMessagesToGroup | If the parameter is zero (by default) or one, the Handler tries to send an outgoing application-level message in the context of the thread that calls the OnixS::CME::iLink3::Session::send method. If the message cannot be sent immediately, it is stored in the queue for the subsequent sending by the sending thread. If this parameter is larger than one, the Handler stores outgoing SBE messages in the queue for the subsequent sending by the sending thread. |
|
noexcept |
bool negotiated | ( | ) | const |
true
if the session is negotiated (the Negotiation Response message has been received in reply to the Negotiation message); otherwise - false
. Session& negotiated | ( | bool | negotiated | ) |
Sets the "negotiated" status.
The session is negotiated when the Negotiation Response message has been received in reply to the Negotiation message.
size_t outboundQueueBytes | ( | ) |
Returns the total number of bytes in the outbound queue.
|
noexcept |
Sets the sequence number of the next outgoing message.
|
noexcept |
If no business message was published, the value is zero.
Sets the sequence number of the last business message published by CME with the PreviousUUID.
|
noexcept |
Session& previousUuid | ( | Messaging::UInt64 | value | ) |
Sets the UUID from the previously Established session.
|
noexcept |
Session& receiveSpinningTimeout | ( | unsigned | timeoutInUs | ) |
Sets the receive spinning timeout value (in microseconds).
Session& receivingThreadAffinity | ( | const CpuIndexes & | cpuIndexes | ) |
const CpuIndexes& receivingThreadAffinity | ( | ) | const |
Sets the receiving thread CPU affinity.
int receivingThreadPolicy | ( | ) | const |
Session& receivingThreadPolicy | ( | int | policy | ) |
Sets the receiving thread policy.
int receivingThreadPriority | ( | ) | const |
Session& receivingThreadPriority | ( | int | priority | ) |
Sets the scheduling priority of the receiving thread.
unsigned reconnectAttempts | ( | ) | const |
Session& reconnectAttempts | ( | unsigned | reconnectAttempts | ) |
Sets the maximum number of tries to restore the telecommunications link.
unsigned reconnectInterval | ( | ) | const |
Session& reconnectInterval | ( | unsigned | seconds | ) |
Sets the time interval between retries to restore the telecommunications link (seconds).
std::string remoteHost | ( | ) | const |
std::string remoteIpAddress | ( | ) | const |
Port remotePort | ( | ) | const |
bool reportNewMessagesWhileWaitingForMissedMessages | ( | ) | const |
true
if new messages are reported even when the message gap is detected, and the reply on the Retransmit Request message is expected; otherwise - false
. Session& reportNewMessagesWhileWaitingForMissedMessages | ( | bool | value | ) |
Sets the option to report new messages even when the message gap is detected, and the reply on the Retransmit Request message is expected.
Session& reset | ( | bool | startOfWeek = false | ) |
Backups the current log files, resets the sequence numbers to 1 and generates a new UUID.
startOfWeek | if true then the PreviousUUID and PreviousSeqNum are reset to 0. |
Session & send | ( | Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > & | msg, |
Messaging::Timestamp | sendingTime = UtcWatch::now() |
||
) |
Session & send | ( | Messaging::MessageHolder< SbeMessageType, MaxMessageSize, MessageInitializer > && | msg, |
Messaging::Timestamp | sendingTime = UtcWatch::now() |
||
) |
Session & send | ( | Messaging::MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > & | msgs, |
Messaging::Timestamp | sendingTime = UtcWatch::now() , |
||
size_t | maxPacketSize = CmeMaxPacketSize |
||
) |
Sends messages.
msgs | Message batch to send. |
maxPacketSize | The maximum number of bytes written to the socket's send buffer together. This parameter could be used to reduce the probability that the operating system will fragment the message across multiple TCP packets. |
sendingTime | The time value to be used for a sendingTimeEpoch field of the message(s) being sent. |
Session& send | ( | MessageBatchCombiner & | msgs, |
Messaging::Timestamp | sendingTime = UtcWatch::now() , |
||
size_t | maxPacketSize = CmeMaxPacketSize |
||
) |
Sends messages.
msgs | Message batch combiner to send. |
maxPacketSize | The maximum number of bytes written to the socket's send buffer together. This parameter could be used to reduce the probability that the operating system will fragment the message across multiple TCP packets. |
sendingTime | The time value to be used for a sendingTimeEpoch field of the message(s) being sent. |
Session& sendingThreadAffinity | ( | const CpuIndexes & | cpuIndexes | ) |
Sets the sending thread CPU affinity.
const CpuIndexes& sendingThreadAffinity | ( | ) | const |
int sendingThreadPolicy | ( | ) | const |
Sets the sending thread policy.
Session& sendingThreadPolicy | ( | int | policy | ) |
int sendingThreadPriority | ( | ) | const |
Session& sendingThreadPriority | ( | int | priority | ) |
Session& sendSequenceMessage | ( | Messaging::KeepAliveLapsed::Enum | keepAliveLapsed = Messaging::KeepAliveLapsed::Lapsed | ) |
Send the Sequence message.
keepAliveLapsed | Indicates whether one Keep Alive interval has lapsed without any message received. |
|
noexcept |
Session& sendSpinningTimeout | ( | unsigned | timeoutInUs | ) |
Sets the send spinning timeout value (in microseconds).
Handle socketHandle | ( | ) |
Returns the socket handle which the session uses to transmit data.
InvalidSocketHandle
value. const SocketOptions& socketOptions | ( | ) | const |
Session& socketOptions | ( | const SocketOptions & | options | ) |
Sets socket options.
SessionStateId::Enum state | ( | ) | const |
const std::string& storageDirectory | ( | ) | const |
|
noexcept |
|
noexcept |
bool tcpNoDelayOption | ( | ) | const |
TCP_NODELAY
option (improve latency at the expense of message throughput). Session& tcpNoDelayOption | ( | bool | value | ) |
Sets the TCP_NODELAY
option (improve latency at the expense of message throughput).
Session& throttle | ( | ) |
Performs the throttling of a session that must be called before each send function call.
If the count of messages per time unit exceeds the throttling limit, the function will be blocked until the given time interval is passed.
Session& throttlingLimit | ( | size_t | messagesCount, |
size_t | intervalInMs = 1000 |
||
) |
Sets throttling limit parameters.
messagesCount | Message limit per time unit. |
intervalInMs | Time interval to limit messages. |
std::string toString | ( | ) | const |
size_t tryThrottle | ( | ) |
Checks the throttling of a session that must be called before each send function call.
If the count of messages per time unit exceeds the throttling limit, the function returns the delay (in milliseconds) until the sending becomes possible. Otherwise, it returns 0.
|
noexcept |
|
staticnoexcept |
Session & warmUp | ( | Messaging::MessageHolder< SbeMessageType, MaxMessageSize > & | msg, |
Messaging::Timestamp | sendingTime = UtcWatch::now() , |
||
int | warmupFlags = 0 |
||
) |
Warms up the sending path.
msg | SBE message to warm up the sending path. |
warmupFlags | Specific flags which can be used to turn on the warmup feature for a specific NIC. |
sendingTime | The time value to be used for a sendingTimeEpoch field of the message(s) being sent. |
Session & warmUp | ( | Messaging::MessageBatch< SbeMessageType, MaxMessageSize, MessageInitializer > & | msgs, |
Messaging::Timestamp | sendingTime = UtcWatch::now() , |
||
size_t | maxPacketSize = CmeMaxPacketSize , |
||
int | warmupFlags = 0 |
||
) |
Warms up the sending path.
msgs | Message batch to send. |
maxPacketSize | The maximum number of bytes written to the socket's send buffer together during the subsequent send call. |
sendingTime | The time value to be used for a sendingTimeEpoch field of the message(s) being sent. |
warmupFlags | Specific flags which can be used to turn on the warmup feature for a specific NIC. |
Session& warmUp | ( | MessageBatchCombiner & | msgs, |
Messaging::Timestamp | sendingTime = UtcWatch::now() , |
||
size_t | maxPacketSize = CmeMaxPacketSize , |
||
int | warmupFlags = 0 |
||
) |
Warms up the sending path.
msgs | Message batch combiner to send. |
maxPacketSize | The maximum number of bytes written to the socket's send buffer together during the subsequent send call. |
sendingTime | The time value to be used for a sendingTimeEpoch field of the message(s) being sent. |
warmupFlags | Specific flags which can be used to turn on the warmup feature for a specific NIC. |
|
static |
|
static |