[jboss-cvs] JBossCache/tests/perf/org/jboss/cache/aop ...

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:31:01 EDT 2006


  User: msurtani
  Date: 06/09/06 11:31:01

  Modified:    tests/perf/org/jboss/cache/aop       
                        LocalMapPerfAopTest.java LocalPerfAopTest.java
                        ReplicatedAsyncMapPerfAopTest.java
                        ReplicatedSyncMapContentionAopTest.java
                        ReplicatedSyncMapPerfAopTest.java
                        ReplicatedSyncPerfAopTest.java Server.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.5       +48 -27    JBossCache/tests/perf/org/jboss/cache/aop/LocalMapPerfAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalMapPerfAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/LocalMapPerfAopTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- LocalMapPerfAopTest.java	20 Jul 2006 11:48:26 -0000	1.4
  +++ LocalMapPerfAopTest.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -31,7 +31,7 @@
   /**
    * Local mode performance test for TreeCache.
    *
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class LocalMapPerfAopTest extends TestCase
  @@ -78,7 +78,8 @@
      private void populateNode() throws Exception
      {
         proxyMaps_ = new Map[nodeList_.size()];
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
   //            String key = Integer.toString(i);
            // put the cache in the aop first
            Map map = populateMap();
  @@ -90,7 +91,8 @@
      private Map populateMap()
      {
         Map map = new HashMap();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
            String value = "This is a test for performance of get and set of regular treecache and aop";
            map.put(key, value);
  @@ -105,7 +107,8 @@
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -120,12 +123,12 @@
   
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-service.xml"));
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache_.startService();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -185,20 +188,25 @@
      private int _put(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
         String value = "This is a modified value for the unit testing";
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
            Map map = (Map) cache_.getObject((String) nodeList_.get(i));
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
   //                proxyMaps_[i].put(key, value);
               map.put(key, value);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
   //                proxyMaps_[i].put(key, value);
               map.put(key, value);
            }
  @@ -210,18 +218,23 @@
      private int _get(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + " value: " +str);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + " value: " +str);
            }
  @@ -233,17 +246,22 @@
      private int _remove(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               proxyMaps_[i].remove(key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               proxyMaps_[i].remove(key);
            }
         }
  @@ -266,11 +284,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  
  
  
  1.5       +50 -31    JBossCache/tests/perf/org/jboss/cache/aop/LocalPerfAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalPerfAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/LocalPerfAopTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- LocalPerfAopTest.java	20 Jul 2006 11:48:26 -0000	1.4
  +++ LocalPerfAopTest.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -28,7 +28,7 @@
   /**
    * Local mode performance test for PojoCache.
    *
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class LocalPerfAopTest extends TestCase
  @@ -77,7 +77,8 @@
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -90,12 +91,12 @@
         cache_ = new PojoCache();
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-service.xml"));
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
  -      cache_.startService();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -204,18 +205,23 @@
      private int _add(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
            String value = Integer.toString(i);
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               cache_.put((String) nodeList_.get(i), key, value);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache_.put((String) nodeList_.get(i), key, value);
            }
         }
  @@ -226,17 +232,22 @@
      private int _get(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               cache_.get((String) nodeList_.get(i), key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache_.get((String) nodeList_.get(i), key);
            }
         }
  @@ -247,17 +258,22 @@
      private int _remove(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               cache_.remove((String) nodeList_.get(i), key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache_.remove((String) nodeList_.get(i), key);
            }
         }
  @@ -280,11 +296,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  
  
  
  1.4       +52 -30    JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedAsyncMapPerfAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedAsyncMapPerfAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedAsyncMapPerfAopTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- ReplicatedAsyncMapPerfAopTest.java	20 Jul 2006 06:04:57 -0000	1.3
  +++ ReplicatedAsyncMapPerfAopTest.java	6 Sep 2006 15:31:01 -0000	1.4
  @@ -31,7 +31,7 @@
   /**
    * Local mode performance test for TreeCache.
    *
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class ReplicatedAsyncMapPerfAopTest extends TestCase
  @@ -87,7 +87,8 @@
      {
         int length = seed1_.length();
         boolean isTrue = false;
  -      while (originalStrBuf_.length() < mapValueSize_) {
  +      while (originalStrBuf_.length() < mapValueSize_)
  +      {
            originalStrBuf_.append(seed1_);
            newStrBuf_.append(seed2_);
         }
  @@ -103,7 +104,8 @@
   
         long time1 = System.currentTimeMillis();
         int nOps = 0;
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
   //            String key = Integer.toString(i);
            // put the cache in the aop first
            Map map = populateMap();
  @@ -122,7 +124,8 @@
      private Map populateMap()
      {
         Map map = new HashMap();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
            String value = originalStrBuf_.toString();
            map.put(key, value);
  @@ -137,7 +140,8 @@
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -155,12 +159,12 @@
         //config.configure(cache_, ); // read in generic replAsync xml
         c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache_.setConfiguration(c);
  -      cache_.startService();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -223,18 +227,23 @@
      private int _put(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
         String value = newStrBuf_.toString();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               proxyMaps_[i].put(key, value);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               proxyMaps_[i].put(key, value);
            }
         }
  @@ -245,18 +254,23 @@
      private int _get(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + " value: " +str);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + ", value: " +str);
            }
  @@ -268,17 +282,22 @@
      private int _remove(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               proxyMaps_[i].remove(key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               proxyMaps_[i].remove(key);
            }
         }
  @@ -301,11 +320,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  
  
  
  1.5       +46 -26    JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncMapContentionAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedSyncMapContentionAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncMapContentionAopTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- ReplicatedSyncMapContentionAopTest.java	20 Jul 2006 11:14:18 -0000	1.4
  +++ ReplicatedSyncMapContentionAopTest.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -34,7 +34,7 @@
   /**
    * Replicated mode performance test for PojoCache to test out contention.
    *
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class ReplicatedSyncMapContentionAopTest extends TestCase
  @@ -93,7 +93,8 @@
      {
         int length = seed1_.length();
         boolean isTrue = false;
  -      while (originalStrBuf_.length() < mapValueSize_) {
  +      while (originalStrBuf_.length() < mapValueSize_)
  +      {
            originalStrBuf_.append(seed1_);
            newStrBuf_.append(seed2_);
         }
  @@ -109,7 +110,8 @@
   
         long time1 = System.currentTimeMillis();
         int nOps = 0;
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
   //            String key = Integer.toString(i);
            // put the cache in the aop first
            Map map = populateMap();
  @@ -128,7 +130,8 @@
      private Map populateMap()
      {
         Map map = new HashMap();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
            String value = originalStrBuf_.toString();
            map.put(key, value);
  @@ -143,7 +146,8 @@
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -158,7 +162,7 @@
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
   //      cache_.setCacheMode(cachingMode_);
  -      cache_.startService();
  +      cache_.start();
         return cache_;
   //        org.jgroups.log.Trace.init();
      }
  @@ -220,11 +224,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  @@ -269,47 +276,58 @@
         public void run()
         {
            long counter = 0;
  -         while(ex_ == null && counter++ < 200)
  +         while (ex_ == null && counter++ < 200)
            {
               long time = System.currentTimeMillis();
  -            try {
  +            try
  +            {
                  Thread.sleep(10000);
  -            } catch (InterruptedException e) {
  +            }
  +            catch (InterruptedException e)
  +            {
   
               }
   
  -            try {
  +            try
  +            {
                  _put();
   //               _get();
  -            } catch (Exception e) {
  -               if(e.getCause() instanceof UpgradeException ||
  +            }
  +            catch (Exception e)
  +            {
  +               if (e.getCause() instanceof UpgradeException ||
                          e.getCause() instanceof TimeoutException)
                  {
  -                  System.err.println("TimeoutException: "+ e.getCause());
  +                  System.err.println("TimeoutException: " + e.getCause());
                     continue;
                  }
                  ex_ = e;
  -               throw new IllegalStateException("Exception in put(): "+e);
  +               throw new IllegalStateException("Exception in put(): " + e);
               }
  -            System.out.println("Loop counter: " +counter++);
  +            System.out.println("Loop counter: " + counter++);
            }
         }
   
         private void _put() throws Exception
         {
            UserTransaction tx = null;
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
            }
   
            String value = "Test";
  -         for (int i = 0; i < nodeList_.size(); i++) {
  +         for (int i = 0; i < nodeList_.size(); i++)
  +         {
               String key = Integer.toString(i) + "aop";
  -            if (hasTx) {
  +            if (hasTx)
  +            {
                  tx.begin();
                  proxyMaps_[i].put(key, value);
                  tx.commit();
  -            } else {
  +            }
  +            else
  +            {
                  proxyMaps_[i].put(key, value);
               }
            }
  @@ -318,12 +336,14 @@
         private void _get() throws Exception
         {
            UserTransaction tx = null;
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
            }
   
            String value = "Test";
  -         for (int i = 0; i < nodeList_.size(); i++) {
  +         for (int i = 0; i < nodeList_.size(); i++)
  +         {
               String key = Integer.toString(i) + "aop";
               proxyMaps_[i].get(key);
            }
  
  
  
  1.5       +52 -30    JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncMapPerfAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedSyncMapPerfAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncMapPerfAopTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- ReplicatedSyncMapPerfAopTest.java	20 Jul 2006 11:48:26 -0000	1.4
  +++ ReplicatedSyncMapPerfAopTest.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -31,7 +31,7 @@
   /**
    * Local mode performance test for TreeCache.
    *
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class ReplicatedSyncMapPerfAopTest extends TestCase
  @@ -85,7 +85,8 @@
   
      private void generateString()
      {
  -      while (originalStrBuf_.length() < mapValueSize_) {
  +      while (originalStrBuf_.length() < mapValueSize_)
  +      {
            originalStrBuf_.append(seed1_);
            newStrBuf_.append(seed2_);
         }
  @@ -101,7 +102,8 @@
   
         long time1 = System.currentTimeMillis();
         int nOps = 0;
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
   //            String key = Integer.toString(i);
            // put the cache in the aop first
            Map map = populateMap();
  @@ -120,7 +122,8 @@
      private Map populateMap()
      {
         Map map = new HashMap();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
            String value = originalStrBuf_.toString();
            map.put(key, value);
  @@ -135,7 +138,8 @@
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -149,13 +153,13 @@
         cache_ = new PojoCache();
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache_.startService();
  +      cache_.start();
   //        org.jgroups.log.Trace.init();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -218,18 +222,23 @@
      private int _put(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
         String value = newStrBuf_.toString();
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               proxyMaps_[i].put(key, value);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               proxyMaps_[i].put(key, value);
            }
         }
  @@ -240,18 +249,23 @@
      private int _get(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + " value: " +str);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               String str = (String) proxyMaps_[i].get(key);
   //                log("_get(): key: " + key + ", value: " +str);
            }
  @@ -263,17 +277,22 @@
      private int _remove(boolean hasTx) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      for (int i = 1; i < nodeList_.size(); i++) {
  +      for (int i = 1; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i) + "aop";
  -         if (hasTx) {
  +         if (hasTx)
  +         {
               tx.begin();
               proxyMaps_[i].remove(key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               proxyMaps_[i].remove(key);
            }
         }
  @@ -296,11 +315,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  
  
  
  1.5       +81 -56    JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncPerfAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedSyncPerfAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/ReplicatedSyncPerfAopTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- ReplicatedSyncPerfAopTest.java	20 Jul 2006 11:48:26 -0000	1.4
  +++ ReplicatedSyncPerfAopTest.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -29,7 +29,7 @@
   /**
    * Replicated synchronous mode performance test for transactional TreeCache.
    *
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
    */
   public class ReplicatedSyncPerfAopTest extends TestCase
  @@ -79,7 +79,8 @@
   
         DummyTransactionManager.destroy();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -97,7 +98,7 @@
   
      void destroyCache(TreeCache cache) throws Exception
      {
  -      cache.stopService();
  +      cache.stop();
         cache = null;
      }
   
  @@ -106,7 +107,7 @@
         log("=== 1 cache with transaction (no concurrent access) ===");
         cache1_ = createCache();
         cache1_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
  -      cache1_.startService();
  +      cache1_.start();
   
         // Formating
         DecimalFormat form = new DecimalFormat("#.00");
  @@ -154,8 +155,8 @@
         cache2_ = createCache();
         cache1_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
  -      cache1_.startService();
  -      cache2_.startService();
  +      cache1_.start();
  +      cache2_.start();
   
         // Formating
         DecimalFormat form = new DecimalFormat("#.00");
  @@ -204,8 +205,8 @@
         cache2_ = createCache();
         cache1_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
  -      cache1_.startService();
  -      cache2_.startService();
  +      cache1_.start();
  +      cache2_.start();
   
         // Formating
         DecimalFormat form = new DecimalFormat("#.00");
  @@ -257,9 +258,9 @@
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         cache3_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
  -      cache1_.startService();
  -      cache2_.startService();
  -      cache3_.startService();
  +      cache1_.start();
  +      cache2_.start();
  +      cache3_.start();
   
         // Formating
         DecimalFormat form = new DecimalFormat("#.00");
  @@ -305,27 +306,34 @@
      private int _add(TreeCache cache, boolean hasTx, boolean oneTxOnly) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.begin();
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
            String value = Integer.toString(i);
  -         if (hasTx && !oneTxOnly) {
  +         if (hasTx && !oneTxOnly)
  +         {
               tx.begin();
               cache.put((String) nodeList_.get(i), key, value);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache.put((String) nodeList_.get(i), key, value);
            }
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.commit();
         }
   
  @@ -335,26 +343,33 @@
      private int _get(TreeCache cache, boolean hasTx, boolean oneTxOnly) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.begin();
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
  -         if (hasTx && !oneTxOnly) {
  +         if (hasTx && !oneTxOnly)
  +         {
               tx.begin();
               cache.get((String) nodeList_.get(i), key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache.get((String) nodeList_.get(i), key);
            }
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.commit();
         }
   
  @@ -364,26 +379,33 @@
      private int _remove(TreeCache cache, boolean hasTx, boolean oneTxOnly) throws Exception
      {
         UserTransaction tx = null;
  -      if (hasTx) {
  +      if (hasTx)
  +      {
            tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.begin();
         }
   
  -      for (int i = 0; i < nodeList_.size(); i++) {
  +      for (int i = 0; i < nodeList_.size(); i++)
  +      {
            String key = Integer.toString(i);
  -         if (hasTx && !oneTxOnly) {
  +         if (hasTx && !oneTxOnly)
  +         {
               tx.begin();
               cache.remove((String) nodeList_.get(i), key);
               tx.commit();
  -         } else {
  +         }
  +         else
  +         {
               cache.remove((String) nodeList_.get(i), key);
            }
         }
   
  -      if (hasTx && oneTxOnly) {
  +      if (hasTx && oneTxOnly)
  +      {
            tx.commit();
         }
   
  @@ -404,11 +426,14 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1) tmp += "/";
  
  
  
  1.5       +10 -5     JBossCache/tests/perf/org/jboss/cache/aop/Server.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Server.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/aop/Server.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- Server.java	20 Jul 2006 06:04:57 -0000	1.4
  +++ Server.java	6 Sep 2006 15:31:01 -0000	1.5
  @@ -16,6 +16,7 @@
   
   /**
    * A standalone dummy server that accepts data from other replicated cache.
  + *
    * @deprecated 1.4 User should use the script under tests/script now.
    */
   public class Server
  @@ -31,12 +32,12 @@
         Configuration c = parser.parseFile("META-INF/replSync-service.xml");
         cache_.setConfiguration(c);
         c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache_.startService();
  +      cache_.start();
      }
   
      void destroyCache() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -51,12 +52,16 @@
         server.initCach();
         boolean isYes = true;
         InputStreamReader reader = new InputStreamReader(System.in);
  -      while (isYes) {
  +      while (isYes)
  +      {
            System.out.println("To abort hit cntrl-c");
   //            System.out.println(server.getCache().printLockInfo());
  -         try {
  +         try
  +         {
               Thread.sleep(10000);
  -         } catch (Exception ex) {
  +         }
  +         catch (Exception ex)
  +         {
            }
            ;
         }
  
  
  



More information about the jboss-cvs-commits mailing list