[jbosscache-commits] JBoss Cache SVN: r5249 - in core/trunk/src: test/java/org/jboss/cache/api and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 28 17:40:44 EST 2008


Author: mircea.markus
Date: 2008-01-28 17:40:44 -0500 (Mon, 28 Jan 2008)
New Revision: 5249

Added:
   core/trunk/src/test/resources/META-INF/conf-test/local-tx-service.xml
Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
Log:
fixed tests and added an an rolledback the mark node as deleted behavior, in order to supress notifications for temporary created nodes

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-28 17:38:15 UTC (rev 5248)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-28 22:40:44 UTC (rev 5249)
@@ -118,7 +118,7 @@
       }
       else
       {
-         acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, true, false, false, true, null);
+         acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, true, false, false, true, null, false);
       }
       return nextInterceptor(ctx);
    }
@@ -130,7 +130,7 @@
 
    protected Object handleLockMethod(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType, boolean recursive) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, lockType, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, lockType, false, false, false, false, null, false);
       if (recursive)
       {
          //acquireLocksOnChildren(cache.peek(fqn, false), lockType, ctx);
@@ -204,7 +204,7 @@
       if (trace) log.trace("Attempting to get WL on node to be moved [" + from + "]");
       if (from != null && !(configuration.getIsolationLevel() == IsolationLevel.NONE))
       {
-         lock(ctx, from, NodeLock.LockType.WRITE, false, timeout, true, false, null);
+         lock(ctx, from, NodeLock.LockType.WRITE, false, timeout, true, false, null, false);
          if (ctx.getGlobalTransaction() != null)
          {
             cache.getTransactionTable().get(ctx.getGlobalTransaction()).addRemovedNode(from);
@@ -215,7 +215,7 @@
       {
          //now for an RL for the new parent.
          if (trace) log.trace("Attempting to get RL on new parent [" + to + "]");
-         lock(ctx, to, NodeLock.LockType.READ, false, timeout, false, false, null);
+         lock(ctx, to, NodeLock.LockType.READ, false, timeout, false, false, null, false);
          acquireLocksOnChildren(peekNode(ctx, to, false, true, false), NodeLock.LockType.READ, ctx);
       }
       Object retValue = nextInterceptor(ctx);
@@ -234,7 +234,7 @@
       List<Fqn> createdNodes = new LinkedList<Fqn>();
       // we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
       // create a lock.
-      boolean created = acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, true, false, true, false, createdNodes);
+      boolean created = acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, true, false, true, false, createdNodes, true);
       if (ctx.getGlobalTransaction() != null)
       {
          TransactionEntry entry = tx_table.get(ctx.getGlobalTransaction());
@@ -263,7 +263,7 @@
 
    protected Object handlePutForExternalReadMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, Object value) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, true, true, false, true, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, true, true, false, true, null, false);
       return nextInterceptor(ctx);
    }
 
@@ -274,61 +274,61 @@
 
    protected Object handleRemoveDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleAddChildMethod(InvocationContext ctx, GlobalTransaction tx, Fqn parentFqn, Object childName, Node cn, boolean createUndoOps) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, parentFqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, parentFqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleEvictMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, false, true, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, false, true, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleGetKeyValueMethod(InvocationContext ctx, Fqn fqn, Object key, boolean sendNodeEvent) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleGetNodeMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleGetKeysMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleGetChildrenNamesMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handlePrintMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    protected Object handleReleaseAllLocksMethod(InvocationContext ctx, Fqn fqn) throws Throwable
    {
-      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null);
+      acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.READ, false, false, false, false, null, false);
       return nextInterceptor(ctx);
    }
 
    private boolean acquireLocksWithTimeout(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType,
                                            boolean createIfNotExists, boolean zeroLockTimeout,
-                                           boolean acquireLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes)
+                                           boolean acquireLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes, boolean markNewNodesAsDeleted)
          throws InterruptedException
    {
       if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE) return false;
@@ -345,7 +345,7 @@
          {
             throw new TimeoutException("Unable to acquire lock on Fqn " + fqn + " after " + timeout + " millis");
          }
-         created = lock(ctx, fqn, lockType, createIfNotExists, timeout, acquireLockOnParent, reverseRemoveCheck, createdNodes);
+         created = lock(ctx, fqn, lockType, createIfNotExists, timeout, acquireLockOnParent, reverseRemoveCheck, createdNodes, markNewNodesAsDeleted);
          firstTry = false;
       }
       while (createIfNotExists && peekNode(ctx, fqn, false, true, false) == null);// keep trying until we have the lock (fixes concurrent remove())
