From 92a6531e409f2691d82591e185a92299d415fc0f Mon Sep 17 00:00:00 2001 From: Joe George Date: Thu, 28 Jan 2021 16:26:44 -0500 Subject: IceGrid and IceStorm --- cpp/src/IceGrid/NodeSessionManager.h | 69 +++++++++++++++++------------------- 1 file changed, 32 insertions(+), 37 deletions(-) (limited to 'cpp/src/IceGrid/NodeSessionManager.h') diff --git a/cpp/src/IceGrid/NodeSessionManager.h b/cpp/src/IceGrid/NodeSessionManager.h index 27abb769ecf..791c4c286be 100644 --- a/cpp/src/IceGrid/NodeSessionManager.h +++ b/cpp/src/IceGrid/NodeSessionManager.h @@ -5,10 +5,6 @@ #ifndef ICE_GRID_NODE_SESSION_MANAGER_H #define ICE_GRID_NODE_SESSION_MANAGER_H -#include -#include -#include - #include #include #include @@ -18,40 +14,40 @@ namespace IceGrid { class NodeI; -typedef IceUtil::Handle NodeIPtr; - class NodeSessionManager; class NodeSessionKeepAliveThread : public SessionKeepAliveThread { public: - NodeSessionKeepAliveThread(const InternalRegistryPrx&, const NodeIPtr&, NodeSessionManager&); + NodeSessionKeepAliveThread(const std::shared_ptr&, const std::shared_ptr&, + NodeSessionManager&); - virtual NodeSessionPrx createSession(InternalRegistryPrx&, IceUtil::Time&); - virtual void destroySession(const NodeSessionPrx&); - virtual bool keepAlive(const NodeSessionPrx&); + virtual std::shared_ptr createSession(std::shared_ptr&, + std::chrono::seconds&) override; + virtual void destroySession(const std::shared_ptr&) override; + virtual bool keepAlive(const std::shared_ptr&) override; - std::string getName() const { return _name; } + std::string getName() const { return "IceGrid session keepalive thread"; } protected: - virtual NodeSessionPrx createSessionImpl(const InternalRegistryPrx&, IceUtil::Time&); + std::shared_ptr createSessionImpl(const std::shared_ptr&, + std::chrono::seconds&); - const NodeIPtr _node; + const std::shared_ptr _node; const std::string _replicaName; NodeSessionManager& _manager; }; -typedef IceUtil::Handle NodeSessionKeepAliveThreadPtr; class NodeSessionManager : public SessionManager { public: - NodeSessionManager(const Ice::CommunicatorPtr&, const std::string&); + NodeSessionManager(const std::shared_ptr&, const std::string&); - void create(const NodeIPtr&); - void create(const InternalRegistryPrx&); + void create(const std::shared_ptr&); + void create(const std::shared_ptr&); void activate(); bool isWaitingForCreate(); bool waitForCreate(); @@ -59,27 +55,27 @@ public: void destroy(); void replicaInit(const InternalRegistryPrxSeq&); - void replicaAdded(const InternalRegistryPrx&); - void replicaRemoved(const InternalRegistryPrx&); + void replicaAdded(const std::shared_ptr&); + void replicaRemoved(const std::shared_ptr&); - NodeSessionPrx getMasterNodeSession() const { return _thread->getSession(); } - std::vector getQueryObjects() { return findAllQueryObjects(true); } + std::shared_ptr getMasterNodeSession() const { return _thread->getSession(); } + std::vector> getQueryObjects() { return findAllQueryObjects(true); } private: - NodeSessionKeepAliveThreadPtr addReplicaSession(const InternalRegistryPrx&); + std::shared_ptr addReplicaSession(const std::shared_ptr&); void reapReplicas(); - void syncServers(const NodeSessionPrx&); + void syncServers(const std::shared_ptr&); bool isDestroyed() { - Lock sync(*this); + std::lock_guard lock(_mutex); return _destroyed; } - class Thread : public NodeSessionKeepAliveThread + class Thread final : public NodeSessionKeepAliveThread { public: @@ -87,41 +83,40 @@ private: { } - virtual NodeSessionPrx - createSession(InternalRegistryPrx& master, IceUtil::Time& timeout) + std::shared_ptr + createSession(std::shared_ptr& master, std::chrono::seconds& timeout) override { - NodeSessionPrx session = NodeSessionKeepAliveThread::createSession(master, timeout); + auto session = NodeSessionKeepAliveThread::createSession(master, timeout); _manager.createdSession(session); _manager.reapReplicas(); return session; } - virtual void - destroySession(const NodeSessionPrx& session) + void + destroySession(const std::shared_ptr& session) override { NodeSessionKeepAliveThread::destroySession(session); _manager.reapReplicas(); } - virtual bool - keepAlive(const NodeSessionPrx& session) + bool + keepAlive(const std::shared_ptr& session) override { bool alive = NodeSessionKeepAliveThread::keepAlive(session); _manager.reapReplicas(); return alive; } }; - typedef IceUtil::Handle ThreadPtr; friend class Thread; - void createdSession(const NodeSessionPrx&); + void createdSession(const std::shared_ptr&); - const NodeIPtr _node; - ThreadPtr _thread; + const std::shared_ptr _node; + std::shared_ptr _thread; bool _destroyed; bool _activated; - typedef std::map NodeSessionMap; + using NodeSessionMap = std::map>; NodeSessionMap _sessions; std::set _replicas; }; -- cgit v1.2.3