// ********************************************************************** // // Copyright (c) 2003-2012 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. // // ********************************************************************** #pragma once #include #include #include #include namespace IceGrid { class NodeCache; class SessionI; typedef IceUtil::Handle SessionIPtr; class NodeSessionI; typedef IceUtil::Handle NodeSessionIPtr; class ServerEntry; typedef IceUtil::Handle ServerEntryPtr; typedef std::vector ServerEntrySeq; class ReplicaCache; class NodeEntry : public IceUtil::Monitor { public: NodeEntry(NodeCache&, const std::string&); virtual ~NodeEntry(); void addDescriptor(const std::string&, const NodeDescriptor&); void removeDescriptor(const std::string&); void addServer(const ServerEntryPtr&); void removeServer(const ServerEntryPtr&); void setSession(const NodeSessionIPtr&); NodePrx getProxy() const; InternalNodeInfoPtr getInfo() const; ServerEntrySeq getServers() const; LoadInfo getLoadInfoAndLoadFactor(const std::string&, float&) const; NodeSessionIPtr getSession() const; bool canRemove(); void loadServer(const ServerEntryPtr&, const ServerInfo&, const SessionIPtr&, int); void destroyServer(const ServerEntryPtr&, const ServerInfo&, int); ServerInfo getServerInfo(const ServerInfo&, const SessionIPtr&); void __incRef(); void __decRef(); void checkSession() const; void setProxy(const NodePrx&); void finishedRegistration(); void finishedRegistration(const Ice::Exception&); private: ServerDescriptorPtr getServerDescriptor(const ServerInfo&, const SessionIPtr&); InternalServerDescriptorPtr getInternalServerDescriptor(const ServerInfo&) const; NodeCache& _cache; IceUtil::Mutex _refMutex; int _ref; const std::string _name; NodeSessionIPtr _session; std::map _servers; std::map _descriptors; mutable bool _registering; mutable NodePrx _proxy; }; typedef IceUtil::Handle NodeEntryPtr; class NodeCache : public CacheByString { public: NodeCache(const Ice::CommunicatorPtr&, ReplicaCache&, const std::string&); NodeEntryPtr get(const std::string&, bool = false) const; const Ice::CommunicatorPtr& getCommunicator() const { return _communicator; } const std::string& getReplicaName() const { return _replicaName; } ReplicaCache& getReplicaCache() const { return _replicaCache; } private: const Ice::CommunicatorPtr _communicator; const std::string _replicaName; ReplicaCache& _replicaCache; }; };