📄 a3cmlconfig.java
字号:
else { try { A3CMLCluster cluster = getCluster(sid); server = cluster.getServer(cid); } catch (Exception exc) { throw new UnknownServerException(exc.getMessage()); } } if (server == null) throw new UnknownServerException("Unknown server id. #" + sid); return server; } /** * Returns the description of a server. * * @param name The server name. * @return The server description if exist. * @exception UnknownServerException * If the server does not exist. */ public final A3CMLServer getServer(String name) throws UnknownServerException { for (Enumeration s = servers.elements(); s.hasMoreElements(); ) { A3CMLServer server = (A3CMLServer) s.nextElement(); if (server.name.equals(name)) return server; } throw new UnknownServerException("Unknown server id for server " + name); } /** * add property * * @param prop A3CMLProperty * @return the previous value of the specified prop.name in * this hashtable, or null if it did not have one. * @exception Exception */ public final A3CMLProperty addProperty(A3CMLProperty prop) throws Exception { return (A3CMLProperty) properties.put(prop.name, prop); } /** * remove property * * @param name property name * @return the value to which the name had been mapped in * this hashtable, or null if the name did not have a mapping. */ public final A3CMLProperty removeProperty(String name) { return (A3CMLProperty) properties.remove(name); } /** * contains property * * @param name property name * @return true if contain name; false otherwise. */ public final boolean containsProperty(String name) { return properties.containsKey(name); } /** * Returns the specified property. */ public final A3CMLProperty getProperty(String name) { return (A3CMLProperty) properties.get(name); } /** * Returns the specified property. */ public final A3CMLProperty getProperty(String name, short sid, short cid) throws Exception { A3CMLProperty prop = null; if (cid == AgentServer.NULL_ID) { A3CMLServer server = getServer(sid); prop = (A3CMLProperty) server.getProperty(name); } else { A3CMLCluster cluster = getCluster(sid); A3CMLServer server = cluster.getServer(cid); prop = (A3CMLProperty) server.getProperty(name); if (prop == null) prop = (A3CMLProperty) cluster.getProperty(name); } return prop; } /** * Get the JVM argument for a particular agent server identified by its id. * * @param id agent server identifier. * @return the arguments as declared in configuration file * @exception UnknownServerException * The specified server does not exist. */ public final String getJvmArgs(short sid) throws UnknownServerException { A3CMLServer server = getServer(sid); return server.getJvmArgs(); } /** * Get the JVM argument for a particular agent server identified by its name. * * @param name agent server name. * @return the arguments as declared in configuration file * @exception UnknownServerException * The specified server does not exist. */ public final String getJvmArgs(String name) throws UnknownServerException { A3CMLServer server = getServer(name); return server.getJvmArgs(); } /** * Get the argument strings for a particular service on a particular * agent server identified by its id. * * @param sid agent server id. * @param classname the service class name. * @return the arguments as declared. * @exception UnknownServerException * The specified server does not exist. * @exception UnknownServiceException * The specified service is not declared on this server. */ public final String getServiceArgs(short sid, String classname) throws UnknownServerException, UnknownServiceException { A3CMLServer server = getServer(sid); return server.getServiceArgs(classname); } /** * Get the argument strings for a particular service on a particular * agent server identified by its name. * * @param sid agent server name. * @param classname the service class name. * @return the arguments as declared. * @exception UnknownServerException * The specified server does not exist. * @exception UnknownServiceException * The specified service is not declared on this server. */ public final String getServiceArgs(String name, String classname) throws UnknownServerException, UnknownServiceException { A3CMLServer server = getServer(name); return server.getServiceArgs(classname); } /* -+-+-+- -+-+-+- */ /* -+-+-+- Code needed for configuration. -+-+-+- */ /* -+-+-+- -+-+-+- */ /** * Adapts the current configuration to the specified persistent server. */ public void configure(A3CMLServer root) throws Exception { short rootid = root.sid; Vector toExplore = new Vector(); // Temporary fix, reset visited and gateway fields reset(); // Search alls directly accessible domains. for (Enumeration n = root.networks.elements(); n.hasMoreElements();) { A3CMLNetwork network = (A3CMLNetwork) n.nextElement(); A3CMLDomain domain = (A3CMLDomain) domains.get(network.domain); domain.gateway = rootid; domain.hops = 1; toExplore.addElement(domain); Log.logger.log(BasicLevel.DEBUG, "configure - toExplore.add(" + domain + ")"); } root.visited = true; root.gateway = -1; root.hops = 0; root.domain = "local"; while (toExplore.size() > 0) { A3CMLDomain domain = (A3CMLDomain) toExplore.elementAt(0); toExplore.removeElementAt(0); A3CMLServer gateway = (A3CMLServer) servers.get(new Short(domain.gateway)); if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - explore(" + domain + ")"); // Parse all nodes of this domain for (Enumeration s = domain.servers.elements(); s.hasMoreElements();) { A3CMLServer server = (A3CMLServer) s.nextElement(); if (server.visited) continue; if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - explore(" + server + ")"); server.visited = true; if (domain.gateway == rootid) { // The server is directly accessible from root server.gateway = -1; server.domain = domain.name; } else { server.gateway = domain.gateway; server.domain = gateway.domain; } server.hops = domain.hops; // If the server is a router then add the accessible domains // to the list. for (Enumeration n = server.networks.elements(); n.hasMoreElements();) { A3CMLNetwork network = (A3CMLNetwork) n.nextElement(); A3CMLDomain d2 = (A3CMLDomain) domains.get(network.domain); if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - parse(" + d2 + ")"); if (d2 == domain) { if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - setPort(" + network.port + ")"); // The server is directly accessible from root server by // this network interface; fixes the communication port // for this server. // AF 03/11/2004 - It seems in fact the domain is the one we are // exploring, so if the server is directly accessible its listen // port is the one of this network... server.port = network.port; continue; } // If the domain is already explored then there is more // than one route to this domain. //if (d2.gateway != -1) // throw new Exception("more than one route to: " + domain); // if (d2.hops != -1)// throw new Exception("more than one route to: " + domain); d2.hops = domain.hops +1; // The domain is not already explored. if (server.gateway == -1) d2.gateway = server.sid; // the server is directly accessible else d2.gateway = server.gateway; // the server itself is routed toExplore.addElement(d2); if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - toExplore.add(" + d2 + ")"); } } } // verify that all declared servers are accessible for (Enumeration s = servers.elements(); s.hasMoreElements();) { A3CMLServer server = (A3CMLServer) s.nextElement(); if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "configure - verify " + server); if (! server.visited) throw new Exception(server + " inaccessible"); } // Search alls directly accessible domains, then set special routes // for HttpNetworks. for (Enumeration n = root.networks.elements(); n.hasMoreElements();) { A3CMLNetwork network = (A3CMLNetwork) n.nextElement(); A3CMLDomain domain = (A3CMLDomain) domains.get(network.domain); if (("fr.dyade.aaa.agent.HttpNetwork".equals(domain.network)) || ("fr.dyade.aaa.agent.HttpsNetwork".equals(domain.network))) { // First search for the listen server.. short router = -1; for (int i=0; i<domain.servers.size(); i++) { A3CMLServer server = (A3CMLServer) domain.servers.elementAt(i); if ((server.port > 0) && (server.sid != rootid)) { router = server.sid; break; } } // .. then set the gateway for all clients. if (router != -1) { for (int i=0; i<domain.servers.size(); i++) { A3CMLServer server = (A3CMLServer) domain.servers.elementAt(i); if ((server.sid != router) && (server.sid != rootid)) server.gateway = router; } } } } } /** * Gets configuration of agent servers by a domain from a Config object. * This method fills the object graph configuration in the <code>Config</code> * object. * * @param domainName domain name * @return the <code>Config</code> object if file exists and is * correct, null otherwise. * * @exception Exception * unspecialized exception when reading and parsing the configuration file */ public A3CMLConfig getDomainConfig(String domainName) throws Exception { if (Log.logger.isLoggable(BasicLevel.DEBUG)) Log.logger.log(BasicLevel.DEBUG, "Config.getDomainConfig(" + domainName + ")"); A3CMLConfig domainConf = new A3CMLConfig(); // add domain "domainName" in domainConf. A3CMLDomain dom = getDomain(domainName).duplicate(); domainConf.addDomain(dom); // add persistent server in domainConf. for (int i = 0; i < dom.servers.size(); i++) { A3CMLServer server = (A3CMLServer) dom.servers.elementAt(i); domainConf.servers.put(new Short(server.sid),server); } // add global properties in domainConf. for (Enumeration p = properties.elements(); p.hasMoreElements(); ) { A3CMLProperty property = (A3CMLProperty) p.nextElement(); domainConf.addProperty(((A3CMLProperty) property).duplicate()); } try { // for Admin Domain // add domain "ADMIN_DOMAIN" in domainConf. A3CMLDomain d0 = getDomain(AgentServer.ADMIN_DOMAIN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -