[jbosscache-commits] JBoss Cache SVN: r4975 - in cache-bench-fwk/trunk: conf and 5 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Jan 4 04:44:30 EST 2008


Author: mircea.markus
Date: 2008-01-04 04:44:30 -0500 (Fri, 04 Jan 2008)
New Revision: 4975

Added:
   cache-bench-fwk/trunk/smartfrog/cacheBenchComponent.sf
   cache-bench-fwk/trunk/smartfrog/main.sf
   cache-bench-fwk/trunk/src/org/cachebench/smartfrog/
   cache-bench-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
Modified:
   cache-bench-fwk/trunk/build.xml
   cache-bench-fwk/trunk/conf/cachebench.xml
   cache-bench-fwk/trunk/runNode.sh
   cache-bench-fwk/trunk/src/org/cachebench/config/ClusterConfig.java
   cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java
Log:
SF integration

Modified: cache-bench-fwk/trunk/build.xml
===================================================================
--- cache-bench-fwk/trunk/build.xml	2008-01-04 02:36:51 UTC (rev 4974)
+++ cache-bench-fwk/trunk/build.xml	2008-01-04 09:44:30 UTC (rev 4975)
@@ -60,6 +60,7 @@
     <pathelement location="${module.framework.basedir}/lib/commons-digester.jar"/>
     <pathelement location="${module.framework.basedir}/lib/commons-beanutils.jar"/>
     <pathelement location="${module.framework.basedir}/lib/commons-math-1.0.jar"/>
+    <pathelement location="${module.framework.basedir}/lib/smartfrog-3.12.014.jar"/>
     <pathelement location="${module.framework.basedir}/conf"/>
   </path>
   
@@ -149,6 +150,7 @@
   <target name="clean.module.framework" description="cleanup module">
     <delete dir="${framework.output.dir}"/>
     <delete dir="${framework.testoutput.dir}"/>
+    <delete dir="${basedir}/smartfrog/sfClasses"/>
   </target>
   
   
@@ -504,4 +506,15 @@
       </java>
    </target>
 
+   <target name="deploy.sf" depends="compile.module.framework" description="builds the smartfrog jar and deploys it">
+      <rmic classname="org.cachebench.smartfrog.CacheBenchmarkPrim" base="${framework.output.dir}" verify="true" debug="true">
+         <classpath refid="framework.module.classpath"/>
+      </rmic>
+      <delete dir="${basedir}/smartfrog/sfClasses"/>
+      <mkdir dir="${basedir}/smartfrog/sfClasses"/>
+      <jar destfile="${basedir}/smartfrog/sfClasses/cacheBenchmark-sf.jar">
+         <fileset dir="${framework.output.dir}" includes="**/smartfrog/**"/>
+         <fileset dir="${basedir}/smartfrog" excludes="**/sfClasses/**"/>
+      </jar>
+   </target>
 </project>

Modified: cache-bench-fwk/trunk/conf/cachebench.xml
===================================================================
--- cache-bench-fwk/trunk/conf/cachebench.xml	2008-01-04 02:36:51 UTC (rev 4974)
+++ cache-bench-fwk/trunk/conf/cachebench.xml	2008-01-04 09:44:30 UTC (rev 4975)
@@ -21,8 +21,8 @@
    -->
    <cluster bindAddress="127.0.0.1">
       <member host="127.0.0.1" port="7800"/>
-      <!--<member host="127.0.0.1" port="7801"/>-->
-      <!--<member host="127.0.0.1" port="7802"/>-->
+      <member host="127.0.0.1" port="7801"/>
+      <member host="127.0.0.1" port="7802"/>
    </cluster>
 
    <!-- Each testcase represents either a single configuration or a cacheing product.

Modified: cache-bench-fwk/trunk/runNode.sh
===================================================================
--- cache-bench-fwk/trunk/runNode.sh	2008-01-04 02:36:51 UTC (rev 4974)
+++ cache-bench-fwk/trunk/runNode.sh	2008-01-04 09:44:30 UTC (rev 4975)
@@ -45,7 +45,7 @@
    echo executing command $START_NODE_COMMAND
    $START_NODE_COMMAND
 else   
