[jboss-cvs] JBossAS SVN: r111135 - in projects/jboss-jca/branches/performance/faban: src/main/java/org/jboss/jca/perf/services/ironjacamar and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 8 13:18:23 EDT 2011


Author: whitingjr
Date: 2011-04-08 13:18:23 -0400 (Fri, 08 Apr 2011)
New Revision: 111135

Modified:
   projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/config.xhtml
   projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/run.xml
   projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java
Log:
Updated service. Fixed shutdown. Changed values to use one JAVA_OPTS value. Service checks shutdown has completed before progressing further.

Modified: projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/config.xhtml
===================================================================
--- projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/config.xhtml	2011-04-08 16:13:52 UTC (rev 111134)
+++ projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/config.xhtml	2011-04-08 17:18:23 UTC (rev 111135)
@@ -190,14 +190,8 @@
                </xforms:bind>
                <xforms:bind id='bind-jcaServer-service-config-interfaceBindname' xforms:nodeset='interfaceBindname'>
                </xforms:bind>
-               <xforms:bind id='bind-jcaServer-service-config-dbConnectUrl' xforms:nodeset='dbConnectUrl'>
+               <xforms:bind id='bind-jcaServer-service-config-javaOptions' xforms:nodeset='javaOptions'>
                </xforms:bind>
-               <xforms:bind id='bind-jcaServer-service-config-dbDriverClass' xforms:nodeset='dbDriverClass'>
-               </xforms:bind>
-               <xforms:bind id='bind-jcaServer-service-config-dbUsername' xforms:nodeset='dbUsername'>
-               </xforms:bind>
-               <xforms:bind id='bind-jcaServer-service-config-dbPassword' xforms:nodeset='dbPassword'>
-               </xforms:bind>
                <xforms:bind id='bind-jcaServer-service-config-listenPort' xforms:nodeset='listenPort'>
                </xforms:bind>
             </xforms:bind>
@@ -278,14 +272,11 @@
     <ok>Ok</ok>
     <cancel>Cancel</cancel>
     <interfaceBindname>Network interface binding name</interfaceBindname>
-    <dbConnectUrl>Database connection Url</dbConnectUrl>
-    <dbDriverClass>Database driver classname</dbDriverClass>
-    <dbUsername>Database user name</dbUsername>
-    <dbPassword>Database password</dbPassword>
     <listenPort>Startup listen port</listenPort>
     <serviceName>Service Name</serviceName>
     <managedHosts>Managed Hosts</managedHosts>
     <runScript>Start script</runScript>
+    <javaOptions>JAVA OPTS</javaOptions>
 </labels>
    </xforms:instance>
 </xforms:model>
@@ -548,18 +539,9 @@
             <xforms:input id='input-jcaServer-service-config-interfaceBindname' xforms:bind='bind-jcaServer-service-config-interfaceBindname'>
                <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/interfaceBindname'/>
             </xforms:input>
-            <xforms:input id='input-jcaServer-service-config-dbConnectUrl' xforms:bind='bind-jcaServer-service-config-dbConnectUrl'>
-               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/dbConnectUrl'/>
+            <xforms:input id='input-jcaServer-service-config-javaOptions' xforms:bind='bind-jcaServer-service-config-javaOptions'>
+               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/javaOptions'/>
             </xforms:input>
-            <xforms:input id='input-jcaServer-service-config-dbDriverFQCN' xforms:bind='bind-jcaServer-service-config-dbDriverClass'>
-               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/dbDriverClass'/>
-            </xforms:input>
-            <xforms:input id='input-jcaServer-service-config-dbUsername' xforms:bind='bind-jcaServer-service-config-dbUsername'>
-               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/dbUsername'/>
-            </xforms:input>
-            <xforms:input id='input-jcaServer-service-config-dbPassword' xforms:bind='bind-jcaServer-service-config-dbPassword'>
-               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/dbPassword'/>
-            </xforms:input>
             <xforms:input id='input-jcaServer-service-config-listenPort' xforms:bind='bind-jcaServer-service-config-listenPort'>
                <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/listenPort'/>
             </xforms:input>

Modified: projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/run.xml
===================================================================
--- projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/run.xml	2011-04-08 16:13:52 UTC (rev 111134)
+++ projects/jboss-jca/branches/performance/faban/benchmarks/simple-http-benchmark/deploy/run.xml	2011-04-08 17:18:23 UTC (rev 111135)
@@ -135,10 +135,7 @@
           <serverHome>Enter JCA server install path.</serverHome>
           <runScript>run.sh</runScript>
           <interfaceBindname>Enter a bind name</interfaceBindname>
-          <dbConnectUrl>Connection URL</dbConnectUrl>
-          <dbDriverClass>Driver class name</dbDriverClass>
-          <dbUsername>Enter a user name</dbUsername>
-          <dbPassword></dbPassword>
+          <javaOptions></javaOptions>
           <listenPort>8080</listenPort>
        </fh:config>
     </fh:service>

