⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nodeinfo.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------Name:      NodeInfo.javaProject:   xmlBlaster.orgCopyright: xmlBlaster.org, see xmlBlaster-LICENSE fileComment:   Holding information about the current node.Author:    xmlBlaster@marcelruff.info------------------------------------------------------------------------------*/package org.xmlBlaster.engine.cluster;import java.util.Properties;import java.util.logging.Logger;import java.util.logging.Level;import org.xmlBlaster.client.qos.DisconnectQos;import org.xmlBlaster.util.Global;import org.xmlBlaster.util.qos.ConnectQosData;import org.xmlBlaster.util.qos.ConnectQosSaxFactory;import org.xmlBlaster.util.qos.address.Address;import org.xmlBlaster.util.qos.address.AddressBase;import org.xmlBlaster.util.qos.address.CallbackAddress;import org.xmlBlaster.util.XmlBlasterException;import org.xmlBlaster.util.def.Constants;import org.xmlBlaster.util.def.ErrorCode;import org.xmlBlaster.util.def.MethodName;import org.xmlBlaster.util.cluster.NodeId;import org.xml.sax.Attributes;import org.xml.sax.SAXException;/** * This class holds the address informations about an * xmlBlaster server instance (=cluster node).  * It is created by the NodeParser from xml markup of by * the ClusterManager (via ClusterNode) for our local node. */public final class NodeInfo{   private final String ME;   /**     * This util global instance is used for I_XmlBlasterAccess, it    * uses the specific settings from NodeInfo to connect to the remote node    */   private final org.xmlBlaster.util.Global remoteGlob;   private static Logger log = Logger.getLogger(NodeInfo.class.getName());   private NodeId nodeId;   private long counter = 0L;   private ConnectQosSaxFactory connectQosSaxFactory;   private ConnectQosData connectQosData;   private DisconnectQos disconnectQos;   /** @deprecated We now use ConnectQos */   private Address tmpAddress = null; // Helper for SAX parsing   /** @deprecated We now use ConnectQos */   private CallbackAddress tmpCbAddress = null; // Helper for SAX parsing   private boolean nameService = false;   private boolean inConnectQos = false;  // parsing inside <connect><qos> ?   private boolean inInfo = false;   private boolean inAddress = false; // parsing inside <address> ?   private boolean inCallback = false; // parsing inside <callback> ?   /** A unique created session id delivered on callback in update() method */   private String cbSessionId = null;   /**    * Holds the ConnectQos of a node.     * @param remoteGlob The global specific to this node instance.     */   public NodeInfo(Global remoteGlob, NodeId nodeId) throws XmlBlasterException {      this.remoteGlob = remoteGlob;      this.setNodeId(nodeId);      this.ME = "NodeInfo." + getId();      this.connectQosData = new ConnectQosData(this.remoteGlob, this.nodeId);   }   /**    * @return The unique name of the managed xmlBlaster instance e.g. "bilbo.mycompany.com"    */   public String getId(){     return nodeId.getId();   }   /**    * @return The unique name of the managed xmlBlaster instance.    */   public NodeId getNodeId() {     return nodeId;   }   /**    * @return The connection configuration for the remote cluster node, never null    */      public ConnectQosData getConnectQosData() {      /*      if (this.connectQosData == null) {         synchronized (this) {            if (this.connectQosData == null) {               this.connectQosData = new ConnectQosData(this.remoteGlob, this.nodeId);            }         }      }      */      return this.connectQosData;   }   /**    * TODO: !!!! is this needed?    * @param The unique name of the managed xmlBlaster instance    */   public void setNodeId(NodeId nodeId) {      if (nodeId == null) throw new IllegalArgumentException("NodeInfo.setNodeId(): NodeId argument is null");      this.nodeId = nodeId;   }   /**    * The expected callback sessionId which used to authenticate the update() call    */   String getCbSessionId() {      return (this.cbSessionId == null) ? "" : this.cbSessionId;   }   /**    * Access the currently used address to access the node    * @return null if not specified  !!!!!! TODO: Changed to throws IllegalArgumentException    */   private Address getAddress() {      return getConnectQosData().getAddress();   }   /**    * Add another address for this cluster node.     * <p />    * The map is sorted with the same sequence as the given XML sequence    */   public void addAddress(Address address){      // All local plugin configurations are added here if this is the local node      getConnectQosData().addAddress(address);   }   /**    * Does the given address belong to this node?    */   public boolean contains(Address other) {      return getConnectQosData().contains(other);   }   /**    * Add another callback address for this cluster node.     */   public void addCbAddress(CallbackAddress cbAddress) {      getConnectQosData().addCallbackAddress(cbAddress);   }   /**    * Is the node acting as a preferred cluster naming service.     * <p />    * NOTE: This mode is currently not supported    */   public boolean isNameService() {      return nameService;   }   /**    * Tag this node as a cluster naming service.     * <p />    * NOTE: This mode is currently not supported    */   public void setNameService(boolean nameService) {      this.nameService = nameService;   }   /**    * Force some cluster specific connection settings.     */   private void postInitialize() throws XmlBlasterException   {      ConnectQosData data = getConnectQosData();            data.setClusterNode(true);      this.remoteGlob.setBootstrapAddress(getAddress());      // Shall we allow a configurable user name for cluster slave logins?      // Required: To use the cluster.node.id as login name      //           so other cluster nodes accept our subscriptionId, e.g. "__subId:heron-3456646466"      //SessionName sessionName = new SessionName(this.getRemoteGlob(), this.remoteGlob.getId() + "/1"); // is done in setUserId already      //data.getSessionQos().setSessionName(sessionName);      data.setUserId(this.remoteGlob.getId() + "/1"); // the login name, e.g. "heron/1"      // The password is from the environment -passwd or more specific -passwd[heron]      // Or from the XML securityQos      // Create a secret callback session id to be able to authenticate update() calls      CallbackAddress callback = data.getCurrentCallbackAddress();      if (callback != null) {         if (callback.getSecretSessionId().equals(AddressBase.DEFAULT_sessionId))            callback.setSecretSessionId(createCbSessionId());         this.cbSessionId = callback.getSecretSessionId();         callback.setRetries(-1);      }      else {         log.severe("Internal problem: Expected a callback address setup but none was delivered");      }      // As we forward many subscribes probably accessing the      // same message but only want one update.      // We cache this update and distribute to all our clients:      // TODO: Please change to use multiSubscribe=false from SubscribeQos      //              as an unSubscribe() deletes all subscribes() at once      //              we have not yet implemented the new desired use of multiSubscribe      data.setDuplicateUpdates(false);      data.getSessionQos().setSessionTimeout(0L); // session lasts forever      data.getSessionQos().clearSessions(true);   // We only login once, kill other (older) sessions of myself!   }   /**    * Called for SAX master start tag

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -