OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.2.2
API documentation
EmdiHandlerImpl.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
5 *
6 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
7 * and international copyright treaties.
8 *
9 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
10 * Services Agreement (the Agreement) and Customer end user license agreements granting
11 * a non-assignable, non-transferable and non-exclusive license to use the software
12 * for it's own data processing purposes under the terms defined in the Agreement.
13 *
14 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
15 * of this source code or associated reference material to any other location for further reproduction
16 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
17 *
18 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
19 * the terms of the Agreement is a violation of copyright law.
20 */
21 #include <boost/unordered_set.hpp>
22 
24 
25 #include "Formatting.h"
26 #include "EmdiPacketProcessor.h"
27 #include "EmdiDataRepository.h"
28 #include "BaseHandlerImp.h"
29 #include "MessagePool.h"
30 
31 
32 namespace OnixS {
33 namespace Eurex {
34 namespace MarketData {
35 namespace Implementation {
36 
38 {
39  typedef BaseHandlerImp base;
40 
41 public:
42  /// Initialize new instance.
43  explicit
44  EmdiHandlerImpl(const EmdiHandlerSettings & settings);
45 
46  /// Finalize instance.
47  ~EmdiHandlerImpl() override;
48 
49  void bindFeedEngine(FeedEngine& feedEngine);
50 
51  /// Start handler.
52  void start ();
53 
54  /// Starts replaying previously logged data.
55  void start(const ReplayOptions& options);
56 
57  /// Stop handler.
58  void stop ();
59 
60  /// Returns commons services as shared object.
61  ListenerHolder& listenerHolder() { return *listenerHolder_; }
62 
63  /// Invoke helpers
64  void invokeError (ErrorCode::Enum code, const std::string& description) override { listenerHolder_->invokeError (code, description); }
65  void invokeWarning (const std::string& description) override { listenerHolder_->invokeWarning (description); }
66 
68 
69  void setPartitionIdFilters(const PartitionIdFilters& filters);
73  void setSecurityIdFilters(const SecurityIdFilters& filters);
75 
76 private:
77  void initLogger(const HandlerSettings &settings);
78 
79 private:
80 
81  void onStarted() override;
82  void onStopped() override;
83 
84  void onPrepareFeeds();
85  bool filterPacket(PartitionId partitionId);
86 
87  void onSnapshotStartRequest();
88  void onSnapshotStopRequest();
89 
90  void onStateChanged(State::Enum newState) override;
91 
92  void checkXmlFile();
93 
94 private:
95  void onIncrementalPacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
96  void onIncrementalPacketGap();
97  void onIncrementalSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
98  void onIncrementalInactivity();
99  void onIncrementalFeedInactivity(OnixS::HandlerCore::MarketData::FE::NetFeedRole::Enum id);
100 
101  void onSnapshotPacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
102  void onSnapshotPacketGap();
103  void onSnapshotSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
104  void onSnapshotInactivity();
105  void onSnapshotFeedInactivity(OnixS::HandlerCore::MarketData::FE::NetFeedRole::Enum id);
106 
107 
108 private:
109  EmdiHandlerSettings settings_;
110 
111  Logging::LogFacility logFacilityForSnapshots_;
112  Logging::LogFacility logFacilityForIncrementals_;
113 
114  MessagesPool incrementalMessagesPool_;
115  AccumulatingAllocator snapShotContentAllocator_;
116 
117 
118  LoggerPtr logger_;
119  boost::scoped_ptr<ListenerHolder> listenerHolder_;
120 
121  boost::scoped_ptr<EmdiPacketProcessor> incrementalPacketProcessor_;
122  boost::scoped_ptr<EmdiPacketProcessor> snapshotPacketProcessor_;
123 
124  MulticastFeedClusterPtr incrementalFeeds_;
125  MulticastFeedClusterPtr snapshotFeeds_;
126 
127  boost::scoped_ptr<FixDecoder> incrementalFixDecoder_;
128  boost::scoped_ptr<FixDecoder> snapshotFixDecoder_;
129 
130  boost::scoped_ptr<EmdiDataRepository> dataRepository_;
131 
132  typedef boost::unordered_set<PartitionId> PartitionIdFilters_;
133  PartitionIdFilters_ partitionIdFilters_;
134 };
135 
136 } // namespace Implementation
137 
139 {
141 
142 public:
143 Impl(const EmdiHandlerSettings & settings)
144  : base(settings)
145 {}
146 };
147 
148 }}}
149 
unsigned int SequenceNumber
Alias for sequence numbers.
void setMarketSegmentIdFilters(const MarketSegmentIdFilters &filters)
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
MarketDepthTraits::MarketSegmentId2Depth MarketSegmentId2Depth
void setSecurityIdFilters(const SecurityIdFilters &filters)
UInt32 PartitionId
Alias for Partition ID type.
Definition: Defines.h:48
boost::scoped_ptr< HandlerCore::Common::HandlerLogger > LoggerPtr
FilteringTraits::PartitionIdFilters PartitionIdFilters
Handler base configuration settings.
EmdiHandlerImpl(const EmdiHandlerSettings &settings)
Initialize new instance.
Definition: Defines.h:30
void invokeError(ErrorCode::Enum code, const std::string &description) override
Invoke helpers.
FilteringTraits::MarketSegmentIdFilters MarketSegmentIdFilters
Defines params which affect logs replay.
Definition: Replay.h:74
ListenerHolder & listenerHolder()
Returns commons services as shared object.
EMDI handler configuration settings.
Implementation::EmdiHandlerImpl base
FilteringTraits::SecurityIdFilters SecurityIdFilters
Enum
Known (selected) error codes.
Definition: ErrorListener.h:36
void setPartitionIdFilters(const PartitionIdFilters &filters)
Impl(const EmdiHandlerSettings &settings)
void setMarketSegmentId2Depth(const MarketSegmentId2Depth &map)
void invokeWarning(const std::string &description) override