[jboss-cvs] JBossCache/tests/stress/org/jboss/cache ...

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


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

  Modified:    tests/stress/org/jboss/cache   EvictionLocalStressTest.java
                        LocalStressTest.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.6       +54 -42    JBossCache/tests/stress/org/jboss/cache/EvictionLocalStressTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EvictionLocalStressTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/stress/org/jboss/cache/EvictionLocalStressTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- EvictionLocalStressTest.java	20 Jul 2006 11:48:27 -0000	1.5
  +++ EvictionLocalStressTest.java	6 Sep 2006 15:31:02 -0000	1.6
  @@ -29,8 +29,8 @@
   /**
    * Local mode stress test for TreeCache.
    *
  - * @version $Id: EvictionLocalStressTest.java,v 1.5 2006/07/20 11:48:27 msurtani Exp $
    * @author <a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
  + * @version $Id: EvictionLocalStressTest.java,v 1.6 2006/09/06 15:31:02 msurtani Exp $
    */
   public class EvictionLocalStressTest extends TestCase
   {
  @@ -45,9 +45,9 @@
      static final int MAX_LOOP = 500;
      static final int SLEEP_TIME = 20;
      static final String ROOT = "/stress/";
  -   private static Log log=LogFactory.getLog(EvictionLocalStressTest.class);
  +   private static Log log = LogFactory.getLog(EvictionLocalStressTest.class);
   
  -   static Exception thread_ex=null;
  +   static Exception thread_ex = null;
   
      static
      {
  @@ -70,23 +70,23 @@
         initCaches(Configuration.CacheMode.LOCAL);
         nodeList_ = nodeGen(depth_, children_);
         log("LocalStressTestCase: cacheMode=TRANSIENT, one cache");
  -      thread_ex=null;
  +      thread_ex = null;
      }
   
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      thread_ex=null;
  +      thread_ex = null;
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
      }
   
   
  -
      void initCaches(Configuration.CacheMode caching_mode) throws Exception
      {
         cachingMode_ = caching_mode;
  @@ -94,13 +94,13 @@
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache_.getConfiguration().setLockAcquisitionTimeout(10000);
  -      cache_.createService();
  -      cache_.startService();
  +      cache_.create();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -138,7 +138,7 @@
   
         System.out.println("number of nodes/locks: " + cache_.getNumberOfNodes() + " / " + cache_.getNumberOfLocksHeld());
   
  -      if(thread_ex != null)
  +      if (thread_ex != null)
            throw thread_ex;
      }
   
  @@ -148,30 +148,35 @@
         Random random_;
         Transaction tx = null;
   
  -      public RunThread(int seed) throws Exception {
  +      public RunThread(int seed) throws Exception
  +      {
            super.setName("RunThread#" + seed);
            seed_ = seed;
            random_ = new Random(seed);
         }
   
  -      private Transaction startTransaction() throws Exception {
  -         DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +      private Transaction startTransaction() throws Exception
  +      {
  +         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
            mgr.begin();
            return mgr.getTransaction();
         }
   
         public void run()
         {
  -         try {
  +         try
  +         {
               _run();
            }
  -         catch(Exception ex) {
  -            thread_ex=ex;
  +         catch (Exception ex)
  +         {
  +            thread_ex = ex;
               // ex.printStackTrace();
            }
         }
   
  -      public void _run() throws Exception {
  +      public void _run() throws Exception
  +      {
            for (int i = 1; i <= MAX_LOOP && thread_ex == null; i++)
            {
               log(i + "/" + MAX_LOOP);
  @@ -195,13 +200,13 @@
   
            // tx=startTransaction();
            //try {
  -            if(log.isTraceEnabled())
  +         if (log.isTraceEnabled())
                  log.trace("op1.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
               cache_.get(node, key);
   
               sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
   
  -            if(log.isTraceEnabled())
  +         if (log.isTraceEnabled())
                  log.trace("op1.put(" + node + ", " + key + ", " + value + ") thread=" + Thread.currentThread());
               cache_.put(node, key, value);
            //}
  @@ -217,19 +222,21 @@
            String key = Integer.toString(i);
            String node = (String) nodeList_.get(i);
   
  -         tx=startTransaction();
  -         try {
  -            if(log.isTraceEnabled())
  +         tx = startTransaction();
  +         try
  +         {
  +            if (log.isTraceEnabled())
                  log.trace("op2.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
               cache_.get(node, key);
               sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
   
  -            if(log.isTraceEnabled())
  +            if (log.isTraceEnabled())
                  log.trace("op2.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
               cache_.get(node, key);
               sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
            }
  -         finally {
  +         finally
  +         {
               tx.commit();
            }
         }
  @@ -242,19 +249,21 @@
            String value = Integer.toString(i);
            String node = (String) nodeList_.get(i);
   
  -         tx=startTransaction();
  -         try {
  -            if(log.isTraceEnabled())
  +         tx = startTransaction();
  +         try
  +         {
  +            if (log.isTraceEnabled())
                  log.trace("op3.put(" + node + ", " + key + ", " + value + ") thread=" + Thread.currentThread());
               cache_.put(node, key, value);
   
               sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
   
  -            if(log.isTraceEnabled())
  +            if (log.isTraceEnabled())
                  log.trace("op3.remove(" + node + ", " + key + ") thread=" + Thread.currentThread());
               cache_.remove(node, key);
            }
  -         finally {
  +         finally
  +         {
               tx.commit();
            }
         }
  @@ -286,11 +295,14 @@
         newList.add(ROOT);
         strList.add(ROOT);
   
  -      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)
  
  
  
  1.7       +38 -23    JBossCache/tests/stress/org/jboss/cache/LocalStressTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalStressTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/stress/org/jboss/cache/LocalStressTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- LocalStressTest.java	20 Jul 2006 11:48:27 -0000	1.6
  +++ LocalStressTest.java	6 Sep 2006 15:31:02 -0000	1.7
  @@ -35,8 +35,8 @@
   /**
    * Local mode stress test for TreeCache.
    *
  - * @version $Revision: 1.6 $
    * @author <a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
  + * @version $Revision: 1.7 $
    */
   public class LocalStressTest extends TestCase
   {
  @@ -52,7 +52,7 @@
      DummyTransactionManager tm_;
      static final int MAX_LOOP = 100;
      static final int SLEEP_TIME = 50;
  -   static Exception thread_ex=null;
  +   static Exception thread_ex = null;
   
      static
      {
  @@ -84,11 +84,12 @@
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      thread_ex=null;
  +      thread_ex = null;
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -101,13 +102,13 @@
         cache_ = new TreeCache();
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache_.createService();
  -      cache_.startService();
  +      cache_.create();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -149,7 +150,7 @@
         t1.join(60000); // wait for 20 secs
         t2.join(60000); // wait for 20 secs
   
  -      if(thread_ex != null)
  +      if (thread_ex != null)
            throw thread_ex;
      }
   
  @@ -166,18 +167,23 @@
            tx_ = tx;
         }
   
  -      public void run() {
  -         try {
  +      public void run()
  +      {
  +         try
  +         {
               _run();
            }
  -         catch(Exception e) {
  -            thread_ex=e;
  +         catch (Exception e)
  +         {
  +            thread_ex = e;
            }
         }
   
         public void _run() throws HeuristicMixedException, SystemException,
  -                                NotSupportedException, HeuristicRollbackException, RollbackException, CacheException {
  -         for (int loop = 0; loop < MAX_LOOP; loop++) {
  +              NotSupportedException, HeuristicRollbackException, RollbackException, CacheException
  +      {
  +         for (int loop = 0; loop < MAX_LOOP; loop++)
  +         {
               sleep_(random_.nextInt(50));
               log("Executing op1. Loop-" + loop);
               op1();
  @@ -192,7 +198,8 @@
   
         // Operation 1
         private void op1() throws SystemException, NotSupportedException, CacheException,
  -                                HeuristicMixedException, HeuristicRollbackException, RollbackException {
  +              HeuristicMixedException, HeuristicRollbackException, RollbackException
  +      {
            int i = random_.nextInt(nodeList_.size() - 1);
            String key = Integer.toString(i);
            String value = Integer.toString(i);
  @@ -209,7 +216,8 @@
   
         // Operation 2
         private void op2() throws SystemException, NotSupportedException, CacheException,
  -                                HeuristicMixedException, HeuristicRollbackException, RollbackException {
  +              HeuristicMixedException, HeuristicRollbackException, RollbackException
  +      {
            int i = random_.nextInt(nodeList_.size() - 1);
            String key = Integer.toString(i);
   
  @@ -224,7 +232,8 @@
   
         // Operation 3
         private void op3() throws SystemException, NotSupportedException, CacheException,
  -                                HeuristicMixedException, HeuristicRollbackException, RollbackException {
  +              HeuristicMixedException, HeuristicRollbackException, RollbackException
  +      {
            int i = random_.nextInt(nodeList_.size() - 1);
            String key = Integer.toString(i);
            String value = Integer.toString(i);
  @@ -239,9 +248,12 @@
   
         private void sleep_(long msecs)
         {
  -         try {
  +         try
  +         {
               Thread.sleep(msecs);
  -         } catch (Exception ex) {
  +         }
  +         catch (Exception ex)
  +         {
            }
         }
      }
  @@ -261,11 +273,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)
  
  
  



More information about the jboss-cvs-commits mailing list