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

Manik Surtani manik at jboss.org
Wed Apr 18 15:09:30 EDT 2007


  User: msurtani
  Date: 07/04/18 15:09:30

  Modified:    src/org/cachebench      SerializableCacheWrapper.java
                        CacheWrapper.java TestResult.java
                        CacheBenchMarkerSlave.java CacheBenchMarker.java
  Log:
  Updated loads of stuff
  
  Revision  Changes    Path
  1.4       +3 -3      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.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- SerializableCacheWrapper.java	13 Mar 2007 14:50:20 -0000	1.3
  +++ SerializableCacheWrapper.java	18 Apr 2007 19:09:29 -0000	1.4
  @@ -5,7 +5,7 @@
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: SerializableCacheWrapper.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
  + * @version $Id: SerializableCacheWrapper.java,v 1.4 2007/04/18 19:09:29 msurtani Exp $
    */
   public interface SerializableCacheWrapper extends CacheWrapper
   {
  @@ -15,7 +15,7 @@
       * @param key The key of the value in cache.
       * @return The value in cache.
       */
  -   public Object getSerializable(Serializable key) throws Exception;
  +   Object getSerializable(Serializable key) throws Exception;
   
      /**
       * Similar to put, only uses serializable objects
  @@ -23,5 +23,5 @@
       * @param key   The serializable key in which the value will be saved.
       * @param value The serializable value be saved.
       */
  -   public void putSerializable(Serializable key, Serializable value) throws Exception;
  +   void putSerializable(Serializable key, Serializable value) throws Exception;
   }
  
  
  
  1.4       +12 -7     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.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- CacheWrapper.java	13 Mar 2007 14:50:20 -0000	1.3
  +++ CacheWrapper.java	18 Apr 2007 19:09:29 -0000	1.4
  @@ -8,7 +8,7 @@
    * accessing and manipulating a cache.
    *
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: CacheWrapper.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
  + * @version $Id: CacheWrapper.java,v 1.4 2007/04/18 19:09:29 msurtani Exp $
    */
   public interface CacheWrapper
   {
  @@ -21,19 +21,19 @@
       *
       * @param parameters
       */
  -   public void init(Properties parameters) throws Exception;
  +   void init(Properties parameters) throws Exception;
   
      /**
       * setUp() is called immediately after init(), and usually involves instantiating
       * a cache.
       */
  -   public void setUp() throws Exception;
  +   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;
  +   void tearDown() throws Exception;
   
      /**
       * This method is called when the framework needs to put an object in cache.  This method is treated
  @@ -43,7 +43,7 @@
       * @param key
       * @param value
       */
  -   public void put(Object key, Object value) throws Exception;
  +   void put(Object key, Object value) throws Exception;
   
      /**
       * Similar to put, get wraps up an operation related to retrieving an object from the cache.  As in the
  @@ -53,11 +53,16 @@
       * @param key
       * @return The value pertaining to the key in cache
       */
  -   public Object get(Object key) throws Exception;
  +   Object get(Object key) throws Exception;
   
      /**
       * 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;
  +   void empty() throws Exception;
  +
  +   /**
  +    * @return the number of members in the cache's cluster
  +    */
  +   int getNumMembers();
   }
  
  
  
  1.4       +55 -1     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.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- TestResult.java	13 Mar 2007 14:50:20 -0000	1.3
  +++ TestResult.java	18 Apr 2007 19:09:30 -0000	1.4
  @@ -7,7 +7,7 @@
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: TestResult.java,v 1.3 2007/03/13 14:50:20 msurtani Exp $
  + * @version $Id: TestResult.java,v 1.4 2007/04/18 19:09:30 msurtani Exp $
    */
   public class TestResult
   {
  @@ -18,6 +18,10 @@
      private boolean testPassed; // This is to indicate whether the test is passed/failed.
      private String errorMsg = ""; // This holds the error message if any error had occured in the test.
      private String footNote = ""; // This is utilized if special notes need to be captured for this test.
  +   private int throughputTransactionsPerSecond;
  +   private int throughputBytesPerSecond;
  +   private int numMembers;
  +   private int numThreads;
   
      public DescriptiveStatistics getGetData()
      {
  @@ -98,4 +102,54 @@
      {
         this.footNote = footNote;
      }
  +
  +   /**
  +    * This is only measured on put() operations as it has little meaning for get()s.
  +    */
  +   public int getThroughputTransactionsPerSecond()
  +   {
  +      return throughputTransactionsPerSecond;
  +   }
  +
  +   public void setThroughputTransactionsPerSecond(int throughputTransactionsPerSecond)
  +   {
  +      this.throughputTransactionsPerSecond = throughputTransactionsPerSecond;
  +   }
  +
  +   /**
  +    * This is only measured on put() operations as it has little meaning for get()s.  Note that the serialized size of objects
  +    * are used to calculate this, not the ACTUAL bytes transmitted, as some cache impls (JBoss Cache >= 1.4) has internal
  +    * marshallers that reduce object sizes to smaller than what they would be if serialized.  For the sake of comparing though,
  +    * one must still consider that an object of, say, 200 bytes when serialized was transmitted, even if the cache compresses
  +    * this to 100 bytes.
  +    */
  +   public int getThroughputBytesPerSecond()
  +   {
  +      return throughputBytesPerSecond;
  +   }
  +
  +   public void setThroughputBytesPerSecond(int throughputBytesPerSecond)
  +   {
  +      this.throughputBytesPerSecond = throughputBytesPerSecond;
  +   }
  +
  +   public int getNumMembers()
  +   {
  +      return numMembers;
  +   }
  +
  +   public void setNumMembers(int numMembers)
  +   {
  +      this.numMembers = numMembers;
  +   }
  +
  +   public int getNumThreads()
  +   {
  +      return numThreads;
  +   }
  +
  +   public void setNumThreads(int numThreads)
  +   {
  +      this.numThreads = numThreads;
  +   }
   }
  
  
  
  1.5       +9 -8      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.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CacheBenchMarkerSlave.java	13 Mar 2007 16:42:25 -0000	1.4
  +++ CacheBenchMarkerSlave.java	18 Apr 2007 19:09:30 -0000	1.5
  @@ -10,10 +10,11 @@
   import java.io.File;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.List;
   
   /**
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: CacheBenchMarkerSlave.java,v 1.4 2007/03/13 16:42:25 msurtani Exp $
  + * @version $Id: CacheBenchMarkerSlave.java,v 1.5 2007/04/18 19:09:30 msurtani Exp $
    */
   public class CacheBenchMarkerSlave
   {
  @@ -67,13 +68,13 @@
               logger.info("Starting Slave....");
   
               // 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.");
  +            List<TestCase> cases = conf.getTestCases();
  +            if (cases.size() == 0) throw new RuntimeException("Unable to proceed; no tests configured!");
  +            if (cases.size() != 1)
  +               logger.warn("Slaves only support running one test case at a time.  You have " + cases.size() + " cases configured.  Will only attempt the first one.");
   
  -            CacheWrapper c = getCacheWrapperInstance(cases[0]);
  -            c.init(cases[0].getParams());
  +            CacheWrapper c = getCacheWrapperInstance(cases.get(0));
  +            c.init(cases.get(0).getParams());
               c.setUp();
   
               logger.info("Slave is listening.  CTRL-C to kill.");
  @@ -85,7 +86,7 @@
            }
            catch (Exception e)
            {
  -            logger.warn("Unable to parse configuration file " + confFile + ". Application terminated");
  +            logger.warn("Unable to parse configuration file " + confFile + ". Application terminated.", e);
               errorLogger.fatal("Unable to parse configuration file " + confFile, e);
            }
         }
  
  
  
  1.5       +23 -28    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.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CacheBenchMarker.java	13 Mar 2007 14:50:20 -0000	1.4
  +++ CacheBenchMarker.java	18 Apr 2007 19:09:30 -0000	1.5
  @@ -17,13 +17,12 @@
   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.4 2007/03/13 14:50:20 msurtani Exp $
  + * @version $Id: CacheBenchMarker.java,v 1.5 2007/04/18 19:09:30 msurtani Exp $
    */
   public class CacheBenchMarker
   {
  @@ -74,8 +73,8 @@
            {
               conf = parseConfiguration(confFile);
               logger.info("Starting Benchmarking....");
  -            TestResult[] results = runTests(); // Run the tests from this point.
  -            if (results != null && results.length != 0)
  +            List<TestResult> results = runTests(); // Run the tests from this point.
  +            if (results != null && results.size() != 0)
               {
                  generateReports(results); // Run the reports...
               }
  @@ -124,33 +123,32 @@
       *
       * @return The Array of TestResult objects with the results of the tests.
       */
  -   private TestResult[] runTests()
  +   private List<TestResult> runTests()
      {
  -      TestCase[] tests = conf.getTestCases();
  -      List results = new ArrayList();
  -      for (int i = 0; i < tests.length; i++)
  +      List<TestResult> results = new ArrayList<TestResult>();
  +      for (TestCase test : conf.getTestCases())
         {
  -         CacheWrapper cache = null;
  +         CacheWrapper cache;
            try
            {
  -            cache = getCacheWrapperInstance(tests[i]);
  +            cache = getCacheWrapperInstance(test);
               if (cache != null)
               {
  -               cache.init(tests[i].getParams());
  +               cache.init(test.getParams());
                  cache.setUp();
  -               List resultsForCache = runTestsOnCache(cache, tests[i]);
  +               List<TestResult> resultsForCache = runTestsOnCache(cache, test);
                  shutdownCache(cache);
                  results.addAll(resultsForCache);
               }
            }
            catch (Exception e)
            {
  -            logger.warn("Unable to Initialize or Setup the Cache - Not performing any tests");
  -            errorLogger.error("Unable to Initialize or Setup the Cache: " + tests[i].getCacheWrapper(), e);
  +            logger.warn("Unable to Initialize or Setup the Cache - Not performing any tests", e);
  +            errorLogger.error("Unable to Initialize or Setup the Cache: " + test.getCacheWrapper(), e);
               errorLogger.error("Skipping this test");
            }
         }
  -      return (TestResult[]) results.toArray(new TestResult[0]);
  +      return results;
      }
   
      /**
  @@ -189,13 +187,11 @@
         return testResult;
      }
   
  -   private List runTestsOnCache(CacheWrapper cache, TestCase testCase)
  +   private List<TestResult> runTestsOnCache(CacheWrapper cache, TestCase testCase)
      {
  -      Iterator testConfigs = testCase.getTests().iterator();
  -      List results = new ArrayList();
  -      while (testConfigs.hasNext())
  +      List<TestResult> results = new ArrayList<TestResult>();
  +      for (TestConfig testConfig: testCase.getTests())
         {
  -         TestConfig testConfig = (TestConfig) testConfigs.next();
            CacheTest testConfigClass = getCacheTestWrapper(testConfig);
            if (testConfigClass != null)
            {
  @@ -204,7 +200,7 @@
               String testCaseName = testCase.getName();
               try
               {
  -               result = testConfigClass.doTest(testCaseName, cache, testName, conf.getSampleSize());
  +               result = testConfigClass.doTest(testCaseName, cache, testName, conf.getSampleSize(), conf.getNumThreads());
               }
               catch (Exception e)
               {
  @@ -226,20 +222,19 @@
         return results;
      }
   
  -   private void generateReports(TestResult[] results)
  +   private void generateReports(List<TestResult> results)
      {
         logger.info("Generating Reports...");
  -      Report[] reports = conf.getReports();
  -      for (int i = 0; i < reports.length; i++)
  +      for (Report report : conf.getReports())
         {
            ReportGenerator generator;
            try
            {
  -            generator = getReportWrapper(reports[i]);
  +            generator = getReportWrapper(report);
               if (generator != null)
               {
                  generator.setResults(results);
  -               generator.setOutputFile(new File(reports[i].getOutputFile()));
  +               generator.setOutputFile(new File(report.getOutputFile()));
                  generator.generate();
                  logger.info("Report Generation Complted");
               }
  @@ -250,9 +245,9 @@
            }
            catch (Exception e)
            {
  -            logger.warn("Unable to generate Report : " + reports[i].getGenerator() + " - See logs for reasons");
  +            logger.warn("Unable to generate Report : " + report.getGenerator() + " - See logs for reasons");
               logger.warn("Skipping this report");
  -            errorLogger.error("Unable to generate Report : " + reports[i].getGenerator(), e);
  +            errorLogger.error("Unable to generate Report : " + report.getGenerator(), e);
               errorLogger.error("Skipping this report");
            }
         }
  
  
  



More information about the jboss-cvs-commits mailing list