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

Manik Surtani msurtani at jboss.com
Mon Aug 14 13:52:34 EDT 2006


  User: msurtani
  Date: 06/08/14 13:52:34

  Modified:    src/org/jboss/cache/interceptors   
                        CacheLoaderInterceptor.java
                        OptimisticLockingInterceptor.java
                        PessimisticLockInterceptor.java
  Log:
  Converted NodeLockingScheme, IsolationLevel and LockType to enums
  
  Revision  Changes    Path
  1.43      +5 -7      JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -b -r1.42 -r1.43
  --- CacheLoaderInterceptor.java	10 Aug 2006 16:28:21 -0000	1.42
  +++ CacheLoaderInterceptor.java	14 Aug 2006 17:52:34 -0000	1.43
  @@ -21,7 +21,7 @@
   /**
    * Loads nodes that don't exist at the time of the call into memory from the CacheLoader
    * @author Bela Ban
  - * @version $Id: CacheLoaderInterceptor.java,v 1.42 2006/08/10 16:28:21 msurtani Exp $
  + * @version $Id: CacheLoaderInterceptor.java,v 1.43 2006/08/14 17:52:34 msurtani Exp $
    */
   public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
   {
  @@ -176,7 +176,7 @@
                  // org.jboss.cache.loader.deadlock.ConcurrentCreationDeadlockTest
                  // - Manik Surtani (21 March 2006)
                  if (acquireLock)
  -                  lock(fqn, DataNode.LOCK_TYPE_WRITE, false); // not recursive
  +                  lock(fqn, DataNode.LockType.WRITE, false); // not recursive
                }
   
                // The complete list of children aren't known without loading them
  @@ -234,7 +234,7 @@
            // create child if it didn't exist
            n.createChild(child_name, child_fqn, n, TreeCache.UNINITIALIZED, null);
         }
  -      lock(fqn, DataNode.LOCK_TYPE_READ, true); // recursive=true: lock entire subtree
  +      lock(fqn, DataNode.LockType.READ, true); // recursive=true: lock entire subtree
         n.setChildrenLoaded(true);
      }
   
  @@ -264,14 +264,12 @@
         return retval;
      }
   
  -   protected void lock(Fqn fqn, int lock_type, boolean recursive) throws Throwable {
  +   protected void lock(Fqn fqn, DataNode.LockType lock_type, boolean recursive) throws Throwable {
   
         if (configuration.isNodeLockingOptimistic()) return;
   
         MethodCall meth=MethodCallFactory.create(MethodDeclarations.lockMethodLocal,
  -                                     new Object[]{fqn,
  -                                                  new Integer(lock_type),
  -                                             Boolean.valueOf(recursive)});
  +                                     new Object[]{fqn, lock_type, Boolean.valueOf(recursive)});
         super.invoke(meth);
      }
   
  
  
  
  1.18      +1 -1      JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticLockingInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- OptimisticLockingInterceptor.java	19 Jul 2006 21:34:43 -0000	1.17
  +++ OptimisticLockingInterceptor.java	14 Aug 2006 17:52:34 -0000	1.18
  @@ -145,7 +145,7 @@
               WorkspaceNode workspaceNode = (WorkspaceNode) it.next();
               DataNode node = workspaceNode.getNode();
   
  -            boolean acquired = node.acquire(gtx, lockAcquisitionTimeout, DataNode.LOCK_TYPE_WRITE);
  +            boolean acquired = node.acquire(gtx, lockAcquisitionTimeout, DataNode.LockType.WRITE);
               if (acquired)
               {
                   if (log.isTraceEnabled()) log.trace("acquired lock on node " + node.getName());
  
  
  
  1.24      +19 -23    JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PessimisticLockInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- PessimisticLockInterceptor.java	14 Aug 2006 17:20:34 -0000	1.23
  +++ PessimisticLockInterceptor.java	14 Aug 2006 17:52:34 -0000	1.24
  @@ -38,7 +38,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.23 2006/08/14 17:20:34 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.24 2006/08/14 17:52:34 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor {
      TransactionTable tx_table=null;
  @@ -61,13 +61,12 @@
      public Object invoke(MethodCall call) throws Throwable {
         JBCMethodCall m = (JBCMethodCall) call;
         Fqn               fqn=null;
  -      int               lock_type=DataNode.LOCK_TYPE_NONE;
  -      long              lock_timeout=lock_acquisition_timeout;
  +      DataNode.LockType lock_type=DataNode.LockType.NONE;
         Object[]          args=m.getArgs();
         InvocationContext ctx = InvocationContext.getCurrent();
   
          if (log.isTraceEnabled()) log.trace("PessimisticLockInterceptor invoked for method " + m);
  -       if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking())
  +       if (InvocationContext.getOptionOverrides() != null && InvocationContext.getOptionOverrides().isSuppressLocking())
          {
             log.trace("Suppressing locking");
             switch (m.getMethodId())
  @@ -101,27 +100,24 @@
            case MethodDeclarations.putDataMethodLocal_id:
            case MethodDeclarations.putDataEraseMethodLocal_id:
            case MethodDeclarations.putKeyValMethodLocal_id:
  -         case MethodDeclarations.putFailFastKeyValueMethodLocal_id:
               createIfNotExists=true;
               fqn=(Fqn)args[1];
  -            lock_type=DataNode.LOCK_TYPE_WRITE;
  -            if(m.getMethodId() == MethodDeclarations.putFailFastKeyValueMethodLocal_id)
  -               lock_timeout=((Long)args[5]).longValue();
  +            lock_type=DataNode.LockType.WRITE;
               break;
            case MethodDeclarations.removeNodeMethodLocal_id:
               fqn=(Fqn)args[1];
  -            lock_type=DataNode.LOCK_TYPE_WRITE;
  +            lock_type=DataNode.LockType.WRITE;
               recursive=true; // remove node and *all* child nodes
               break;
            case MethodDeclarations.removeKeyMethodLocal_id:
            case MethodDeclarations.removeDataMethodLocal_id:
            case MethodDeclarations.addChildMethodLocal_id:
               fqn=(Fqn)args[1];
  -            lock_type=DataNode.LOCK_TYPE_WRITE;
  +            lock_type=DataNode.LockType.WRITE;
               break;
            case MethodDeclarations.evictNodeMethodLocal_id:
               fqn=(Fqn)args[0];
  -            lock_type=DataNode.LOCK_TYPE_WRITE;
  +            lock_type=DataNode.LockType.WRITE;
               break;
            case MethodDeclarations.getKeyValueMethodLocal_id:
            case MethodDeclarations.getNodeMethodLocal_id:
  @@ -130,11 +126,11 @@
            case MethodDeclarations.releaseAllLocksMethodLocal_id:
            case MethodDeclarations.printMethodLocal_id:
               fqn=(Fqn)args[0];
  -            lock_type=DataNode.LOCK_TYPE_READ;
  +            lock_type=DataNode.LockType.READ;
               break;
            case MethodDeclarations.lockMethodLocal_id:
               fqn=(Fqn)args[0];
  -            lock_type=((Integer)args[1]).intValue();
  +            lock_type=(DataNode.LockType)args[1];
               recursive=((Boolean)args[2]).booleanValue();
               break;
            case MethodDeclarations.commitMethod_id:
  @@ -189,7 +185,7 @@
       * @param lock_type DataNode.LOCK_TYPE_READ, DataNode.LOCK_TYPE_WRITE or DataNode.LOCK_TYPE_NONE
       * @param recursive Lock children recursively
       */
  -   private void lock(Fqn fqn, GlobalTransaction gtx, int lock_type, boolean recursive, boolean createIfNotExists)
  +   private void lock(Fqn fqn, GlobalTransaction gtx, DataNode.LockType lock_type, boolean recursive, boolean createIfNotExists)
            throws TimeoutException, LockingException, InterruptedException {
         Node       n;
         Node       child_node;
  @@ -211,7 +207,7 @@
            return;
   
         if(configuration.getIsolationLevel() == IsolationLevel.NONE)
  -         lock_type=DataNode.LOCK_TYPE_NONE;
  +         lock_type=DataNode.LockType.NONE;
   
         n=cache;
         for(int i=0; i < treeNodeSize; i++) {
  @@ -236,19 +232,19 @@
               return;
            }
   
  -         if(lock_type == DataNode.LOCK_TYPE_NONE) {
  +         if(lock_type == DataNode.LockType.NONE) {
               // acquired=false;
               n=child_node;
               continue;
            }
            else {
  -            if(lock_type == DataNode.LOCK_TYPE_WRITE && i == (treeNodeSize - 1)) {
  +            if(lock_type == DataNode.LockType.WRITE && i == (treeNodeSize - 1)) {
                  //acquired=child_node.acquire(owner, lock_timeout, DataNode.LOCK_TYPE_WRITE);
  -               acquired = lockManager.acquire(child_node, owner, DataNode.LOCK_TYPE_WRITE);
  +               acquired = lockManager.acquire(child_node, owner, DataNode.LockType.WRITE);
               }
               else {
                  //acquired=child_node.acquire(owner, lock_timeout, DataNode.LOCK_TYPE_READ);
  -               acquired = lockManager.acquire(child_node, owner, DataNode.LOCK_TYPE_READ);
  +               acquired = lockManager.acquire(child_node, owner, DataNode.LockType.READ);
               }
            }
   
  @@ -397,7 +393,7 @@
   
      private class LockManager
      {
  -       boolean acquire(Node node, Object owner, int lockType) throws InterruptedException
  +       boolean acquire(Node node, Object owner, DataNode.LockType lockType) throws InterruptedException
          {
               // TODO: MANIK: The lock map should not be accessed by methods on the Node.  This is temporary until it can properly be refactored out.
              return ((TreeCacheProxyImpl) node).acquire(owner, lock_acquisition_timeout, lockType);
  @@ -408,7 +404,7 @@
              return ((TreeCacheProxyImpl) node).getLock();
          }
   
  -       public Set acquireAll(Node node, Object owner, int lockType) throws InterruptedException
  +       public Set acquireAll(Node node, Object owner, DataNode.LockType lockType) throws InterruptedException
          {
              return ((TreeCacheProxyImpl) node).acquireAll(owner, lock_acquisition_timeout, lockType);
          }
  
  
  



More information about the jboss-cvs-commits mailing list