@@ -362,9 +362,10 @@
     *                              reach a node that does not exists
     * @param reverseRemoveCheck    see {@link #manageReverseRemove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.NodeSPI, boolean)}
     * @param createdNodes          a list to which any nodes created can register their Fqns so that calling code is aware of which nodes have been newly created.
+    * @param markNewNodesAsDeleted
     */
    private boolean lock(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType, boolean createIfNotExists, long timeout,
-                        boolean acquireWriteLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes)
+                        boolean acquireWriteLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes, boolean markNewNodesAsDeleted)
          throws TimeoutException, LockingException, InterruptedException
    {
       Thread currentThread = Thread.currentThread();
@@ -390,10 +391,11 @@
             if (createIfNotExists)
             {
                // if the new node is to be marked as deleted, do not notify!
-               currentNode = parent.addChildDirect(new Fqn(childName), true);
+               currentNode = parent.addChildDirect(new Fqn(childName), !markNewNodesAsDeleted);
                created = true;
-               if (trace) log.trace("Child node was null, so created child node " + childName + System.identityHashCode(currentNode));
+               if (trace) log.trace("Child node was null, so created child node " + childName);
                if (createdNodes != null) createdNodes.add(currentNode.getFqn());
+               if (markNewNodesAsDeleted) currentNode.markAsDeleted(true);
             }
             else
             {

Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java	2008-01-28 17:38:15 UTC (rev 5248)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java	2008-01-28 22:40:44 UTC (rev 5249)
@@ -43,7 +43,7 @@
    {
       // start a single cache instance
       CacheFactory<String, String> cf = new DefaultCacheFactory();
-      cache = cf.createCache("/META-INF/news/local-cache-service.xml", false);
+      cache = cf.createCache("META-INF/conf-test/local-tx-service.xml", false);
       cache.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
       cache.start();
       events.clear();

Added: core/trunk/src/test/resources/META-INF/conf-test/local-tx-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/local-tx-service.xml	                        (rev 0)
+++ core/trunk/src/test/resources/META-INF/conf-test/local-tx-service.xml	2008-01-28 22:40:44 UTC (rev 5249)
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample TreeCache Service Configuration                               -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+
+   <!-- ==================================================================== -->
+   <!-- Defines TreeCache configuration                                      -->
+   <!-- ==================================================================== -->
+
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+          name="jboss.cache:service=TreeCache">
+
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+
+
+      <!-- Configure the TransactionManager -->
+      <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+
+
+      <!--
+          Node locking level : SERIALIZABLE
+                               REPEATABLE_READ (default)
+                               READ_COMMITTED
+                               READ_UNCOMMITTED
+                               NONE
+      -->
+      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+      <!--
+           Valid modes are LOCAL
+                           REPL_ASYNC
+                           REPL_SYNC
+                           INVALIDATION_ASYNC
+                           INVALIDATION_SYNC
+      -->
+      <attribute name="CacheMode">LOCAL</attribute>
+
+      <!-- Name of cluster. Needs to be the same for all clusters, in order
+           to find each other
+      -->
+      <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+      <!-- JGroups protocol stack properties. Can also be a URL,
+           e.g. file:/home/bela/default.xml
+         <attribute name="ClusterProperties"></attribute>
+      -->
+
+      <!-- JGroups protocol stack properties NOT NEEDED since CacheMode is LOCAL -->
+
+
+      <!--
+          The max amount of time (in milliseconds) we wait until the
+          state (ie. the contents of the cache) are retrieved from
+          existing members in a clustered environment
+      -->
+      <attribute name="StateRetrievalTimeout">20000</attribute>
+
+      <!--
+          Number of milliseconds to wait until all responses for a
+          synchronous call have been received.
+      -->
+      <attribute name="SyncReplTimeout">20000</attribute>
+
+      <!-- Max number of milliseconds to wait for a lock acquisition -->
+      <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+
+      <!-- Specific eviction policy configurations. This is LRU -->
+      <attribute name="EvictionPolicyConfig">
+         <config>
+            <attribute name="wakeUpIntervalSeconds">5</attribute>
+            <!-- This defaults to 200000 if not specified -->
+            <attribute name="eventQueueSize">200000</attribute>
+            <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+            <!-- Cache wide default -->
+            <region name="/_default_">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+            <region name="/org/jboss/data">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+            <region name="/org/jboss/test/data">
+               <attribute name="maxNodes">5</attribute>
+               <attribute name="timeToLiveSeconds">4</attribute>
+            </region>
+         </config>
+      </attribute>
+
+      <!--
+         Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+         class loader, e.g., inside an application server. Default is "false".
+      -->
+      <attribute name="UseRegionBasedMarshalling">false</attribute>
+   </mbean>
+
+
+</server>




More information about the jbosscache-commits mailing list