// ********************************************************************** // // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. // // ********************************************************************** #ifndef OBSERVERS_H #define OBSERVERS_H #include #include #include #include #ifdef __SUNPRO_CC # pragma error_messages(off,hidef) #endif namespace IceStorm { class Instance; typedef IceUtil::Handle InstancePtr; class TraceLevels; typedef IceUtil::Handle TraceLevelsPtr; } namespace IceStormElection { class Observers : public IceUtil::Shared, public IceUtil::Mutex { public: Observers(const IceStorm::InstancePtr&); void setMajority(unsigned int); // Check that we have enough nodes for replication. bool check(); void clear(); void init(const std::set&, const LogUpdate&, const TopicContentSeq&); void createTopic(const LogUpdate&, const std::string&); void destroyTopic(const LogUpdate&, const std::string&); void addSubscriber(const LogUpdate&, const std::string&, const IceStorm::SubscriberRecord&); void removeSubscriber(const LogUpdate&, const std::string&, const Ice::IdentitySeq&); void getReapedSlaves(std::vector&); private: void wait(const std::string&); const IceStorm::TraceLevelsPtr _traceLevels; unsigned int _majority; struct ObserverInfo { ObserverInfo(int i, const ReplicaObserverPrx& o, const Ice::AsyncResultPtr& r = 0) : id(i), observer(o), result (r) {} int id; ReplicaObserverPrx observer; ::Ice::AsyncResultPtr result; }; std::vector _observers; IceUtil::Mutex _reapedMutex; std::vector _reaped; }; typedef IceUtil::Handle ObserversPtr; } #ifdef __SUNPRO_CC # pragma error_messages(default,hidef) #endif #endif // OBSERVERS_H