OnixS C++ CME MDP Premium Market Data Handler 5.10.3
Users' manual and API documentation
Loading...
Searching...
No Matches
MulticastSender.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 protected by copyright law
4// and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable OnixS Software
7// Services Agreement (the Agreement) and Customer end user license agreements granting
8// a non-assignable, non-transferable and non-exclusive license to use the software
9// for it's own data processing purposes under the terms defined in the Agreement.
10//
11// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12// of this source code or associated reference material to any other location for further reproduction
13// or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14//
15// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16// the terms of the Agreement is a violation of copyright law.
17//
18#pragma once
19
20#include <unordered_map>
21#include <memory>
22
27
28namespace OnixS { namespace Networking { class MulticastClient; }}
29
31
34{
35public:
38 static constexpr PacketSize DefaultMaxPacketSize = 1420;
39
52 const RealtimeFeedSettings& feedSettings,
55 PacketSize packetMaxSize = DefaultMaxPacketSize);
56
68 const MulticastRecoveryFeedSettings& feedSettings,
71 PacketSize packetMaxSize = DefaultMaxPacketSize);
72
75
89 Threading::Event send(const void* data, size_t dataSize);
90
97 void sendA(const void* data, size_t dataSize);
98
105 void sendB(const void* data, size_t dataSize);
106
112 void sendPrimary(const void* data, size_t dataSize);
113
119 void sendSecondary(const void* data, size_t dataSize);
120
124
127 NetFeedRole::Enum secondaryFeed() const noexcept;
128
131 bool hasSecondary() const noexcept;
132
134 MulticastTarget& operator=(const MulticastTarget&) = delete;
135
136private:
137 using MulticastClientPtr = std::unique_ptr<OnixS::Networking::MulticastClient>;
138 class AsyncSecondarySender;
139
140 static void construct(MulticastClientPtr& client, const FeedConnectionSettings& connection);
141 static void constructIfConfigured(MulticastClientPtr& client, const FeedConnectionSettings& connection);
142 static void destruct(MulticastClientPtr& client);
143 static void send(MulticastClientPtr& client, const void* data, size_t dataSize);
144 void validateDataSize(size_t dataSize) const;
145
146 MulticastClientPtr& getFeed(NetFeedRole::Enum role) noexcept;
147 const MulticastClientPtr& getFeed(NetFeedRole::Enum role) const noexcept;
148
149 const Messaging::TimeSpan arbitrageDelay_ = Messaging::TimeSpan{};
150 ReplayDelayer& delayPolicy_;
151 const PacketSize packetMaxSize_;
152 NetFeedRole::Enum primaryFeed_ = NetFeedRole::A;
153
154 MulticastClientPtr feedA_;
155 MulticastClientPtr feedB_;
156 std::unique_ptr<AsyncSecondarySender> asyncSecondarySender_;
157};
158
159using MulticastTargetPtr = std::unique_ptr<MulticastTarget>;
160
163{
164public:
175 const FeedSettings& feedSettings,
176 Messaging::TimeSpan arbitrageDelay = Messaging::TimeSpan{},
178
181
191 Threading::Event send(NetFeedType::Enum target, const void* data, size_t dataSize);
192
201
204
205private:
206 std::unordered_map<NetFeedType::Enum, MulticastTargetPtr> targets_;
207};
208
#define ONIXS_CME_MDH_TESTING_NAMESPACE_END
Definition Bootstrap.h:64
#define ONIXS_CME_MDH_TESTING_NAMESPACE_BEGIN
Definition Bootstrap.h:63
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:148
#define ONIXS_CMEMDH_NODISCARD
Definition Compiler.h:150
The collection of parameters defining feed connection.
Collection of parameters affecting recovery feeds behavior.
Collection of parameters affecting real-time feeds behavior.
~MulticastSender()
Releases all configured multicast targets.
MulticastSender(const MulticastSender &)=delete
MulticastSender & operator=(const MulticastSender &)=delete
Threading::Event send(NetFeedType::Enum target, const void *data, size_t dataSize)
Sends a datagram to the requested network feed type.
MulticastSender(const FeedSettings &feedSettings, Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service())
Initializes multicast targets from the feed settings.
MulticastTargetPtr & getTarget(NetFeedType::Enum target)
Returns the multicast target configured for the requested network feed type.
~MulticastTarget()
Leaves joined multicast groups and releases owned multicast clients.
void sendB(const void *data, size_t dataSize)
Sends a datagram to feed B when feed B is configured.
NetFeedRole::Enum secondaryFeed() const noexcept
Returns the feed role used as the secondary feed.
void sendA(const void *data, size_t dataSize)
Sends a datagram to feed A when feed A is configured.
NetFeedRole::Enum primaryFeed() const noexcept
Returns the feed role used as the primary feed.
void sendSecondary(const void *data, size_t dataSize)
Sends a datagram immediately to the secondary feed when it is configured.
bool hasSecondary() const noexcept
Indicates whether the configured layout has a secondary feed.
Threading::Event send(const void *data, size_t dataSize)
Sends a datagram to the primary feed and sends to the secondary feed when it is configured.
static constexpr PacketSize DefaultMaxPacketSize
Default maximum datagram payload size accepted by a directly constructed multicast target.
void sendPrimary(const void *data, size_t dataSize)
Sends a datagram to the primary feed.
MulticastTarget(const RealtimeFeedSettings &feedSettings, Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service(), PacketSize packetMaxSize=DefaultMaxPacketSize)
Initializes the target from realtime multicast feed settings.
MulticastTarget(const MulticastRecoveryFeedSettings &feedSettings, Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service(), PacketSize packetMaxSize=DefaultMaxPacketSize)
Initializes the target from multicast recovery feed settings.
std::unique_ptr< MulticastTarget > MulticastTargetPtr
SharedFuture< void > Event
Completion signal for an asynchronous operation that does not produce a value.
Definition Future.h:208
Messaging::UInt16 PacketSize
Integral type for measuring packets.
static ReplayDelayer & service()
Returns the instance reference.
Feed roles (primary, secondary).
Enum
List of known feed roles.
@ A
Identifies primary feed (A).
Enum
Feed types based on type of market data service.