Received: from ucsinet22.oracle.com (/156.151.31.94) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 Nov 2011 11:37:10 -0700 Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pA3Ib8vZ024416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Nov 2011 18:37:09 GMT Received: from mailout02.kenai.com (mailout02.kenai.com [192.9.171.175]) by acsinet13.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pA3Ib1eA014109; Thu, 3 Nov 2011 18:37:03 GMT Received: from mail01.java.net (jnxmlm02z1.network.org [192.9.171.232]) by mailout02.kenai.com (Postfix) with ESMTP id 85D4546B319; Thu, 3 Nov 2011 18:37:01 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail01.java.net (Postfix) with ESMTP id 1D1104A4E2D; Thu, 3 Nov 2011 18:37:01 +0000 (GMT) X-Virus-Scanned: amavisd-new at network.org Received: from mail01.java.net ([127.0.0.1]) by localhost (jnxmlm02z1.network.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id SH5JQuSXgesd; Thu, 3 Nov 2011 18:37:00 +0000 (GMT) Received: by mail01.java.net (Postfix, from userid 60005) id C8F884A4E29; Thu, 3 Nov 2011 18:37:00 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail01.java.net (Postfix) with ESMTP id 6097D4A4E24 for ; Thu, 3 Nov 2011 18:36:57 +0000 (GMT) X-Virus-Scanned: amavisd-new at network.org Received: from mail01.java.net ([127.0.0.1]) by localhost (jnxmlm02z1.network.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id LF5LxXV7jKtJ for ; Thu, 3 Nov 2011 18:36:52 +0000 (GMT) Received: from java.net (jnxapp05z1.network.org [192.9.171.236]) by mail01.java.net (Postfix) with ESMTP id CA1D94A4E1D for ; Thu, 3 Nov 2011 18:36:52 +0000 (GMT) Date: Thu, 3 Nov 2011 18:36:52 +0000 From: jfialli@java.net To: commits@shoal.java.net Message-Id: <4eb2df44c0a08_2878834443f8@jnxapp05z1.network.org.tmail> Subject: [shoal~svn:1715] updated GMS NetworkUtility code to follow java.net.preferIPv6Adddresses c Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Reply-To: commits@shoal.java.net X-Loop: commits@shoal.java.net X-Sequence: 282 Errors-to: commits-owner@shoal.java.net Precedence: list X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: X-Flow-Control-Info: class=Default ip=192.9.171.175 ct-class=R6 ct-vol1=-79 ct-vol2=6 ct-vol3=6 ct-risk=63 ct-spam1=95 ct-spam2=22 ct-bulk=7 rcpts=8 size=10226 X-Source-IP: mailout02.kenai.com [192.9.171.175] X-CT-RefId: str=0001.0A020203.4EB2DF4F.00C2,ss=1,re=-2.300,fgs=0 Project: shoal Repository: svn Revision: 1715 Author: jfialli Date: 2011-11-03 18:36:50 UTC Link: Log Message: ------------ updated GMS NetworkUtility code to follow java.net.preferIPv6Adddresses convention. use ipv6 addresses when that well known jdk property is set to true. Updated the GMS tcp listener and default multicast address to be ipv6 when that property is set to true. Revisions: ---------- 1715 Modified Paths: --------------- branches/gms-transport-modules/gms/impl/src/main/resources/com/sun/enterprise/ee/cms/logging/LogStrings.properties branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/GrizzlyNetworkManager.java branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/NetworkUtility.java branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/grizzly2/GrizzlyNetworkManager2.java branches/gms-transport-modules/gms/project.properties Diffs: ------ Index: branches/gms-transport-modules/gms/project.properties =================================================================== --- branches/gms-transport-modules/gms/project.properties (revision 1714) +++ branches/gms-transport-modules/gms/project.properties (revision 1715) @@ -58,7 +58,7 @@ shoal.jar.name=${shoal.image.name}-${shoal.image.version} # fix hardcoding this. ideal to get this from the hudson build process. -shoal.gms.version=1.6.10 +shoal.gms.version=1.6.14 # Where dependencies will be stored. appserv.repo.hostname=koori.sfbay.sun.com Index: branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/NetworkUtility.java =================================================================== --- branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/NetworkUtility.java (revision 1714) +++ branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/NetworkUtility.java (revision 1715) @@ -62,6 +62,7 @@ import java.util.Enumeration; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; @@ -97,10 +98,13 @@ public volatile static NetworkInterface firstNetworkInterface; public volatile static InetAddress firstInetAddressV4; public volatile static InetAddress firstInetAddressV6; + public static AtomicBoolean preferIPv6Addresses = null; private static final boolean IS_AIX_JDK; static { + boolean preferIPv6Addresses = getPreferIpv6Addresses(); + InetAddress GET_ADDRESS = null; try { GET_ADDRESS = InetAddress.getByName( IPV4ANYADDRESS ); @@ -119,7 +123,7 @@ } ANYADDRESSV6 = GET_ADDRESS; - ANYADDRESS = ( ANYADDRESSV4 == null ) ? ANYADDRESSV6 : ANYADDRESSV4; + ANYADDRESS = ( ANYADDRESSV4 == null || preferIPv6Addresses) ? ANYADDRESSV6 : ANYADDRESSV4; GET_ADDRESS = null; try { @@ -139,10 +143,11 @@ } LOOPBACKV6 = GET_ADDRESS; - LOOPBACK = ( LOOPBACKV4 == null ) ? LOOPBACKV6 : LOOPBACKV4; + LOOPBACK = ( LOOPBACKV4 == null || preferIPv6Addresses) ? LOOPBACKV6 : LOOPBACKV4; - if( LOOPBACK == null || ANYADDRESS == null ) + if( LOOPBACK == null || ANYADDRESS == null ) { throw new IllegalStateException( "failure initializing statics. Neither IPV4 nor IPV6 seem to work" ); + } } private static Method isLoopbackMethod = null; @@ -222,6 +227,22 @@ return allLocalAddresses; } + public static InetAddress getAnyAddress() { + if (getPreferIpv6Addresses() && ANYADDRESSV6 != null) { + return ANYADDRESSV6; + } else { + return ANYADDRESSV4; + } + } + + public static InetAddress getLoopbackAddress() { + if (getPreferIpv6Addresses() && LOOPBACKV6 != null) { + return LOOPBACKV6; + } else { + return LOOPBACKV4; + } + } + /** * Return a first network interface except for the lookback * But, if any network interfaces were not found locally, the lookback interface is returned. @@ -271,7 +292,25 @@ } public static boolean getPreferIpv6Addresses() { - return Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses", "false")); + if (preferIPv6Addresses == null) { + String propValue = null; + boolean result = false; + try { + propValue = System.getProperty("java.net.preferIPv6Addresses", "false"); + result = Boolean.parseBoolean(propValue); + } catch (Throwable t) { + if (LOG.isLoggable(Level.WARNING)) { + LOG.log(Level.WARNING, "netutil.invalidPreferIPv6Addresses", new Object[]{t.getLocalizedMessage()}); + LOG.log(Level.WARNING, "stack trace", t); + } + } finally { + preferIPv6Addresses = new AtomicBoolean(result); + } + } + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "NetworkUtlity.getPreferIpv6Addresses=" + preferIPv6Addresses.get()); + } + return preferIPv6Addresses.get(); } /** @@ -747,8 +786,9 @@ static void displayInterfaceInformation(NetworkInterface netint) throws SocketException { System.out.printf("Display name: %s\n", netint.getDisplayName()); System.out.printf("Name: %s\n", netint.getName()); + System.out.printf("PreferIPv6Addresses: %b\n", getPreferIpv6Addresses()); + Enumeration inetAddresses = netint.getInetAddresses(); - for (InetAddress inetAddress : Collections.list(inetAddresses)) { System.out.printf("InetAddress: %s\n", inetAddress); } Index: branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/GrizzlyNetworkManager.java =================================================================== --- branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/GrizzlyNetworkManager.java (revision 1714) +++ branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/GrizzlyNetworkManager.java (revision 1715) @@ -107,8 +107,8 @@ public int writeSelectorPoolSize; final public String UNKNOWN = "Unknown_"; - final public String DEFAULT_MULTICAST_ADDRESS = "230.30.1.1"; - + final public String DEFAULT_IPv4_MULTICAST_ADDRESS = "230.30.1.1"; + final public String DEFAULT_IPv6_MULTICAST_ADDRESS = "FF01:0:0:0:0:0:0:1"; public final ConcurrentHashMap pingMessageLockMap = new ConcurrentHashMap(); protected VirtualMulticastSender vms = null; @@ -130,6 +130,7 @@ return validateMulticastAddress != null && validateMulticastAddress.isMulticastAddress(); } + @SuppressWarnings( "unchecked" ) public void configure( final Map properties ) { Logger shoalLogger = getLogger(); host = Utility.getStringProperty( BIND_INTERFACE_ADDRESS.toString(), null, properties ); @@ -141,6 +142,8 @@ // tcpPort = NetworkUtility.getAvailableTCPPort( host, tcpStartPort, tcpEndPort ); multicastPort = Utility.getIntProperty( MULTICASTPORT.toString(), 9090, properties ); + final String DEFAULT_MULTICAST_ADDRESS = NetworkUtility.getPreferIpv6Addresses() ? + DEFAULT_IPv6_MULTICAST_ADDRESS : DEFAULT_IPv4_MULTICAST_ADDRESS; multicastAddress = Utility.getStringProperty( MULTICASTADDRESS.toString(), DEFAULT_MULTICAST_ADDRESS, properties ); if (!validMulticastAddress(multicastAddress)) { shoalLogger.log(Level.SEVERE, "grizzlynetmgr.invalidmcastaddr", Index: branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/grizzly2/GrizzlyNetworkManager2.java =================================================================== --- branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/grizzly2/GrizzlyNetworkManager2.java (revision 1714) +++ branches/gms-transport-modules/gms/impl/src/main/java/com/sun/enterprise/mgmt/transport/grizzly/grizzly2/GrizzlyNetworkManager2.java (revision 1715) @@ -152,7 +152,7 @@ final TCPNIOTransport transport = tcpTransportBuilder.build(); final TCPNIOServerConnection serverConnection = transport.bind( - host != null ? host : "0.0.0.0", + host != null ? host : NetworkUtility.getAnyAddress().getHostAddress(), new PortRange(tcpStartPort, tcpEndPort), SERVER_CONNECTION_BACKLOG); tcpPort = ((InetSocketAddress) serverConnection.getLocalAddress()).getPort(); Index: branches/gms-transport-modules/gms/impl/src/main/resources/com/sun/enterprise/ee/cms/logging/LogStrings.properties =================================================================== --- branches/gms-transport-modules/gms/impl/src/main/resources/com/sun/enterprise/ee/cms/logging/LogStrings.properties (revision 1714) +++ branches/gms-transport-modules/gms/impl/src/main/resources/com/sun/enterprise/ee/cms/logging/LogStrings.properties (revision 1715) @@ -173,3 +173,5 @@ router.signal.queue.blocking=signal processing blocked due to signal queue being full for {0} ms. Router signal queue capacity: {1} mgmt.blockingiomulticast.setinterfacefailed=GMS1120: Unable to configure MulticastSocket to use specified interface with address: {0}. Continuning with default MulticastSocket interface of {1}. mgmt.disableUDPmulticast=GMS1121: Disabling UDP multicast. {0}={1} +netutil.invalidPreferIPv6Addresses=GMS1122: Unable to access or invalid value for JDK property java.net.preferIPv6Addresses due to exception {0}, defaulting to false. +