Subscriber.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 SUBSCRIBER_H
11 #define SUBSCRIBER_H
12 
16 #include <Ice/ObserverHelper.h>
17 #include <IceUtil/RecMutex.h>
18 
19 namespace IceStorm
20 {
21 
22  class Instance;
24 
25  class Subscriber;
27 
28  class Subscriber : public IceUtil::Shared
29  {
30  public:
31 
33 
34  Ice::ObjectPrx proxy() const; // Get the per subscriber object.
35  Ice::Identity id() const; // Return the id of the subscriber.
36  IceStorm::SubscriberRecord record() const; // Get the subscriber record.
37 
38  // Returns false if the subscriber should be reaped.
39  bool queue(bool, const EventDataSeq&);
40  bool reap();
41  void resetIfReaped();
42  bool errored() const;
43 
44  void destroy();
45 
46  // To be called by the AMI callbacks only.
47  void completed(const Ice::AsyncResultPtr&);
48  void error(bool, const Ice::Exception&);
49 
50  void shutdown();
51 
52  void updateObserver();
53 
55  {
56  SubscriberStateOnline, // Online waiting to send events.
57  SubscriberStateOffline, // Offline, retrying.
58  SubscriberStateError, // Error state, awaiting reaping.
60  };
61 
62  virtual void flush() = 0;
63 
64  protected:
65 
67 
68  Subscriber(const InstancePtr&, const IceStorm::SubscriberRecord&, const Ice::ObjectPrx&, int, int);
69 
70  // Immutable
72  const IceStorm::SubscriberRecord _rec; // The subscriber record.
73  const int _retryCount; // The retryCount.
74  const int _maxOutstanding; // The maximum number of oustanding events.
75  const Ice::ObjectPrx _proxy; // The per subscriber object proxy, if any.
76  const Ice::ObjectPrx _proxyReplica; // The replicated per subscriber object proxy, if any.
77 
78  IceUtil::Monitor<IceUtil::RecMutex> _lock;
79 
80  bool _shutdown;
81 
82  SubscriberState _state; // The subscriber state.
83 
84  int _outstanding; // The current number of outstanding responses.
85  int _outstandingCount; // The current number of outstanding events when batching events (only used for metrics).
86  EventDataSeq _events; // The queue of events to send.
87 
88  // The next time to try sending a new event if we're offline.
91 
92  IceInternal::ObserverHelperT<IceStorm::Instrumentation::SubscriberObserver> _observer;
93  };
94 
99 
100 }
101 
102 #endif // SUBSCRIBER_H
Instrumentation.h
IceStorm::Subscriber::SubscriberStateOnline
@ SubscriberStateOnline
Definition: Subscriber.h:56
IceStorm::Subscriber::resetIfReaped
void resetIfReaped()
Definition: Subscriber.cpp:742
IceStorm
Definition: DBTypes.ice:22
IceStorm::Subscriber::_outstanding
int _outstanding
Definition: Subscriber.h:84
IceStorm::Subscriber
Definition: Subscriber.h:28
IceStorm::Subscriber::_next
IceUtil::Time _next
Definition: Subscriber.h:89
IceStorm::Subscriber::_state
SubscriberState _state
Definition: Subscriber.h:82
IceStorm::EventDataSeq
std::deque< ::IceStorm::EventDataPtr > EventDataSeq
A sequence of EventData.
Definition: IceStormInternal.h:463
IceStorm::Subscriber::setState
void setState(SubscriberState)
Definition: Subscriber.cpp:1025
IceStormInternal.h
IceStorm::operator!=
bool operator!=(const IceStorm::Subscriber &, const IceStorm::Subscriber &)
Definition: Subscriber.cpp:1064
IceStorm::Subscriber::_outstandingCount
int _outstandingCount
Definition: Subscriber.h:85
IceStorm::operator==
bool operator==(const TopicLink &lhs, const TopicLink &rhs)
Definition: IceStormInternal.h:724
IceStorm::Subscriber::SubscriberStateReaped
@ SubscriberStateReaped
Definition: Subscriber.h:59
IceStorm::Subscriber::_shutdown
bool _shutdown
Definition: Subscriber.h:80
IceStorm::SubscriberPtr
IceUtil::Handle< Subscriber > SubscriberPtr
Definition: Subscriber.h:25
IceStorm::Subscriber::_lock
IceUtil::Monitor< IceUtil::RecMutex > _lock
Definition: Subscriber.h:78
IceStorm::Subscriber::create
static SubscriberPtr create(const InstancePtr &, const IceStorm::SubscriberRecord &)
Definition: Subscriber.cpp:522
IceStorm::Subscriber::reap
bool reap()
Definition: Subscriber.cpp:729
IceStorm::Subscriber::proxy
Ice::ObjectPrx proxy() const
Definition: Subscriber.cpp:645
IceStorm::Subscriber::_proxyReplica
const Ice::ObjectPrx _proxyReplica
Definition: Subscriber.h:76
IceStorm::SubscriberRecord
Used to store persistent information for persistent subscribers.
Definition: SubscriberRecord.h:214
IceStorm::Subscriber::_maxOutstanding
const int _maxOutstanding
Definition: Subscriber.h:74
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
IceStorm::Subscriber::id
Ice::Identity id() const
Definition: Subscriber.cpp:651
IceStorm::Subscriber::SubscriberStateError
@ SubscriberStateError
Definition: Subscriber.h:58
IceStorm::Subscriber::updateObserver
void updateObserver()
Definition: Subscriber.cpp:950
IceStorm::Subscriber::completed
void completed(const Ice::AsyncResultPtr &)
Definition: Subscriber.cpp:898
IceStorm::Subscriber::errored
bool errored() const
Definition: Subscriber.cpp:752
IceStorm::Subscriber::SubscriberState
SubscriberState
Definition: Subscriber.h:54
IceStorm::Subscriber::record
IceStorm::SubscriberRecord record() const
Definition: Subscriber.cpp:657
IceStorm::Subscriber::flush
virtual void flush()=0
IceStorm::InstancePtr
IceUtil::Handle< Instance > InstancePtr
Definition: Instance.h:126
IceStorm::Subscriber::_events
EventDataSeq _events
Definition: Subscriber.h:86
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
IceStorm::Subscriber::_proxy
const Ice::ObjectPrx _proxy
Definition: Subscriber.h:75
IceStorm::operator<
bool operator<(const TopicLink &lhs, const TopicLink &rhs)
Definition: IceStormInternal.h:729
SubscriberRecord.h
IceStorm::Subscriber::error
void error(bool, const Ice::Exception &)
Definition: Subscriber.cpp:785
IceStorm::Subscriber::_currentRetry
int _currentRetry
Definition: Subscriber.h:90
IceStorm::Subscriber::_retryCount
const int _retryCount
Definition: Subscriber.h:73
IceUtil::Handle
Definition: forward_declarations.h:29
IceStorm::Subscriber::_rec
const IceStorm::SubscriberRecord _rec
Definition: Subscriber.h:72
IceStorm::Subscriber::_instance
const InstancePtr _instance
Definition: Subscriber.h:71
IceStorm::Subscriber::Subscriber
Subscriber(const InstancePtr &, const IceStorm::SubscriberRecord &, const Ice::ObjectPrx &, int, int)
Definition: Subscriber.cpp:965
IceStorm::Subscriber::_observer
IceInternal::ObserverHelperT< IceStorm::Instrumentation::SubscriberObserver > _observer
Definition: Subscriber.h:92
IceStorm::Subscriber::shutdown
void shutdown()
Definition: Subscriber.cpp:936
IceStorm::Subscriber::SubscriberStateOffline
@ SubscriberStateOffline
Definition: Subscriber.h:57
IceStorm::Subscriber::queue
bool queue(bool, const EventDataSeq &)
Definition: Subscriber.cpp:663
IceStorm::Subscriber::destroy
void destroy()
Definition: Subscriber.cpp:759