util/cluster/NodeInfo.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      NodeInfo.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Comment:   Holding information about the current node.
00006 ------------------------------------------------------------------------------*/
00007 #ifndef _UTIL_CLUSTER_NODEINFO_H
00008 #define _UTIL_CLUSTER_NODEINFO_H
00009 
00010 #include <util/xmlBlasterDef.h>
00011 #include <string>
00012 #include <map>
00013 
00014 #include <util/qos/address/CallbackAddress.h>
00015 #include <util/qos/address/Address.h>
00016 #include <util/cluster/NodeId.h>
00017 
00018 namespace org { namespace xmlBlaster { namespace util { namespace cluster {
00019 
00024 typedef std::map<std::string, org::xmlBlaster::util::qos::address::AddressBaseRef> AddressMap;
00025 typedef std::map<std::string, org::xmlBlaster::util::cluster::NodeId>          NodeMap;
00026 
00027 class Dll_Export NodeInfo
00028 {
00029 private:
00030    std::string          ME;
00031    org::xmlBlaster::util::Global&         global_;
00032    org::xmlBlaster::util::cluster::NodeId          nodeId_;
00033    org::xmlBlaster::util::qos::address::Address         tmpAddress_; // = null; // Helper for SAX parsing
00034    org::xmlBlaster::util::qos::address::CallbackAddress tmpCbAddress_; // = null; // Helper for SAX parsing
00035    AddressMap      cbAddressMap_; // = null;
00036    AddressMap      addressMap_; // = null;
00037    NodeMap         backupNodeMap_; // = null;
00038    bool            nameService_; //  = false;
00039    bool            inAddress_; // = false; // parsing inside <address> ?
00040    bool            inCallback_; //  = false; // parsing inside <callback> ?
00041    bool            inBackupnode_; // = false; // parsing inside <backupnode> ?
00042 
00043    void init()
00044    {
00045       nameService_  = false;
00046       inAddress_    = false;
00047       inCallback_   = false;
00048       inBackupnode_ = false;
00049    }
00050 
00051    void copy(const NodeInfo& info)
00052    {
00053    tmpAddress_   = info.tmpAddress_;
00054    tmpCbAddress_ = info.tmpCbAddress_;
00055    nameService_  = info.nameService_;
00056    inAddress_    = info.inAddress_;
00057    inCallback_   = info.inCallback_;
00058    inBackupnode_ = info.inBackupnode_;
00059    }
00060 
00061 
00065 public:
00066    NodeInfo(org::xmlBlaster::util::Global& global, org::xmlBlaster::util::cluster::NodeId nodeId);
00067 
00068    NodeInfo(const NodeInfo& info);
00069 
00070    NodeInfo& operator=(const NodeInfo& info);
00071 
00075    std::string getId() const;
00076 
00080    org::xmlBlaster::util::cluster::NodeId getNodeId() const;
00081 
00085    void setNodeId(org::xmlBlaster::util::cluster::NodeId nodeId);
00086 
00091    org::xmlBlaster::util::qos::address::AddressBaseRef getAddress() const;
00092 
00098    void addAddress(const org::xmlBlaster::util::qos::address::AddressBaseRef& address);
00099 
00103    AddressMap getAddressMap() const;
00104 
00108    bool contains(const org::xmlBlaster::util::qos::address::AddressBaseRef& other);
00109 
00114    org::xmlBlaster::util::qos::address::AddressBaseRef getCbAddress();
00115 
00119    AddressMap getCbAddressMap() const;
00120 
00124    void addCbAddress(const org::xmlBlaster::util::qos::address::AddressBaseRef& cbAddress);
00125 
00131    bool isNameService() const;
00132 
00138    void setNameService(bool nameService);
00139 
00144    NodeMap getBackupnodeMap() const;
00145 
00149    void addBackupnode(const org::xmlBlaster::util::cluster::NodeId& backupId);
00150 
00155    std::string toXml(const std::string& extraOffset="");
00156 };
00157 
00158 }}}}
00159 
00160 #endif