-   TO_EXECUTE="java -cp $CLASSPATH $SYS_PROPS org.cachebench.CacheBenchmarkRunner $3"
+   TO_EXECUTE="java -cp $CLASSPATH $3 $SYS_PROPS org.cachebench.CacheBenchmarkRunner $4"
    echo executing $TO_EXECUTE
    java -cp $CLASSPATH $3 $SYS_PROPS org.cachebench.CacheBenchmarkRunner $4
 fi

Added: cache-bench-fwk/trunk/smartfrog/cacheBenchComponent.sf
===================================================================
--- cache-bench-fwk/trunk/smartfrog/cacheBenchComponent.sf	                        (rev 0)
+++ cache-bench-fwk/trunk/smartfrog/cacheBenchComponent.sf	2008-01-04 09:44:30 UTC (rev 4975)
@@ -0,0 +1,20 @@
+#include "org/smartfrog/components.sf"
+
+BaseCacheBenchPrim extends Prim {
+   sfClass "org.cachebench.smartfrog.CacheBenchmarkPrim";
+
+   scriptToExec "runNode.sh"
+
+   //FQN of the directory where the framework was checked out (noramally is th eparent of the dir that contains this file)
+   //this should be edited
+   cacheBenchmarkHome "c:/projects/jboss/cache/benchmark/cache-bench-fwk";
+
+   //should be the name of a subdirectory of 'cache-products' directory.
+   cacheDistribution "jbosscache-2.0.0";
+
+   //defines on how many nodes the benchmark will run
+   clusterSize 1;
+
+   //might take a value from 0..max_nr_of_nodes, representing the index of the current node in the cluster
+   nodeIndex TBD;
+}
\ No newline at end of file

Added: cache-bench-fwk/trunk/smartfrog/main.sf
===================================================================
--- cache-bench-fwk/trunk/smartfrog/main.sf	                        (rev 0)
+++ cache-bench-fwk/trunk/smartfrog/main.sf	2008-01-04 09:44:30 UTC (rev 4975)
@@ -0,0 +1,13 @@
+#include "org/smartfrog/components.sf"
+#include "cacheBenchComponent.sf"
+
+sfConfig extends Compound {
+
+   node1 extends BaseCacheBenchPrim{
+      sfProcessHost "localhost";
+      nodeIndex 1;
+      scriptToExec "runNode.bat"
+   }
+   
+}
+

Modified: cache-bench-fwk/trunk/src/org/cachebench/config/ClusterConfig.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/ClusterConfig.java	2008-01-04 02:36:51 UTC (rev 4974)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/ClusterConfig.java	2008-01-04 09:44:30 UTC (rev 4975)
@@ -1,5 +1,8 @@
 package org.cachebench.config;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.List;
@@ -11,8 +14,13 @@
  */
 public class ClusterConfig
 {
+
+   public static final Log log = LogFactory.getLog(ClusterConfig.class);
+
    private int currentNodeIndex = -1;
 
+   private int clusterSize = -1;
+
    private List<NodeAddress> members = new ArrayList<NodeAddress>();
 
    private String bindAddress;
@@ -35,18 +43,36 @@
 
    public List<NodeAddress> getMembers()
    {
+      if (members.size() > getClusterSize())
+      {
+         return members.subList(0, clusterSize);
+      }
       return members;
    }
 
    public int getPortForThisNode()
    {
-      NodeAddress address = members.get(getCurrentNodeIndex());
+      NodeAddress address = getMembers().get(getCurrentNodeIndex());
       return Integer.parseInt(address.getPort());
    }
 
    public int getClusterSize()
    {
-      return members.size();
+      if (clusterSize < 0)
+      {
+         String clusterSizeStr = System.getProperty("clusterSize");
+         if (clusterSizeStr != null)
+         {
+            int size = Integer.parseInt(clusterSizeStr);
+            log.info("Received cluster size: " + size);
+            clusterSize = size;
+         }
+         else
+         {
+            return members.size();
+         }
+      }
+      return clusterSize;
    }
 
    public boolean isMaster()
@@ -59,11 +85,6 @@
       members.add(member);
    }
 
-   public void setCurrentNodeIndex(int currentNodeIndex)
-   {
-      this.currentNodeIndex = currentNodeIndex;
-   }
-
    public String getBindAddress()
    {
       return bindAddress;
@@ -86,6 +107,6 @@
 
    public String toString()
    {
-      return "{bindAddress:" + bindAddress + ", members:" + members + "}";
+      return "{bindAddress:" + bindAddress + ", members:" + getMembers() + ", clusterSize:" + getClusterSize() + "}";
    }
 }