Modified: projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java
===================================================================
--- projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java	2011-04-08 16:13:52 UTC (rev 111134)
+++ projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java	2011-04-08 17:18:23 UTC (rev 111135)
@@ -56,21 +56,19 @@
    public ServiceContext sc ;
    private Logger logger = Logger.getLogger(IronJacamarService.class.getName());
    private List<String> jcaServers;
-   private String serverHome;
+   private String binDirectory, libDirectory;
    private String serverStartScript;
-   private String jcaStartCommand, javaOpts, jcaStopCommand;
+   private String jcaCommand, javaOpts;
    private String interfaceBindname;
-   private String dbConnectUrl, dbDriverClass, dbUserName, dbPassword;
+   private String shutdownCommand = "java -jar fungal-cli.jar";
    private Long port;
    private static final String SERVER_HOME = "serverHome";
    private static final String RUN_SCRIPT = "runScript";
    private static final String INTERFACE_BINDNAME = "interfaceBindname";
-   private static final String DB_CONNECT_URL = "dbConnectUrl";
-   private static final String DB_DRIVER_CLASS = "dbDriverClass";
-   private static final String DB_USERNAME = "dbUsername";
-   private static final String DB_PASSWORD = "dbPassword";
+   private static final String JAVA_OPTIONS = "javaOptions";
    private static final String LISTEN_PORT = "listenPort";
-   private static final String JAVA_OPTS = "JAVA_OPTS";
+   private static final String BIN = "bin";
+   private static final String LIB = "lib";
       
    /**
     * This method first extracts the properties from the configuration xml.
@@ -98,9 +96,9 @@
       }
       else 
       {
-         this.serverHome = sc.getProperty(SERVER_HOME);
+         this.binDirectory = String.format("%1$s/%2$s/",  sc.getProperty(SERVER_HOME), BIN);
+         this.libDirectory = String.format("%1$s/%2$s/",  sc.getProperty(SERVER_HOME), LIB);
       }
-      
       if (StringUtils.isBlank( sc.getProperty(RUN_SCRIPT)) )
       {
          throw new ConfigurationException("Start script file name is undefined, enter a file name.");
@@ -109,34 +107,9 @@
       {
          this.serverStartScript = sc.getProperty(RUN_SCRIPT);
       }
-      if (StringUtils.isBlank(sc.getProperty(DB_CONNECT_URL)) )
-      {
-         throw new ConfigurationException("db connect url is undefined, enter a url.");
-      }
-      else 
-      {
-         this.dbConnectUrl  = sc.getProperty(DB_CONNECT_URL);
-      }
-      if (StringUtils.isBlank(sc.getProperty(DB_DRIVER_CLASS)))
-      {
-         throw new ConfigurationException("db driver class is undefined, enter a url.");
-      }
-      else 
-      {
-         this.dbDriverClass  = sc.getProperty(DB_DRIVER_CLASS);
-      }
-      if (StringUtils.isBlank(sc.getProperty(DB_USERNAME)))
-      {
-         throw new ConfigurationException("db username is undefined, enter a username.");
-      }
-      else 
-      {
-         this.dbUserName = sc.getProperty(DB_USERNAME);
-      }
+
+      this.javaOpts = StringUtils.defaultString( sc.getProperty(JAVA_OPTIONS)); // this is allowed to be empty
       
-      this.dbPassword = StringUtils.defaultString( sc.getProperty(DB_PASSWORD));
-      // an empty value for the password is permitted
-      
       this.interfaceBindname = sc.getProperty(INTERFACE_BINDNAME);
       // an empty value is permitted
       
@@ -159,26 +132,19 @@
       }
       
       //build command
-      String fullScriptPath = String.format("%1$s/bin/%2$s", this.serverHome,this.serverStartScript);
-      String hostFlag = StringUtils.EMPTY;
-      
+      String fullScriptPath = String.format("%1$s/%2$s", this.binDirectory,this.serverStartScript);
       if (StringUtils.isNotBlank(this.interfaceBindname))
       {
-         this.jcaStartCommand = withBindFlag(this.interfaceBindname, fullScriptPath);
-         hostFlag = withHostFlag(this.interfaceBindname);
+         this.jcaCommand = withBindFlag(this.interfaceBindname, fullScriptPath);
+         this.shutdownCommand = withHostFlag(this.interfaceBindname, this.shutdownCommand);
       }
-      this.jcaStopCommand = String.format("java -jar %1$s/lib/fungal-cli.jar %2$s shutdown", this.serverHome, hostFlag); 
-      
-      this.javaOpts = withDBConnectUrl(this.dbConnectUrl);
-      this.javaOpts = withDBDriverFQCN(this.dbDriverClass);
-      this.javaOpts = withUsernamePassword(this.dbUserName, this.dbPassword);
       if (logger.isLoggable(Level.FINE))
       {
          logger.fine("Configuring IronJacamar Complete.");
       }
+      this.shutdownCommand += " shutdown";
    }
-   
-   
+
    @Start
    public void startup()
    {
@@ -188,14 +154,14 @@
          {
             logger.fine(String.format( "Starting IronJacamar on [%1$s]" , host));
          }
-         Command command = new Command(this.jcaStartCommand);
+         Command command = new Command(this.jcaCommand);
          if (logger.isLoggable(Level.FINE))
          {
             logger.fine("Starting IronJacamar.");
          }
-         command.setWorkingDirectory(String.format("%1$s/bin", this.serverHome));
+         command.setWorkingDirectory(this.binDirectory);
          command.setSynchronous(false);
-         command.setEnvironment(new String[] {String.format("%1$s=%2$s", JAVA_OPTS, this.javaOpts) });
+         command.setEnvironment(new String[] {String.format("%1$s=%2$s", "JAVA_OPTS", this.javaOpts) });
          try
          {
             RunContext.exec(host, command);
@@ -228,7 +194,7 @@
          private static final short WAIT_MILLIS = 2000;// two seconds
          
          /**
-          * This annonymous inner class is used as a callable to check the IronJacamar
+          * This anonymous inner class is used as a callable to check the IronJacamar
           * server has completed starting up.
           * The basis for checking is if the server is listening on a specific port.
           * The port number and host are needed.
@@ -292,12 +258,12 @@
          {
             logger.fine(String.format( "Stopping IronJacamar on [%1$s]" , host));
          }
-         Command command = new Command(this.jcaStopCommand);
+         Command command = new Command(String.format( "java -jar fungal-cli.jar -h %1$s shutdown", this.interfaceBindname));
          if (logger.isLoggable(Level.FINE))
          {
             logger.fine("Starting IronJacamar.");
          }
-         command.setWorkingDirectory(String.format("%1$s/lib", this.serverHome));
+         command.setWorkingDirectory(this.libDirectory);
          command.setSynchronous(false);
          try
          {
@@ -314,6 +280,70 @@
       }
    }
    
+   private static boolean checkServerStoppedListening(final String host, final Long port)
+      throws Exception 
+   {
+      Boolean returnValue = false;
+      
+      returnValue = RunContext.exec(host, new RemoteCallable<Boolean>()
+      {
+         /** The serialVersionUID */
+         private static final long serialVersionUID = -456331954257819201L;
+         private static final short CHECK_COUNT = 60;
+         private static final short WAIT_MILLIS = 2000;// two seconds
+         
+         /**
+          * This anonymous inner class is used as a callable to check the IronJacamar
+          * server has completed shutting down.
+          * The basis for checking is if the server is listening on a specific port.
+          * The port number and host are needed.
+          */
+         @Override
+         public Boolean call() throws Exception
+         {
+            Boolean returnValue = new Boolean(false);
+            /**
+             * Try checking for a listener
+             */
+            short count = 0;
+            while (count < CHECK_COUNT)
+            {
+               count += 1;
+               Socket s = null;
+               try
+               {
+                  s = new Socket(host, port.intValue());
+                  /*
+                   * Still running, sleep and check again
+                   */
+               }
+               catch (IOException ioe)
+               {// not listening
+                  returnValue = new Boolean(true);
+                  break; // done
+               }
+               finally
+               {
+                  if (null != s)
+                  {
+                     try
+                     {
+                        s.close();
+                        s = null;
+                     }
+                     catch (IOException ioe)
+                     {/* ignore this exception */ 
+                     }
+                  }
+               }
+               Thread.sleep(WAIT_MILLIS);
+            }
+            return returnValue;
+         }
+      });
+      return returnValue;
+   }
+   
    @ClearLogs
    public void clearLogs()
    {
@@ -347,47 +377,20 @@
       }
       return returnValue;
    }
