Author: manik.surtani(a)jboss.com
Date: 2007-10-23 07:54:46 -0400 (Tue, 23 Oct 2007)
New Revision: 4672
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
Log:
Minor patches
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-23 11:16:08 UTC (rev
4671)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-23 11:54:46 UTC (rev
4672)
@@ -2225,7 +2225,7 @@
}
InvocationContext ctx = getInvocationContext();
boolean isRollback = checkIsRollingBack(ctx.getTransaction());
- NodeSPI<K, V> n = findNodeCheck(tx, fqn);
+ NodeSPI<K, V> n = findNodeCheck(tx, fqn, isRollback);
Map<K, V> rawData = n.getDataDirect();
if (!isRollback) notifier.notifyNodeModified(fqn, true,
NodeModifiedEvent.ModificationType.PUT_MAP, rawData, ctx);
@@ -2292,7 +2292,7 @@
// if this is a rollback then don't fire notifications.
boolean isRollback = checkIsRollingBack(ctx.getTransaction());
- NodeSPI<K, V> n = findNodeCheck(tx, fqn);
+ NodeSPI<K, V> n = findNodeCheck(tx, fqn, isRollback);
Map<K, V> rawData = n.getDataDirect();
if (!isRollback)
notifier.notifyNodeModified(fqn, true,
NodeModifiedEvent.ModificationType.PUT_DATA, rawData, ctx);
@@ -2319,6 +2319,7 @@
Map<K, V> newData = Collections.singletonMap(key, value);
if (!isRollback)
notifier.notifyNodeModified(fqn, false,
NodeModifiedEvent.ModificationType.PUT_DATA, newData, ctx);
+
return old_value;
}
@@ -4061,9 +4062,9 @@
}
}
- private NodeSPI<K, V> findNodeCheck(GlobalTransaction tx, Fqn fqn)
+ private NodeSPI<K, V> findNodeCheck(GlobalTransaction tx, Fqn fqn, boolean
includeInvalid)
{
- NodeSPI<K, V> n = findNode(fqn);
+ NodeSPI<K, V> n = findNode(fqn, null, includeInvalid);
if (n == null)
{
String errStr = "node " + fqn + " not found (gtx=" + tx +
", caller=" + Thread.currentThread() + ")";
@@ -4090,9 +4091,6 @@
return false;
}
- // mark the node to be removed (and all children) as invalid so anyone holding a
direct reference to it will
- // be aware that it is no longer valid.
- n.setValid(false, true);
if (log.isTraceEnabled()) log.trace("Performing a real remove for node "
+ f + ", marked for removal.");
if (skipMarkerCheck || n.isDeleted())
@@ -4103,10 +4101,18 @@
n.markAsDeleted(true);
// but now remove all children, since the call has been to
remove("/")
n.removeChildrenDirect();
+
+ // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
+ // be aware that it is no longer valid.
+ n.setValid(false, true);
+ n.setValid(true, false);
return true;
}
else
{
+ // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
+ // be aware that it is no longer valid.
+ n.setValid(false, true);
return n.getParent().removeChildDirect(n.getFqn().getLastElement());
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2007-10-23
11:16:08 UTC (rev 4671)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2007-10-23
11:54:46 UTC (rev 4672)
@@ -8,26 +8,6 @@
package org.jboss.cache.transaction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheImpl;
@@ -37,10 +17,23 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.NodeLock;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
/**
* Tests transactional access to a local CacheImpl.
* Note: we use DummpyTranasctionManager to replace jta
@@ -990,6 +983,9 @@
assertTrue(cache.exists(A_B));
assertTrue(cache.exists(A));
+ assert cache.peek(A, true, true).isValid();
+ assert cache.peek(A_B, true, true).isValid();
+
assertEquals("v2", cache.get(A_B, "k"));
}