JBoss Cache SVN: r6257 - in core/trunk/src/main/java/org/jboss/cache: mvcc and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-14 11:35:49 -0400 (Mon, 14 Jul 2008)
New Revision: 6257
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
Log:
Tidied up NodeFactory implementations
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -128,6 +128,7 @@
this.commandsFactory = commandsFactory;
this.lockStrategyFactory = lockStrategyFactory;
this.nodeFactory = nodeFactory;
+ if (nodeFactory == null) throw new NullPointerException();
init();
}
@@ -263,8 +264,8 @@
{
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
- Fqn child_fqn = Fqn.fromRelativeElements(this.fqn, childName);
- NodeSPI newChild = nodeFactory.createNode(childName, Fqn.fromRelativeElements(fqn, childName), delegate, null, true);
+ Fqn childFqn = Fqn.fromRelativeElements(fqn, childName);
+ NodeSPI newChild = nodeFactory.createNode(childName, childFqn, delegate, null, true);
if (newChild == null)
{
throw new IllegalStateException();
@@ -276,13 +277,13 @@
child = (NodeSPI) children().get(childName);
if (child == null)
{
- if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
+ if (notify) cache.getNotifier().notifyNodeCreated(childFqn, true, ctx);
child = newChild;
children.put(childName, child);
if (gtx != null)
{
- CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(child_fqn);
+ CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(childFqn);
ctx.getTransactionContext().addModification(createNodeCommand);
}
}
@@ -293,9 +294,9 @@
{
if (trace)
{
- log.trace("created child: fqn=" + child_fqn);
+ log.trace("created child: fqn=" + childFqn);
}
- if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, false, ctx);
+ if (notify) cache.getNotifier().notifyNodeCreated(childFqn, false, ctx);
}
}
return child;
@@ -764,6 +765,7 @@
n.children = children;
n.commandsFactory = commandsFactory;
n.delegate = delegate;
+ n.nodeFactory = nodeFactory;
n.flags.clear();
n.flags.addAll(flags);
n.lockStrategyFactory = lockStrategyFactory;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -19,13 +19,6 @@
super(node);
}
-// to aid with debugging. remove when finalised.
-// @Override
-// protected void assertInternalNodeType()
-// {
-// if (node != null) throw new IllegalArgumentException("NullMarkerNodes can only wrap null values!");
-// }
-
/**
* @return always returns true
*/
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -25,15 +25,8 @@
public ReadCommittedNode(InternalNode node)
{
super(node);
-// assertInternalNodeType();
}
-// to aid with debugging. remove when finalised.
-// protected void assertInternalNodeType()
-// {
-// if (!(node instanceof NodeReference)) throw new IllegalArgumentException("ReadCommittedNodes can only wrap NodeReferences!");
-// }
-
public boolean isNullNode()
{
return false;
@@ -59,10 +52,6 @@
InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
node = backupDelegationTarget.copy();
}
- // TODO: See if data versions are even needed in the first place!!
- // TODO: Make sure this works with custom versions as well!
-// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
-// node.setVersion(newVersion);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -22,13 +22,6 @@
super(node);
}
-// to aid with debugging. remove when finalised.
-// @Override
-// protected void assertInternalNodeType()
-// {
-// if (!(node instanceof UnversionedNode)) throw new IllegalArgumentException("RepeatableReadNodes can only wrap UnversionedNodes!");
-// }
-
@Override
public void markForUpdate(InvocationContext ctx, DataContainer container, NodeFactory nodeFactory, boolean allowWriteSkew)
{
@@ -41,8 +34,7 @@
// check for write skew.
NodeInvocationDelegate underlyingNode = (NodeInvocationDelegate) container.peek(fqn, false, true); // even check for invalid nodes. we should check tombstones too.
- // TODO: See if data versions are even needed in the first place!!
- //if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
+
if (!allowWriteSkew && underlyingNode != null && underlyingNode.getDelegationTarget() != node)
{
String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Another process has changed the node since we last read it!").toString();
@@ -53,11 +45,6 @@
// make a backup copy
backup = node;
node = backup.copy();
- // TODO: See if data versions are even needed in the first place!!
- // update version on copy
- // TODO: Make sure this works with custom versions as well!
-// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
-// node.setVersion(newVersion);
}
@Override
17 years, 5 months
JBoss Cache SVN: r6256 - in core/trunk/src: main/java/org/jboss/cache/config and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-14 10:39:46 -0400 (Mon, 14 Jul 2008)
New Revision: 6256
Added:
core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/PessimisticNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/optimistic/OptimisticNodeFactory.java
Removed:
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/InternalNode.java
core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/VersionedNode.java
core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
Log:
Tidied up NodeFactory implementations
Copied: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java (from rev 6255, core/trunk/src/main/java/org/jboss/cache/NodeFactory.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache;
+
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.cache.invocation.NodeInvocationDelegate;
+import org.jboss.cache.lock.LockStrategyFactory;
+import org.jboss.cache.mvcc.ReadCommittedNode;
+import org.jboss.cache.optimistic.TransactionWorkspace;
+import org.jboss.cache.optimistic.WorkspaceNode;
+
+import java.util.Map;
+
+/**
+ * Generates new nodes based on the {@link CacheSPI} configuration.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+public abstract class AbstractNodeFactory<K, V> implements NodeFactory<K, V>
+{
+ protected CacheSPI<K, V> cache;
+ protected boolean useVersionedNode;
+ protected Configuration configuration;
+ protected InvocationContextContainer invocationContextContainer;
+ protected InterceptorChain interceptorChain;
+ protected CommandsFactory commandsFactory;
+ protected LockStrategyFactory lockStrategyFactory;
+ protected ComponentRegistry componentRegistry;
+
+
+ @Inject
+ private void injectComponentRegistry(ComponentRegistry componentRegistry)
+ {
+ this.componentRegistry = componentRegistry;
+ }
+
+ @Inject
+ public void injectDependencies(CacheSPI<K, V> cache, Configuration configuration,
+ InvocationContextContainer invocationContextContainer,
+ InterceptorChain interceptorChain, CommandsFactory commandsFactory, LockStrategyFactory lockStrategyFactory)
+ {
+ this.cache = cache;
+ this.configuration = configuration;
+ this.invocationContextContainer = invocationContextContainer;
+ this.interceptorChain = interceptorChain;
+ this.commandsFactory = commandsFactory;
+ this.lockStrategyFactory = lockStrategyFactory;
+ }
+
+ public NodeSPI<K, V> createNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
+ {
+ UnversionedNode<K, V> internal = createInternalNode(childName, fqn, parent, data, mapSafe);
+
+ // always assume that new nodes do not have data loaded
+ internal.setDataLoaded(false);
+ NodeSPI<K, V> nid = createNodeInvocationDelegate(internal, false);
+
+ // back reference
+ internal.setDelegate(nid);
+ return nid;
+ }
+
+ protected UnversionedNode<K, V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
+ {
+ throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
+ }
+
+ public WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace)
+ {
+ throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
+ }
+
+ public ReadCommittedNode createWrappedNode(InternalNode<K, V> node)
+ {
+ throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
+ }
+
+ public NodeSPI<K, V> createRootNode()
+ {
+ return createNode(null, Fqn.ROOT, null, null, false);
+ }
+
+ public NodeSPI<K, V> createNodeInvocationDelegate(InternalNode<K, V> internalNode, boolean wrapWithNodeReference)
+ {
+ if (wrapWithNodeReference)
+ throw new UnsupportedOperationException("wrapWithNodeReferences is not supported in this impl!");
+ NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate<K, V>(internalNode);
+ nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
+ nid.injectDependencies(cache);
+ return nid;
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -68,7 +68,7 @@
{
if (trace) log.trace("Starting data container");
// create a new root temporarily.
- NodeSPI tempRoot = nodeFactory.createRootDataNode();
+ NodeSPI tempRoot = nodeFactory.createRootNode();
// if we don't already have a root or the new (temp) root is of a different class (optimistic vs pessimistic) to
// the current root, then we use the new one.
Modified: core/trunk/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -18,39 +18,39 @@
*/
public interface InternalNode<K, V>
{
- NodeSPI getParent();
+ NodeSPI<K, V> getParent();
- CacheSPI getCache();
+ CacheSPI<K, V> getCache();
boolean isChildrenLoaded();
void setChildrenLoaded(boolean flag);
- Object getDirect(Object key);
+ V getDirect(K key);
- Map getDataDirect();
+ Map<K, V> getDataDirect();
- Object putDirect(Object key, Object value);
+ V putDirect(K key, V value);
- NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify);
+ NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify);
- Object removeDirect(Object key);
+ V removeDirect(K key);
void addChildDirect(NodeSPI child);
- NodeSPI addChildDirect(Fqn f);
+ NodeSPI<K, V> addChildDirect(Fqn f);
- NodeSPI addChildDirect(Fqn f, boolean notify);
+ NodeSPI<K, V> addChildDirect(Fqn f, boolean notify);
- NodeSPI addChildDirect(Object o, boolean notify);
+ NodeSPI<K, V> addChildDirect(Object o, boolean notify);
void clearDataDirect();
- NodeSPI getChildDirect(Fqn fqn);
+ NodeSPI<K, V> getChildDirect(Fqn fqn);
Set<Object> getChildrenNamesDirect();
- Set<Object> getKeysDirect();
+ Set<K> getKeysDirect();
boolean removeChildDirect(Object childName);
@@ -60,7 +60,7 @@
void setChildrenMapDirect(Map<Object, Node<K, V>> children);
- void putAllDirect(Map data);
+ void putAllDirect(Map<K, V> data);
void removeChildrenDirect();
@@ -72,13 +72,13 @@
void setFqn(Fqn fqn);
- NodeSPI getChildDirect(Object childName);
+ NodeSPI<K, V> getChildDirect(Object childName);
- Set<NodeSPI> getChildrenDirect();
+ Set<NodeSPI<K, V>> getChildrenDirect();
boolean hasChildrenDirect();
- Set<NodeSPI> getChildrenDirect(boolean includeMarkedForRemoval);
+ Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval);
boolean isDataLoaded();
@@ -114,7 +114,7 @@
*
* @return a copy.
*/
- InternalNode copy();
+ InternalNode<K, V> copy();
NodeLock getLock();
Deleted: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -1,187 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache;
-
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.ComponentFactory;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.invocation.NodeInvocationDelegate;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.LockStrategyFactory;
-import org.jboss.cache.mvcc.NodeReference;
-import org.jboss.cache.mvcc.NullMarkerNode;
-import org.jboss.cache.mvcc.ReadCommittedNode;
-import org.jboss.cache.mvcc.RepeatableReadNode;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.optimistic.WorkspaceNodeImpl;
-
-import java.util.Map;
-
-/**
- * Generates new nodes based on the {@link CacheSPI} configuration.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-public class NodeFactory<K, V> extends ComponentFactory
-{
- private CacheSPI<K, V> cache;
- private boolean useVersionedNode;
- private Configuration configuration;
- private InvocationContextContainer invocationContextContainer;
- private InterceptorChain interceptorChain;
- private CommandsFactory commandsFactory;
- private LockStrategyFactory lockStrategyFactory;
- private boolean useRepeatableRead;
- private static final NullMarkerNode NULL_MARKER = new NullMarkerNode(null);
-
- @Override
- protected <T> T construct(Class<T> componentType)
- {
- throw new UnsupportedOperationException("Should never be called!");
- }
-
- /**
- * Creates an MVCC wrapped node - either a {@link org.jboss.cache.mvcc.ReadCommittedNode} or it's subclass, a
- * {@link org.jboss.cache.mvcc.RepeatableReadNode} based on cache configuration. If a null is passed in as the InternalNode,
- * this method will return a special {@link org.jboss.cache.mvcc.NullMarkerNode} instance if using repeatable read,
- * or a null if read committed.
- *
- * @param node internal node to wrap.
- * @return a ReadCommittedNode
- */
- public ReadCommittedNode createMvccNode(InternalNode node)
- {
- if (node == null) return useRepeatableRead ? NULL_MARKER : null;
- ReadCommittedNode rcn = useRepeatableRead ? new RepeatableReadNode(node) : new ReadCommittedNode(node);
- rcn.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
- rcn.injectDependencies(cache);
- return rcn;
- }
-
- public enum NodeType
- {
- UNVERSIONED_NODE, VERSIONED_NODE, WORKSPACE_NODE
- }
-
- /**
- * Constructs an instance of the factory
- */
- public NodeFactory(CacheSPI<K, V> cache)
- {
- this.cache = cache;
- init();
- }
-
- public NodeFactory()
- {
- }
-
- @Inject
- public void injectDependencies(CacheSPI<K, V> cache, Configuration configuration,
- InvocationContextContainer invocationContextContainer,
- InterceptorChain interceptorChain, CommandsFactory commandsFactory, LockStrategyFactory lockStrategyFactory)
- {
- this.cache = cache;
- this.configuration = configuration;
- this.invocationContextContainer = invocationContextContainer;
- this.interceptorChain = interceptorChain;
- this.commandsFactory = commandsFactory;
- this.lockStrategyFactory = lockStrategyFactory;
- }
-
- /**
- * Initialises the node factory with the configuration from the cache.
- */
- @Start
- public void init()
- {
- useVersionedNode = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
- useRepeatableRead = configuration.getIsolationLevel() == IsolationLevel.REPEATABLE_READ;
- }
-
-
- /**
- * Creates a new {@link Node} instance.
- *
- * @param childName the new node's name
- * @param fqn the new node's Fqn
- * @param parent the new node's parent
- * @param data the new node's attribute map
- * @param mapSafe <code>true</code> if param <code>data</code> can safely
- * be directly assigned to the new node's data field;
- * <code>false</code> if param <code>data</code>'s contents
- * should be copied into the new node's data field.
- * @return the new node
- */
- public NodeSPI<K, V> createDataNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
- {
- // TODO: See if data versions are needed with MVCC. Should use cheaper UnversionedNode otherwise.
- UnversionedNode un = useVersionedNode ? new VersionedNode<K, V>(fqn, parent, data, cache) : new UnversionedNode<K, V>(childName, fqn, data, cache);
-
- // it is internal nodes that are wrapped in NIDs.
- InternalNode in = un;
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC && !useRepeatableRead)
- {
- // this is MVCC with READ_COMMITTED. Make sure we use node references.
- in = new NodeReference(un);
- }
- // always assume that new nodes do not have data loaded
- un.setDataLoaded(false);
- NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate(in);
-
- // Too slow to have these autowired for now. Look at manually wiring them.
- nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
- nid.injectDependencies(cache);
- un.injectDependencies(cache, commandsFactory, lockStrategyFactory);
-
-// componentRegistry.wireDependencies(nid);
-// componentRegistry.wireDependencies(un);
- // back ref
- un.setDelegate(nid);
- return nid;
- }
-
- public Node<K, V> createNode(Object childName, Node<K, V> parent, Map<K, V> data)
- {
- return createNodeOfType(parent, childName, parent, data);
- }
-
- public Node<K, V> createNodeOfType(Node<K, V> template, Object childName, Node<K, V> parent, Map<K, V> data)
- {
- // not a workspace node.
- return createDataNode(childName, Fqn.fromRelativeElements(parent.getFqn(), childName), (NodeSPI<K, V>) parent, data, false);
- }
-
- public WorkspaceNode<K, V> createWorkspaceNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace)
- {
- return new WorkspaceNodeImpl<K, V>(dataNode, workspace);
- }
-
- public NodeSPI<K, V> createRootDataNode()
- {
- return createDataNode(null, Fqn.ROOT, null, null, false);
- }
-
- public NodeSPI createNodeInvocationDelegate(InternalNode internalNode, boolean wrapWithNodeReference)
- {
- if (wrapWithNodeReference && internalNode instanceof NodeReference)
- throw new IllegalArgumentException("Cannot wrap a NodeReference with a NodeReference!");
- if (wrapWithNodeReference && useRepeatableRead)
- throw new IllegalArgumentException("Cannot use NodeReferences with RepeatableRead!");
- if (wrapWithNodeReference) internalNode = new NodeReference(internalNode);
- NodeInvocationDelegate nid = new NodeInvocationDelegate(internalNode);
- nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
- nid.injectDependencies(cache);
- return nid;
- }
-}
Added: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,27 @@
+package org.jboss.cache;
+
+import org.jboss.cache.mvcc.ReadCommittedNode;
+import org.jboss.cache.optimistic.TransactionWorkspace;
+import org.jboss.cache.optimistic.WorkspaceNode;
+
+import java.util.Map;
+
+/**
+ * An interface for a factory that creates nodes. This used to be a concrete class prior to 3.0.0. Made into an
+ * interface to simplify logic of different locking schemes and node types.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface NodeFactory<K, V>
+{
+ ReadCommittedNode createWrappedNode(InternalNode<K, V> node);
+
+ WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace);
+
+ NodeSPI<K, V> createNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe);
+
+ NodeSPI<K, V> createRootNode();
+
+ NodeSPI<K, V> createNodeInvocationDelegate(InternalNode<K, V> internalNode, boolean wrapWithNodeReference);
+}
Added: core/trunk/src/main/java/org/jboss/cache/PessimisticNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/PessimisticNodeFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/PessimisticNodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,20 @@
+package org.jboss.cache;
+
+import java.util.Map;
+
+/**
+ * Node factory specific to pessimistic locking.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class PessimisticNodeFactory<K, V> extends AbstractNodeFactory<K, V>
+{
+ @Override
+ protected UnversionedNode<K, V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
+ {
+ UnversionedNode<K, V> internal = new UnversionedNode<K, V>(childName, fqn, data, cache);
+ internal.injectDependencies(cache, commandsFactory, lockStrategyFactory, this);
+ return internal;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -756,10 +756,13 @@
public String dumpRegions()
{
StringBuilder sb = new StringBuilder();
- for (Region r : regionsRegistry.values())
+ if (regionsRegistry != null)
{
- sb.append("\tRegion ").append(r);
- sb.append("\n");
+ for (Region r : regionsRegistry.values())
+ {
+ sb.append("\tRegion ").append(r);
+ sb.append("\n");
+ }
}
return sb.toString();
}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -60,6 +60,7 @@
protected NodeSPI delegate;
CommandsFactory commandsFactory;
protected LockStrategyFactory lockStrategyFactory;
+ private NodeFactory nodeFactory;
/**
* Constructs a new node with an FQN of Root.
@@ -82,7 +83,7 @@
/**
* Constructs a new node with a name, etc.
*/
- protected UnversionedNode(Object childName, Fqn fqn, Map data, CacheSPI cache)
+ public UnversionedNode(Object childName, Fqn fqn, Map data, CacheSPI cache)
{
if (cache == null)
{
@@ -121,11 +122,12 @@
this.delegate = delegate;
}
- public void injectDependencies(CacheSPI spi, CommandsFactory commandsFactory, LockStrategyFactory lockStrategyFactory)
+ public void injectDependencies(CacheSPI spi, CommandsFactory commandsFactory, LockStrategyFactory lockStrategyFactory, NodeFactory nodeFactory)
{
this.cache = spi;
this.commandsFactory = commandsFactory;
this.lockStrategyFactory = lockStrategyFactory;
+ this.nodeFactory = nodeFactory;
init();
}
@@ -247,22 +249,22 @@
return getOrCreateChild(child_name, gtx, true, notify);
}
- private NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean createIfNotExists, boolean notify)
+ private NodeSPI getOrCreateChild(Object childName, GlobalTransaction gtx, boolean createIfNotExists, boolean notify)
{
NodeSPI child;
- if (child_name == null)
+ if (childName == null)
{
throw new IllegalArgumentException("null child name");
}
- child = (NodeSPI) children().get(child_name);
+ child = (NodeSPI) children().get(childName);
InvocationContext ctx = cache.getInvocationContext();
if (createIfNotExists && child == null)
{
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
- Fqn child_fqn = Fqn.fromRelativeElements(this.fqn, child_name);
- NodeSPI newChild = (NodeSPI) cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name, delegate, null);
+ Fqn child_fqn = Fqn.fromRelativeElements(this.fqn, childName);
+ NodeSPI newChild = nodeFactory.createNode(childName, Fqn.fromRelativeElements(fqn, childName), delegate, null, true);
if (newChild == null)
{
throw new IllegalStateException();
@@ -271,12 +273,12 @@
{
// check again to see if the child exists
// after acquiring exclusive lock
- child = (NodeSPI) children().get(child_name);
+ child = (NodeSPI) children().get(childName);
if (child == null)
{
if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
child = newChild;
- children.put(child_name, child);
+ children.put(childName, child);
if (gtx != null)
{
@@ -496,13 +498,13 @@
return children == null ? Collections.emptySet() : new HashSet<Object>(children.keySet());
}
- public Set<Object> getKeysDirect()
+ public Set<K> getKeysDirect()
{
if (data == null)
{
return Collections.emptySet();
}
- return Collections.unmodifiableSet(new HashSet<Object>(data.keySet()));
+ return Collections.unmodifiableSet(new HashSet<K>(data.keySet()));
}
public boolean removeChildDirect(Object childName)
@@ -641,18 +643,19 @@
return (NodeSPI) (children == null ? null : children.get(childName));
}
- public Set<NodeSPI> getChildrenDirect()
+ public Set<NodeSPI<K, V>> getChildrenDirect()
{
// strip out deleted child nodes...
if (children == null || children.size() == 0) return Collections.emptySet();
- Set<NodeSPI> exclDeleted = new HashSet<NodeSPI>();
+ Set<NodeSPI<K, V>> exclDeleted = new HashSet<NodeSPI<K, V>>();
for (Node n : children.values())
{
NodeSPI spi = (NodeSPI) n;
if (!spi.isDeleted()) exclDeleted.add(spi);
}
- return Collections.unmodifiableSet(exclDeleted);
+ exclDeleted = Collections.unmodifiableSet(exclDeleted);
+ return exclDeleted;
}
public boolean hasChildrenDirect()
@@ -660,7 +663,7 @@
return children != null && children.size() != 0;
}
- public Set<NodeSPI> getChildrenDirect(boolean includeMarkedForRemoval)
+ public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
{
if (includeMarkedForRemoval)
{
Modified: core/trunk/src/main/java/org/jboss/cache/VersionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/VersionedNode.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/VersionedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -41,7 +41,7 @@
*/
private NodeSPI<K, V> parent;
- protected VersionedNode(Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, CacheSPI<K, V> cache)
+ public VersionedNode(Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, CacheSPI<K, V> cache)
{
super(fqn.getLastElement(), fqn, data, cache);
if (parent == null && !fqn.isRoot()) throw new NullPointerException("parent");
Modified: core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.config;
-import org.jboss.cache.NodeFactory;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.util.Util;
@@ -25,7 +24,6 @@
private transient TransactionManager transactionManager;
private transient Channel channel;
private transient ChannelFactory muxChannelFactory;
- private transient NodeFactory nodeFactory;
private transient BuddyGroup buddyGroup;
private RPCManager rpcManager;
@@ -34,8 +32,6 @@
*/
public void reset()
{
- // only reset the node factory and channel for now.
- nodeFactory = null;
channel = null;
rpcManager = null;
}
@@ -130,16 +126,6 @@
this.transactionManager = transactionManager;
}
- public NodeFactory getNodeFactory()
- {
- return nodeFactory;
- }
-
- public void setNodeFactory(NodeFactory nodeFactory)
- {
- this.nodeFactory = nodeFactory;
- }
-
@Override
public boolean equals(Object obj)
{
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -175,9 +175,11 @@
s.add(ReplicationQueueFactory.class);
s.add(LockManagerFactory.class);
s.add(ContextMetaFactory.class);
- s.add(CommandsMetaFactory.class);
+ s.add(NodeMetaFactory.class);
s.add(StateTransferManagerFactory.class);
s.add(RegionManagerFactory.class);
+ s.add(NodeMetaFactory.class);
+ s.add(CommandsMetaFactory.class);
return s;
}
Added: core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,34 @@
+package org.jboss.cache.factories;
+
+import org.jboss.cache.NodeFactory;
+import org.jboss.cache.PessimisticNodeFactory;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.cache.mvcc.MVCCNodeFactory;
+import org.jboss.cache.optimistic.OptimisticNodeFactory;
+
+/**
+ * Creates node factories.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = NodeFactory.class)
+public class NodeMetaFactory extends ComponentFactory
+{
+ @SuppressWarnings("unchecked")
+ protected <T> T construct(Class<T> componentType)
+ {
+ switch (configuration.getNodeLockingScheme())
+ {
+ case MVCC:
+ return (T) new MVCCNodeFactory();
+ case OPTIMISTIC:
+ return (T) new OptimisticNodeFactory();
+ case PESSIMISTIC:
+ return (T) new PessimisticNodeFactory();
+ default:
+ throw new ConfigurationException("Unknown locking scheme " + configuration.getNodeLockingScheme());
+ }
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -1,6 +1,5 @@
package org.jboss.cache.factories;
-import org.jboss.cache.NodeFactory;
import org.jboss.cache.RPCManager;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.RuntimeConfig;
@@ -15,7 +14,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@DefaultFactoryFor(classes = {RPCManager.class, NodeFactory.class})
+@DefaultFactoryFor(classes = RPCManager.class)
public class RuntimeConfigAwareFactory extends EmptyConstructorFactory
{
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -125,7 +125,7 @@
if (!locked)
throw new TimeoutException("Unable to lock node " + node.getFqn() + " after timeout " + timeout + " for copying into workspace");
- WorkspaceNode wn = nodeFactory.createWorkspaceNode(node, workspace);
+ WorkspaceNode wn = nodeFactory.createWrappedNode(node, workspace);
lockManager.unlock(node, gtx);
return wn;
Added: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,77 @@
+package org.jboss.cache.mvcc;
+
+import org.jboss.cache.AbstractNodeFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InternalNode;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnversionedNode;
+import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.lock.IsolationLevel;
+
+import java.util.Map;
+
+/**
+ * Creates nodes specific to MVCC logic.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MVCCNodeFactory<K, V> extends AbstractNodeFactory<K, V>
+{
+ private boolean useRepeatableRead;
+ private static final NullMarkerNode NULL_MARKER = new NullMarkerNode(null);
+
+ /**
+ * Initialises the node factory with the configuration from the cache.
+ */
+ @Start
+ public void init()
+ {
+ useRepeatableRead = configuration.getIsolationLevel() == IsolationLevel.REPEATABLE_READ;
+ }
+
+ /**
+ * Creates an MVCC wrapped node - either a {@link org.jboss.cache.mvcc.ReadCommittedNode} or it's subclass, a
+ * {@link org.jboss.cache.mvcc.RepeatableReadNode} based on cache configuration. If a null is passed in as the InternalNode,
+ * this method will return a special {@link org.jboss.cache.mvcc.NullMarkerNode} instance if using repeatable read,
+ * or a null if read committed.
+ *
+ * @param node internal node to wrap.
+ * @return a ReadCommittedNode
+ */
+ @Override
+ public ReadCommittedNode createWrappedNode(InternalNode<K, V> node)
+ {
+ if (node == null) return useRepeatableRead ? NULL_MARKER : null;
+ ReadCommittedNode rcn = useRepeatableRead ? new RepeatableReadNode(node) : new ReadCommittedNode(node);
+ rcn.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
+ rcn.injectDependencies(cache);
+ return rcn;
+ }
+
+ @Override
+ public NodeSPI<K, V> createNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
+ {
+ UnversionedNode<K, V> internal = new UnversionedNode<K, V>(childName, fqn, data, cache);
+ internal.injectDependencies(cache, commandsFactory, lockStrategyFactory, this);
+
+ // always assume that new nodes do not have data loaded
+ internal.setDataLoaded(false);
+ NodeSPI<K, V> nid = createNodeInvocationDelegate(internal, !useRepeatableRead);
+
+ // back reference
+ internal.setDelegate(nid);
+ return nid;
+ }
+
+ @Override
+ public NodeSPI<K, V> createNodeInvocationDelegate(InternalNode<K, V> internalNode, boolean wrapWithNodeReference)
+ {
+ if (wrapWithNodeReference && internalNode instanceof NodeReference)
+ throw new IllegalArgumentException("Cannot wrap a NodeReference with a NodeReference!");
+ if (wrapWithNodeReference && useRepeatableRead)
+ throw new IllegalArgumentException("Cannot use NodeReferences with RepeatableRead!");
+ if (wrapWithNodeReference) internalNode = new NodeReference<K, V>(internalNode);
+ return super.createNodeInvocationDelegate(internalNode, false);
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -66,8 +66,8 @@
* Attempts to provide the context with a set of wrapped nodes based on the Collection of fqns passed in. If the nodes
* already exist in the context then the node is not wrapped again.
* <p/>
- * {@link InternalNode}s are wrapped using {@link NodeFactory#createMvccNode(org.jboss.cache.InternalNode)} and as such,
- * null internal nodes are treated according to isolation level used. See {@link NodeFactory#createMvccNode(org.jboss.cache.InternalNode)}
+ * {@link InternalNode}s are wrapped using {@link org.jboss.cache.NodeFactory#createWrappedNode(org.jboss.cache.InternalNode)}
+ * and as such, null internal nodes are treated according to isolation level used. See {@link org.jboss.cache.NodeFactory#createWrappedNode(org.jboss.cache.InternalNode)}
* for details on this behaviour.
* <p/>
* Note that if the context has the {@link org.jboss.cache.config.Option#isForceWriteLock()} option set, then write locks are
@@ -113,7 +113,7 @@
if (trace) log.trace("Node " + f + " is not in context, fetching from container.");
// simple implementation. Peek the node, wrap it, put wrapped node in the context.
InternalNode node = dataContainer.peekInternalNode(f, false);
- ReadCommittedNode wrapped = nodeFactory.createMvccNode(node);
+ ReadCommittedNode wrapped = nodeFactory.createWrappedNode(node);
if (wrapped != null) ctx.putLookedUpNode(f, wrapped);
return wrapped;
}
@@ -196,7 +196,7 @@
{
needToCopy = true;
}
- n = nodeFactory.createMvccNode(in);
+ n = nodeFactory.createWrappedNode(in);
context.putLookedUpNode(fqn, n);
if (needToCopy) n.markForUpdate(context, dataContainer, nodeFactory, allowWriteSkew);
}
@@ -221,7 +221,7 @@
parent.removeChildDirect(fqn.getLastElement());
in = ((NodeInvocationDelegate) temp).getDelegationTarget();
- n = nodeFactory.createMvccNode(in);
+ n = nodeFactory.createWrappedNode(in);
n.setCreated(true);
context.putLookedUpNode(fqn, n);
n.markForUpdate(context, dataContainer, nodeFactory, allowWriteSkew);
@@ -326,7 +326,7 @@
if (node == null)
{
InternalNode in = dataContainer.peekInternalNode(fqn, false);
- node = nodeFactory.createMvccNode(in);
+ node = nodeFactory.createWrappedNode(in);
ctx.putLookedUpNode(fqn, node);
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -28,11 +28,11 @@
* @since 3.0
*/
@ThreadSafe
-public class NodeReference implements InternalNode
+public class NodeReference<K, V> implements InternalNode<K, V>
{
- transient volatile InternalNode delegate;
+ transient volatile InternalNode<K, V> delegate;
- public NodeReference(InternalNode delegate)
+ public NodeReference(InternalNode<K, V> delegate)
{
this.delegate = delegate;
}
@@ -40,7 +40,7 @@
/**
* @return the InternalNode being delegated to.
*/
- public InternalNode getDelegate()
+ public InternalNode<K, V> getDelegate()
{
return delegate;
}
@@ -50,17 +50,17 @@
*
* @param delegate node to delegate to.
*/
- public void setDelegate(InternalNode delegate)
+ public void setDelegate(InternalNode<K, V> delegate)
{
this.delegate = delegate;
}
- public NodeSPI getParent()
+ public NodeSPI<K, V> getParent()
{
return delegate.getParent();
}
- public CacheSPI getCache()
+ public CacheSPI<K, V> getCache()
{
return delegate.getCache();
}
@@ -75,27 +75,27 @@
delegate.setChildrenLoaded(flag);
}
- public Object getDirect(Object key)
+ public V getDirect(K key)
{
return delegate.getDirect(key);
}
- public Map getDataDirect()
+ public Map<K, V> getDataDirect()
{
return delegate.getDataDirect();
}
- public Object putDirect(Object key, Object value)
+ public V putDirect(K key, V value)
{
return delegate.putDirect(key, value);
}
- public NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify)
+ public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify)
{
return delegate.getOrCreateChild(child_name, gtx, notify);
}
- public Object removeDirect(Object key)
+ public V removeDirect(K key)
{
return delegate.removeDirect(key);
}
@@ -105,17 +105,17 @@
delegate.addChildDirect(child);
}
- public NodeSPI addChildDirect(Fqn f)
+ public NodeSPI<K, V> addChildDirect(Fqn f)
{
return delegate.addChildDirect(f);
}
- public NodeSPI addChildDirect(Fqn f, boolean notify)
+ public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
{
return delegate.addChildDirect(f, notify);
}
- public NodeSPI addChildDirect(Object o, boolean notify)
+ public NodeSPI<K, V> addChildDirect(Object o, boolean notify)
{
return delegate.addChildDirect(o, notify);
}
@@ -125,17 +125,17 @@
delegate.clearDataDirect();
}
- public NodeSPI getChildDirect(Fqn fqn)
+ public NodeSPI<K, V> getChildDirect(Fqn fqn)
{
return delegate.getChildDirect(fqn);
}
- public Set getChildrenNamesDirect()
+ public Set<Object> getChildrenNamesDirect()
{
return delegate.getChildrenNamesDirect();
}
- public Set getKeysDirect()
+ public Set<K> getKeysDirect()
{
return delegate.getKeysDirect();
}
@@ -150,22 +150,22 @@
return delegate.removeChildDirect(f);
}
- public Map getChildrenMapDirect()
+ public Map<Object, Node<K, V>> getChildrenMapDirect()
{
return delegate.getChildrenMapDirect();
}
- public Map getChildrenMapDirect(boolean b)
+ public Map<Object, Node<K, V>> getChildrenMapDirect(boolean b)
{
return delegate.getChildrenMapDirect(b);
}
- public void setChildrenMapDirect(Map children)
+ public void setChildrenMapDirect(Map<Object, Node<K, V>> children)
{
delegate.setChildrenMapDirect(children);
}
- public void putAllDirect(Map data)
+ public void putAllDirect(Map<K, V> data)
{
delegate.putAllDirect(data);
}
@@ -195,12 +195,12 @@
delegate.setFqn(fqn);
}
- public NodeSPI getChildDirect(Object childName)
+ public NodeSPI<K, V> getChildDirect(Object childName)
{
return delegate.getChildDirect(childName);
}
- public Set getChildrenDirect()
+ public Set<NodeSPI<K, V>> getChildrenDirect()
{
return delegate.getChildrenDirect();
}
@@ -210,7 +210,7 @@
return delegate.hasChildrenDirect();
}
- public Set getChildrenDirect(boolean includeMarkedForRemoval)
+ public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
{
return delegate.getChildrenDirect(includeMarkedForRemoval);
}
@@ -285,10 +285,10 @@
return delegate.isResident();
}
- public InternalNode copy()
+ public InternalNode<K, V> copy()
{
- InternalNode cloneDelegate = delegate.copy();
- return new NodeReference(cloneDelegate);
+ InternalNode<K, V> cloneDelegate = delegate.copy();
+ return new NodeReference<K, V>(cloneDelegate);
}
public NodeLock getLock()
@@ -296,7 +296,7 @@
return delegate.getLock();
}
- public void addChild(Object nodeName, Node nodeToAdd)
+ public void addChild(Object nodeName, Node<K, V> nodeToAdd)
{
delegate.addChild(nodeName, nodeToAdd);
}
Added: core/trunk/src/main/java/org/jboss/cache/optimistic/OptimisticNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/OptimisticNodeFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/OptimisticNodeFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -0,0 +1,32 @@
+package org.jboss.cache.optimistic;
+
+import org.jboss.cache.AbstractNodeFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnversionedNode;
+import org.jboss.cache.VersionedNode;
+
+import java.util.Map;
+
+/**
+ * Node factory specific to optimistic locking.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class OptimisticNodeFactory<K, V> extends AbstractNodeFactory<K, V>
+{
+ @Override
+ protected UnversionedNode<K, V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
+ {
+ VersionedNode<K, V> internal = new VersionedNode<K, V>(fqn, parent, data, cache);
+ internal.injectDependencies(cache, commandsFactory, lockStrategyFactory, this);
+ return internal;
+ }
+
+ @Override
+ public WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace)
+ {
+ return new WorkspaceNodeImpl<K, V>(dataNode, workspace, this);
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -46,11 +46,12 @@
private Set<Fqn> childrenAdded;
private Set<Fqn> childrenRemoved;
private Map<K, V> optimisticDataMap;
+ private NodeFactory<K, V> nodeFactory;
/**
* Constructs with a node and workspace.
*/
- public WorkspaceNodeImpl(NodeSPI<K, V> node, TransactionWorkspace workspace)
+ public WorkspaceNodeImpl(NodeSPI<K, V> node, TransactionWorkspace workspace, NodeFactory<K, V> nodeFactory)
{
NodeInvocationDelegate delegate = (NodeInvocationDelegate) node;
if (!(delegate.getDelegationTarget() instanceof VersionedNode))
@@ -68,6 +69,7 @@
}
initFlags();
+ this.nodeFactory = nodeFactory;
}
protected void initFlags()
@@ -229,15 +231,14 @@
}
@SuppressWarnings("unchecked")
- public NodeSPI<K, V> createChild(Object child_name, NodeSPI<K, V> parent, CacheSPI<K, V> cache, DataVersion version)
+ public NodeSPI<K, V> createChild(Object childName, NodeSPI<K, V> parent, CacheSPI<K, V> cache, DataVersion version)
{
- if (child_name == null)
+ if (childName == null)
{
return null;
}
- NodeFactory<K, V> factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
- NodeSPI<K, V> child = (NodeSPI<K, V>) factory.createNodeOfType(parent, child_name, parent, null);
+ NodeSPI<K, V> child = nodeFactory.createNode(childName, Fqn.fromRelativeElements(parent.getFqn(), childName), parent, null, true);
getChildrenAddedSet().add(child.getFqn());
if (childrenRemoved != null) childrenRemoved.remove(child.getFqn());
setFlag(CHILDREN_MODIFIED_IN_WORKSPACE, true);
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -46,18 +46,13 @@
private NodeFactory factory;
- private NodeFactory.NodeType nodeType;
-
private Set<Fqn> internalFqns;
- public DefaultStateTransferIntegrator(Fqn targetFqn, CacheSPI<?, ?> cache)
+ public DefaultStateTransferIntegrator(Fqn targetFqn, CacheSPI<?, ?> cache, NodeFactory nodefactory)
{
this.targetFqn = targetFqn;
this.cache = cache;
- this.factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
- this.nodeType = cache.getConfiguration().getNodeLockingScheme().isVersionedScheme()
- ? NodeFactory.NodeType.VERSIONED_NODE
- : NodeFactory.NodeType.UNVERSIONED_NODE;
+ this.factory = nodefactory;
this.internalFqns = cache.getInternalFqns();
}
@@ -71,7 +66,6 @@
protected void integrateTransientState(ObjectInputStream in, NodeSPI target) throws Exception
{
boolean transientSet = false;
-// ClassLoader oldCL = setClassLoader(cl);
try
{
if (log.isTraceEnabled())
@@ -180,11 +174,6 @@
return factory;
}
- protected NodeFactory.NodeType getNodeType()
- {
- return nodeType;
- }
-
protected Fqn getTargetFqn()
{
return targetFqn;
@@ -321,7 +310,7 @@
// We handle this NodeData. Create a TreeNode and
// integrate its data
- NodeSPI target = factory.createDataNode(name, fqn, parent, attrs, false);
+ NodeSPI target = factory.createNode(name, fqn, parent, attrs, false);
parent.addChild(name, target);
// JBCACHE-913
@@ -417,7 +406,7 @@
// Missing level -- have to create empty node
// This shouldn't really happen -- internal fqns should
// be immediately under the root
- child = factory.createDataNode(name, Fqn.fromRelativeElements(ancFqn, name), ancestor, null, true);
+ child = factory.createNode(name, Fqn.fromRelativeElements(ancFqn, name), ancestor, null, true);
ancestor.addChild(name, child);
}
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -11,6 +11,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.RegionEmptyException;
import org.jboss.cache.RegionManager;
@@ -45,16 +46,18 @@
private boolean fetchTransientState;
private boolean fetchPersistentState;
private long stateRetrievalTimeout;
+ private NodeFactory nodeFactory;
@Inject
- public void injectDependencies(CacheSPI cache, Marshaller marshaller, RegionManager regionManager, Configuration configuration, CacheLoaderManager cacheLoaderManager)
+ public void injectDependencies(CacheSPI cache, Marshaller marshaller, RegionManager regionManager, Configuration configuration, CacheLoaderManager cacheLoaderManager, NodeFactory nodeFactory)
{
this.cache = cache;
this.regionManager = regionManager;
this.marshaller = marshaller;
this.configuration = configuration;
this.cacheLoaderManager = cacheLoaderManager;
+ this.nodeFactory = nodeFactory;
}
@Start(priority = 19)
@@ -226,6 +229,6 @@
protected StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream istream, Fqn fqn) throws Exception
{
- return StateTransferFactory.getStateTransferIntegrator(istream, fqn, cache);
+ return StateTransferFactory.getStateTransferIntegrator(istream, fqn, cache, nodeFactory);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferFactory.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeFactory;
import org.jboss.cache.Version;
import java.io.IOException;
@@ -43,7 +44,7 @@
return new DefaultStateTransferGenerator(cache); // current default
}
- public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheSPI cache)
+ public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheSPI cache, NodeFactory nodeFactory)
throws Exception
{
short version;
@@ -69,6 +70,6 @@
if (version < RV_200 && version > 0) // <= 0 is actually a version > 15.31.63
throw new IllegalStateException("State transfer with cache replication version < 2.0.0 not supported");
else
- return new DefaultStateTransferIntegrator(fqn, cache); // current default
+ return new DefaultStateTransferIntegrator(fqn, cache, nodeFactory); // current default
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-07-14 12:55:41 UTC (rev 6255)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-07-14 14:39:46 UTC (rev 6256)
@@ -67,7 +67,7 @@
protected NodeSPI createNode(Fqn fqn)
{
UnversionedNode un = new UnversionedNode(fqn);
- un.injectDependencies(null, null, new LockStrategyFactory());
+ un.injectDependencies(null, null, new LockStrategyFactory(), null);
return new NodeInvocationDelegate(un);
}
}
17 years, 5 months
JBoss Cache SVN: r6255 - in core/trunk/src: main/java/org/jboss/cache/commands and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-14 08:55:41 -0400 (Mon, 14 Jul 2008)
New Revision: 6255
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java
Log:
Ensure MVCC uses UnversionedNodes throughout.
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -105,7 +105,7 @@
@Start
public void init()
{
- useVersionedNode = configuration.getNodeLockingScheme() != NodeLockingScheme.PESSIMISTIC;
+ useVersionedNode = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
useRepeatableRead = configuration.getIsolationLevel() == IsolationLevel.REPEATABLE_READ;
}
@@ -130,7 +130,7 @@
// it is internal nodes that are wrapped in NIDs.
InternalNode in = un;
- if (useVersionedNode && !useRepeatableRead)
+ if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC && !useRepeatableRead)
{
// this is MVCC with READ_COMMITTED. Make sure we use node references.
in = new NodeReference(un);
@@ -172,8 +172,13 @@
return createDataNode(null, Fqn.ROOT, null, null, false);
}
- public NodeSPI createNodeInvocationDelegate(InternalNode internalNode)
+ public NodeSPI createNodeInvocationDelegate(InternalNode internalNode, boolean wrapWithNodeReference)
{
+ if (wrapWithNodeReference && internalNode instanceof NodeReference)
+ throw new IllegalArgumentException("Cannot wrap a NodeReference with a NodeReference!");
+ if (wrapWithNodeReference && useRepeatableRead)
+ throw new IllegalArgumentException("Cannot use NodeReferences with RepeatableRead!");
+ if (wrapWithNodeReference) internalNode = new NodeReference(internalNode);
NodeInvocationDelegate nid = new NodeInvocationDelegate(internalNode);
nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
nid.injectDependencies(cache);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -35,7 +35,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.commands.write.VersionedInvalidateCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
@@ -159,19 +158,9 @@
public InvalidateCommand buildInvalidateCommand(Fqn fqn)
{
- if (configuration.getNodeLockingScheme().isVersionedScheme())
- {
- VersionedInvalidateCommand command = new VersionedInvalidateCommand(fqn);
- command.initialize(txManager);
- command.initialize(cacheSpi, dataContainer, notifier);
- return command;
- }
- else
- {
- InvalidateCommand command = new InvalidateCommand(fqn);
- command.initialize(cacheSpi, dataContainer, notifier);
- return command;
- }
+ InvalidateCommand command = new InvalidateCommand(fqn);
+ command.initialize(cacheSpi, dataContainer, notifier);
+ return command;
}
public GetDataMapCommand buildGetDataMapCommand(Fqn fqn)
@@ -439,19 +428,9 @@
case InvalidateCommand.METHOD_ID:
{
- if (configuration.getNodeLockingScheme().isVersionedScheme())
- {
- VersionedInvalidateCommand returnValue = new VersionedInvalidateCommand();
- returnValue.initialize(txManager);
- returnValue.initialize(cacheSpi, dataContainer, notifier);
- command = returnValue;
- }
- else
- {
- InvalidateCommand returnValue = new InvalidateCommand();
- returnValue.initialize(cacheSpi, dataContainer, notifier);
- command = returnValue;
- }
+ InvalidateCommand returnValue = new InvalidateCommand();
+ returnValue.initialize(cacheSpi, dataContainer, notifier);
+ command = returnValue;
break;
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -3,6 +3,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.legacy.write.LegacyEvictCommand;
import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.VersionedInvalidateCommand;
/**
* Extends the default commands factory impl for optimistic locking.
@@ -19,4 +21,37 @@
command.initialize(notifier, dataContainer);
return command;
}
+
+ @Override
+ public InvalidateCommand buildInvalidateCommand(Fqn fqn)
+ {
+ VersionedInvalidateCommand command = new VersionedInvalidateCommand(fqn);
+ command.initialize(txManager);
+ command.initialize(cacheSpi, dataContainer, notifier);
+ return command;
+ }
+
+ @Override
+ public ReplicableCommand fromStream(int id, Object[] parameters)
+ {
+ ReplicableCommand command;
+ boolean skipSetParams = false;
+ switch (id)
+ {
+ case InvalidateCommand.METHOD_ID:
+ {
+ VersionedInvalidateCommand returnValue = new VersionedInvalidateCommand(null);
+ returnValue.initialize(cacheSpi, dataContainer, notifier);
+ command = returnValue;
+ break;
+ }
+ default:
+ // pass up to superclass
+ command = super.fromStream(id, parameters);
+ skipSetParams = true;
+ }
+
+ if (!skipSetParams) command.setParameters(id, parameters);
+ return command;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -13,6 +13,7 @@
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
@@ -106,6 +107,14 @@
}
@Override
+ public InvalidateCommand buildInvalidateCommand(Fqn fqn)
+ {
+ InvalidateCommand command = new InvalidateCommand(fqn);
+ command.initialize(cacheSpi, dataContainer, notifier);
+ return command;
+ }
+
+ @Override
public ReplicableCommand fromStream(int id, Object[] parameters)
{
ReplicableCommand command;
@@ -184,15 +193,20 @@
command = returnValue;
break;
}
+ case InvalidateCommand.METHOD_ID:
+ {
+ InvalidateCommand returnValue = new InvalidateCommand(null);
+ returnValue.initialize(cacheSpi, dataContainer, notifier);
+ command = returnValue;
+ break;
+ }
default:
// pass up to superclass
command = super.fromStream(id, parameters);
skipSetParams = true;
}
- if (!skipSetParams)
- {
- command.setParameters(id, parameters);
- }
+
+ if (!skipSetParams) command.setParameters(id, parameters);
return command;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -145,7 +145,8 @@
*/
public boolean isVersionedScheme()
{
- return this == MVCC || this == OPTIMISTIC;
+// return this == MVCC || this == OPTIMISTIC;
+ return this == OPTIMISTIC;
}
}
@@ -927,6 +928,7 @@
/**
* Returns the {@link org.jboss.cache.config.CustomInterceptorConfig}, if any, associated with this configuration
* object. The custom interceptors will be added to the cache at startup in the sequence defined by this list.
+ *
* @return List of cutom interceptors, never null
*/
public List<CustomInterceptorConfig> getCustomInterceptors()
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -11,6 +11,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.lock.TimeoutException;
import java.util.concurrent.BlockingQueue;
@@ -82,7 +83,7 @@
// hacky temp solution till we have an ioc fwk to inject configuration elements as needed
Configuration c = region.getCacheConfiguration();
Configuration.CacheMode cm = c != null ? c.getCacheMode() : Configuration.CacheMode.LOCAL;
- allowTombstones = c != null && c.getNodeLockingScheme().isVersionedScheme() &&
+ allowTombstones = c != null && c.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC &&
(cm == Configuration.CacheMode.INVALIDATION_ASYNC || cm == Configuration.CacheMode.INVALIDATION_SYNC);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -56,7 +56,7 @@
protected Notifier notifier;
protected boolean isActivation = false;
- protected boolean usingVersionedInvalidation = false;
+// protected boolean usingVersionedInvalidation = false;
protected MVCCNodeHelper helper;
@@ -75,7 +75,7 @@
this.txTable = txTable;
this.clm = clm;
CacheMode mode = configuration.getCacheMode();
- usingVersionedInvalidation = configuration.getNodeLockingScheme().isVersionedScheme() && mode.isInvalidation();
+// usingVersionedInvalidation = mode.isInvalidation();
this.dataContainer = dataContainer;
this.notifier = notifier;
this.helper = helper;
@@ -143,7 +143,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, false, false, !usingVersionedInvalidation);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, false, false, true);
}
return invokeNextInterceptor(ctx, command);
}
@@ -364,7 +364,7 @@
}
// check this first!!!
- if (!n.isValid() && configuration.getNodeLockingScheme().isVersionedScheme())
+ if (!n.isValid()) // && configuration.getNodeLockingScheme().isVersionedScheme())
{
// attempt to load again; this only happens if we have tombstones lying around, or we are using invalidation.
if (trace) log.trace("loading again from cache loader since in-memory node is marked as invalid");
@@ -442,7 +442,8 @@
n.setInternalState(nodeData);
// set this node as valid?
- if (usingVersionedInvalidation) n.setValid(true, false);
+// if (usingVersionedInvalidation) n.setValid(true, false);
+ n.setValid(true, false);
notifier.notifyNodeLoaded(fqn, false, nodeData, ctx);
if (isActivation)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -126,10 +126,10 @@
Object returnValue = invokeNextInterceptor(ctx, command);
// persist additional internal state, if any, and then clean up internal resources
Set<Fqn> affectedFqns = preparingTxs.remove(gtx);
- if (affectedFqns != null && !affectedFqns.isEmpty())
- {
- storeInternalState(affectedFqns, ctx);
- }
+// if (affectedFqns != null && !affectedFqns.isEmpty())
+// {
+// storeInternalState(affectedFqns, ctx);
+// }
return returnValue;
}
else
@@ -278,22 +278,22 @@
return txMgr != null && txMgr.getTransaction() != null;
}
- private void storeInternalState(Set<Fqn> affectedFqns, InvocationContext ctx) throws Exception
- {
- if (configuration.getNodeLockingScheme().isVersionedScheme())
- {
- for (Fqn f : affectedFqns)
- {
- // NOT going to store tombstones!!
- NodeSPI n = ctx.lookUpNode(f);
- if (n != null && !n.isDeleted())
- {
- Map internalState = n.getInternalState(true);
- loader.put(f, internalState);
- }
- }
- }
- }
+// private void storeInternalState(Set<Fqn> affectedFqns, InvocationContext ctx) throws Exception
+// {
+// if (configuration.getNodeLockingScheme().isVersionedScheme())
+// {
+// for (Fqn f : affectedFqns)
+// {
+// // NOT going to store tombstones!!
+// NodeSPI n = ctx.lookUpNode(f);
+// if (n != null && !n.isDeleted())
+// {
+// Map internalState = n.getInternalState(true);
+// loader.put(f, internalState);
+// }
+// }
+// }
+// }
private void recursiveMove(Fqn fqn, Fqn newFqn) throws Exception
{
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -14,6 +14,7 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
+import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.TimeoutException;
@@ -274,7 +275,7 @@
if (parentLockNeeded && (needToCopyNode || needToCopyParent))
{
ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(parentFqn);
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node.getDelegationTarget()));
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node.getDelegationTarget(), configuration.getIsolationLevel() == IsolationLevel.READ_COMMITTED));
}
// now deal with children.
@@ -306,7 +307,7 @@
{
rcn.markForUpdate(ctx, dataContainer, nodeFactory, allowWriteSkew);
ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(fqn.getParent());
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(rcn.getDelegationTarget()));
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(rcn.getDelegationTarget(), configuration.getIsolationLevel() == IsolationLevel.READ_COMMITTED));
Map<Object, NodeSPI> children = rcn.getChildrenMapDirect();
if (children != null)
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -19,6 +19,13 @@
super(node);
}
+// to aid with debugging. remove when finalised.
+// @Override
+// protected void assertInternalNodeType()
+// {
+// if (node != null) throw new IllegalArgumentException("NullMarkerNodes can only wrap null values!");
+// }
+
/**
* @return always returns true
*/
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -25,8 +25,15 @@
public ReadCommittedNode(InternalNode node)
{
super(node);
+// assertInternalNodeType();
}
+// to aid with debugging. remove when finalised.
+// protected void assertInternalNodeType()
+// {
+// if (!(node instanceof NodeReference)) throw new IllegalArgumentException("ReadCommittedNodes can only wrap NodeReferences!");
+// }
+
public boolean isNullNode()
{
return false;
@@ -92,13 +99,8 @@
{
// add newly created nodes to parents.
NodeSPI parent = lookupParent(fqn, ctx, container);
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node));
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node, false));
}
- else if (fqn.isRoot())
- {
- // set root node reference in data container.
- container.setRoot(nodeFactory.createNodeInvocationDelegate(node));
- }
else
{
updateNode(ctx, container, nodeFactory);
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -22,6 +22,13 @@
super(node);
}
+// to aid with debugging. remove when finalised.
+// @Override
+// protected void assertInternalNodeType()
+// {
+// if (!(node instanceof UnversionedNode)) throw new IllegalArgumentException("RepeatableReadNodes can only wrap UnversionedNodes!");
+// }
+
@Override
public void markForUpdate(InvocationContext ctx, DataContainer container, NodeFactory nodeFactory, boolean allowWriteSkew)
{
@@ -56,10 +63,14 @@
@Override
protected void updateNode(InvocationContext ctx, DataContainer dataContainer, NodeFactory nf)
{
- if (!deleted)
+ if (getFqn().isRoot())
{
+ dataContainer.setRoot(nf.createNodeInvocationDelegate(node, false));
+ }
+ else if (!deleted)
+ {
NodeSPI parent = lookupParent(getFqn(), ctx, dataContainer);
- parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ parent.addChildDirect(nf.createNodeInvocationDelegate(node, false));
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -25,4 +25,10 @@
{
c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
}
+
+ @Override
+ public void testInvalidations() throws Exception
+ {
+ // TODO: Think about how this test should be written for MVCC
+ }
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java 2008-07-14 10:53:05 UTC (rev 6254)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java 2008-07-14 12:55:41 UTC (rev 6255)
@@ -25,4 +25,10 @@
{
c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
}
+
+ @Override
+ public void testInvalidations() throws Exception
+ {
+ // TODO: Think about how this test should be written for MVCC
+ }
}
17 years, 5 months
JBoss Cache SVN: r6254 - core/trunk/src/main/java/org/jboss/cache/mvcc.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-14 06:53:05 -0400 (Mon, 14 Jul 2008)
New Revision: 6254
Modified:
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
Log:
Corrected version skew check not using data versions.
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 08:21:45 UTC (rev 6253)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 10:53:05 UTC (rev 6254)
@@ -6,7 +6,7 @@
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContext;
-import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.optimistic.DataVersioningException;
/**
@@ -33,11 +33,10 @@
changed = true;
// check for write skew.
- NodeSPI underlyingNode = container.peek(fqn, false, true); // even check for invalid nodes. we should check tombstones too.
- DataVersion underlyingNodeVersion = underlyingNode == null ? null : underlyingNode.getVersion();
+ NodeInvocationDelegate underlyingNode = (NodeInvocationDelegate) container.peek(fqn, false, true); // even check for invalid nodes. we should check tombstones too.
// TODO: See if data versions are even needed in the first place!!
//if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
- if (!allowWriteSkew && underlyingNode != null && underlyingNode != node)
+ if (!allowWriteSkew && underlyingNode != null && underlyingNode.getDelegationTarget() != node)
{
String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Another process has changed the node since we last read it!").toString();
if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for update.");
17 years, 5 months
JBoss Cache SVN: r6253 - in core/trunk/src: main/resources and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-14 04:21:45 -0400 (Mon, 14 Jul 2008)
New Revision: 6253
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/trunk/src/main/resources/all-elements-file-3.x.xml
core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
core/trunk/src/main/resources/config-samples/eviction-enabled.xml
core/trunk/src/main/resources/config-samples/optimistically-locked.xml
core/trunk/src/main/resources/config2to3.xslt
core/trunk/src/main/resources/jbosscache-config-3.0.xsd
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/resources/configs/clonable-config.xml
core/trunk/src/test/resources/configs/local-lru-eviction.xml
core/trunk/src/test/resources/configs/local-passivation.xml
core/trunk/src/test/resources/configs/local-tx.xml
core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
core/trunk/src/test/resources/configs/parser-test.xml
core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
core/trunk/src/test/resources/configs/string-property-replaced.xml
core/trunk/src/test/resources/jbc2-registry-configs.xml
core/trunk/src/test/resources/unit-test-cache-service.xml
Log:
changed the way eviction is configured
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-07-14 08:21:45 UTC (rev 6253)
@@ -1,10 +1,7 @@
package org.jboss.cache.config.parsing.element;
import org.jboss.cache.RegionManagerImpl;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
+import org.jboss.cache.config.*;
import org.jboss.cache.config.parsing.ParsedAttributes;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.XmlParserBase;
@@ -32,13 +29,22 @@
{
EvictionConfig evictionConfig = new EvictionConfig();
String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
- if (existsAttribute(wakeUpInterval)) evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
+ if (existsAttribute(wakeUpInterval))
+ {
+ evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
+ }
+ else
+ {
+ throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
+ }
- Element element = getSingleElement("defaults", evictionElement);
- processDefaults(evictionConfig, element);
+ String defaultPolicyClassStr = getAttributeValue(evictionElement, "defaultPolicyClass");
+ if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefaultEvictionPolicyClass(defaultPolicyClassStr);
+ String defaultEventQueueSize = getAttributeValue(evictionElement, "defaultEventQueueSize");
+ if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>(3);
- Element rootRegion = getSingleElement("root", evictionElement);
+ Element rootRegion = getSingleElement("default", evictionElement);
String defaultPolicyClass = evictionConfig.getDefaultEvictionPolicyClass();
int defaultEvQueueSize = evictionConfig.getDefaultEventQueueSize();
if (rootRegion != null)
@@ -59,15 +65,6 @@
return evictionConfig;
}
- private void processDefaults(EvictionConfig evictionConfig, Element element)
- {
- if (element == null) return;
- String policyClass = getAttributeValue(element, "policyClass");
- if (existsAttribute(policyClass)) evictionConfig.setDefaultEvictionPolicyClass(policyClass);
- String eventQueueSize = getAttributeValue(element, "eventQueueSize");
- if (existsAttribute(eventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(eventQueueSize));
- }
-
private EvictionRegionConfig getEvictionRegionConfig(Element element, String defaultPolicyClass, int defaultEventQueueSize)
{
EvictionRegionConfig erc = new EvictionRegionConfig();
Modified: core/trunk/src/main/resources/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -60,13 +60,12 @@
</jgroupsConfig>
</transport>
- <eviction wakeUpInterval="5">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
<attribute name="timeToLive">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -3,12 +3,11 @@
xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="mvcc"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">3</attribute>
- </root>
+ </default>
<region name="/org/jboss/test/data">
<attribute name="maxNodes">100</attribute>
<attribute name="timeToLiveSeconds">3</attribute>
Modified: core/trunk/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -3,12 +3,11 @@
xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="mvcc"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
Modified: core/trunk/src/main/resources/config-samples/optimistically-locked.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/optimistically-locked.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/config-samples/optimistically-locked.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -4,13 +4,12 @@
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" nodeLockingScheme="optimistic"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval fetchInMemoryState="false"/>
- <eviction wakeUpInterval="1000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy"/>
- <root>
+ <eviction wakeUpInterval="1000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy">
+ <default>
<attribute name="maxNodes">10</attribute>
<attribute name="timeToLiveSeconds">0</attribute>
<attribute name="maxAgeSeconds">0</attribute>
- </root>
+ </default>
<region name="/testingRegion">
<attribute name="maxNodes">10</attribute>
<attribute name="timeToLiveSeconds">0</attribute>
Modified: core/trunk/src/main/resources/config2to3.xslt
===================================================================
--- core/trunk/src/main/resources/config2to3.xslt 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/config2to3.xslt 2008-07-14 08:21:45 UTC (rev 6253)
@@ -272,22 +272,18 @@
select="concat(normalize-space(./config/attribute[@name='wakeUpIntervalSeconds']), '000')"/>
</xsl:attribute>
</xsl:if>
- <xsl:if test="./config/attribute[@name='policyClass'] | ./config/attribute[@name='policyClass']">
- <defaults>
- <xsl:if test="./config/attribute[@name='policyClass']">
- <xsl:attribute name="policyClass">
- <xsl:value-of select="normalize-space(./config/attribute[@name='policyClass'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./config/attribute[@name='eventQueueSize']">
- <xsl:attribute name="eventQueueSize">
- <xsl:value-of select="normalize-space(./config/attribute[@name='eventQueueSize'])"/>
- </xsl:attribute>
- </xsl:if>
- </defaults>
+ <xsl:if test="./config/attribute[@name='policyClass']">
+ <xsl:attribute name="defaultPolicyClass">
+ <xsl:value-of select="normalize-space(./config/attribute[@name='policyClass'])"/>
+ </xsl:attribute>
</xsl:if>
+ <xsl:if test="./config/attribute[@name='eventQueueSize']">
+ <xsl:attribute name="defaultEventQueueSize">
+ <xsl:value-of select="normalize-space(./config/attribute[@name='eventQueueSize'])"/>
+ </xsl:attribute>
+ </xsl:if>
<xsl:if test="./config/region[@name='/_default_']">
- <root>
+ <default>
<xsl:if test="./config/region[@name='/_default_' and string-length(@policyClass) > 0]">
<xsl:attribute name="policyClass">
<xsl:value-of
@@ -295,7 +291,7 @@
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="./config/region[@name='/_default_']/*"/>
- </root>
+ </default>
</xsl:if>
<xsl:for-each select="./config/region[@name!='/_default_']">
<region>
Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-07-14 08:21:45 UTC (rev 6253)
@@ -153,16 +153,12 @@
<xs:complexType name="evictionType">
<xs:sequence>
- <xs:element name="defaults" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="policyClass" type="xs:string"/>
- <xs:attribute name="eventQueueSize" type="positiveInteger"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="root" type="evictionRegionType" minOccurs="0"/>
+ <xs:element name="default" type="evictionRegionType" minOccurs="0"/>
<xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="evictionRegionType"/>
</xs:sequence>
- <xs:attribute name="wakeUpInterval" type="positiveInteger"/>
+ <xs:attribute name="wakeUpInterval" type="positiveInteger" use="required"/>
+ <xs:attribute name="defaultPolicyClass" type="xs:string"/>
+ <xs:attribute name="defaultEventQueueSize" type="positiveInteger"/>
</xs:complexType>
<xs:complexType name="evictionRegionType">
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-14 08:21:45 UTC (rev 6253)
@@ -46,12 +46,11 @@
public void testNormalConfig()
{
String xml =
- " <eviction wakeUpInterval=\"5\">\n" +
- " <defaults policyClass=\"org.jboss.cache.eviction.MRUPolicy\" eventQueueSize=\"123456\"/>\n" +
- " <root>\n" +
+ " <eviction wakeUpInterval=\"5\" defaultPolicyClass=\"org.jboss.cache.eviction.MRUPolicy\" defaultEventQueueSize=\"123456\">\n" +
+ " <default>\n" +
" <attribute name=\"maxNodes\">6</attribute>\n" +
" <attribute name=\"minTimeToLive\">7</attribute>\n" +
- " </root>\n" +
+ " </default>\n" +
" <region name=\"/org/jboss/data\">\n" +
" <attribute name=\"minTimeToLive\">1002</attribute>\n" +
" <attribute name=\"maxNodes\">2021</attribute>\n" +
@@ -95,13 +94,12 @@
public void testLruConfig()
{
String xml =
- " <eviction wakeUpInterval=\"45000\">\n" +
- " <defaults policyClass=\"org.jboss.cache.eviction.LRUPolicy\" eventQueueSize=\"4\"/>\n" +
- " <root>\n" +
+ " <eviction wakeUpInterval=\"45000\" defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"4\">\n" +
+ " <default>\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000000</attribute>\n" +
" <attribute name=\"maxAge\">15000</attribute>\n" +
- " </root>\n" +
+ " </default>\n" +
" <region name=\"/fifo\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000000</attribute>\n" +
@@ -155,7 +153,7 @@
public void testMissingPolicyOnRegion()
{
String xml =
- " <eviction defaultPolicyClass=\"org.jboss.cache.eviction.LRUPolicy\" defaultEventQueueSize=\"200000\">\n" +
+ " <eviction defaultEventQueueSize=\"200000\" wakeUpInterval=\"5000\">\n" +
" <region name=\"/org/jboss/data\">\n" +
" <attribute name=\"timeToLive\">1002</attribute>\n" +
" </region>\n" +
@@ -189,10 +187,10 @@
{
String xml =
" <eviction wakeUpInterval=\"5000\">\n" +
- " <root>\n" +
+ " <default>\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLive\">1000</attribute>\n" +
- " </root>\n" +
+ " </default>\n" +
" <region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.LFUPolicy\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"minNodes\">1000</attribute>\n" +
Modified: core/trunk/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/trunk/src/test/resources/configs/clonable-config.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/clonable-config.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -44,13 +44,12 @@
</locator>
</buddy>
</replication>
- <eviction wakeUpInterval="45000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="4"/>
- <root>
+ <eviction wakeUpInterval="45000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="4">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
<attribute name="maxAge">15000</attribute>
- </root>
+ </default>
<region name="/fifo" policyClass="org.jboss.cache.eviction.FIFOPolicy">
<attribute name="maxNodes">5000</attribute>
</region>
Modified: core/trunk/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -6,12 +6,11 @@
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
Modified: core/trunk/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-passivation.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/local-passivation.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -6,12 +6,11 @@
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
- <eviction wakeUpInterval="1000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="1000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1</attribute>
- </root>
+ </default>
<region name="/org/jboss/test/data">
<attribute name="maxNodes">100</attribute>
<attribute name="timeToLiveSeconds">1</attribute>
Modified: core/trunk/src/test/resources/configs/local-tx.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-tx.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/local-tx.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -7,12 +7,11 @@
<serialization useRegionBasedMarshalling="false"/>
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
Modified: core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -34,12 +34,11 @@
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.FIFOPolicy">
<attribute name="maxNodes">5000</attribute>
</region>
Modified: core/trunk/src/test/resources/configs/parser-test.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/parser-test.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -2,8 +2,8 @@
<!-- file used for functional test of the xml parser -->
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
@@ -58,12 +58,11 @@
<jmxStatistics enabled="false"/>
- <eviction wakeUpInterval="5">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy" eventQueueSize="200000"/>
- <root>
+ <eviction wakeUpInterval="5" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
@@ -82,7 +81,7 @@
<!-- we can now have multiple cache loaders, which get chained -->
<loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"
- ignoreModifications="true" purgeOnStartup="true">
+ ignoreModifications="true" purgeOnStartup="true">
<properties>
cache.jdbc.table.name=jbosscache
cache.jdbc.table.create=true
Modified: core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -35,10 +35,10 @@
</transport>
<eviction wakeUpInterval="5000">
- <root policyClass="org.jboss.cache.eviction.LRUPolicy">
+ <default policyClass="org.jboss.cache.eviction.LRUPolicy">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.LFUPolicy">
<attribute name="maxNodes">5000</attribute>
<attribute name="minNodes">1000</attribute>
Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -23,12 +23,11 @@
</locator>
</buddy>
</replication>
- <eviction wakeUpInterval="5000">
- <defaults policyClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.cache.eviction.LRUPolicy}"/>
- <root>
+ <eviction wakeUpInterval="5000" defaultPolicyClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.cache.eviction.LRUPolicy}">
+ <default>
<attribute name="maxNodes">${test.property.EvictionPolicyConfig.maxNodes:5000}</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
</eviction>
<loaders passivation="true" shared="false">
<preload>
Modified: core/trunk/src/test/resources/jbc2-registry-configs.xml
===================================================================
(Binary files differ)
Modified: core/trunk/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-07-11 20:15:20 UTC (rev 6252)
+++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-07-14 08:21:45 UTC (rev 6253)
@@ -11,12 +11,11 @@
<replication>
<sync replTimeout="15000"/>
</replication>
- <eviction wakeUpInterval="2000">
- <defaults policyClass="org.jboss.cache.eviction.LRUPolicy"/>
- <root>
+ <eviction wakeUpInterval="2000" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy">
+ <default>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
- </root>
+ </default>
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLiveSeconds">1000</attribute>
17 years, 5 months
JBoss Cache SVN: r6252 - in core/trunk/src: main/java/org/jboss/cache/eviction and 12 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-11 16:15:20 -0400 (Fri, 11 Jul 2008)
New Revision: 6252
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
Log:
removed refrences to deprecated API (seconds based setters/getters) from surce code and tests
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -367,7 +367,7 @@
wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
}
- ec.setWakeupIntervalSeconds(wakeupIntervalSeconds);
+ ec.setWakeupInterval(wakeupIntervalSeconds * 1000);
int eventQueueSize = 0;
temp = XmlConfigHelper.getTagContents(element,
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -567,8 +567,8 @@
if (region.getEvictionPolicyConfig() instanceof EvictionPolicyConfigBase)
{
EvictionPolicyConfigBase cfg = (EvictionPolicyConfigBase) region.getEvictionPolicyConfig();
- int minTTL = cfg.getMinTimeToLiveSeconds();
- return minTTL >= 1 && (entry.getModifiedTimeStamp() + (1000 * minTTL) > System.currentTimeMillis());
+ long minTTL = cfg.getMinTimeToLive();
+ return minTTL >= 1 && (entry.getModifiedTimeStamp() + minTTL > System.currentTimeMillis());
}
else
{
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -23,7 +23,7 @@
* nodes with expiration keys set, a warning is logged.
* <p/>
* If a node in the eviction region does not have an expiration value, then
- * {@link ExpirationConfiguration#getTimeToLiveSeconds} (if set) will be used.
+ * {@link org.jboss.cache.eviction.ExpirationConfiguration#getTimeToLive()} (if set) will be used.
* The expiration is updated when a node is added or updated.
* <p/>
* If there is no time-to-live set, and a node in the eviction region does not
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -40,36 +40,36 @@
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
// no idle or max time limit
- if (config.getTimeToLiveSeconds() == 0 && config.getMaxAgeSeconds() == 0) return false;
+ if (config.getTimeToLive() == 0 && config.getMaxAge() == 0) return false;
long currentTime = System.currentTimeMillis();
- if (config.getTimeToLiveSeconds() != 0)
+ if (config.getTimeToLive() != 0)
{
long idleTime = currentTime - entry.getModifiedTimeStamp();
if (trace)
{
log.trace("Node " + entry.getFqn() + " has been idle for " + idleTime + "ms");
}
- if ((idleTime >= (config.getTimeToLiveSeconds() * 1000)))
+ if ((idleTime >= (config.getTimeToLive())))
{
if (trace)
{
log.trace("Node " + entry.getFqn() + " should be evicted because of idle time");
- log.trace("Time to live in millies is: " + (config.getTimeToLiveSeconds() * 1000));
+ log.trace("Time to live in millies is: " + (config.getTimeToLive()));
log.trace("Config instance is: " + System.identityHashCode(config));
}
return true;
}
}
- if (config.getMaxAgeSeconds() != 0)
+ if (config.getMaxAge() != 0)
{
long objectLifeTime = currentTime - entry.getCreationTimeStamp();
if (trace)
{
log.trace("Node " + entry.getFqn() + " has been alive for " + objectLifeTime + "ms");
}
- if ((objectLifeTime >= (config.getMaxAgeSeconds() * 1000)))
+ if ((objectLifeTime >= config.getMaxAge()))
{
if (trace)
{
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -119,6 +119,7 @@
/**
* Use {@link #getMaxAge()}
+ * @deprecated
*/
@Deprecated
public int getMaxAgeSeconds()
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -38,7 +38,7 @@
Configuration cacheConfig = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
cacheConfig.setCacheMode(Configuration.CacheMode.LOCAL);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(cacheConfig, false);
- cache.getConfiguration().getEvictionConfig().setWakeupIntervalSeconds(1);
+ cache.getConfiguration().getEvictionConfig().setWakeupInterval(1000);
createNewRegion();
cache.start();
evController = new EvictionController(cache);
@@ -54,8 +54,8 @@
evRegConfig.setRegionFqn(Fqn.fromString("/" + TEST_NODES_ROOT));
evRegConfig.setEventQueueSize(100);
LRUConfiguration lruConfig = new LRUConfiguration();
- lruConfig.setMaxAgeSeconds(100000);
- lruConfig.setTimeToLiveSeconds(100000);
+ lruConfig.setMaxAge(100000000);
+ lruConfig.setTimeToLive(100000000);
lruConfig.setMaxNodes(3);
evRegConfig.setEvictionPolicyConfig(lruConfig);
evConfig.getEvictionRegionConfigs().add(evRegConfig);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -343,12 +343,12 @@
private void configureEviction(Configuration cfg)
{
EvictionConfig ec = new EvictionConfig();
- ec.setWakeupIntervalSeconds(1);
+ ec.setWakeupInterval(1000);
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionName("/_default_");
LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxAgeSeconds(2);
- epc.setTimeToLiveSeconds(1);
+ epc.setMaxAge(2000);
+ epc.setTimeToLive(1000);
epc.setMaxNodes(1);
erc.setEvictionPolicyConfig(epc);
List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -48,10 +48,10 @@
{
EvictionConfig c = new EvictionConfig();
c.setDefaultEvictionPolicyClass(NullEvictionPolicy.class.getName());
- c.setWakeupIntervalSeconds(1);
+ c.setWakeupInterval(1000);
LRUConfiguration epc = new LRUConfiguration();
- epc.setMaxAgeSeconds(1);
- epc.setTimeToLiveSeconds(1);
+ epc.setMaxAge(1000);
+ epc.setTimeToLive(1000);
EvictionRegionConfig erc = new EvictionRegionConfig(fqn, epc);
c.setEvictionRegionConfigs(Collections.singletonList(erc));
return c;
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -57,7 +57,7 @@
assertFalse(ec1 == ec2);
assertEquals(4, ec2.getDefaultEventQueueSize());
- assertEquals(45, ec2.getWakeupIntervalSeconds());
+ assertEquals(45000, ec2.getWakeupInterval());
assertEquals(LRUPolicy.class.getName(), ec2.getDefaultEvictionPolicyClass());
List<EvictionRegionConfig> ercs1 = ec1.getEvictionRegionConfigs();
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -119,7 +119,6 @@
EvictionRegionConfig evictionRegionConfig = evConfig.getEvictionRegionConfigs().get(0);
assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl.DEFAULT_REGION.toString());
assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl.DEFAULT_REGION.toString());
- assert ((LRUConfiguration) evictionRegionConfig.getEvictionPolicyConfig()).getTimeToLiveSeconds() == 1000;
assert ((LRUConfiguration) evictionRegionConfig.getEvictionPolicyConfig()).getTimeToLive() == 1000000;
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -38,7 +38,7 @@
public class ConcurrentEvictionTest
{
private Cache<Integer, String> cache_;
- private int wakeupIntervalMillis_ = 0;
+ private long wakeupIntervalMillis_ = 0;
private String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
private String cacheLoaderDir = "/JBossCacheFileCacheLoader";
@@ -46,7 +46,7 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupInterval();
if (wakeupIntervalMillis_ < 0)
{
fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
@@ -88,9 +88,9 @@
{
EvictionConfig ec = new EvictionConfig("org.jboss.cache.eviction.LRUPolicy");
ec.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
- ec.setWakeupIntervalSeconds(5);
+ ec.setWakeupInterval(5000);
- EvictionRegionConfig erc = UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("_default_", 5000, 1000);
+ EvictionRegionConfig erc = UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("_default_", 5000, 1000000);
List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
erConfigs.add(erc);
ec.setEvictionRegionConfigs(erConfigs);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -32,7 +32,7 @@
public class ElementSizePolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
final long DURATION = 10000;
@@ -42,7 +42,7 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis < 0)
{
@@ -58,7 +58,7 @@
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = conf.getEvictionConfig();
evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.ElementSizePolicy");
- evConfig.setWakeupIntervalSeconds(3);
+ evConfig.setWakeupInterval(3000);
evConfig.setDefaultEventQueueSize(200000);
List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -32,7 +32,7 @@
public void testPolicyPerRegion() throws Exception
{
this.setupCache("configs/policyPerRegion-eviction.xml");
- assertEquals(5, cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds());
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
Region region = regionManager.getRegion("/org/jboss/data", true);
EvictionPolicy policy = region.getEvictionPolicy();
@@ -66,8 +66,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(10, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
// test the default region. use a region name that isn't defined explicitly in conf file.
region = regionManager.getRegion("/a/b/c", false);
@@ -77,8 +77,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
cache.stop();
}
@@ -86,7 +86,7 @@
public void testMixedPolicies() throws Exception
{
this.setupCache("configs/mixedPolicy-eviction.xml");
- assertEquals(5, cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds());
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
Region region = regionManager.getRegion("/org/jboss/data", true);
EvictionPolicy policy = region.getEvictionPolicy();
@@ -112,8 +112,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
region = regionManager.getRegion("/maxAgeTest", false);
policy = region.getEvictionPolicy();
@@ -122,8 +122,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(10, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
cache.stop();
}
@@ -131,7 +131,7 @@
public void testLegacyPolicyConfiguration() throws Exception
{
this.setupCache("configs/local-lru-eviction.xml");
- assertEquals(5, cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds());
+ assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());
Region region = regionManager.getRegion("/org/jboss/data", false);
EvictionPolicy policy = region.getEvictionPolicy();
@@ -140,7 +140,7 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
+ assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
region = regionManager.getRegion("/org/jboss/test/data", false);
policy = region.getEvictionPolicy();
@@ -149,7 +149,7 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(5, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(4, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
+ assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive());
region = regionManager.getRegion("/test", true);
policy = region.getEvictionPolicy();
@@ -158,7 +158,7 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(4, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
+ assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive());
region = regionManager.getRegion("/maxAgeTest", true);
policy = region.getEvictionPolicy();
@@ -167,8 +167,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(8, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(10, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge());
// test the default region. use a region name that isn't defined explicitly in conf file.
region = regionManager.getRegion("/a/b/c", false);
@@ -178,8 +178,8 @@
assertTrue(policy instanceof LRUPolicy);
assertTrue(configuration instanceof LRUConfiguration);
assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes());
- assertEquals(1000, ((LRUConfiguration) configuration).getTimeToLiveSeconds());
- assertEquals(0, ((LRUConfiguration) configuration).getMaxAgeSeconds());
+ assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLive());
+ assertEquals(0, ((LRUConfiguration) configuration).getMaxAge());
cache.stop();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -47,7 +47,7 @@
{
Configuration conf = new Configuration();
EvictionConfig econf = new EvictionConfig(ExpirationPolicy.class.getName());
- econf.setWakeupIntervalSeconds(1);
+ econf.setWakeupInterval(1000);
conf.setEvictionConfig(econf);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(conf, false);
cache.start();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -34,7 +34,7 @@
public class FIFOPolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
final long DURATION = 10000;
@@ -44,7 +44,7 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis < 0)
{
@@ -59,7 +59,7 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupIntervalSeconds(3);
+ evConfig.setWakeupInterval(3000);
evConfig.setDefaultEventQueueSize(20000);
evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.FIFOPolicy");
List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
@@ -181,7 +181,7 @@
}
}
- int period = wakeupIntervalMillis + 500;
+ long period = wakeupIntervalMillis + 500;
log("sleeping for " + period + "ms");
EvictionController evictionController = new EvictionController(cache);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -33,7 +33,7 @@
public class LFUPolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
final long DURATION = 10000;
@@ -43,7 +43,7 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis < 0)
{
@@ -58,7 +58,7 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupIntervalSeconds(3);
+ evConfig.setWakeupInterval(3000);
evConfig.setDefaultEventQueueSize(200000);
List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
erConfigs.add(createEvictionRegionConfig("/_default_",500,10));
@@ -149,7 +149,7 @@
}
}
- int period = wakeupIntervalMillis + 500;
+ long period = wakeupIntervalMillis + 500;
log("sleeping for " + period + "ms");
TestingUtil.sleepThread(period);// it really depends the eviction thread time.
@@ -252,7 +252,7 @@
}
}
- int period = (wakeupIntervalMillis + 500);
+ long period = (wakeupIntervalMillis + 500);
log("period is " + period);
TestingUtil.sleepThread(period);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -123,7 +123,7 @@
Region region = regionManager.getRegion("/a/b", true);
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(0);
+ config.setTimeToLive(0);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
@@ -145,7 +145,7 @@
Region region = regionManager.getRegion("/a/b", true);
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(1);
+ config.setTimeToLive(1000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
@@ -171,7 +171,7 @@
Region region = regionManager.getRegion("/a/b", true);
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(1);
+ config.setTimeToLive(1000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
@@ -199,8 +199,8 @@
Region region = regionManager.getRegion("/a/b", true);
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(0);
- config.setMaxAgeSeconds(1);
+ config.setTimeToLive(0);
+ config.setMaxAge(1000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
@@ -226,8 +226,8 @@
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(0);
- config.setMaxAgeSeconds(1);
+ config.setTimeToLive(0);
+ config.setMaxAge(1000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
@@ -256,8 +256,8 @@
// Should have a maximum of 2 nodes.
config.setMaxNodes(2);
- config.setTimeToLiveSeconds(1);
- config.setMaxAgeSeconds(3);
+ config.setTimeToLive(1000);
+ config.setMaxAge(3000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NODE_EVENT));
@@ -301,8 +301,8 @@
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
config.setMaxNodes(2);
- config.setTimeToLiveSeconds(1);
- config.setMaxAgeSeconds(3);
+ config.setTimeToLive(1000);
+ config.setMaxAge(3000);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.REMOVE_NODE_EVENT));
@@ -336,9 +336,9 @@
Region region = regionManager.getRegion("/a/b", true);
LRUConfiguration config = (LRUConfiguration) region.getEvictionPolicyConfig();
- config.setMaxAgeSeconds(1000);
+ config.setMaxAge(1000000);
config.setMaxNodes(0);
- config.setTimeToLiveSeconds(1000);
+ config.setTimeToLive(1000000);
for (int i = 0; i < 100; i++)
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -39,7 +39,7 @@
EvictionElementParser.parseEvictionPolicyConfig(element, config);
assertEquals(5000, config.getMaxNodes());
- assertEquals(1000, config.getTimeToLiveSeconds());
+ assertEquals(1000000, config.getTimeToLive());
}
public void testXMLParsing2() throws Exception
@@ -55,8 +55,8 @@
EvictionElementParser.parseEvictionPolicyConfig(element, config);
assertEquals(10000, config.getMaxNodes());
- assertEquals(8, config.getTimeToLiveSeconds());
- assertEquals(10, config.getMaxAgeSeconds());
+ assertEquals(8000, config.getTimeToLive());
+ assertEquals(10000, config.getMaxAge());
}
public void testXMLParsing3() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -27,9 +27,9 @@
public class LRUPolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis_ = 0;
- int dataRegionTTLMillis = 6000;
- int testRegionTTLMillis = 4000;
+ long wakeupIntervalMillis = 0;
+ long dataRegionTTLMillis = 6000;
+ long testRegionTTLMillis = 4000;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
@@ -41,20 +41,20 @@
{
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = conf.getEvictionConfig();
- evConfig.setWakeupIntervalSeconds(1);
+ evConfig.setWakeupInterval(1000);
List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/org/jboss/test/data", 5, dataRegionTTLMillis / 1000));
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/test", 10000, testRegionTTLMillis / 1000));
+ regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/org/jboss/test/data", 5, dataRegionTTLMillis));
+ regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/test", 10000, testRegionTTLMillis));
evConfig.setEvictionRegionConfigs(regionConfigs);
conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
conf.setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf);
- wakeupIntervalMillis_ = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- System.out.println("-- wakeupInterval is " + wakeupIntervalMillis_);
- if (wakeupIntervalMillis_ < 0)
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
+ System.out.println("-- wakeupInterval is " + wakeupIntervalMillis);
+ if (wakeupIntervalMillis < 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
t1_ex = t2_ex = null;
@@ -89,7 +89,7 @@
cache.put(fqn, str, str);
}
- TestingUtil.sleepThread(wakeupIntervalMillis_ + 500);
+ TestingUtil.sleepThread(wakeupIntervalMillis + 500);
for (int i = 0; i < 5; i++)
{
@@ -129,7 +129,7 @@
}
}
System.out.println(cache.toString());
- TestingUtil.sleepThread(wakeupIntervalMillis_ + 500);
+ TestingUtil.sleepThread(wakeupIntervalMillis + 500);
System.out.println(cache.toString());
String val = (String) cache.get(rootStr + "3", rootStr + "3");
assertNull("Node should be empty ", val);
@@ -148,7 +148,7 @@
cache.put(fqn, str, str);
}
- int period = (wakeupIntervalMillis_ / 2 + 500);
+ long period = (wakeupIntervalMillis / 2 + 500);
System.out.println("-- sleeping for " + period + "ms");
TestingUtil.sleepThread(period);
String str = rootStr + "7";
@@ -165,7 +165,7 @@
val = (String) cache.get(rootStr + "7", rootStr + "7");
System.out.println("-- val=" + val);
assertNotNull("Node should not be empty ", val);
- period = dataRegionTTLMillis + wakeupIntervalMillis_ + 500; // this is the TTL for nodes + time for the eviction thread to kick in
+ period = dataRegionTTLMillis + wakeupIntervalMillis + 500; // this is the TTL for nodes + time for the eviction thread to kick in
System.out.println("-- sleeping for " + period + "ms");
TestingUtil.sleepThread(period);
val = (String) cache.get(rootStr + "7", rootStr + "7");
@@ -183,7 +183,7 @@
cache.put(fqn, str, str);
}
- int period = (wakeupIntervalMillis_ / 2 + 500);
+ long period = (wakeupIntervalMillis / 2 + 500);
System.out.println("-- period is " + period);
// TestingUtil.sleepThread(period); // it really depends the eviction thread time.
String str1 = rootStr + "7";
@@ -199,7 +199,7 @@
String val = (String) cache.get(rootStr + "7/7", rootStr + "7/7");
assertNotNull("Node should not be empty ", val);
cache.removeNode(fqn1);
- TestingUtil.sleepThread(wakeupIntervalMillis_ + 500);
+ TestingUtil.sleepThread(wakeupIntervalMillis + 500);
val = (String) cache.get(rootStr + "7/7", rootStr + "7/7");
assertNull("Node should be empty ", val);
}
@@ -216,7 +216,7 @@
// Give eviction time to run a few times, then confirm parent
// is completely gone
- int period = (wakeupIntervalMillis_ + testRegionTTLMillis) * 2;
+ long period = (wakeupIntervalMillis + testRegionTTLMillis) * 2;
System.out.println("-- Sleeping for " + period);
TestingUtil.sleepThread(period);
assertFalse("Parent not completely removed", cache.getRoot().hasChild(parent));
@@ -304,7 +304,7 @@
}
// wait for an eviction
- TestingUtil.sleepThread(2 * (wakeupIntervalMillis_ + testRegionTTLMillis));
+ TestingUtil.sleepThread(2 * (wakeupIntervalMillis + testRegionTTLMillis));
String val = (String) cache.get(rootStr + "3", rootStr + "3");
assertNull("Node should be empty ", val);
@@ -321,7 +321,7 @@
cache.removeNode(Fqn.ROOT);
// wait for an eviction
- TestingUtil.sleepThread(2 * wakeupIntervalMillis_ + 1000);
+ TestingUtil.sleepThread(2 * wakeupIntervalMillis + 1000);
val = (String) cache.get(rootStr + "3", rootStr + "3");
assertNull("Node should be empty ", val);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -32,7 +32,7 @@
public class MRUPolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
final long DURATION = 10000;
@@ -42,7 +42,7 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis < 0)
{
@@ -63,7 +63,7 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupIntervalSeconds(3);
+ evConfig.setWakeupInterval(3000);
evConfig.setDefaultEventQueueSize(200000);
evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.MRUPolicy");
List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -60,13 +60,13 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
EvictionConfig evConfig = config.getEvictionConfig();
- evConfig.setWakeupIntervalSeconds(1);
+ evConfig.setWakeupInterval(1000);
evConfig.setDefaultEventQueueSize(200000);
evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.NullEvictionPolicy");
List<EvictionRegionConfig> regionConfigs = new ArrayList<EvictionRegionConfig>();
regionConfigs.add(buildEvictionRegionConfig("/_default_"));
regionConfigs.add(buildEvictionRegionConfig("/test"));
- regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/lru", 10000,1));
+ regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("/lru", 10000,1000));
evConfig.setEvictionRegionConfigs(regionConfigs);
config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -52,13 +52,13 @@
public class ProgrammaticLRUPolicyTest
{
CacheSPI<Object, Object> cache;
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis < 0)
{
@@ -72,7 +72,7 @@
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
CacheFactory<Object, Integer> instance = new DefaultCacheFactory();
cache = (CacheSPI) instance.createCache(conf, false);
- conf.getEvictionConfig().setWakeupIntervalSeconds(5);
+ conf.getEvictionConfig().setWakeupInterval(5000);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -22,7 +22,7 @@
public class ReplicatedLRUPolicyTest
{
CacheSPI<Object, Object> cache_, cache1_, cache2_;
- int wakeupIntervalMillis_ = 0;
+ long wakeupIntervalMillis = 0;
EvictionListener listener_ = new EvictionListener();
@BeforeMethod(alwaysRun = true)
@@ -40,11 +40,11 @@
cache2_.getConfiguration().setUseRegionBasedMarshalling(true);
cache2_.start();
- wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- log("wakeupInterval is " + wakeupIntervalMillis_);
- if (wakeupIntervalMillis_ <= 0)
+ wakeupIntervalMillis = cache_.getConfiguration().getEvictionConfig().getWakeupInterval();
+ log("wakeupInterval is " + wakeupIntervalMillis);
+ if (wakeupIntervalMillis <= 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
}
@@ -83,7 +83,7 @@
cache_.put(fqn, str, str);
}
- TestingUtil.sleepThread(2 * wakeupIntervalMillis_);
+ TestingUtil.sleepThread(2 * wakeupIntervalMillis);
String val = (String) cache_.get(rootStr + "3", rootStr + "3");
assertNull("DataNode should be evicted already ", val);
val = (String) cache2_.get(rootStr + "3", rootStr + "3");
@@ -100,11 +100,11 @@
cache_.put(fqn, str, str);
}
- TestingUtil.sleepThread(wakeupIntervalMillis_ - 1000);
+ TestingUtil.sleepThread(wakeupIntervalMillis - 1000);
String str = rootStr + "7";
Fqn fqn = Fqn.fromString(str);
cache_.get(fqn, str);
- TestingUtil.sleepThread(wakeupIntervalMillis_);
+ TestingUtil.sleepThread(wakeupIntervalMillis);
String val = (String) cache_.get(rootStr + "3", rootStr + "3");
assertNull("DataNode should be empty ", val);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -16,7 +16,7 @@
protected EvictionPolicyConfigBase getEvictionPolicyConfig()
{
LRUConfiguration cfg = new LRUConfiguration();
- cfg.setTimeToLiveSeconds(1);
+ cfg.setTimeToLive(1000);
return cfg;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -54,7 +54,7 @@
// cache-wide
EvictionConfig ec = new EvictionConfig();
- ec.setWakeupIntervalSeconds(1);
+ ec.setWakeupInterval(1000);
ec.setEvictionRegionConfigs(evictionRegionConfigs);
cache = new DefaultCacheFactory().createCache(false);
@@ -83,7 +83,7 @@
public void testWithMinimumTTL()
{
- ((EvictionPolicyConfigBase) cache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs().get(0).getEvictionPolicyConfig()).setMinTimeToLiveSeconds(3);
+ ((EvictionPolicyConfigBase) cache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs().get(0).getEvictionPolicyConfig()).setMinTimeToLive(3000);
cache.start();
cache.put(fqn, "k", "v");
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -160,14 +160,14 @@
}
- public static EvictionRegionConfig buildLruEvictionRegionConfig(String regionNaame, int maxNodes, int timeToLive)
+ public static EvictionRegionConfig buildLruEvictionRegionConfig(String regionNaame, int maxNodes, long timeToLive)
{
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionName(regionNaame);
LRUConfiguration lruConfig = new LRUConfiguration();
lruConfig.setEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
if (maxNodes >= 0) lruConfig.setMaxNodes(maxNodes);
- if (timeToLive >= 0) lruConfig.setTimeToLiveSeconds(timeToLive);
+ if (timeToLive >= 0) lruConfig.setTimeToLive(timeToLive);
erc.setEvictionPolicyConfig(lruConfig);
return erc;
}
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -41,7 +41,7 @@
// the FIFO policy cfg
FIFOConfiguration cfg = new FIFOConfiguration();
cfg.setMaxNodes(1);
- cfg.setMinTimeToLiveSeconds(0);
+ cfg.setMinTimeToLive(0);
// the region configuration
EvictionRegionConfig regionCfg = new EvictionRegionConfig();
@@ -55,7 +55,7 @@
EvictionConfig ec = new EvictionConfig();
- ec.setWakeupIntervalSeconds(2);
+ ec.setWakeupInterval(2000);
ec.setEvictionRegionConfigs(evictionRegionConfigs);
c1.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -172,7 +172,7 @@
assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toString(), wrapper.getEvictionPolicyConfig().toString());
EvictionConfig ec = c.getEvictionConfig();
assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize());
- assertEquals("EC wakeup", 5, ec.getWakeupIntervalSeconds());
+ assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefaultEvictionPolicyClass());
List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
EvictionRegionConfig erc = ercs.get(0);
@@ -181,7 +181,7 @@
LRUConfiguration lru = (LRUConfiguration) erc.getEvictionPolicyConfig();
assertEquals("EPC0 pol", LRUPolicy.class.getName(), lru.getEvictionPolicyClass());
assertEquals("EPC0 maxnodes", 5000, lru.getMaxNodes());
- assertEquals("EPC0 ttl", 1000, lru.getTimeToLiveSeconds());
+ assertEquals("EPC0 ttl", 1000000, lru.getTimeToLive());
erc = ercs.get(1);
assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName());
assertEquals("ERC1 queue size", 20000, erc.getEventQueueSize());
@@ -200,8 +200,8 @@
lru = (LRUConfiguration) erc.getEvictionPolicyConfig();
assertEquals("EPC3 pol", LRUPolicy.class.getName(), lru.getEvictionPolicyClass());
assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
- assertEquals("EPC3 maxage", 10, lru.getMaxAgeSeconds());
- assertEquals("EPC3 ttl", 8, lru.getTimeToLiveSeconds());
+ assertEquals("EPC3 maxage", 10000, lru.getMaxAge());
+ assertEquals("EPC3 ttl", 8000, lru.getTimeToLive());
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -111,13 +111,13 @@
EvictionConfig ec = new EvictionConfig();
ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
- ec.setWakeupIntervalSeconds(1000); // a long time; really disabled
+ ec.setWakeupInterval(1000000); // a long time; really disabled
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionFqn(Fqn.ROOT);
erc.setRegionName("_default_");
LRUConfiguration epc = new LRUConfiguration();
epc.setMaxNodes(1000);
- epc.setTimeToLiveSeconds(1000);
+ epc.setTimeToLive(1000000);
erc.setEvictionPolicyConfig(epc);
List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
ercs.add(erc);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -141,13 +141,13 @@
EvictionConfig ec = new EvictionConfig();
ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
- ec.setWakeupIntervalSeconds(1000); // a long time; really disabled
+ ec.setWakeupInterval(1000000); // a long time; really disabled
EvictionRegionConfig erc = new EvictionRegionConfig();
erc.setRegionFqn(Fqn.ROOT);
erc.setRegionName("_default_");
LRUConfiguration epc = new LRUConfiguration();
epc.setMaxNodes(1000);
- epc.setTimeToLiveSeconds(1000);
+ epc.setTimeToLive(1000000);
erc.setEvictionPolicyConfig(epc);
List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
ercs.add(erc);
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -32,7 +32,7 @@
public class BasicPassivationTest
{
CacheSPI cache;
- int wakeupIntervalMillis_ = 0;
+ long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
Throwable t1_ex, t2_ex;
final long DURATION = 10000;
@@ -45,11 +45,11 @@
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis_ = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- log("wakeupInterval is " + wakeupIntervalMillis_);
- if (wakeupIntervalMillis_ < 0)
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
+ log("wakeupInterval is " + wakeupIntervalMillis);
+ if (wakeupIntervalMillis < 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
t1_ex = t2_ex = null;
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -30,16 +30,16 @@
public class ConcurrentPassivationTest
{
private CacheSPI cache;
- private int wakeupIntervalMillis_ = 0;
+ private long wakeupIntervalMillis = 0;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
initCaches();
- wakeupIntervalMillis_ = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- if (wakeupIntervalMillis_ < 0)
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
+ if (wakeupIntervalMillis < 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
}
@@ -72,9 +72,9 @@
}
// Loop for long enough to have 5 runs of the eviction thread
- long loopDone = System.currentTimeMillis() + (5 * wakeupIntervalMillis_);
+ long loopDone = System.currentTimeMillis() + (5 * wakeupIntervalMillis);
- System.out.println("Initialised; Loop for " + (5 * wakeupIntervalMillis_) + " millis");
+ System.out.println("Initialised; Loop for " + (5 * wakeupIntervalMillis) + " millis");
while (System.currentTimeMillis() < loopDone)
{
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -36,7 +36,7 @@
{
CacheSPI<String, String> cache;
protected final static Log log = LogFactory.getLog(LocalPassivationIntegrationTest.class);
- int wakeupIntervalMillis_ = 0;
+ long wakeupIntervalMillis = 0;
PassivationListener listener_;
private static final int LISTENER_WAIT_TIME = 200; // needed since notifications are delivered asynchronously
@@ -56,11 +56,11 @@
cache.getNotifier().addCacheListener(listener_);
listener_.resetCounter();
- wakeupIntervalMillis_ = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
- log("wakeupInterval is " + wakeupIntervalMillis_);
- if (wakeupIntervalMillis_ <= 0)
+ wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
+ log("wakeupInterval is " + wakeupIntervalMillis);
+ if (wakeupIntervalMillis <= 0)
{
- fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
+ fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -87,7 +87,7 @@
protected void configureEviction() throws Exception
{
EvictionConfig ec = new EvictionConfig();
- ec.setWakeupIntervalSeconds(1);
+ ec.setWakeupInterval(1000);
List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
@@ -95,7 +95,7 @@
erc.setRegionFqn(RegionManagerImpl.DEFAULT_REGION);
LRUConfiguration epc = new LRUConfiguration();
epc.setMaxNodes(0);
- epc.setTimeToLiveSeconds(5);
+ epc.setTimeToLive(5000);
erc.setEvictionPolicyConfig(epc);
ercs.add(erc);
@@ -103,7 +103,7 @@
erc.setRegionFqn(BASE);
epc = new LRUConfiguration();
epc.setMaxNodes(0);
- epc.setTimeToLiveSeconds(1);
+ epc.setTimeToLive(1000);
erc.setEvictionPolicyConfig(epc);
ercs.add(erc);
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -60,7 +60,7 @@
private CacheSPI<String, String> cache1;
private CacheSPI<String, String> cache2;
protected final static Log log = LogFactory.getLog(ReplicatedPassivationIntegrationTest.class);
- int wakeupIntervalMillis = 0;
+ long wakeupIntervalMillis = 0;
PassivationListener listener;
Fqn base = Fqn.fromString("/org/jboss/test/data");
@@ -84,7 +84,7 @@
cache2.getNotifier().addCacheListener(listener);
listener.resetCounter();
- wakeupIntervalMillis = cache2.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis = cache2.getConfiguration().getEvictionConfig().getWakeupInterval();
log("wakeupInterval is " + wakeupIntervalMillis);
if (wakeupIntervalMillis <= 0)
{
@@ -115,7 +115,7 @@
private EvictionConfig buildEvictionConfig() throws Exception
{
EvictionConfig cfg = new EvictionConfig();
- cfg.setWakeupIntervalSeconds(1);
+ cfg.setWakeupInterval(1000);
cfg.setDefaultEventQueueSize(200000);
cfg.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
List<EvictionRegionConfig> erc = new LinkedList<EvictionRegionConfig>();
@@ -125,14 +125,14 @@
region1.setRegionFqn(Fqn.ROOT);
LRUConfiguration epc1 = new LRUConfiguration();
epc1.setMaxNodes(5000);
- epc1.setTimeToLiveSeconds(3);
+ epc1.setTimeToLive(3000);
region1.setEvictionPolicyConfig(epc1);
EvictionRegionConfig region2 = new EvictionRegionConfig();
region2.setRegionFqn(base);
LRUConfiguration epc2 = new LRUConfiguration();
epc2.setMaxNodes(100);
- epc2.setTimeToLiveSeconds(3);
+ epc2.setTimeToLive(3000);
region2.setEvictionPolicyConfig(epc2);
erc.add(region1);
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-07-11 17:01:51 UTC (rev 6251)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-07-11 20:15:20 UTC (rev 6252)
@@ -70,17 +70,17 @@
{
throw new IllegalStateException("No such region!");
}
- int ttl = 0;
+ long ttl = 0;
if (erConfig.getEvictionPolicyConfig() instanceof LRUConfiguration)
{
LRUConfiguration configuration = (LRUConfiguration) erConfig.getEvictionPolicyConfig();
- ttl = configuration.getTimeToLiveSeconds();
+ ttl = configuration.getTimeToLive();
}
else
{
throw new IllegalArgumentException("Only LRU being handled for now; please add other implementations here");
}
- TestingUtil.sleepThread(ttl * 1000 + 500);
+ TestingUtil.sleepThread(ttl + 500);
evictRegion(region);
}
17 years, 5 months
JBoss Cache SVN: r6251 - in core/trunk/src/main/java/org/jboss/cache: mvcc and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-11 13:01:51 -0400 (Fri, 11 Jul 2008)
New Revision: 6251
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
Log:
Do we actualy need data versions with MVCC?
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-11 15:46:23 UTC (rev 6250)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-11 17:01:51 UTC (rev 6251)
@@ -125,6 +125,7 @@
*/
public NodeSPI<K, V> createDataNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
{
+ // TODO: See if data versions are needed with MVCC. Should use cheaper UnversionedNode otherwise.
UnversionedNode un = useVersionedNode ? new VersionedNode<K, V>(fqn, parent, data, cache) : new UnversionedNode<K, V>(childName, fqn, data, cache);
// it is internal nodes that are wrapped in NIDs.
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-11 15:46:23 UTC (rev 6250)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-11 17:01:51 UTC (rev 6251)
@@ -52,6 +52,7 @@
InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
node = backupDelegationTarget.copy();
}
+ // TODO: See if data versions are even needed in the first place!!
// TODO: Make sure this works with custom versions as well!
// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
// node.setVersion(newVersion);
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-11 15:46:23 UTC (rev 6250)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-11 17:01:51 UTC (rev 6251)
@@ -8,7 +8,6 @@
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DataVersioningException;
-import org.jboss.cache.optimistic.DefaultDataVersion;
/**
* A node delegate that encapsulates repeatable read semantics when writes are initiated, committed or rolled back.
@@ -36,9 +35,11 @@
// check for write skew.
NodeSPI underlyingNode = container.peek(fqn, false, true); // even check for invalid nodes. we should check tombstones too.
DataVersion underlyingNodeVersion = underlyingNode == null ? null : underlyingNode.getVersion();
- if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
+ // TODO: See if data versions are even needed in the first place!!
+ //if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
+ if (!allowWriteSkew && underlyingNode != null && underlyingNode != node)
{
- String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Attempting to overwrite version ").append(node.getVersion()).append(" but current version has progressed to ").append(underlyingNodeVersion).toString();
+ String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Another process has changed the node since we last read it!").toString();
if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for update.");
throw new DataVersioningException(errormsg);
}
@@ -46,11 +47,11 @@
// make a backup copy
backup = node;
node = backup.copy();
-
+ // TODO: See if data versions are even needed in the first place!!
// update version on copy
// TODO: Make sure this works with custom versions as well!
- DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
- node.setVersion(newVersion);
+// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
+// node.setVersion(newVersion);
}
@Override
17 years, 5 months
JBoss Cache SVN: r6250 - core/trunk/src/main/java/org/jboss/cache/mvcc.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-11 11:46:23 -0400 (Fri, 11 Jul 2008)
New Revision: 6250
Modified:
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
Log:
Fixed CCE with creation
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-11 14:34:06 UTC (rev 6249)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-11 15:46:23 UTC (rev 6250)
@@ -46,9 +46,12 @@
if (changed) return; // already copied
changed = true;
- backup = node;
- InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
- node = backupDelegationTarget.copy();
+ if (!created)
+ {
+ backup = node;
+ InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
+ node = backupDelegationTarget.copy();
+ }
// TODO: Make sure this works with custom versions as well!
// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
// node.setVersion(newVersion);
@@ -138,7 +141,6 @@
// swap refs
((NodeReference) backup).setDelegate(node);
node = backup;
-
}
public void rollbackUpdate()
17 years, 5 months
JBoss Cache SVN: r6249 - in searchable/trunk: src/main/java/org/jboss/cache/search and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-11 10:34:06 -0400 (Fri, 11 Jul 2008)
New Revision: 6249
Added:
searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheImplTest.java
Modified:
searchable/trunk/TODO.txt
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java
Log:
Wrote up setSort() test in LocalCacheTest.
Modified: searchable/trunk/TODO.txt
===================================================================
--- searchable/trunk/TODO.txt 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/TODO.txt 2008-07-11 14:34:06 UTC (rev 6249)
@@ -10,4 +10,6 @@
4 - Non-string keys.
-Think.
\ No newline at end of file
+Think.
+
+5 - Mock objects.
\ No newline at end of file
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/pom.xml 2008-07-11 14:34:06 UTC (rev 6249)
@@ -47,6 +47,9 @@
<version>1.0.4</version>
</dependency>
+
+ <!-- Test dependencies -->
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
@@ -61,6 +64,14 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.3</version>
+ <scope>test</scope>
+ </dependency>
+
+
</dependencies>
<build>
<plugins>
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -65,7 +65,7 @@
int getResultSize();
/**
- * Allows lucene to sort the results.
+ * Allows lucene to sort the results. Integers are sorted in descending order.
*
* @param s - lucene sort object
*/
@@ -89,7 +89,7 @@
public void disableFullTextFilter(String name);
/**
- * Takes in a lucene filter and sets it to the filter field in the class.
+ * Allows lucene to filter the results.
*
* @param f - lucene filter
*/
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -41,7 +41,7 @@
*/
public class CacheQueryImpl implements CacheQuery
{
- private Cache cache;
+// private Cache cache; - Removed on 11/07/2008, cache is assigned but never used. Hence removed.
private Class[] classes;
private Sort sort;
private Filter filter;
@@ -63,7 +63,7 @@
public CacheQueryImpl(Query luceneQuery, SearchFactoryImpl searchFactory, Cache cache)
{
this.luceneQuery = luceneQuery;
- this.cache = cache;
+// this.cache = cache;
entityLoader = new CacheEntityLoader(cache);
this.searchFactory = searchFactory;
}
@@ -94,7 +94,7 @@
{
if (resultSize == null)
{
- //get result size without object initialization
+// get result size without object initialization
IndexSearcher searcher = buildSearcher(searchFactory);
if (searcher == null)
{
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -11,34 +11,32 @@
import java.util.HashMap;
/**
- * Class that implements {@link org.hibernate.search.cfg.Cfg} so that within JBossCache Searchable, there is no
+ * Class that implements {@link org.hibernate.search.cfg.SearchConfiguration} so that within JBossCache Searchable, there is no
* need for a Hibernate Core configuration object.
*
* @author Navin Surtani - navin(a)surtani.org
*/
public class SearchableCacheCfgImpl implements SearchConfiguration
{
- protected Map<String, PersistentClass> classes;
+ protected Map<String, Class> classes;
private Properties properties;
public SearchableCacheCfgImpl(Class[] classArray, Properties properties)
{
// null chks
+ if (classArray == null) throw new NullPointerException("Classes provided are null");
this.properties = properties;
if (this.properties == null) this.properties = new Properties();
- classes = new HashMap<String, PersistentClass>();
+ classes = new HashMap<String, Class>();
// loop thru your classArray
// populate your Map
- // you bog
-
+
for (Class c: classArray)
{
String classname = c.getName();
- RootClass rc = new RootClass();
- rc.setClassName(classname);
- classes.put(classname, rc);
+ classes.put(classname, c);
}
}
@@ -47,7 +45,7 @@
return classes.values().iterator();
}
- public PersistentClass getClassMapping(String name)
+ public Class getClassMapping(String name)
{
return classes.get(name);
}
@@ -64,8 +62,8 @@
public ReflectionManager getReflectionManager()
{
- //TODO: Am I meant to throw unsupported exception?
- return null;
+ throw new UnsupportedOperationException("This method is not supported within JBossCache Searchable");
+
}
}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -63,7 +63,7 @@
// set classes in the cfg
SearchFactoryImpl searchFactory = new SearchFactoryImpl(cfg);
- // boolean isPojoCache = c instanceof PojoCache; keep this for later usage
+// boolean isPojoCache = c instanceof PojoCache; keep this for later usage
// Step 2: Add cache listener to listen for events happening in the cache.
//SearchableListener listener = isPojoCache ? new SearchablePojoListener(searchFactory) : new SearchableCoreListener(searchFactory);
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -32,8 +32,8 @@
public SearchableCacheImpl(Cache<K, V> cache, SearchFactoryImpl searchFactory)
{
- if (cache == null) throw new NullPointerException("Blah");
- if (searchFactory == null) throw new NullPointerException("Blah");
+ if (cache == null) throw new NullPointerException("Cache is null");
+ if (searchFactory == null) throw new NullPointerException("searchFactory is null");
this.cache = cache;
this.searchFactory = searchFactory;
}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheImplTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheImplTest.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -0,0 +1,28 @@
+package org.jboss.cache.search;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+
+@Test (groups = "functional")
+public class SearchableCacheImplTest
+{
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void testConstructorWithNullCache()
+ {
+ SearchableCacheImpl nullCache = new SearchableCacheImpl(null, null);
+
+ }
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void testConstructorWithNullSearchFactory()
+ {
+ Cache cache = new DefaultCacheFactory().createCache();
+ SearchableCacheImpl nullSearchFactory = new SearchableCacheImpl(cache, null);
+ }
+}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -11,7 +11,7 @@
/**
* @author Navin Surtani - navin(a)surtani.org
*/
-@Test
+@Test (groups = "functional")
public class BrokenAnnotationTest
{
@Test (expectedExceptions = IllegalArgumentException.class)
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -4,6 +4,9 @@
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.QueryWrapperFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
@@ -198,4 +201,39 @@
}
+ public void testSetSort() throws ParseException
+ {
+ person2.setAge(35);
+ person3.setAge(12);
+
+ Sort sort = new Sort ("age");
+
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+
+ cacheQuery.setSort(sort);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert found.get(0).equals(person2);
+ assert found.get(1).equals(person3);
+ }
+
+ public void testSetFilter() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("goat");
+ Filter filter = new QueryWrapperFilter(luceneQuery);
+
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ cacheQuery.setFilter(filter);
+ }
+
}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java 2008-07-11 13:58:16 UTC (rev 6248)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java 2008-07-11 14:34:06 UTC (rev 6249)
@@ -1,10 +1,7 @@
package org.jboss.cache.search.test;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.pojo.annotation.Replicable;
@@ -25,6 +22,8 @@
private String name;
@Field (store = Store.YES)
private String blurb;
+ @Field (store = Store.YES, index = Index.UN_TOKENIZED )
+ private int age;
public String getName()
{
@@ -46,6 +45,16 @@
this.blurb = blurb;
}
+ public int getAge()
+ {
+ return age;
+ }
+
+ public void setAge(int age)
+ {
+ this.age = age;
+ }
+
public boolean equals(Object o)
{
if (this == o) return true;
17 years, 5 months