[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/passivation ...

Manik Surtani manik at jboss.org
Wed May 23 06:28:48 EDT 2007


  User: msurtani
  Date: 07/05/23 06:28:48

  Modified:    tests/functional/org/jboss/cache/passivation   
                        PassivationToJDBCCacheLoaderTest.java
                        PassivationToBdbjeCacheLoaderTest.java
                        PassivationActivationCallbacksTestCase.java
  Log:
  Initiated a bunch of performance fixes, including replacing CopyOnWriteArraySets with org.jboss.cache.util.concurrent.ConcurrentHashSet.
  Also ran an imports optimiser on the code base - there were a lot of unused imports floating about.
  
  Revision  Changes    Path
  1.4       +21 -22    JBossCache/tests/functional/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationToJDBCCacheLoaderTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- PassivationToJDBCCacheLoaderTest.java	19 Feb 2007 12:56:24 -0000	1.3
  +++ PassivationToJDBCCacheLoaderTest.java	23 May 2007 10:28:48 -0000	1.4
  @@ -8,7 +8,6 @@
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  -
   import org.jboss.cache.config.CacheLoaderConfig;
   import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.xml.XmlHelper;
  @@ -21,7 +20,7 @@
    * This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
    *
    * @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
  - * @version $Id: PassivationToJDBCCacheLoaderTest.java,v 1.3 2007/02/19 12:56:24 mmarkus Exp $
  + * @version $Id: PassivationToJDBCCacheLoaderTest.java,v 1.4 2007/05/23 10:28:48 msurtani Exp $
    */
   public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
   {
  
  
  
  1.13      +53 -45    JBossCache/tests/functional/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationToBdbjeCacheLoaderTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- PassivationToBdbjeCacheLoaderTest.java	25 Oct 2006 04:50:20 -0000	1.12
  +++ PassivationToBdbjeCacheLoaderTest.java	23 May 2007 10:28:48 -0000	1.13
  @@ -2,7 +2,6 @@
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  -
   import org.jboss.cache.config.CacheLoaderConfig;
   import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.xml.XmlHelper;
  @@ -16,9 +15,10 @@
    * Berkeley DB instead of a file-based CacheLoader
    * 
    * @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
  - * @version $Id: PassivationToBdbjeCacheLoaderTest.java,v 1.12 2006/10/25 04:50:20 bstansberry Exp $
  + * @version $Id: PassivationToBdbjeCacheLoaderTest.java,v 1.13 2007/05/23 10:28:48 msurtani Exp $
    */
  -public class PassivationToBdbjeCacheLoaderTest extends PassivationTestsBase {
  +public class PassivationToBdbjeCacheLoaderTest extends PassivationTestsBase
  +{
   
       private String tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp");
       private File dir = new File(tmp_location);
  @@ -28,20 +28,27 @@
           if (!dir.exists()) dir.mkdirs();
       }
   
  -   protected void configureCache() throws Exception {
  +   protected void configureCache() throws Exception
  +   {
   
  -      class MyFilter implements FileFilter {
  -         public boolean accept(File file) {
  +      class MyFilter implements FileFilter
  +      {
  +         public boolean accept(File file)
  +         {
               return file.getName().endsWith(".jdb");
            }
         }
   
  -      File[] files=dir.listFiles(new MyFilter());
  -      if (files != null) {
  -         for (int i = 0; i < files.length; i += 1) {
  +      File[] files = dir.listFiles(new MyFilter());
  +      if (files != null)
  +      {
  +         for (int i = 0; i < files.length; i += 1)
  +         {
               File file = files[i];
  -            if (file.isFile()) {
  -               if (!file.delete()) {
  +            if (file.isFile())
  +            {
  +               if (!file.delete())
  +               {
                     System.err.println("Unable to delete: " + file);
                  }
               }
  @@ -73,7 +80,8 @@
           return XmlConfigurationParser.parseCacheLoaderConfig(element);
       }
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(PassivationToBdbjeCacheLoaderTest.class);
      }
   
  
  
  
  1.4       +60 -58    JBossCache/tests/functional/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationActivationCallbacksTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- PassivationActivationCallbacksTestCase.java	7 Feb 2007 22:06:43 -0000	1.3
  +++ PassivationActivationCallbacksTestCase.java	23 May 2007 10:28:48 -0000	1.4
  @@ -6,13 +6,7 @@
    */
   package org.jboss.cache.passivation;
   
  -import java.util.ArrayList;
  -import java.util.HashSet;
  -import java.util.List;
  -import java.util.Set;
  -
   import junit.framework.TestCase;
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.AbstractCacheListener;
  @@ -21,7 +15,6 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.Node;
   import org.jboss.cache.RegionManager;
   import org.jboss.cache.config.CacheLoaderConfig;
   import org.jboss.cache.config.EvictionConfig;
  @@ -31,14 +24,16 @@
   import org.jboss.cache.loader.FileCacheLoaderConfig;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
  -import org.jboss.cache.xml.XmlHelper;
  -import org.w3c.dom.Element;
  +
  +import java.util.ArrayList;
  +import java.util.HashSet;
  +import java.util.List;
  +import java.util.Set;
   
   /**
    * Tests that the TreeCacheListener implementation used by EJB3 SFSBs works. 
    * 
    * @author Brian Stansberry
  - *
    */
   public class PassivationActivationCallbacksTestCase extends TestCase
   {
  @@ -47,7 +42,7 @@
   
      //Cache Loader fields
      private CacheSPI         cache;
  -   private CacheLoader   loader=null;
  +   private CacheLoader loader = null;
      private CacheListener listener = null;
      
      protected void setUp() throws Exception
  @@ -72,12 +67,12 @@
      {
         String tmp_location = "/tmp/fcl";
         String OS = System.getProperty("os.name").toLowerCase();      
  -      if(OS.indexOf("win") > -1 || OS.indexOf("nt") > -1) 
  +      if (OS.indexOf("win") > -1 || OS.indexOf("nt") > -1)
         {
  -         tmp_location= "c:\\tmp\\fcl";
  +         tmp_location = "c:\\tmp\\fcl";
         } 
         
  -      tmp_location=System.getProperty("java.io.tmpdir", tmp_location);
  +      tmp_location = System.getProperty("java.io.tmpdir", tmp_location);
         
         
         CacheLoaderConfig clc = new CacheLoaderConfig();
  @@ -167,52 +162,59 @@
         @Override
         public void nodeActivated(Fqn fqn, boolean pre) 
         {
  -         if(pre) 
  +         if (pre)
               return;  // we are not interested in postActivate event
            
  -         if(!fqn.isChildOrEquals(BASE)) return;  // don't care about fqn that doesn't belong to me.
  +         if (!fqn.isChildOrEquals(BASE)) return;  // don't care about fqn that doesn't belong to me.
   
            Object bean = null;
  -         try {
  +         try
  +         {
               bean = cache.get(fqn, "bean");
  -         } catch (CacheException e) {
  -            log.error("nodeActivate(): can't retrieve bean instance from: " +fqn + " with exception: " +e);
  +         }
  +         catch (CacheException e)
  +         {
  +            log.error("nodeActivate(): can't retrieve bean instance from: " + fqn + " with exception: " + e);
               activationException = e;
               return;
            }
  -         if(bean == null)
  +         if (bean == null)
            {
               activationException = new IllegalStateException("nodeActivate(): null bean instance.");
               throw (IllegalStateException) activationException;
            }
   
  -         if(log.isTraceEnabled())
  +         if (log.isTraceEnabled())
            {
  -            log.trace("nodeActivate(): saw postActivate event on fqn: " +fqn);
  +            log.trace("nodeActivate(): saw postActivate event on fqn: " + fqn);
            }
   
            activated.add(fqn);
         }
   
         @Override
  -      public void nodePassivated(Fqn fqn, boolean pre) {
  -         if(!pre) return;  // we are not interested in postPassivate event
  -         if(!fqn.isChildOrEquals(BASE)) return;  // don't care about fqn that doesn't belong to me.
  +      public void nodePassivated(Fqn fqn, boolean pre)
  +      {
  +         if (!pre) return;  // we are not interested in postPassivate event
  +         if (!fqn.isChildOrEquals(BASE)) return;  // don't care about fqn that doesn't belong to me.
   
  -         try {
  +         try
  +         {
               // TODO Can this cause deadlock in the cache level? Should be ok but need review.
               Object bean = cache.get(fqn, "bean");
               if (bean != null)
               {
  -               if(log.isTraceEnabled())
  +               if (log.isTraceEnabled())
                  {
  -                  log.trace("nodePassivate(): send prePassivate event on fqn: " +fqn);
  +                  log.trace("nodePassivate(): send prePassivate event on fqn: " + fqn);
                  }
                  passivated.add(fqn);
               }
   
  -         } catch (CacheException e) {
  -            log.error("nodePassivate(): can't retrieve bean instance from: " +fqn + " with exception: " +e);
  +         }
  +         catch (CacheException e)
  +         {
  +            log.error("nodePassivate(): can't retrieve bean instance from: " + fqn + " with exception: " + e);
               passivationException = e;
               return;
            }
  
  
  



More information about the jboss-cvs-commits mailing list