Added: cache-bench-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java	                        (rev 0)
+++ cache-bench-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java	2008-01-04 09:44:30 UTC (rev 4975)
@@ -0,0 +1,90 @@
+package org.cachebench.smartfrog;
+
+import org.smartfrog.sfcore.common.SmartFrogException;
+import org.smartfrog.sfcore.common.SmartFrogResolutionException;
+import org.smartfrog.sfcore.logging.LogSF;
+import org.smartfrog.sfcore.prim.Prim;
+import org.smartfrog.sfcore.prim.PrimImpl;
+import org.smartfrog.sfcore.prim.TerminationRecord;
+
+import java.io.File;
+import java.rmi.RemoteException;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class CacheBenchmarkPrim extends PrimImpl implements Prim
+{
+   private static LogSF log;
+
+   private int nodeIndex = -1;
+   private String cacheDistribution;
+   private File toRunIn;
+   private int clusterSize = -1;
+   private String scriptToExec;
+
+   public CacheBenchmarkPrim() throws RemoteException
+   {
+   }
+
+   public synchronized void sfDeploy() throws SmartFrogException, RemoteException
+   {
+      super.sfDeploy();
+      log = super.sfGetApplicationLog();
+      log.setLevel(LogSF.LOG_LEVEL_ALL);
+      log.trace("deploy started");
+      //reading the attributes here
+      nodeIndex = (Integer) sfResolve("nodeIndex");
+      log.info("Received current index: " + nodeIndex);
+      cacheDistribution = (String) sfResolve("cacheDistribution");
+      log.info("Received cache distribution: " + cacheDistribution);
+      toRunIn = getFwkHomeDir();
+      log.info("Received homedir: " + toRunIn);
+      clusterSize = (Integer)sfResolve("clusterSize");
+      log.info("Received cluster size: " + clusterSize);
+      scriptToExec = (String) sfResolve("scriptToExec");
+      log.info("Received stringToExec: " + scriptToExec);
+      log.trace("Deploy finished");
+   }
+
+   public synchronized void sfStart() throws SmartFrogException, RemoteException
+   {
+      super.sfStart();
+      log.trace("parsing the configuration...");
+      try
+      {
+         String command = scriptToExec + " " + nodeIndex + " " + cacheDistribution + " -DclusterSize=" + clusterSize;
+         log.info("Executing command: " + command);
+         Process process = Runtime.getRuntime().exec(command, null, toRunIn);
+         int exitValue = process.waitFor();
+         if (exitValue != 0)
+         {
+            sfTerminate(new TerminationRecord(TerminationRecord.ABNORMAL, "we have an not 0 exit code: " + exitValue, null));
+         }
+      }
+      catch (Exception e)
+      {
+         log.error("Unexpected error:" + e.getMessage(), e);
+         throw new RemoteException("Unexpected error",e);
+      }
+   }
+
+   private File getFwkHomeDir()
+         throws SmartFrogResolutionException, RemoteException
+   {
+      File toRunIn;
+      String cacheBenchmarkHome = sfResolve("cacheBenchmarkHome") + "";
+      toRunIn = new File(cacheBenchmarkHome);
+      if (!toRunIn.isDirectory())
+      {
+         log.error("cacheBenchmarkHome is not specified correctly: " + cacheBenchmarkHome);
+      }
+      return toRunIn;
+   }
+
+   protected synchronized void sfTerminateWith(TerminationRecord terminationRecord)
+   {
+      super.sfTerminateWith(terminationRecord);
+      log.trace("sfTerminateWith called with value:" +  terminationRecord);
+   }
+}

Modified: cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java	2008-01-04 02:36:51 UTC (rev 4974)
+++ cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java	2008-01-04 09:44:30 UTC (rev 4975)
@@ -191,7 +191,6 @@
                      cache.put(key + cycleNumber, value);
                      long statValue = (System.currentTimeMillis() - startTime);
                      stats.addValue(statValue);
-                     log.debug("The Put stat : " + statValue);
                   }
                   else
                   {
@@ -201,7 +200,6 @@
                      sCache.putSerializable(key + cycleNumber, sValue);
                      long statValue = (System.currentTimeMillis() - startTime);
                      stats.addValue(statValue);
-                     log.debug("The Put stat : " + statValue);
                   }
                }
                catch (Exception e)




More information about the jbosscache-commits mailing list