admin@glassfish.java.net

code review: removal of obsolete isInstanceRunning(), isInstanceAlreadyStarted() checks in PEMain

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Thu, 01 Feb 2007 13:57:21 -0800

Abhijit,

Please review these changes per our conversation. Kedar et al please
comment if you have thoghts

https://glassfish.dev.java.net/issues/show_bug.cgi?id=2299

Diffs below, here's a bit more context. Both call sites get around
to making a new RMIClient to connect to itself.


     public static void main(String[] args) {
         final TimingDelta delta = new TimingDelta();
         new AtStartup().submit( RunnableBase.SUBMIT_ASYNC );

         // parse args
         boolean verbose = false;
         boolean dbg = false;

         //set the system locale for this instance
         setSystemLocale();

         if ( OLD_INSTANCE_STATUS_CHECK ) {
             if(args[0].trim().equals(STOP)) {
                 // check if instance is already running
                 if (isInstanceRunning()) {
                     PEMain.shutdown();
                 return;

                 } else {
                     getLogger().log(Level.INFO, "instance.notRunning");
                 return;
                 }
             }
         }

...

        //Set system properties that correspond directly to
asenv.conf/bat. This
        //keeps us from having to pass them all from -D on the
command line.
        ASenvPropertyReader reader = new ASenvPropertyReader(
            System.getProperty
(SystemPropertyConstants.CONFIG_ROOT_PROPERTY));
        reader.setSystemProperties();

         if ( OLD_INSTANCE_STATUS_CHECK ) {
             // check if instance is already running
             if (isInstanceAlreadyStarted()) {
                 getLogger().log(Level.SEVERE,
"instance.alreadyRunning");
             System.exit(0);
             }
         }

            getLogger().log(Level.FINE, "instance.start", SERVER_INSTANCE);

            //_server = new ApplicationServer();
            _server = new OnDemandServer();
...
}
...


     /**
      * Get status of the instance.
      */
     private static int getInstanceStatus() {
         final String stubFile = getStubFilePath();
         final String seedFile = getSeedFilePath();
         final RMIClient rmiClient = new RMIClient(true, stubFile,
seedFile);
         return rmiClient.getInstanceStatusCode();
     }

     /**
      * Is instance in running state.
      */
     private static boolean isInstanceRunning() {
         return (getInstanceStatus() == Status.kInstanceRunningCode);
     }

     /**
      * Is instance in starting or running state.
      */
     private static boolean isInstanceStartingOrRunning() {
         int statusCode = getInstanceStatus();
         return (statusCode == Status.kInstanceStartingCode
                 || statusCode == Status.kInstanceRunningCode);
     }

     /**
      * method to check if server is already up or not
      */
     public static boolean isInstanceAlreadyStarted() {
         return isInstanceStartingOrRunning();
     }





MB2:/gf/build/glassfish/appserv-core lloyd$ cvs diff -u -w src/java/
com/sun/enterprise/server/PEMain.java
Index: src/java/com/sun/enterprise/server/PEMain.java
===================================================================
RCS file: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/
server/PEMain.java,v
retrieving revision 1.12
diff -u -w -r1.12 PEMain.java
--- src/java/com/sun/enterprise/server/PEMain.java 13 Jan 2007
03:26:42 -0000 1.12
+++ src/java/com/sun/enterprise/server/PEMain.java 1 Feb 2007
21:51:23 -0000
@@ -144,7 +144,7 @@
          return _logger;
      }
- // ---------------------------------------------------------
Public Methods
+ private static final boolean OLD_INSTANCE_STATUS_CHECK =
false;
      public static void main(String[] args) {
@@ -156,6 +156,7 @@
          //set the system locale for this instance
          setSystemLocale();
+ if ( OLD_INSTANCE_STATUS_CHECK ) {
         if(args[0].trim().equals(STOP)) {
             // check if instance is already running
             if (isInstanceRunning()) {
@@ -167,6 +168,7 @@
                 return;
             }
                 }
+ }
         try {
@@ -217,11 +219,13 @@
             System.getProperty
(SystemPropertyConstants.CONFIG_ROOT_PROPERTY));
         reader.setSystemProperties();
+ if ( OLD_INSTANCE_STATUS_CHECK ) {
             // check if instance is already running
             if (isInstanceAlreadyStarted()) {
                 getLogger().log(Level.SEVERE,
"instance.alreadyRunning");
                 System.exit(0);
             }
+ }
             getLogger().log(Level.FINE, "instance.start",
SERVER_INSTANCE);