dev@glassfish.java.net

Re: Slow Startup time for Glassfish and asadmin on Mac

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Mon, 14 Jun 2010 20:29:32 -0700

I don't have a Mac. Run a simple java program on your Mac --

Note that AFAIK the code is > 3 years old and has been tested constantly
-- every start-domain exercises it. Every asadmin command runs this
code too.

------------------------------------
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
     public static void main(String[] args) {
         try {
             System.out.println(getCanonicalHostName());
         }
         catch (Exception ex) {
         }
     }


  public static String getCanonicalHostName() throws UnknownHostException {
         InetAddress localhost = InetAddress.getLocalHost();
         String defaultHostname = localhost.getHostName();
         String hostname = localhost.getCanonicalHostName();
         String hostaddress = localhost.getHostAddress();

         // check to see if ip returned or canonical hostname is
different than hostname
         // It is possible for dhcp connected computers to have an
erroneous name returned
         // that is created by the dhcp server. If that happens, return
just the default hostname
         if (hostname.equals(hostaddress) ||
                 !hostname.startsWith(defaultHostname)) {
             // don't want IP or canonical hostname, this will cause a
lot of problems for dhcp users
             // get just plan host name instead
             hostname = defaultHostname;
         }

         return hostname;
     }



On 6/14/2010 8:22 PM, Jason Lee wrote:
> On 6/14/10 9:57 PM, Ludovic Champenois wrote:
>> at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
>> at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:850)
>> at
>> java.net.InetAddress.getAddressFromNameService(InetAddress.java:1201)
>> at java.net.InetAddress.getAllByName0(InetAddress.java:1154)
>> at java.net.InetAddress.getAllByName0(InetAddress.java:1129)
>> at java.net.InetAddress.getHostFromNameService(InetAddress.java:551)
>> at java.net.InetAddress.getCanonicalHostName(InetAddress.java:505)
>> at
>> com.sun.enterprise.universal.glassfish.GFLauncherUtils.getCanonicalHostName(GFLauncherUtils.java:160)
>>
>> at
>> com.sun.enterprise.universal.glassfish.ASenvPropertyReader.setProperties(ASenvPropertyReader.java:229)
>>
>>
>>
>> getCanonicalHostName() may be very slow sometimes (20 sec), see
>> http://www.google.com/search?q=getCanonicalHostName+very+slow&btnG=Search&hl=en&sa=2
>>
>>
>> Maybe Byron can take a look?
> For what it's worth, here are some log entries (started with --verbose):
>
> Mon Jun 14 22:16:02 CDT 2010 <-- I added this to asadmin right before
> the java invocation just to see
> Jun 14, 2010 10:16:34 PM
> com.sun.enterprise.admin.launcher.GFLauncherLogger info
> Jun 14, 2010 10:16:35 PM com.sun.enterprise.glassfish.bootstrap.ASMain
> main
> Jun 14, 2010 10:17:14 PM com.sun.enterprise.util.EarlyLogger add
> 2010-06-14T22:17:27.420-0500|INFO|glassfish3.1|null|_ThreadID=26;_ThreadName={felix.fileinstall.poll=5000
>
>

-- 
Byron Nevins  -  Oracle Corporation
Home: 650-359-1290
Cell: 650-784-4123
Sierra: 209-295-2188