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 <IceStorm/Election.h>
15#include <IceStorm/Replica.h>
16#include <IceUtil/IceUtil.h>
17
18#ifdef __SUNPRO_CC
19#pragma error_messages(off, hidef)
20#endif
21
22namespace IceStorm
23{
24 class Instance;
25 typedef IceUtil::Handle<Instance> InstancePtr;
26 class TraceLevels;
27 typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
28} // namespace IceStorm
29
30namespace 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>&,
45 const LogUpdate&,
46 const TopicContentSeq&);
47 void createTopic(const LogUpdate&, const std::string&);
48 void destroyTopic(const LogUpdate&, const std::string&);
49 void addSubscriber(const LogUpdate&, const std::string&, const IceStorm::SubscriberRecord&);
50 void removeSubscriber(const LogUpdate&, const std::string&, const Ice::IdentitySeq&);
51 void getReapedSlaves(std::vector<int>&);
52
53 private:
54 void wait(const std::string&);
55
56 const IceStorm::TraceLevelsPtr _traceLevels;
57 unsigned int _majority;
58
59 struct ObserverInfo
60 {
61 ObserverInfo(int i, const ReplicaObserverPrx& o, const Ice::AsyncResultPtr& r = 0) :
62 id(i), observer(o), result(r)
63 {
64 }
65
66 int id;
67 ReplicaObserverPrx observer;
68 ::Ice::AsyncResultPtr result;
69 };
70
71 std::vector<ObserverInfo> _observers;
72 IceUtil::Mutex _reapedMutex;
73 std::vector<int> _reaped;
74 };
75
77
78} // namespace IceStormElection
79
80#ifdef __SUNPRO_CC
81#pragma error_messages(default, hidef)
82#endif
83
84#endif // OBSERVERS_H
void getReapedSlaves(std::vector< int > &)
Definition Observers.cpp:73
void createTopic(const LogUpdate &, const std::string &)
void setMajority(unsigned int)
Definition Observers.cpp:24
void init(const std::set< IceStormElection::GroupNodeInfo > &, const LogUpdate &, const TopicContentSeq &)
Definition Observers.cpp:80
void addSubscriber(const LogUpdate &, const std::string &, const IceStorm::SubscriberRecord &)
Observers(const IceStorm::InstancePtr &)
Definition Observers.cpp:18
void removeSubscriber(const LogUpdate &, const std::string &, const Ice::IdentitySeq &)
void destroyTopic(const LogUpdate &, const std::string &)
::IceInternal::ProxyHandle<::IceProxy::IceStormElection::ReplicaObserver > ReplicaObserverPrx
Definition Election.h:1195
::std::vector<::IceStormElection::TopicContent > TopicContentSeq
A sequence of topic content.
Definition Election.h:1225
IceUtil::Handle< Observers > ObserversPtr
Definition Instance.h:33
IceUtil::Handle< TraceLevels > TraceLevelsPtr
Definition Instance.h:44
IceUtil::Handle< Instance > InstancePtr
Definition Instance.h:128
A struct used for marking the last log update.
Definition LLURecord.h:103
Used to store persistent information for persistent subscribers.