Author: mircea.markus
Date: 2007-10-22 06:45:50 -0400 (Mon, 22 Oct 2007)
New Revision: 4659
Removed:
core/trunk/src/test/java/org/jboss/cache/api/StructuralNodesTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
core/trunk/src/main/java/org/jboss/cache/Node.java
core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/test/resources/log4j.xml
Log:
roll back - JBCACHE-1153
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2007-10-21 10:03:05 UTC
(rev 4658)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2007-10-22 10:45:50 UTC
(rev 4659)
@@ -16,7 +16,6 @@
protected Map<Object, Node<K, V>> children;
protected Fqn fqn;
protected boolean resident;
- protected boolean structural;
public boolean isDeleted()
{
@@ -55,10 +54,6 @@
}
- public boolean isStructural()
- {
- return structural;
- }
public boolean equals(Object another)
{
Modified: core/trunk/src/main/java/org/jboss/cache/Node.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Node.java 2007-10-21 10:03:05 UTC (rev 4658)
+++ core/trunk/src/main/java/org/jboss/cache/Node.java 2007-10-22 10:45:50 UTC (rev 4659)
@@ -292,17 +292,6 @@
*/
void setResident(boolean resident);
- /**
- * Structural nodes are the nodes created to support other nodes that hold data. E.g.
the operation
- * cache.put("/a/b/c","key","value") the nodes
"/a" and "/a/b" are created only for supporting the existence of
- * "/a/b/c" which holds data -"/a" and "/a/b" are
structural nodes.
- * A node is no longer considered structural when it's attribut map is changed,
i.e. attributes are added.
- * Structural nodes are not considered for viction, i.e. they are marked as resident.
When a node moves to
- * non-structural state it will automatically be marked as non-resident. Structural
nodes might be marked as
- * non-resident and considered for eviction. This property is internally computed (as
described bellow) and is not replicated.
- */
- boolean isStructural();
-
/**
* Tests whether this node is configured to be exclusively locked when inserting or
removing children.
* <p />
Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2007-10-21 10:03:05 UTC (rev
4658)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2007-10-22 10:45:50 UTC (rev
4659)
@@ -439,14 +439,6 @@
boolean hasChildrenDirect();
/**
- * It is internally decided (i.e. wthin the cache, one cannot specify it from the
outside)
- * whether a node is structural or not - so this method fits better here than in Node
interface.
- * @see org.jboss.cache.Node#isStructural()
- */
- void setStructural(boolean structural);
-
-
- /**
* Very similar to {@link #getDataDirect()}, except that this method may also encode
some internal data as attributes in the map,
* using special <tt>_JBOSS_INTERNAL_XXX</tt> Strings as keys. Designed
to be used by {@link org.jboss.cache.statetransfer.StateTransferGenerator}
* and {@link org.jboss.cache.interceptors.CacheStoreInterceptor} which attempt to
serialize nodes into a stream for storage or transfer.
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-10-21 10:03:05 UTC
(rev 4658)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-10-22 10:45:50 UTC
(rev 4659)
@@ -752,12 +752,6 @@
this.lockForChildInsertRemove = lockForChildInsertRemove;
}
- public void setStructural(boolean structural)
- {
- this.setResident(structural);
- this.structural = structural;
- }
-
@SuppressWarnings("unchecked")
public void setInternalState(Map state)
{
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2007-10-21
10:03:05 UTC (rev 4658)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2007-10-22
10:45:50 UTC (rev 4659)
@@ -197,7 +197,6 @@
if (isTargetFqn && !workspace.isVersioningImplicit())
versionToPassIn = version;
NodeSPI newUnderlyingChildNode = workspaceNode.createChild(childName,
workspaceNode.getNode(), cache, versionToPassIn);
- newUnderlyingChildNode.setStructural(true);
// now assign "workspaceNode" to the new child created.
workspaceNode = nodeFactory.createWorkspaceNode(newUnderlyingChildNode,
workspace);
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2007-10-21
10:03:05 UTC (rev 4658)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2007-10-22
10:45:50 UTC (rev 4659)
@@ -211,7 +211,6 @@
Map mergedData = workspaceNode.getMergedData();
underlyingNode.clearDataDirect();
underlyingNode.putAllDirect(mergedData);
- underlyingNode.setStructural(workspaceNode.isStructural());
updateVersion = true;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2007-10-21
10:03:05 UTC (rev 4658)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2007-10-22
10:45:50 UTC (rev 4659)
@@ -78,7 +78,6 @@
case MethodDeclarations.putKeyValMethodLocal_id:
log.trace("Creating nodes if necessary");
createNodes((Fqn) args[1], ctx.getGlobalTransaction());
- markNodeNonStructural(ctx);
break;
}
@@ -195,14 +194,6 @@
log.trace("bypassed locking as method " + m.getName() + "()
doesn't require locking");
}
}
- //this should be executed before calling eviction code/super.invoke()
- //else, all nodes would be seen as resident by the eviction interceptor
- if (m.getMethodId() == MethodDeclarations.putDataMethodLocal_id ||
- m.getMethodId() == MethodDeclarations.putDataEraseMethodLocal_id ||
- m.getMethodId() == MethodDeclarations.putKeyValMethodLocal_id)
- {
- this.markNodeNonStructural(ctx);
- }
if (m.getMethodId() == MethodDeclarations.lockMethodLocal_id)
{
return null;
@@ -236,19 +227,6 @@
return o;
}
- private void markNodeNonStructural(InvocationContext ctx)
- {
- MethodCall m = ctx.getMethodCall();
- Object[] args = m.getArgs();
- Fqn fqn = (Fqn) args[1];
- NodeSPI nodeSpi = cache.getRoot().getChildDirect(fqn);
- if (nodeSpi == null)
- {
- throw new IllegalStateException("Could not add attribute to a NULL
node!");
- }
- nodeSpi.setStructural(false);
- }
-
private long getLockAcquisitionTimeout(InvocationContext ctx)
{
long timeout = lock_acquisition_timeout;
@@ -329,7 +307,6 @@
if (child_node == null && createIfNotExists)
{
child_node = n.addChildDirect(new Fqn(child_name));
- child_node.setStructural(true);
created = true;
}
@@ -490,11 +467,7 @@
Fqn childFqn = new Fqn(child_name);
NodeSPI child_node = n.getChildDirect(childFqn);
- if (child_node == null)
- {
- child_node = n.addChildDirect(childFqn);
- child_node.setStructural(true);
- }
+ if (child_node == null) child_node = n.addChildDirect(childFqn);
// test if this node needs to be 'undeleted'
// reverse the "remove" if the node has been previously removed in the
same tx, if this operation is a put()
if (gtx != null && needToReverseRemove(child_node, tx_table.get(gtx),
NodeLock.LockType.WRITE, false, true))
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-10-21
10:03:05 UTC (rev 4658)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-10-22
10:45:50 UTC (rev 4659)
@@ -103,7 +103,6 @@
public void putAll(Map<K, V> data)
{
realPut(data, false);
- this.structural = false;
modified = true;
}
@@ -111,13 +110,11 @@
{
clearData();
putAll(data);
- this.structural = false;
}
public V put(K key, V value)
{
modified = true;
- this.structural = false;
return optimisticDataMap.put(key, value);
}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/StructuralNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/StructuralNodesTest.java 2007-10-21
10:03:05 UTC (rev 4658)
+++ core/trunk/src/test/java/org/jboss/cache/api/StructuralNodesTest.java 2007-10-22
10:45:50 UTC (rev 4659)
@@ -1,143 +0,0 @@
-package org.jboss.cache.api;
-
-import org.jboss.cache.CacheImpl;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.misc.TestingUtil;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-import org.testng.annotations.AfterMethod;
-
-import javax.transaction.TransactionManager;
-import javax.transaction.SystemException;
-import javax.transaction.NotSupportedException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Testser class for strctural nodes functionality.
- *
- * @author <a href="mailto:mircea.markus@jboss.com">Mircea
Markus</a>
- * @since 2.1.0
- */
-@Test(groups = {"functional"})
-public class StructuralNodesTest
-{
- private CacheImpl<Object, Object> cache;
-
-
- @AfterMethod(alwaysRun = true)
- public void closeCache()
- {
- cache.remove("/");
- cache.stop();
- }
-
- /**
- * Tests that when creaitng a node its parents are marked by default as structural,
and are by default resident.
- * When modifying the attribute map, the node is not structural anymore and also is
not resident.
- */
- public void testHappyFlowPessimistic()
- {
- Configuration cacheConfig =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
false);
- cache = (CacheImpl<Object, Object>)
DefaultCacheFactory.getInstance().createCache(cacheConfig, true);
- cache.put("/a/b/c/d/e","k","v");
-
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isStructural());
- assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isResident());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b/c")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("a/b/c")).isResident());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("a/b/c/d")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("a/b/c/d")).isResident());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("a/b/c/d/e")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("a/b/c/d/e")).isResident());
-
- //now add some attributes to some nodes - this should make them both non-structural
and non-resident
- Map data = new HashMap();
- cache.put("/a", data);
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a")).isResident());
- }
-
-
- /**
- * There is a bunch of method calls that will make the structural nodes not
structural.
- * This tests that for all those method calls the 'structural' flag is set to
false.
- */
- public void testMakeNonStructural()
- {
- Configuration cacheConfig =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
false);
- cache = (CacheImpl<Object, Object>)
DefaultCacheFactory.getInstance().createCache(cacheConfig, true);
-
-
-
- cache.put("/put/putIfAbsent/putAll/test","k","v");
-
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/put")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent/putAll")).isStructural());
-
-
cache.getRoot().getChild(Fqn.fromString("/put")).put("k","v");
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put")).isResident());
-
-
cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent")).putIfAbsent("k","v");
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent")).isResident());
-
-
cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent/putAll")).putAll(new
HashMap<Object,Object>());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent/putAll")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/put/putIfAbsent/putAll")).isResident());
-
- }
-
- /**
- * When we use optimisic locking, check that nodes made non-structural during
transaction are non-structural after commiting.
- */
- public void testOptmisticLockingWithCommit() throws Exception
- {
- Configuration config =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
false);
- config.setNodeLockingOptimistic(true);
- cache = (CacheImpl<Object, Object>)
DefaultCacheFactory.getInstance().createCache(config, true);
- cache.put("/a/b/c","k","v");
-
- TransactionManager txManager = cache.getTransactionManager();
- txManager.begin();
-
cache.getRoot().getChild(Fqn.fromString("/a/b")).put("key","value");
- txManager.commit();
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isStructural());
- assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isResident());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b/c")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b/c")).isResident());
- }
-
- /**
- * When we use optimisic locking, check that nodes made non-structural during
transaction are structural after rollback.
- */
- public void testOptmisticLockingWithRollback() throws Exception
- {
- Configuration config =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
false);
- config.setNodeLockingOptimistic(true);
- cache = (CacheImpl<Object, Object>)
DefaultCacheFactory.getInstance().createCache(config, true);
- cache.put("/a/b/c","k","v");
-
- TransactionManager txManager = cache.getTransactionManager();
- txManager.begin();
-
cache.getRoot().getChild(Fqn.fromString("/a/b")).put("key","value");
- txManager.rollback();
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isStructural());
- assertTrue(cache.getRoot().getChild(Fqn.fromString("/a")).isResident());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isStructural());
-
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b/c")).isStructural());
-
assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b/c")).isResident());
- }
-
-}
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2007-10-21 10:03:05 UTC (rev 4658)
+++ core/trunk/src/test/resources/log4j.xml 2007-10-22 10:45:50 UTC (rev 4659)
@@ -63,15 +63,15 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="INFO"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jboss.tm">
- <priority value="WARN"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jgroups">
- <priority value="WARN"/>
+ <priority value="DEBUG"/>
</category>
<!-- ======================= -->
@@ -80,7 +80,7 @@
<root>
<!--<appender-ref ref="CONSOLE"/>-->
- <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>