[jboss-cvs] CacheBenchFwk/src/org/cachebench ...

Manik Surtani manik at jboss.org
Tue Mar 13 10:50:20 EDT 2007


  User: msurtani
  Date: 07/03/13 10:50:20

  Modified:    src/org/cachebench      CacheBenchMarkerSlave.java
                        SerializableCacheWrapper.java CacheWrapper.java
                        TestResult.java CacheBenchMarker.java
  Log:
  wc
  
  Revision  Changes    Path
  1.2       +148 -146  CacheBenchFwk/src/org/cachebench/CacheBenchMarkerSlave.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheBenchMarkerSlave.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/src/org/cachebench/CacheBenchMarkerSlave.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CacheBenchMarkerSlave.java	13 Mar 2007 14:43:05 -0000	1.1
  +++ CacheBenchMarkerSlave.java	13 Mar 2007 14:50:20 -0000	1.2
  @@ -1,27 +1,19 @@
   package org.cachebench;
   
  +import org.apache.commons.digester.Digester;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.cachebench.config.Configuration;
   import org.cachebench.config.TestCase;
  -import org.cachebench.config.TestConfig;
  -import org.cachebench.config.Report;
  -import org.cachebench.tests.CacheTest;
  -import org.cachebench.reportgenerators.ReportGenerator;
   import org.cachebench.utils.Instantiator;
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.digester.Digester;
   
  -import java.net.URL;
  -import java.net.MalformedURLException;
  -import java.util.List;
  -import java.util.ArrayList;
  -import java.util.Iterator;
  -import java.util.Date;
   import java.io.File;
  +import java.net.MalformedURLException;
  +import java.net.URL;
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: CacheBenchMarkerSlave.java,v 1.1 2007/03/13 14:43:05 msurtani Exp $
  + * @version $Id: CacheBenchMarkerSlave.java,v 1.2 2007/03/13 14:50:20 msurtani Exp $
    */
   public class CacheBenchMarkerSlave
   {
  @@ -56,6 +48,7 @@
       {
           // first, try and find the configuration on the filesystem.
           URL confFile = findOnFS(s);
  +      final Object o = new Object();
           if (confFile == null)
           {
               confFile = findInClasspath(s);
  @@ -76,11 +69,19 @@
                   // will only start the first valid test.  Slaves don't support more than one test at a time
                   TestCase[] cases = conf.getTestCases();
                   if (cases.length == 0) throw new RuntimeException("Unable to proceed; no tests configured!");
  -                if (cases.length != 1) logger.warn("Slaves only support running one test case at a time.  You have " + cases.length + " cases configured.  Will only attempt the first one.");
  +            if (cases.length != 1)
  +               logger.warn("Slaves only support running one test case at a time.  You have " + cases.length + " cases configured.  Will only attempt the first one.");
   
  +            CacheWrapper c = getCacheWrapperInstance(cases[0]);
  +            c.init(cases[0].getParams());
  +            c.setUp();
   
  +            logger.info("Slave is listening.  CTRL-C to kill.");
  +            synchronized (o)
  +            {
  +               wait();
  +            }
   
  -                logger.info("Benchmarking Completed.  Hope you enjoyed using this!");
               }
               catch (Exception e)
               {
  @@ -147,7 +148,8 @@
           return getClass().getClassLoader().getResource(filename);
       }
   
  -    private CacheWrapper getCacheWrapperInstance(TestCase testCaseClass) {
  +   private CacheWrapper getCacheWrapperInstance(TestCase testCaseClass)
  +   {
           CacheWrapper cache = null;
           try
           {
  
  
  
  1.3       +15 -13    CacheBenchFwk/src/org/cachebench/SerializableCacheWrapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SerializableCacheWrapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/src/org/cachebench/SerializableCacheWrapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- SerializableCacheWrapper.java	27 Dec 2005 05:25:12 -0000	1.2
  +++ SerializableCacheWrapper.java	13 Mar 2007 14:50:20 -0000	1.3
  @@ -5,12 +5,13 @@
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: SerializableCacheWrapper.java,v 1.2 2005/12/27 05:25:12 imran Exp $
  + * @version $Id: SerializableCacheWrapper.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
    */
   public interface SerializableCacheWrapper extends CacheWrapper
   {
       /**
        * Similar to get, only uses serializable objects
  +    *
        * @param key The key of the value in cache.
        * @return The value in cache.
        */
  @@ -18,6 +19,7 @@
   
       /**
        * Similar to put, only uses serializable objects
  +    *
        * @param key The serializable key in which the value will be saved.
        * @param value The serializable value be saved.
        */
  
  
  
  1.3       +50 -53    CacheBenchFwk/src/org/cachebench/CacheWrapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheWrapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/src/org/cachebench/CacheWrapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- CacheWrapper.java	27 Dec 2005 05:25:34 -0000	1.2
  +++ CacheWrapper.java	13 Mar 2007 14:50:20 -0000	1.3
  @@ -8,7 +8,7 @@
    * accessing and manipulating a cache.
    * 
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: CacheWrapper.java,v 1.2 2005/12/27 05:25:34 imran Exp $
  + * @version $Id: CacheWrapper.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
    */
   public interface CacheWrapper
   {
  @@ -26,14 +26,12 @@
       /**
        * setUp() is called immediately after init(), and usually involves instantiating
        * a cache.
  -     *
        */
       public void setUp() throws Exception;
       
       /**
        * This is called at the very end of all tests on this cache, and is used for clean-up
        * operations.
  -     *
        */
       public void tearDown() throws Exception;
       
  @@ -60,7 +58,6 @@
       /**
        * This is called after each test type (if emptyCacheBetweenTests is set to true in cachebench.xml) and is
        * used to flush the cache.
  -     *
        */
       public void empty() throws Exception;
   }
  
  
  
  1.3       +90 -74    CacheBenchFwk/src/org/cachebench/TestResult.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TestResult.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/src/org/cachebench/TestResult.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- TestResult.java	27 Dec 2005 05:24:40 -0000	1.2
  +++ TestResult.java	13 Mar 2007 14:50:20 -0000	1.3
  @@ -1,12 +1,13 @@
   package org.cachebench;
   
  -import java.util.Date;
   import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
   
  +import java.util.Date;
  +
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: TestResult.java,v 1.2 2005/12/27 05:24:40 imran Exp $
  + * @version $Id: TestResult.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
    */
   public class TestResult
   {
  @@ -22,64 +23,79 @@
       {
           return getData;
       }
  +
       public void setGetData(DescriptiveStatistics getData)
       {
           this.getData = getData;
       }
  +
       public DescriptiveStatistics getPutData()
       {
           return putData;
       }
  +
       public void setPutData(DescriptiveStatistics putData)
       {
           this.putData = putData;
       }
  +
       public String getTestName()
       {
           return testName;
       }
  +
       public void setTestName(String testName)
       {
           this.testName = testName;
       }
  +
       public String getTestType()
       {
           return testType;
       }
  +
       public void setTestType(String testType)
       {
           this.testType = testType;
       }
  +
       public Date getTestTime()
       {
           return testTime;
       }
  +
       public void setTestTime(Date testTime)
       {
           this.testTime = testTime;
       }
   
  -    public boolean isTestPassed() {
  +   public boolean isTestPassed()
  +   {
           return testPassed;
       }
   
  -    public void setTestPassed(boolean testPassed) {
  +   public void setTestPassed(boolean testPassed)
  +   {
           this.testPassed = testPassed;
       }
   
  -    public String getErrorMsg() {
  +   public String getErrorMsg()
  +   {
           return errorMsg;
       }
   
  -    public void setErrorMsg(String errorMsg) {
  +   public void setErrorMsg(String errorMsg)
  +   {
           this.errorMsg = errorMsg;
       }
   
  -    public String getFootNote() {
  +   public String getFootNote()
  +   {
           return footNote;
       }
   
  -    public void setFootNote(String footNote) {
  +   public void setFootNote(String footNote)
  +   {
           this.footNote = footNote;
       }
   }
  
  
  
  1.4       +320 -301  CacheBenchFwk/src/org/cachebench/CacheBenchMarker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheBenchMarker.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/src/org/cachebench/CacheBenchMarker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- CacheBenchMarker.java	27 Dec 2005 05:26:43 -0000	1.3
  +++ CacheBenchMarker.java	13 Mar 2007 14:50:20 -0000	1.4
  @@ -1,14 +1,6 @@
   package org.cachebench;
   
   
  -import java.io.File;
  -import java.net.MalformedURLException;
  -import java.net.URL;
  -import java.util.ArrayList;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Date;
  -
   import org.apache.commons.digester.Digester;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -20,10 +12,18 @@
   import org.cachebench.tests.CacheTest;
   import org.cachebench.utils.Instantiator;
   
  +import java.io.File;
  +import java.net.MalformedURLException;
  +import java.net.URL;
  +import java.util.ArrayList;
  +import java.util.Date;
  +import java.util.Iterator;
  +import java.util.List;
  +
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: CacheBenchMarker.java,v 1.3 2005/12/27 05:26:43 imran Exp $
  + * @version $Id: CacheBenchMarker.java,v 1.4 2007/03/13 14:50:20 msurtani Exp $
    */
   public class CacheBenchMarker
   {
  @@ -75,10 +75,12 @@
                   conf = parseConfiguration(confFile);
                   logger.info("Starting Benchmarking....");
                   TestResult[] results = runTests(); // Run the tests from this point.
  -                if(results != null && results.length != 0) {
  +            if (results != null && results.length != 0)
  +            {
                       generateReports(results); // Run the reports...
                   }
  -                else {
  +            else
  +            {
                       logger.warn("No Results to be reported");
                   }
                   logger.info("Benchmarking Completed.  Hope you enjoyed using this!");
  @@ -119,6 +121,7 @@
   
       /**
        * Executes each test case and returns the result.
  +    *
        * @return The Array of TestResult objects with the results of the tests.
        */
       private TestResult[] runTests()
  @@ -131,7 +134,8 @@
               try
               {
                   cache = getCacheWrapperInstance(tests[i]);
  -                if(cache != null) {
  +            if (cache != null)
  +            {
                       cache.init(tests[i].getParams());
                       cache.setUp();
                       List resultsForCache = runTestsOnCache(cache, tests[i]);
  @@ -153,6 +157,7 @@
        * Peforms the necessary external tasks for cache benchmarking.
        * These external tasks are defined in the cachebench.xml and would
        * be executed against the cache under test.
  +    *
        * @param cache The CacheWrapper for the cache in test.
        * @param testResult The TestResult of the test to which the tasks are executed.
        */
  @@ -160,10 +165,12 @@
       {
           try
           {
  -            if (conf.isEmptyCacheBetweenTests()) {
  +         if (conf.isEmptyCacheBetweenTests())
  +         {
                   cache.empty();
               }
  -            if (conf.isGcBetweenTestsEnabled()) {
  +         if (conf.isGcBetweenTestsEnabled())
  +         {
                   System.gc();
                   Thread.sleep(conf.getSleepBetweenTests());
               }
  @@ -172,10 +179,11 @@
           {
               // Nothing doing here...
           }
  -        catch(Exception e) {
  +      catch (Exception e)
  +      {
               // The Empty process of the cache failed. Add a foot note for the TestResult here.
  -            testResult.setFootNote("The Cache Empty process failed after test case: "+ testResult.getTestName() + " : "+ testResult.getTestType());
  -            errorLogger.error("The Cache Empty process failed after test case : "+ testResult.getTestName() +", "+ testResult.getTestType(), e);
  +         testResult.setFootNote("The Cache Empty process failed after test case: " + testResult.getTestName() + " : " + testResult.getTestType());
  +         errorLogger.error("The Cache Empty process failed after test case : " + testResult.getTestName() + ", " + testResult.getTestType(), e);
           }
   
           return testResult;
  @@ -189,24 +197,27 @@
           {
               TestConfig testConfig = (TestConfig) testConfigs.next();
               CacheTest testConfigClass = getCacheTestWrapper(testConfig);
  -            if(testConfigClass != null) {
  +         if (testConfigClass != null)
  +         {
                   TestResult result;
                   String testName = testConfig.getName();
                   String testCaseName = testCase.getName();
  -                try {
  -                    result = testConfigClass.doTest(testCaseName, cache, testName, conf.getSampleSize() );
  +            try
  +            {
  +               result = testConfigClass.doTest(testCaseName, cache, testName, conf.getSampleSize());
                   }
  -                catch(Exception e) {
  +            catch (Exception e)
  +            {
                       // The test failed. We should add a test result object with a error message and indicate that it failed.
                       result = new TestResult();
  -                    result.setTestName( testCaseName );
  -                    result.setTestTime( new Date() );
  -                    result.setTestType( testName );
  +               result.setTestName(testCaseName);
  +               result.setTestTime(new Date());
  +               result.setTestType(testName);
   
                       result.setTestPassed(false);
  -                    result.setErrorMsg("Failed to Execute - See logs for details : "+ e.getMessage());
  -                    logger.warn("Test case : "+ testCaseName + ", Test : "+ testName + " - Failed");
  -                    errorLogger.error("Test case : "+ testCaseName + ", Test : "+ testName + " - Failed : "+ e.getMessage(), e);
  +               result.setErrorMsg("Failed to Execute - See logs for details : " + e.getMessage());
  +               logger.warn("Test case : " + testCaseName + ", Test : " + testName + " - Failed");
  +               errorLogger.error("Test case : " + testCaseName + ", Test : " + testName + " - Failed : " + e.getMessage(), e);
                   }
                   executeTestTasks(cache, result);
                   results.add(result);
  @@ -225,19 +236,21 @@
               try
               {
                   generator = getReportWrapper(reports[i]);
  -                if(generator != null) {
  +            if (generator != null)
  +            {
                       generator.setResults(results);
                       generator.setOutputFile(new File(reports[i].getOutputFile()));
                       generator.generate();
                       logger.info("Report Generation Complted");
                   }
  -                else {
  +            else
  +            {
                       logger.info("Report not Generated - See logs for reasons");
                   }
               }
               catch (Exception e)
               {
  -                logger.warn("Unable to generate Report : "+ reports[i].getGenerator() + " - See logs for reasons");
  +            logger.warn("Unable to generate Report : " + reports[i].getGenerator() + " - See logs for reasons");
                   logger.warn("Skipping this report");
                   errorLogger.error("Unable to generate Report : " + reports[i].getGenerator(), e);
                   errorLogger.error("Skipping this report");
  @@ -276,7 +289,8 @@
           return getClass().getClassLoader().getResource(filename);
       }
   
  -    private CacheWrapper getCacheWrapperInstance(TestCase testCaseClass) {
  +   private CacheWrapper getCacheWrapperInstance(TestCase testCaseClass)
  +   {
           CacheWrapper cache = null;
           try
           {
  @@ -292,7 +306,8 @@
           return cache;
       }
   
  -    private ReportGenerator getReportWrapper(Report reportClass) {
  +   private ReportGenerator getReportWrapper(Report reportClass)
  +   {
           ReportGenerator report = null;
           try
           {
  @@ -309,11 +324,12 @@
   
       }
   
  -    private CacheTest getCacheTestWrapper(TestConfig testConfig) {
  +   private CacheTest getCacheTestWrapper(TestConfig testConfig)
  +   {
           CacheTest cacheTestClass = null;
           try
           {
  -            cacheTestClass = (CacheTest) Instantiator.getInstance().createClass( testConfig.getTestClass() );
  +         cacheTestClass = (CacheTest) Instantiator.getInstance().createClass(testConfig.getTestClass());
   
           }
           catch (Exception e)
  @@ -326,11 +342,14 @@
   
       }
   
  -    private void shutdownCache(CacheWrapper cache) {
  -        try {
  +   private void shutdownCache(CacheWrapper cache)
  +   {
  +      try
  +      {
               cache.tearDown();
           }
  -        catch(Exception e) {
  +      catch (Exception e)
  +      {
               logger.warn("Cache Shutdown - Failed.");
               errorLogger.error("Cache Shutdown failed : ", e);
           }
  
  
  



More information about the jboss-cvs-commits mailing list