Observers.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 OBSERVERS_H
11 #define OBSERVERS_H
12 
13 #include <Ice/Ice.h>
14 #include <IceUtil/IceUtil.h>
15 #include <IceStorm/Election.h>
16 #include <IceStorm/Replica.h>
17 
18 #ifdef __SUNPRO_CC
19 # pragma error_messages(off,hidef)
20 #endif
21 
22 namespace IceStorm
23 {
24  class Instance;
26  class TraceLevels;
28 }
29 
30 namespace IceStormElection
31 {
32 
33  class Observers : public IceUtil::Shared, public IceUtil::Mutex
34  {
35  public:
37 
38  void setMajority(unsigned int);
39 
40  // Check that we have enough nodes for replication.
41  bool check();
42  void clear();
43 
44  void init(const std::set<IceStormElection::GroupNodeInfo>&, const LogUpdate&, const TopicContentSeq&);
45  void createTopic(const LogUpdate&, const std::string&);
46  void destroyTopic(const LogUpdate&, const std::string&);
47  void addSubscriber(const LogUpdate&, const std::string&, const IceStorm::SubscriberRecord&);
48  void removeSubscriber(const LogUpdate&, const std::string&, const Ice::IdentitySeq&);
49  void getReapedSlaves(std::vector<int>&);
50 
51  private:
52 
53  void wait(const std::string&);
54 
55  const IceStorm::TraceLevelsPtr _traceLevels;
56  unsigned int _majority;
57  struct ObserverInfo
58  {
59  ObserverInfo(int i, const ReplicaObserverPrx& o, const Ice::AsyncResultPtr& r = 0) :
60  id(i), observer(o), result(r) {}
61  int id;
62  ReplicaObserverPrx observer;
63  ::Ice::AsyncResultPtr result;
64  };
65  std::vector<ObserverInfo> _observers;
66  IceUtil::Mutex _reapedMutex;
67  std::vector<int> _reaped;
68  };
70 
71 }
72 
73 #ifdef __SUNPRO_CC
74 # pragma error_messages(default,hidef)
75 #endif
76 
77 #endif // OBSERVERS_H
IceStorm
Definition: DBTypes.ice:22
IceStormElection::ObserversPtr
IceUtil::Handle< Observers > ObserversPtr
Definition: Instance.h:32
IceStormElection::Observers::removeSubscriber
void removeSubscriber(const LogUpdate &, const std::string &, const Ice::IdentitySeq &)
Definition: Observers.cpp:170
IceStormElection::Observers
Definition: Observers.h:33
Replica.h
IceStormElection::LogUpdate
A struct used for marking the last log update.
Definition: LLURecord.h:100
IceStorm::TraceLevelsPtr
IceUtil::Handle< TraceLevels > TraceLevelsPtr
Definition: Instance.h:43
IceStorm::SubscriberRecord
Used to store persistent information for persistent subscribers.
Definition: SubscriberRecord.h:214
IceStormElection::Observers::getReapedSlaves
void getReapedSlaves(std::vector< int > &)
Definition: Observers.cpp:74
IceStormElection::TopicContentSeq
::std::vector< ::IceStormElection::TopicContent > TopicContentSeq
A sequence of topic content.
Definition: Election.h:819
IceStormElection
Definition: DBTypes.ice:17
IceStormElection::Observers::check
bool check()
Definition: Observers.cpp:31
IceStormElection::Observers::clear
void clear()
Definition: Observers.cpp:67
IceStormElection::Observers::destroyTopic
void destroyTopic(const LogUpdate &, const std::string &)
Definition: Observers.cpp:148
IceStormElection::Observers::addSubscriber
void addSubscriber(const LogUpdate &, const std::string &, const IceStorm::SubscriberRecord &)
Definition: Observers.cpp:159
IceStorm::InstancePtr
IceUtil::Handle< Instance > InstancePtr
Definition: Instance.h:126
IceStormElection::Observers::setMajority
void setMajority(unsigned int)
Definition: Observers.cpp:25
Election.h
IceUtil::Handle
Definition: forward_declarations.h:29
IceStormElection::Observers::init
void init(const std::set< IceStormElection::GroupNodeInfo > &, const LogUpdate &, const TopicContentSeq &)
Definition: Observers.cpp:81
IceInternal::ProxyHandle< ::IceProxy::IceStormElection::ReplicaObserver >
armarx::Mutex
boost::mutex Mutex
Definition: Synchronization.h:131
IceStormElection::Observers::Observers
Observers(const IceStorm::InstancePtr &)
Definition: Observers.cpp:18
IceStormElection::Observers::createTopic
void createTopic(const LogUpdate &, const std::string &)
Definition: Observers.cpp:137