[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...

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


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

  Modified:    src/org/jboss/cache/interceptors   
                        CacheMgmtInterceptorMBean.java
                        OptimisticReplicationInterceptor.java
                        CacheMgmtInterceptor.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.7       +1 -3      JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptorMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheMgmtInterceptorMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptorMBean.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- CacheMgmtInterceptorMBean.java	10 May 2007 04:00:23 -0000	1.6
  +++ CacheMgmtInterceptorMBean.java	23 May 2007 10:28:50 -0000	1.7
  @@ -21,13 +21,11 @@
    */
   package org.jboss.cache.interceptors;
   
  -import javax.management.NotificationBroadcaster;
  -
   /**
    * Interface capturing basic cache management statistics
    *
    * @author Jerry Gauthier
  - * @version $Id: CacheMgmtInterceptorMBean.java,v 1.6 2007/05/10 04:00:23 bstansberry Exp $
  + * @version $Id: CacheMgmtInterceptorMBean.java,v 1.7 2007/05/23 10:28:50 msurtani Exp $
    */
   public interface CacheMgmtInterceptorMBean extends InterceptorMBean
   {
  
  
  
  1.38      +9 -10     JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticReplicationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -b -r1.37 -r1.38
  --- OptimisticReplicationInterceptor.java	30 Mar 2007 14:02:09 -0000	1.37
  +++ OptimisticReplicationInterceptor.java	23 May 2007 10:28:50 -0000	1.38
  @@ -20,11 +20,11 @@
   import org.jboss.cache.optimistic.WorkspaceNode;
   import org.jboss.cache.transaction.GlobalTransaction;
   import org.jboss.cache.transaction.OptimisticTransactionEntry;
  +import org.jboss.cache.util.concurrent.ConcurrentHashSet;
   
   import java.util.ArrayList;
   import java.util.List;
  -import java.util.Map;
  -import java.util.concurrent.ConcurrentHashMap;
  +import java.util.Set;
   
   /**
    * Replication interceptor for the optimistically locked interceptor chain.  Responsible for replicating
  @@ -41,9 +41,8 @@
   
      // record of local broacasts - so we do not broadcast rollbacks/commits that resuted from
      // local prepare failures
  -   private static final Object DUMMY_VALUE = new Object();
      // we really just need a set here, but concurrent CopyOnWriteArraySet has poor performance when writing.
  -   private final Map<GlobalTransaction, Object> broadcastTxs = new ConcurrentHashMap<GlobalTransaction, Object>();
  +   private final Set<GlobalTransaction> broadcastTxs = new ConcurrentHashSet<GlobalTransaction>();
   
      public Object invoke(MethodCall m) throws Throwable
      {
  @@ -84,7 +83,7 @@
               //lets broadcast the commit first
               Throwable remoteCommitException = null;
               gtx = getGlobalTransaction(ctx);
  -            if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.containsKey(gtx))
  +            if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.contains(gtx))
               {
                  //we dont do anything
                  try
  @@ -108,7 +107,7 @@
               //    lets broadcast the rollback first
               gtx = getGlobalTransaction(ctx);
               Throwable remoteRollbackException = null;
  -            if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.containsKey(gtx))
  +            if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.contains(gtx))
               {
                  //we dont do anything
                  try
  @@ -168,7 +167,7 @@
            MethodCall toBroadcast = mapDataVersionedMethodCalls(methodCall, getTransactionWorkspace(gtx));
   
            //record the things we have possibly sent
  -         broadcastTxs.put(gtx, DUMMY_VALUE);
  +         broadcastTxs.add(gtx);
            if (log.isDebugEnabled())
            {
               log.debug("(" + cache.getLocalAddress()
  
  
  
  1.30      +44 -20    JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheMgmtInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -b -r1.29 -r1.30
  --- CacheMgmtInterceptor.java	10 May 2007 04:00:23 -0000	1.29
  +++ CacheMgmtInterceptor.java	23 May 2007 10:28:50 -0000	1.30
  @@ -21,47 +21,71 @@
    */
   package org.jboss.cache.interceptors;
   
  -import java.util.HashMap;
  -import java.util.Map;
  -
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.jmx.CacheNotificationBroadcaster;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   /**
    * Captures cache management statistics
    *
    * @author Jerry Gauthier
  - * @version $Id: CacheMgmtInterceptor.java,v 1.29 2007/05/10 04:00:23 bstansberry Exp $
  + * @version $Id: CacheMgmtInterceptor.java,v 1.30 2007/05/23 10:28:50 msurtani Exp $
    */
   public class CacheMgmtInterceptor 
      extends Interceptor 
      implements CacheMgmtInterceptorMBean
   {
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_CACHE_STARTED = CacheNotificationBroadcaster.NOTIF_CACHE_STARTED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_CACHE_STOPPED = CacheNotificationBroadcaster.NOTIF_CACHE_STOPPED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_CREATED = CacheNotificationBroadcaster.NOTIF_NODE_CREATED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_MODIFIED = CacheNotificationBroadcaster.NOTIF_NODE_MODIFIED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_REMOVED = CacheNotificationBroadcaster.NOTIF_NODE_REMOVED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_MOVED = CacheNotificationBroadcaster.NOTIF_NODE_MOVED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_VISITED = CacheNotificationBroadcaster.NOTIF_NODE_VISITED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_EVICTED = CacheNotificationBroadcaster.NOTIF_NODE_EVICTED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_LOADED = CacheNotificationBroadcaster.NOTIF_NODE_LOADED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_ACTIVATED = CacheNotificationBroadcaster.NOTIF_NODE_ACTIVATED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_NODE_PASSIVATED = CacheNotificationBroadcaster.NOTIF_NODE_PASSIVATED;
  -   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   /**
  +    * @deprecated use constants in {@link CacheNotificationBroadcaster}
  +    */
      public static final String NOTIF_VIEW_CHANGED = CacheNotificationBroadcaster.NOTIF_VIEW_CHANGED;
      
      private long m_hit_times = 0;
  
  
  



More information about the jboss-cvs-commits mailing list