TopicI.h
Go to the documentation of this file.
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
9 
10 #ifndef TOPIC_I_H
11 #define TOPIC_I_H
12 
14 #include <IceStorm/Election.h>
16 #include <IceStorm/Util.h>
17 #include <Ice/ObserverHelper.h>
18 #include <list>
19 
20 namespace IceStorm
21 {
22 
23  // Forward declarations
24  class PersistentInstance;
26 
27  class Subscriber;
29 
30  class TopicImpl : public IceUtil::Shared
31  {
32  public:
33 
34  TopicImpl(const PersistentInstancePtr&, const std::string&, const Ice::Identity&, const SubscriberRecordSeq&);
35 
36  std::string getName() const;
37  Ice::ObjectPrx getPublisher() const;
38  Ice::ObjectPrx getNonReplicatedPublisher() const;
39  Ice::ObjectPrx subscribeAndGetPublisher(const QoS&, const Ice::ObjectPrx&);
40  void unsubscribe(const Ice::ObjectPrx&);
42  void link(const TopicPrx&, Ice::Int);
43  void unlink(const TopicPrx&);
44  LinkInfoSeq getLinkInfoSeq() const;
45  Ice::IdentitySeq getSubscribers() const;
46  void reap(const Ice::IdentitySeq&);
47  void destroy();
48 
50 
51  void update(const SubscriberRecordSeq&);
52 
53  // Internal methods
54  bool destroyed() const;
55  Ice::Identity id() const;
56  TopicPrx proxy() const;
57  void shutdown();
58  void publish(bool, const EventDataSeq&);
59 
60  // Observer methods.
62  void observerRemoveSubscriber(const IceStormElection::LogUpdate&, const Ice::IdentitySeq&);
64 
65  Ice::ObjectPtr getServant() const;
66 
67  void updateObserver();
69 
70  private:
71 
72  IceStormElection::LogUpdate destroyInternal(const IceStormElection::LogUpdate&, bool);
73  void removeSubscribers(const Ice::IdentitySeq&);
74 
75  //
76  // Immutable members.
77  //
78  const Ice::ObjectPrx _publisherReplicaProxy;
79  const PersistentInstancePtr _instance;
80  const std::string _name; // The topic name
81  const Ice::Identity _id; // The topic identity
82 
83  IceInternal::ObserverHelperT<IceStorm::Instrumentation::TopicObserver> _observer;
84 
85  /*const*/ Ice::ObjectPrx _publisherPrx; // The actual publisher proxy.
86  /*const*/ TopicLinkPrx _linkPrx; // The link proxy.
87 
88  Ice::ObjectPtr _servant; // The topic implementation servant.
89 
90  // Mutex protecting the subscribers.
91  IceUtil::Mutex _subscribersMutex;
92 
93  //
94  // We keep a vector of subscribers since the optimized behaviour
95  // should be publishing events, not searching through the list of
96  // subscribers for a particular subscriber. I tested
97  // vector/list/map and although there was little difference vector
98  // was the fastest of the three.
99  //
100  std::vector<SubscriberPtr> _subscribers;
101 
102  bool _destroyed; // Has this Topic been destroyed?
103 
104  LLUMap _lluMap;
105  SubscriberMap _subscriberMap;
106  };
107 
109 
110 } // End namespace IceStorm
111 
112 #endif
Instrumentation.h
IceStorm::SubscriberRecordSeq
::std::vector< ::IceStorm::SubscriberRecord > SubscriberRecordSeq
Definition: SubscriberRecord.h:225
IceStorm::TopicImpl::destroy
void destroy()
Definition: TopicI.cpp:801
IceStorm::TopicImpl::getLinkInfoSeq
LinkInfoSeq getLinkInfoSeq() const
Definition: TopicI.cpp:767
IceStorm
Definition: DBTypes.ice:22
IceStorm::TopicImpl::getName
std::string getName() const
Definition: TopicI.cpp:445
IceStorm::TopicImpl::observerAddSubscriber
void observerAddSubscriber(const IceStormElection::LogUpdate &, const SubscriberRecord &)
Definition: TopicI.cpp:1034
IceStorm::EventDataSeq
std::deque< ::IceStorm::EventDataPtr > EventDataSeq
A sequence of EventData.
Definition: IceStormInternal.h:463
IceStormInternal.h
IceStorm::TopicImpl::getServant
Ice::ObjectPtr getServant() const
Definition: TopicI.cpp:1180
IceStorm::TopicImpl::shutdown
void shutdown()
Definition: TopicI.cpp:752
IceStormElection::LogUpdate
A struct used for marking the last log update.
Definition: LLURecord.h:100
IceStorm::TopicImpl::destroyed
bool destroyed() const
Definition: TopicI.cpp:902
IceStorm::TopicImpl::updateObserver
void updateObserver()
Definition: TopicI.cpp:1186
IceStorm::TopicImplPtr
IceUtil::Handle< TopicImpl > TopicImplPtr
Definition: TopicI.h:108
IceStorm::SubscriberPtr
IceUtil::Handle< Subscriber > SubscriberPtr
Definition: Subscriber.h:25
IceStorm::TopicImpl::unsubscribe
void unsubscribe(const Ice::ObjectPrx &)
Definition: TopicI.cpp:580
IceStorm::TopicImpl::update
void update(const SubscriberRecordSeq &)
Definition: TopicI.cpp:846
IceStorm::TopicImpl::unlink
void unlink(const TopicPrx &)
Definition: TopicI.cpp:690
Util.h
IceStorm::TopicImpl::getPublisher
Ice::ObjectPrx getPublisher() const
Definition: TopicI.cpp:452
IceStorm::SubscriberRecord
Used to store persistent information for persistent subscribers.
Definition: SubscriberRecord.h:214
IceStorm::TopicImpl::reap
void reap(const Ice::IdentitySeq &)
Definition: TopicI.cpp:729
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
IceStormElection::TopicContent
The contents of topic.
Definition: Election.ice:23
IceStorm::TopicImpl::updateSubscriberObservers
void updateSubscriberObservers()
Definition: TopicI.cpp:1196
IceStorm::TopicImpl::TopicImpl
TopicImpl(const PersistentInstancePtr &, const std::string &, const Ice::Identity &, const SubscriberRecordSeq &)
Definition: TopicI.cpp:341
IceStorm::TopicImpl
Definition: TopicI.h:30
IceStorm::TopicImpl::proxy
TopicPrx proxy() const
Definition: TopicI.cpp:916
IceDB::Dbi< std::string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream >
IceStorm::TopicImpl::publish
void publish(bool, const EventDataSeq &)
Definition: TopicI.cpp:963
IceStorm::TopicImpl::observerRemoveSubscriber
void observerRemoveSubscriber(const IceStormElection::LogUpdate &, const Ice::IdentitySeq &)
Definition: TopicI.cpp:1100
IceStorm::TopicImpl::getLinkProxy
TopicLinkPrx getLinkProxy()
Definition: TopicI.cpp:614
Election.h
IceUtil::Handle
Definition: forward_declarations.h:29
IceStorm::TopicImpl::id
Ice::Identity id() const
Definition: TopicI.cpp:909
IceInternal::ProxyHandle< ::IceProxy::IceStorm::TopicLink >
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
IceStorm::TopicImpl::observerDestroyTopic
void observerDestroyTopic(const IceStormElection::LogUpdate &)
Definition: TopicI.cpp:1159
armarx::Mutex
boost::mutex Mutex
Definition: Synchronization.h:131
IceStorm::TopicImpl::subscribeAndGetPublisher
Ice::ObjectPrx subscribeAndGetPublisher(const QoS &, const Ice::ObjectPrx &)
Definition: TopicI.cpp:496
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
IceStorm::TopicImpl::link
void link(const TopicPrx &, Ice::Int)
Definition: TopicI.cpp:626
IceStorm::TopicImpl::getNonReplicatedPublisher
Ice::ObjectPrx getNonReplicatedPublisher() const
Definition: TopicI.cpp:463
IceStorm::PersistentInstancePtr
IceUtil::Handle< PersistentInstance > PersistentInstancePtr
Definition: Instance.h:161
IceStorm::TopicImpl::getSubscribers
Ice::IdentitySeq getSubscribers() const
Definition: TopicI.cpp:788
IceStorm::TopicImpl::getContent
IceStormElection::TopicContent getContent() const
Definition: TopicI.cpp:826