[jboss-cvs] JBossAS SVN: r111071 - 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
Wed Mar 30 12:11:41 EDT 2011


Author: whitingjr
Date: 2011-03-30 12:11:41 -0400 (Wed, 30 Mar 2011)
New Revision: 111071

Modified:
   projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/simple/http/JCAWebDriver.java
   projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java
Log:
Updated IronJacamar service to handle shutdown. Updated the benchmark driver to test header indicating transaction status.

Modified: projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/simple/http/JCAWebDriver.java
===================================================================
--- projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/simple/http/JCAWebDriver.java	2011-03-30 12:51:39 UTC (rev 111070)
+++ projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/simple/http/JCAWebDriver.java	2011-03-30 16:11:41 UTC (rev 111071)
@@ -1,6 +1,8 @@
 package org.jboss.jca.perf.benchmark.simple.http;
 
 import java.io.IOException;
+import java.net.ConnectException;
+import java.net.HttpURLConnection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -11,6 +13,7 @@
 import com.sun.faban.driver.BenchmarkOperation;
 import com.sun.faban.driver.CycleType;
 import com.sun.faban.driver.DriverContext;
+import com.sun.faban.driver.FatalException;
 import com.sun.faban.driver.FixedTime;
 import com.sun.faban.driver.FlatMix;
 import com.sun.faban.driver.HttpTransport;
@@ -48,6 +51,9 @@
    
    private static final String URL_FORMAT = "http://%1$s:%2$s/%3$s/%4$s";
    private static final String MESSAGE = "calling %1$s";
+   private static final String SUCCESS = "SUCCESS";
+   private static final String TRANSACTION_STATUS = "status";
+   private static final int SC_OK = 200;
    
    public JCAWebDriver()
       throws XPathExpressionException
@@ -60,7 +66,12 @@
       
       servletURL = String.format(URL_FORMAT, context.getXPathValue(XPATH_HOST), port, webContext, resourcePath);
    }
-   
+
+   /**
+    * This operation calls the JCA container over HTTP. The request executes a
+    * transaction. The status header indicates the outcome.
+    * @throws Exception
+    */
    @BenchmarkOperation
    (
       name="doRequest"
@@ -68,7 +79,7 @@
       , timing = Timing.AUTO
    )
    public void doRequest()
-      throws IOException
+      throws Exception
    {
       if (logger.isLoggable(Level.FINEST))
       {
@@ -77,12 +88,20 @@
       try
       {
          http.fetchURL(servletURL);
+         if (HttpURLConnection.HTTP_OK != http.getResponseCode() && !SUCCESS.equals(http.getResponseHeader(TRANSACTION_STATUS)))
+         {
+            throw new Exception("Transaction failed."); // this will increment the failure count
+         }
       }
+      catch (ConnectException ce )
+      {
+         logger.info(ce.getMessage() + " [" +servletURL+ "]");
+         throw new FatalException(ce.getMessage());
+      }
       catch (IOException ioe) 
       {
          logger.info(ioe.getMessage() + " [" +servletURL+ "]");
          throw ioe;
       }
    }
-   
 }

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-03-30 12:51:39 UTC (rev 111070)
+++ projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/services/ironjacamar/IronJacamarService.java	2011-03-30 16:11:41 UTC (rev 111071)
@@ -56,9 +56,9 @@
    public ServiceContext sc ;
    private Logger logger = Logger.getLogger(IronJacamarService.class.getName());
    private List<String> jcaServers;
-   private String workingDirectory;
+   private String serverHome;
    private String serverStartScript;
-   private String jcaCommand, javaOpts;
+   private String jcaStartCommand, javaOpts, jcaStopCommand;
    private String interfaceBindname;
    private String dbConnectUrl, dbDriverClass, dbUserName, dbPassword;
    private Long port;
@@ -71,7 +71,6 @@
    private static final String DB_PASSWORD = "dbPassword";
    private static final String LISTEN_PORT = "listenPort";
    private static final String JAVA_OPTS = "JAVA_OPTS";
-   private static final String BIN = "bin";
       
    /**
     * This method first extracts the properties from the configuration xml.
@@ -99,7 +98,7 @@
       }
       else 
       {
-         this.workingDirectory = String.format("%1$s/%2$s/",  sc.getProperty(SERVER_HOME), BIN);
+         this.serverHome = sc.getProperty(SERVER_HOME);
       }
       
       if (StringUtils.isBlank( sc.getProperty(RUN_SCRIPT)) )
@@ -160,11 +159,16 @@
       }
       
       //build command
-      String fullScriptPath = String.format("%1$s/%2$s", this.workingDirectory,this.serverStartScript);
+      String fullScriptPath = String.format("%1$s/bin/%2$s", this.serverHome,this.serverStartScript);
+      String hostFlag = StringUtils.EMPTY;
+      
       if (StringUtils.isNotBlank(this.interfaceBindname))
       {
-         this.jcaCommand = withBindFlag(this.interfaceBindname, fullScriptPath);
+         this.jcaStartCommand = withBindFlag(this.interfaceBindname, fullScriptPath);
+         hostFlag = withHostFlag(this.interfaceBindname);
       }
+      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);
@@ -184,12 +188,12 @@
          {
             logger.fine(String.format( "Starting IronJacamar on [%1$s]" , host));
          }
-         Command command = new Command(this.jcaCommand);
+         Command command = new Command(this.jcaStartCommand);
          if (logger.isLoggable(Level.FINE))
          {
             logger.fine("Starting IronJacamar.");
          }
-         command.setWorkingDirectory(this.workingDirectory);
+         command.setWorkingDirectory(String.format("%1$s/bin", this.serverHome));
          command.setSynchronous(false);
          command.setEnvironment(new String[] {String.format("%1$s=%2$s", JAVA_OPTS, this.javaOpts) });
          try
@@ -288,23 +292,16 @@
          {
             logger.fine(String.format( "Stopping IronJacamar on [%1$s]" , host));
          }
-         Command command = new Command("java -jar fungal-cli.jar shutdown");
+         Command command = new Command(this.jcaStopCommand);
          if (logger.isLoggable(Level.FINE))
          {
             logger.fine("Starting IronJacamar.");
          }
-         command.setWorkingDirectory(this.workingDirectory);
+         command.setWorkingDirectory(String.format("%1$s/lib", this.serverHome));
          command.setSynchronous(false);
-         //command.setEnvironment(new String[] {String.format("%1$s=%2$s", JAVA_OPTS, this.javaOpts) });
          try
          {
             RunContext.exec(host, command);
-            // check it is running
-            /*if (!checkServerListening(host, port))
-            {
-               logger.severe(String.format( "IronJacamar server did not stop on [%1$s]" , host));
-            }
-            */
             if (logger.isLoggable(Level.FINE))
             {
                logger.fine(String.format("Completed IronJacamar shutdown on [%1$s].", host) );
@@ -344,12 +341,22 @@
    private String withBindFlag(String bindValue, String command)
    {
       String returnValue = command;
-      if (null != bindValue && !"".equals(bindValue.trim()))
+      if (StringUtils.isNotBlank(bindValue))
       {
          returnValue = String.format("%1$s -b %2$s", command, bindValue);
       }
       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



More information about the jboss-cvs-commits mailing list