Author: mircea.markus
Date: 2008-06-26 13:10:38 -0400 (Thu, 26 Jun 2008)
New Revision: 6063
Modified:
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
Log:
updated node locking scheme
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-26 17:05:52
UTC (rev 6062)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-26 17:10:38
UTC (rev 6063)
@@ -200,7 +200,7 @@
@Dynamic
private boolean syncRollbackPhase = false;
private BuddyReplicationConfig buddyReplicationConfig;
- private boolean nodeLockingOptimistic = false;
+
private NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC; // TODO:
Make this default MVCC once MVCC is completely implemented.
private String muxStackName = null;
private boolean usingMultiplexer = false;
@@ -379,7 +379,6 @@
testImmutability("nodeLockingScheme");
testImmutability("nodeLockingOptimistic");
this.nodeLockingScheme = nodeLockingScheme;
- this.nodeLockingOptimistic = (nodeLockingScheme == NodeLockingScheme.OPTIMISTIC);
}
public void setUseReplQueue(boolean useReplQueue)
@@ -394,10 +393,16 @@
this.isolationLevel = isolationLevel;
}
+ /**
+ * Starting with 3.x there are 3 locking schemes, so if true is passed in then state
is not defined.
+ * It is here for backward compatibility reasons only and should not be used by new
code.
+ */
+ @Deprecated
public void setNodeLockingOptimistic(boolean nodeLockingOptimistic)
{
testImmutability("nodeLockingOptimistic");
- this.nodeLockingOptimistic = nodeLockingOptimistic;
+ if (nodeLockingOptimistic) setNodeLockingScheme(NodeLockingScheme.OPTIMISTIC);
+ else setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
}
public void setStateRetrievalTimeout(long stateRetrievalTimeout)
@@ -409,7 +414,6 @@
public void setNodeLockingScheme(String nodeLockingScheme)
{
testImmutability("nodeLockingScheme");
- testImmutability("nodeLockingOptimistic");
if (nodeLockingScheme == null)
{
throw new ConfigurationException("Node locking scheme cannot be null",
"NodeLockingScheme");
@@ -420,8 +424,6 @@
log.warn("Unknown node locking scheme '" + nodeLockingScheme +
"', using defaults.");
this.nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
}
-
- this.nodeLockingOptimistic = (this.nodeLockingScheme ==
NodeLockingScheme.OPTIMISTIC);
}
public String getNodeLockingSchemeString()
@@ -558,7 +560,7 @@
@Deprecated
public boolean isNodeLockingOptimistic()
{
- return nodeLockingOptimistic;
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
}
public boolean isUseReplQueue()
@@ -786,7 +788,6 @@
if (inactiveOnStartup != that.inactiveOnStartup) return false;
if (lockAcquisitionTimeout != that.lockAcquisitionTimeout) return false;
if (lockParentForChildInsertRemove != that.lockParentForChildInsertRemove) return
false;
- if (nodeLockingOptimistic != that.nodeLockingOptimistic) return false;
if (objectInputStreamPoolSize != that.objectInputStreamPoolSize) return false;
if (objectOutputStreamPoolSize != that.objectOutputStreamPoolSize) return false;
if (replQueueInterval != that.replQueueInterval) return false;
@@ -850,7 +851,6 @@
result = 31 * result + (syncCommitPhase ? 1 : 0);
result = 31 * result + (syncRollbackPhase ? 1 : 0);
result = 31 * result + (buddyReplicationConfig != null ?
buddyReplicationConfig.hashCode() : 0);
- result = 31 * result + (nodeLockingOptimistic ? 1 : 0);
result = 31 * result + (nodeLockingScheme != null ? nodeLockingScheme.hashCode() :
0);
result = 31 * result + (muxStackName != null ? muxStackName.hashCode() : 0);
result = 31 * result + (usingMultiplexer ? 1 : 0);
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-26
17:05:52 UTC (rev 6062)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -266,8 +266,8 @@
if (existsAttribute(lockParentForChildInsertRemove))
config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
String lockAcquisitionTimeout =
locking.getAttribute("lockAcquisitionTimeout");
if (existsAttribute(lockAcquisitionTimeout))
config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
- String optimistic = locking.getAttribute("optimistic");
- if (existsAttribute(optimistic))
config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ String nodeLockingScheme = locking.getAttribute("nodeLockingScheme");
+ if (existsAttribute(nodeLockingScheme))
config.setNodeLockingScheme(nodeLockingScheme);
}
private Element getSingleElement(String elementName)
Modified: core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-06-26 17:05:52
UTC (rev 6062)
+++ core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-06-26 17:10:38
UTC (rev 6063)
@@ -75,13 +75,13 @@
//test pessimistic loking
Configuration config = new Configuration();
- config.setNodeLockingOptimistic(false);
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
DataVersion dataVersion = new DefaultDataVersion(2);
container.setDependencies(config, null, null);
assert nodes.adfgNode == container.peekVersioned(nodes.adfg, dataVersion, true) :
"if NOT opt locking same value as peek(boolean, boolean) expected";
//test optimistic locking with same version
- config.setNodeLockingOptimistic(true);
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
DataVersion adfgDataVersion = new DefaultDataVersion(2);
nodes.adfgNode.setVersion(adfgDataVersion);
assert nodes.adfgNode == container.peekVersioned(nodes.adfg, adfgDataVersion, true)
: "same version, expcting node to be returned";
Modified: core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-06-26
17:05:52 UTC (rev 6062)
+++
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -55,7 +55,7 @@
*/
public void testDeletedChildResurrectionPessimistic1() throws Exception
{
- deletedChildResurrectionTest1(false);
+ deletedChildResurrectionTest1(Configuration.NodeLockingScheme.PESSIMISTIC);
}
/**
@@ -66,7 +66,7 @@
*/
public void testDeletedChildResurrectionOptimistic1() throws Exception
{
- deletedChildResurrectionTest1(true);
+ deletedChildResurrectionTest1(Configuration.NodeLockingScheme.OPTIMISTIC);
}
/**
@@ -77,7 +77,7 @@
*/
public void testDeletedChildResurrectionPessimistic2() throws Exception
{
- deletedChildResurrectionTest2(false);
+ deletedChildResurrectionTest2(Configuration.NodeLockingScheme.PESSIMISTIC);
}
/**
@@ -88,7 +88,7 @@
*/
public void testDeletedChildResurrectionOptimistic2() throws Exception
{
- deletedChildResurrectionTest2(true);
+ deletedChildResurrectionTest2(Configuration.NodeLockingScheme.OPTIMISTIC);
}
/**
@@ -96,9 +96,9 @@
* child and then inserting a different child under the parent Fqn results
* in the pre-existing child remaining in the cache after tx commit.
*/
- private void deletedChildResurrectionTest1(boolean optimistic) throws Exception
+ private void deletedChildResurrectionTest1(Configuration.NodeLockingScheme
lockingScheme) throws Exception
{
- cache.getConfiguration().setNodeLockingOptimistic(optimistic);
+ cache.getConfiguration().setNodeLockingScheme(lockingScheme);
cache.start();
CacheSPI spi = (CacheSPI) cache;
Node<Object, Object> root = cache.getRoot();
@@ -123,9 +123,9 @@
* child and then inserting a different child under the parent Fqn results
* in the pre-existing child remaining in the cache after tx commit.
*/
- private void deletedChildResurrectionTest2(boolean optimistic) throws Exception
+ private void deletedChildResurrectionTest2(Configuration.NodeLockingScheme
lockingScheme) throws Exception
{
- cache.getConfiguration().setNodeLockingOptimistic(optimistic);
+ cache.getConfiguration().setNodeLockingScheme(lockingScheme);
cache.start();
Node<Object, Object> root = cache.getRoot();
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-06-26
17:05:52 UTC (rev 6062)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -176,7 +176,7 @@
Configuration config =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
true);
config.setCacheMode(Configuration.CacheMode.LOCAL);
- config.setNodeLockingOptimistic(true);
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(config, true);
cache.put(Fqn.fromString("/a/b"), "key", "value");
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-26
17:05:52 UTC (rev 6062)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -1,6 +1,5 @@
package org.jboss.cache.config.parsing;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.config.*;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.MRUConfiguration;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-06-26
17:05:52 UTC (rev 6062)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -51,7 +51,7 @@
{
txManager = new DummyTransactionManagerLookup().getTransactionManager();
Configuration config =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
true);
- config.setNodeLockingOptimistic(true);
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
config.setEvictionConfig(buildEvictionConfig());
cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(config);
}
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-06-26
17:05:52 UTC (rev 6062)
+++
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-06-26
17:10:38 UTC (rev 6063)
@@ -6,6 +6,7 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
@@ -192,7 +193,7 @@
public void testOptimisticChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingOptimistic(true);
+
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
InterceptorChain chain =
getInterceptorChainFactory(cache).buildInterceptorChain();
List<CommandInterceptor> list = chain.asList();
@@ -215,7 +216,7 @@
public void testOptimisticReplicatedChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingOptimistic(true);
+
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache.getConfiguration().setCacheMode("REPL_SYNC");
InterceptorChain chain =
getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -240,7 +241,7 @@
public void testOptimisticCacheLoaderChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingOptimistic(true);
+
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, false));
cache.create();
InterceptorChain chain =
getInterceptorChainFactory(cache).buildInterceptorChain();
@@ -266,7 +267,7 @@
public void testOptimisticPassivationCacheLoaderChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
- cache.getConfiguration().setNodeLockingOptimistic(true);
+
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(true, false));
cache.create();
InterceptorChain chain =
getInterceptorChainFactory(cache).buildInterceptorChain();
Modified: core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-26
17:05:52 UTC (rev 6062)
+++ core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-26
17:10:38 UTC (rev 6063)
@@ -3,7 +3,7 @@
<jbosscache>
<locking isolationLevel="REPEATABLE_READ"
lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
- optimistic="false"/>
+ nodeLockingScheme="Optimistic"/>
<transaction
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
Modified: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml 2008-06-26
17:05:52 UTC (rev 6062)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml 2008-06-26
17:10:38 UTC (rev 6063)
@@ -2,7 +2,8 @@
<jbosscache>
- <locking isolationLevel="REPEATABLE_READ"
lockParentForChildInsertRemove="true"
lockAcquisitionTimeout="10234"/>
+ <locking isolationLevel="REPEATABLE_READ"
lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
+ nodeLockingScheme="Optimistic"/>
<transaction
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>