/** * This method will set the HA Server information based solely on the server configuration * properties. It does not rely on any database access. * * <p>This is used by the auto-installation process - see {@link AutoInstallServlet}. * * @throws Exception */ public void setHaServerFromPropertiesOnly() throws Exception { PropertyItemWithValue preconfigDb = getConfigurationPropertyFromAll(ServerProperties.PROP_AUTOINSTALL_DB); if (preconfigDb != null && preconfigDb.getValue() != null) { if ("overwrite".equals(preconfigDb.getValue().toLowerCase())) { setExistingSchemaOption(ExistingSchemaOption.OVERWRITE.name()); } else if ("skip".equals(preconfigDb.getValue().toLowerCase())) { setExistingSchemaOption(ExistingSchemaOption.SKIP.name()); } else if ("auto".equals(preconfigDb.getValue().toLowerCase())) { setExistingSchemaOption(null); } else { LOG.warn( "An invalid setting for [" + ServerProperties.PROP_AUTOINSTALL_DB + "] was provided: [" + preconfigDb.getValue() + "]. Valid values are 'auto', 'overwrite' or 'skip'. Defaulting to 'auto'"); preconfigDb.setRawValue("auto"); setExistingSchemaOption(null); } } else { LOG.debug( "[" + ServerProperties.PROP_AUTOINSTALL_DB + "] was not provided. Defaulting to 'auto'"); setExistingSchemaOption(null); } // create a ha server stub with some defaults - we'll fill this in based on our property // settings ServerInformation.Server preconfiguredHaServer = new ServerInformation.Server( "", "", ServerInformation.Server.DEFAULT_ENDPOINT_PORT, ServerInformation.Server.DEFAULT_ENDPOINT_SECURE_PORT, ServerInformation.Server.DEFAULT_AFFINITY_GROUP); // determine the name of the server - its either preconfigured as the high availability name, or // we auto-determine it by using the machine's canonical hostname PropertyItemWithValue haNameProp = getPropHaServerName(); if (haNameProp != null) { preconfiguredHaServer.setName( haNameProp.getValue()); // this leaves it alone if value is null or empty } if (preconfiguredHaServer.getName().equals("")) { String serverName = getDefaultServerName(); // gets hostname if (serverName == null || "".equals(serverName)) { throw new Exception( "Server name is not preconfigured and could not be determined automatically"); } preconfiguredHaServer.setName(serverName); } // the public endpoint address is one that can be preconfigured in the special autoinstall // property. // if that is not specified, then we use either the connector's bind address or the server bind // address. // if nothing was specified, we'll default to the canonical host name. String publicEndpointAddress; PropertyItemWithValue preconfigAddr = getConfigurationPropertyFromAll(ServerProperties.PROP_AUTOINSTALL_PUBLIC_ENDPOINT); if (preconfigAddr != null && preconfigAddr.getValue() != null && !"".equals(preconfigAddr.getValue().trim())) { // its preconfigured using the autoinstall setting, use that and ignore the other settings publicEndpointAddress = preconfigAddr.getValue().trim(); } else { PropertyItemWithValue connBindAddress = getConfigurationPropertyFromAll(ServerProperties.PROP_CONNECTOR_BIND_ADDRESS); if (connBindAddress != null && connBindAddress.getValue() != null && !"".equals(connBindAddress.getValue().trim()) && !"0.0.0.0".equals(connBindAddress.getValue().trim())) { // the server-side connector bind address is explicitly set, use that publicEndpointAddress = connBindAddress.getValue().trim(); } else { PropertyItemWithValue serverBindAddress = getConfigurationPropertyFromAll(ServerProperties.PROP_SERVER_BIND_ADDRESS); if (serverBindAddress != null && serverBindAddress.getValue() != null && !"".equals(serverBindAddress.getValue().trim()) && !"0.0.0.0".equals(serverBindAddress.getValue().trim())) { // the main JBossAS server bind address is set and it isn't 0.0.0.0, use that publicEndpointAddress = serverBindAddress.getValue().trim(); } else { publicEndpointAddress = InetAddress.getLocalHost().getCanonicalHostName(); } } } preconfiguredHaServer.setEndpointAddress(publicEndpointAddress); // define the public endpoint ports. // note that if using a different transport other than (ssl)servlet, we'll // take the connector's bind port and use it for both ports. This is to support a special // deployment // use-case - 99% of the time, the agents will go through the web/tomcat connector and thus // we'll use // the http/https ports for the public endpoints. PropertyItemWithValue connectorTransport = getConfigurationPropertyFromAll(ServerProperties.PROP_CONNECTOR_TRANSPORT); if (connectorTransport != null && connectorTransport.getValue() != null && connectorTransport.getValue().contains("socket")) { // we aren't using the (ssl)servlet protocol, take the connector bind port and use it for the // public endpoint ports PropertyItemWithValue connectorBindPort = getConfigurationPropertyFromAll(ServerProperties.PROP_CONNECTOR_BIND_PORT); if (connectorBindPort == null || connectorBindPort.getValue() == null || "".equals(connectorBindPort.getValue().trim()) || "0".equals(connectorBindPort.getValue().trim())) { throw new Exception( "Using non-servlet transport [" + connectorTransport + "] but didn't define a port"); } preconfiguredHaServer.setEndpointPort(Integer.parseInt(connectorBindPort.getValue())); preconfiguredHaServer.setEndpointSecurePort(Integer.parseInt(connectorBindPort.getValue())); } else { // this is the typical use-case - the transport is probably (ssl)servlet so use the web // http/https ports try { PropertyItemWithValue httpPort = getPropHaEndpointPort(); preconfiguredHaServer.setEndpointPortString(httpPort.getValue()); } catch (Exception e) { LOG.warn("Could not determine port, will use default: " + e); } try { PropertyItemWithValue httpsPort = getPropHaEndpointSecurePort(); preconfiguredHaServer.setEndpointSecurePortString(httpsPort.getValue()); } catch (Exception e) { LOG.warn("Could not determine secure port, will use default: " + e); } } // everything looks good - remember these setHaServer(preconfiguredHaServer); this.haServerName = preconfiguredHaServer.getName(); }