-   /**
-    * This method adds a host variable to the command line
-    * @param hostValue
-    * @param command
-    * @return
-    */
-   private String withHostFlag(String hostValue)
-   {
-      return String.format("-h %1$s", hostValue);
-   }
    
-   /**
-    * This method adds a property to the command line defining the connect url
-    * @param url
-    * @param command
-    * @return
-    */
-   private String withDBConnectUrl(String url)
-   {
-      return String.format("-Ddb-vendor.connectionURL=%1$s", url);
-   }
-   
-   /**
-    * This method adds a property to the command line defining the driver class name
-    * @param url
-    * @param command
-    * @return
-    */
-   private String withDBDriverFQCN(String fqcn)
-   {
-      return String.format("%1$s -Ddb-vendor.driverClass=%2$s", javaOpts, fqcn);
-   }
-   /**
-    * This method adds a username and password property.
+   /** This method adds the host flag to the command
     * 
-    * @param fqcn
-    * @param command
+    * @param bindValue the interface bind name
+    * @param command 
     * @return
     */
-   private String withUsernamePassword(String username, String password)
+   private String withHostFlag(String bindValue, String command)
    {
-      return String.format("%1$s -Ddb-vendor.userName=%2$s -Ddb-vendor.password=%3$s ", javaOpts, username, password);
+      String returnValue = command;
+      if (StringUtils.isNotBlank(bindValue))
+      {
+         returnValue = String.format("%1$s -h %2$s ", command, bindValue);
+      }
+      return returnValue;
    }
 }



More information about the jboss-cvs-commits mailing list