Author: manik.surtani(a)jboss.com
Date: 2008-10-09 12:51:41 -0400 (Thu, 09 Oct 2008)
New Revision: 6899
Added:
core/branches/flat/src/test/java/org/jboss/starobrno/api/
core/branches/flat/src/test/java/org/jboss/starobrno/api/batch/
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/repeatable_read/
core/branches/flat/src/test/java/org/jboss/starobrno/tx/
core/branches/flat/src/test/java/org/jboss/starobrno/tx/LocalModeTxTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java
Removed:
core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/
Modified:
core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/container/RepeatableReadEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java
Log:
More fixed
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -25,7 +25,6 @@
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
-import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -113,7 +112,7 @@
throw new UnsupportedOperationException("Unsupported in this implementation
(" + getClass().getSimpleName() + ")!");
}
- public ReadCommittedNode createWrappedNode(InternalNode<K, V> node,
InternalNode<K, V> parent)
+ public Object createWrappedNode(InternalNode<K, V> node, InternalNode<K,
V> parent)
{
throw new UnsupportedOperationException("Unsupported in this implementation
(" + getClass().getSimpleName() + ")!");
}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -1,777 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.cache;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.Configuration.NodeLockingScheme;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.NonVolatile;
-import org.jboss.starobrno.factories.annotations.Start;
-import org.jboss.starobrno.factories.annotations.Stop;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A container for the root node in the cache, which also provides helpers for
efficiently accessing nodes, walking trees, etc.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-@NonVolatile
-public class DataContainerImpl implements DataContainer
-{
- private static final Log log = LogFactory.getLog(DataContainerImpl.class);
- private static boolean trace = log.isTraceEnabled();
-
- /**
- * Root node.
- */
- private volatile NodeSPI root;
- private volatile InternalNode rootInternal;
-
- /**
- * Set<Fqn> of Fqns of the topmost node of internal regions that should
- * not included in standard state transfers.
- */
- private final Set<Fqn> internalFqns = new HashSet<Fqn>();
- private NodeFactory nodeFactory;
- private LockManager lockManager;
- private BuddyFqnTransformer buddyFqnTransformer;
- private Configuration config;
- private boolean usingMvcc;
- private static final InternalNode[] NULL_ARRAY = {null, null};
-
- @Inject
- public void injectDependencies(NodeFactory nodeFactory, LockManager lockManager,
BuddyFqnTransformer transformer, Configuration configuration)
- {
- setDependencies(nodeFactory, lockManager);
-
- // We need to create a root node even at this stage since certain components rely
on this being available before
- // start() is called.
- // TODO: Investigate which components rely on this being available before start(),
and why!
- //TODO - remove setDependencies method at this point
- createRootNode();
- this.buddyFqnTransformer = transformer;
- config = configuration;
- }
-
- public void setDependencies(NodeFactory nodeFactory, LockManager lockManager)
- {
- this.nodeFactory = nodeFactory;
- this.lockManager = lockManager;
- }
-
- @Start(priority = 12)
- public void createRootNode()
- {
- usingMvcc = config != null && config.getNodeLockingScheme() ==
NodeLockingScheme.MVCC;
- if (trace) log.trace("Starting data container. Using MVCC? " +
usingMvcc);
- // create a new root temporarily.
- 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.
-
- Class currentRootType = root == null ? null :
root.getDelegationTarget().getClass();
- Class tempRootType = tempRoot.getDelegationTarget().getClass();
-
- if (!tempRootType.equals(currentRootType))
- {
- if (trace) log.trace("Setting root node to an instance of " +
tempRootType);
- setRoot(tempRoot);
- }
-
- if (usingMvcc && rootInternal == null) setRoot(root); // sets the
"internal root"
-
- if (root != null) root.setChildrenLoaded(true);
- if (rootInternal != null) rootInternal.setChildrenLoaded(true);
- }
-
- @Stop(priority = 100)
- public void stop()
- {
- // empty in-memory state
- if (root != null)
- {
- root.clearDataDirect();
- root.removeChildrenDirect();
- }
- else if (rootInternal != null)
- {
- rootInternal.clear();
- rootInternal.removeChildren();
- }
- }
-
- @Deprecated
- public NodeSPI getRoot()
- {
- return root;
- }
-
- /**
- * Sets the root node reference to the node passed in.
- *
- * @param root node
- */
- public void setRoot(Object root)
- {
- if (root == null) throw new CacheException("Attempting to set a null node as a
root node!");
- // Mega-Ugh!
- if (usingMvcc && root instanceof InternalNode)
- {
- if (log.isDebugEnabled()) log.debug("Setting rootInternal to " +
root);
- rootInternal = (InternalNode) root;
- this.root = null;
- }
- else
- {
- this.root = (NodeSPI) root;
- if (usingMvcc)
- {
- if (log.isDebugEnabled()) log.debug("Setting rootInternal to " +
this.root.getDelegationTarget());
- rootInternal = this.root.getDelegationTarget();
- this.root = null;
- }
- }
- }
-
- public boolean isResident(Fqn fqn)
- {
- if (usingMvcc)
- {
- InternalNode in = peekInternalNode(fqn, false);
- return in != null && in.isResident();
- }
- else
- {
- NodeSPI<?, ?> nodeSPI = peek(fqn, false, false);
- return nodeSPI != null && nodeSPI.isResident();
- }
- }
-
- public void registerInternalFqn(Fqn fqn)
- {
- internalFqns.add(fqn);
- }
-
- public NodeSPI peek(Fqn fqn)
- {
- return peek(fqn, false, false);
- }
-
- public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes)
- {
- return peek(fqn, includeDeletedNodes, false);
- }
-
- public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes, boolean
includeInvalidNodes)
- {
- if (fqn == null || fqn.size() == 0) return getRoot();
- NodeSPI n = getRoot();
- int fqnSize = fqn.size();
- for (int i = 0; i < fqnSize; i++)
- {
- Object obj = fqn.get(i);
- n = n.getChildDirect(obj);
- if (n == null)
- {
- return null;
- }
- else if (!includeDeletedNodes && n.isDeleted())
- {
- return null;
- }
- else if (!includeInvalidNodes && !n.isValid())
- {
- return null;
- }
- }
- return n;
- }
-
- public boolean exists(Fqn fqn)
- {
- return usingMvcc ? peekInternalNode(fqn, false) != null : peek(fqn, false, false)
!= null;
- }
-
- public boolean hasChildren(Fqn fqn)
- {
- if (fqn == null) return false;
-
- if (usingMvcc)
- {
- InternalNode in = peekInternalNode(fqn, false);
- return in != null && in.hasChildren();
- }
- else
- {
- NodeSPI n = peek(fqn);
- return n != null && n.hasChildrenDirect();
- }
- }
-
- public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node,
boolean mapSafe)
- {
- if (usingMvcc)
- return buildNodeData(list, node.getDelegationTarget(), node.getData(),
mapSafe);
- else
- return buildNodeDataLegacy(list, node, mapSafe);
- }
-
- private List<NodeData> buildNodeData(List<NodeData> list,
InternalNode<?, ?> node, Map dataInNode, boolean mapSafe)
- {
- NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()),
dataInNode, mapSafe);
- list.add(data);
- for (InternalNode childNode : node.getChildrenMap().values())
- {
- buildNodeData(list, childNode, childNode.getData(), true);
- }
- return list;
- }
-
- @Deprecated
- private List<NodeData> buildNodeDataLegacy(List<NodeData> list, NodeSPI
node, boolean mapSafe)
- {
- NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()),
node.getDataDirect(), mapSafe);
- list.add(data);
- for (Object childNode : node.getChildrenDirect())
- {
- buildNodeData(list, (NodeSPI) childNode, true);
- }
- return list;
- }
-
- public List<Fqn> getNodesForEviction(Fqn fqn, boolean recursive)
- {
- List<Fqn> result = new ArrayList<Fqn>();
- if (usingMvcc)
- {
- InternalNode node = peekInternalNode(fqn, false);
- if (recursive)
- {
- if (node != null) recursiveAddEvictionNodes(node, result);
- }
- else
- {
- if (node == null)
- {
- result.add(fqn);
- return result;
- }
- if (fqn.isRoot())
- {
- for (Object childName : node.getChildrenNames())
- {
- if (!node.isResident()) result.add(Fqn.fromRelativeElements(fqn,
childName));
- }
- }
- else if (!node.isResident())
- {
- result.add(fqn);
- }
- }
- return result;
- }
- else
- {
- NodeSPI node = peek(fqn, false);
- if (recursive)
- {
- if (node != null) recursiveAddEvictionNodes(node, result);
- }
- else
- {
- if (node == null)
- {
- result.add(fqn);
- return result;
- }
- if (fqn.isRoot())
- {
- for (Object childName : node.getChildrenNamesDirect())
- {
- if (!node.isResident()) result.add(Fqn.fromRelativeElements(fqn,
childName));
- }
- }
- else if (!node.isResident())
- {
- result.add(fqn);
- }
- }
- return result;
- }
- }
-
- private void recursiveAddEvictionNodes(NodeSPI<?, ?> node, List<Fqn>
result)
- {
- for (NodeSPI<?, ?> child : node.getChildrenDirect())
- {
- recursiveAddEvictionNodes(child, result);
- }
- Fqn fqn = node.getFqn();
- if (!fqn.isRoot() && !node.isResident())
- {
- result.add(fqn);
- }
- }
-
- private void recursiveAddEvictionNodes(InternalNode<?, ?> node, List<Fqn>
result)
- {
- for (InternalNode child : node.getChildren())
- {
- recursiveAddEvictionNodes(child, result);
- }
- Fqn fqn = node.getFqn();
- if (!fqn.isRoot() && !node.isResident())
- {
- result.add(fqn);
- }
- }
-
- @Override
- public String toString()
- {
- return toString(false);
- }
-
- public Set<Fqn> getInternalFqns()
- {
- return Collections.unmodifiableSet(internalFqns);
- }
-
- /**
- * Returns a debug string with optional details of contents.
- *
- * @param details if true, details are printed
- * @return detailed contents of the container
- */
- @SuppressWarnings("deprecation")
- public String toString(boolean details)
- {
- StringBuilder sb = new StringBuilder();
- int indent = 0;
-
- if (!details)
- {
- sb.append(getClass().getName()).append("
[").append(getNumberOfNodes()).append(" nodes, ");
- sb.append(getNumberOfLocksHeld()).append(" locks]");
- }
- else
- {
- if (root == null)
- return sb.toString();
- for (Object n : root.getChildrenDirect())
- {
- ((NodeSPI) n).print(sb, indent);
- sb.append("\n");
- }
- }
- return sb.toString();
- }
-
- public int getNumberOfLocksHeld()
- {
- return numLocks(root);
- }
-
- private int numLocks(NodeSPI n)
- {
- int num = 0;
- if (n != null)
- {
- if (lockManager.isLocked(n))
- {
- num++;
- }
- for (Object cn : n.getChildrenDirect(true))
- {
- num += numLocks((NodeSPI) cn);
- }
- }
- return num;
- }
-
- public int getNumberOfNodes()
- {
- if (!usingMvcc) return numNodes(root) - 1;
- return numNodesMvcc(rootInternal) - 1;
- }
-
- private int numNodesMvcc(InternalNode node)
- {
- int count = 1; //for 'node'
- if (node != null)
- {
- Set<InternalNode> children = node.getChildren();
- for (InternalNode child : children)
- {
- count += numNodesMvcc((InternalNode) child);
- }
- }
- return count;
- }
-
- private int numNodes(NodeSPI n)
- {
- int count = 1;// for n
- if (n != null)
- {
- for (Object child : n.getChildrenDirect())
- {
- count += numNodes((NodeSPI) child);
- }
- }
- return count;
- }
-
- /**
- * Prints information about the contents of the nodes in the cache's current
- * in-memory state. Does not load any previously evicted nodes from a
- * cache loader, so evicted nodes will not be included.
- *
- * @return details
- */
- public String printDetails()
- {
- StringBuilder sb = new StringBuilder();
- if (root == null)
- rootInternal.printDetails(sb, 0);
- else
- root.printDetails(sb, 0);
- sb.append("\n");
- return sb.toString();
- }
-
-
- /**
- * Returns lock information.
- *
- * @return lock info
- */
- public String printLockInfo()
- {
- return lockManager.printLockInfo(root);
- }
-
- public int getNumberOfAttributes(Fqn fqn)
- {
- return usingMvcc ? numAttributes(peekInternalNode(fqn, false)) :
numAttributes(peek(fqn));
- }
-
- private int numAttributes(NodeSPI n)
- {
- int count = 0;
- for (Object child : n.getChildrenDirect())
- {
- count += numAttributes((NodeSPI) child);
- }
- count += n.getDataDirect().size();
- return count;
- }
-
- private int numAttributesMvcc(InternalNode n)
- {
- int count = 0;
- for (Object child : n.getChildren())
- {
- count += numAttributesMvcc((InternalNode) child);
- }
- count += n.getData().size();
- return count;
- }
-
- private int numAttributes(InternalNode n)
- {
- int count = 0;
- for (Object child : n.getChildren())
- {
- count += numAttributes((NodeSPI) child);
- }
- count += n.getData().size();
- return count;
- }
-
- public int getNumberOfAttributes()
- {
- return usingMvcc ? numAttributesMvcc(rootInternal) : numAttributes(root);
- }
-
- public boolean removeFromDataStructure(Fqn f, boolean skipMarkerCheck)
- {
- return usingMvcc ? removeMvcc(f, skipMarkerCheck) : removeLegacy(f,
skipMarkerCheck);
- }
-
- private boolean removeMvcc(Fqn f, boolean skipMarkerCheck)
- {
- InternalNode n = peekInternalNode(f, true);
- if (n == null)
- {
- return false;
- }
-
- if (trace) log.trace("Performing a real remove for node " + f + ",
marked for removal.");
- if (skipMarkerCheck || n.isRemoved())
- {
- if (n.getFqn().isRoot())
- {
- // do not actually delete; just remove deletion marker
- n.setRemoved(true);
-
- // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
- // be aware that it is no longer valid.
- n.setValid(false, true);
- n.setValid(true, false);
-
- // but now remove all children, since the call has been to
remove("/")
- n.removeChildren();
- return true;
- }
- else
- {
- // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
- // be aware that it is no longer valid.
- n.setValid(false, true);
- InternalNode parent = peekInternalNode(f.getParent(), true);
- return parent.removeChild(n.getFqn().getLastElement());
- }
- }
- else
- {
- if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked
for removal as expected, not removing!");
- return false;
- }
- }
-
-
- private boolean removeLegacy(Fqn f, boolean skipMarkerCheck)
- {
- NodeSPI n = peek(f, true);
- if (n == null)
- {
- return false;
- }
-
- if (trace) log.trace("Performing a real remove for node " + f + ",
marked for removal.");
- if (skipMarkerCheck || n.isDeleted())
- {
- if (n.getFqn().isRoot())
- {
- // do not actually delete; just remove deletion marker
- n.markAsDeleted(true);
-
- // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
- // be aware that it is no longer valid.
- n.setValid(false, true);
- n.setValid(true, false);
-
- // but now remove all children, since the call has been to
remove("/")
- n.removeChildrenDirect();
- return true;
- }
- else
- {
- // mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
- // be aware that it is no longer valid.
- n.setValid(false, true);
- NodeSPI parent = peek(f.getParent(), true);
- return parent.removeChildDirect(n.getFqn().getLastElement());
- }
- }
- else
- {
- if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked
for removal as expected, not removing!");
- return false;
- }
- }
-
- public void evict(Fqn fqn, boolean recursive)
- {
- List<Fqn> toEvict = getNodesForEviction(fqn, recursive);
- for (Fqn aFqn : toEvict)
- {
- evict(aFqn);
- }
- }
-
- public boolean evict(Fqn fqn)
- {
- if (!exists(fqn)) return true;
- if (hasChildren(fqn))
- {
- if (trace)
- log.trace("removing DATA as node has children: evict(" + fqn +
")");
- if (usingMvcc)
- removeData(fqn);
- else
- removeDataLegacy(fqn);
- return false;
- }
- else
- {
- if (trace) log.trace("removing NODE as it is a leaf: evict(" + fqn +
")");
- if (usingMvcc)
- removeNode(fqn);
- else
- removeNodeLegacy(fqn);
- return true;
- }
- }
-
- private void removeNodeLegacy(Fqn fqn)
- {
- NodeSPI targetNode = peek(fqn, false, true);
- if (targetNode == null) return;
- NodeSPI parentNode = targetNode.getParentDirect();
- targetNode.setValid(false, false);
- if (parentNode != null)
- {
- parentNode.removeChildDirect(fqn.getLastElement());
- parentNode.setChildrenLoaded(false);
- }
- }
-
- private void removeNode(Fqn fqn)
- {
- InternalNode targetNode = peekInternalNode(fqn, true);
- if (targetNode == null) return;
- InternalNode parentNode = peekInternalNode(fqn.getParent(), true);
- targetNode.setValid(false, false);
- if (parentNode != null)
- {
- parentNode.removeChild(fqn.getLastElement());
- parentNode.setChildrenLoaded(false);
- }
- }
-
- private void removeDataLegacy(Fqn fqn)
- {
- NodeSPI n = peek(fqn);
- if (n == null)
- {
- log.warn("node " + fqn + " not found");
- return;
- }
- n.clearDataDirect();
- n.setDataLoaded(false);
- }
-
- private void removeData(Fqn fqn)
- {
- InternalNode n = peekInternalNode(fqn, false);
- if (n == null)
- {
- log.warn("node " + fqn + " not found");
- return;
- }
- n.clear();
- n.setDataLoaded(false);
- }
-
- public Object[] createNodes(Fqn fqn)
- {
- List<NodeSPI> result = new ArrayList<NodeSPI>(fqn.size());
- Fqn tmpFqn = Fqn.ROOT;
-
- int size = fqn.size();
-
- // root node
- NodeSPI n = root;
- for (int i = 0; i < size; i++)
- {
- Object childName = fqn.get(i);
- tmpFqn = Fqn.fromRelativeElements(tmpFqn, childName);
-
- NodeSPI childNode;
- Map children = n.getChildrenMapDirect();
- childNode = (NodeSPI) children.get(childName);
-
- if (childNode == null)
- {
- childNode = n.addChildDirect(Fqn.fromElements(childName));
- result.add(childNode);
- }
-
- n = childNode;
- }
- return new Object[]{result, n};
- }
-
- public InternalNode peekInternalNode(Fqn fqn, boolean includeInvalidNodes)
- {
- if (fqn == null || fqn.size() == 0) return rootInternal;
- InternalNode n = rootInternal;
- int fqnSize = fqn.size();
- for (int i = 0; i < fqnSize; i++)
- {
- Object obj = fqn.get(i);
- n = n.getChild(obj);
- if (n == null)
- {
- return null;
- }
- else if (!includeInvalidNodes && !n.isValid())
- {
- return null;
- }
- }
- return n;
- }
-
- public InternalNode[] peekInternalNodeAndDirectParent(Fqn fqn, boolean
includeInvalidNodes)
- {
- if (fqn == null || fqn.size() == 0) return new InternalNode[]{rootInternal, null};
- InternalNode n = rootInternal;
- InternalNode directParent = null;
- int fqnSize = fqn.size();
- for (int i = 0; i < fqnSize; i++)
- {
- directParent = n;
- Object obj = fqn.get(i);
- n = directParent.getChild(obj);
- if (n == null)
- {
- return NULL_ARRAY;
- }
- else if (!includeInvalidNodes && !n.isValid())
- {
- return NULL_ARRAY;
- }
- }
- return new InternalNode[]{n, directParent};
- }
-
- public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer)
- {
- this.buddyFqnTransformer = buddyFqnTransformer;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-10-09 13:45:15
UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-10-09 16:51:41
UTC (rev 6899)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache;
-import org.jboss.cache.mvcc.ReadCommittedNode;
import java.util.Map;
@@ -34,7 +33,7 @@
*/
public interface NodeFactory<K, V>
{
- ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K,
V> parent);
+ Object createWrappedNode(InternalNode<K, V> node, InternalNode<K, V>
parent);
/**
* Creates a new node and populates its attributes.
Modified:
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -1,24 +1,24 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.jboss.cache.commands.read;
import org.apache.commons.logging.Log;
@@ -28,10 +28,8 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.mvcc.ReadCommittedNode;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -69,12 +67,13 @@
@SuppressWarnings("unchecked")
public Object perform(InvocationContext ctx)
{
- ReadCommittedNode n = (ReadCommittedNode) (fqn == null ? null :
ctx.lookUpNode(fqn));
- if (n == null || n.isDeleted()) return null;
- Map<Object, InternalNode<?, ?>> childrenMap =
n.getDelegationTarget().getChildrenMap();
- Collection<InternalNode> children = (Collection<InternalNode>)
(childrenMap.isEmpty() ? Collections.emptySet() : childrenMap.values());
-
- return getCorrectedChildNames(children, ctx);
+// ReadCommittedNode n = (ReadCommittedNode) (fqn == null ? null :
ctx.lookUpNode(fqn));
+// if (n == null || n.isDeleted()) return null;
+// Map<Object, InternalNode<?, ?>> childrenMap =
n.getDelegationTarget().getChildrenMap();
+// Collection<InternalNode> children = (Collection<InternalNode>)
(childrenMap.isEmpty() ? Collections.emptySet() : childrenMap.values());
+//
+// return getCorrectedChildNames(children, ctx);
+ return null;
}
/**
@@ -104,11 +103,11 @@
{
Fqn childFqn = n.getKey();
- if (childFqn.isDirectChildOf(fqn))
- {
- ReadCommittedNode childNode = (ReadCommittedNode) n.getValue();
- if (childNode.isCreated()) childNames.add(childFqn.getLastElement());
- }
+// if (childFqn.isDirectChildOf(fqn))
+// {
+// ReadCommittedNode childNode = (ReadCommittedNode) n.getValue();
+// if (childNode.isCreated()) childNames.add(childFqn.getLastElement());
+// }
}
return childNames;
}
Modified:
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -30,7 +30,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.cache.notifications.Notifier;
import java.util.Collection;
@@ -159,12 +158,14 @@
private InternalNode lookupInAllScopes(InvocationContext ctx, Fqn fqn)
{
+ return null;
+ /*
ReadCommittedNode nodeSPI = (ReadCommittedNode) lookupForEviction(ctx, fqn);
if (nodeSPI == null)
{
return dataContainer.peekInternalNode(fqn, true);
}
- return nodeSPI.getDelegationTarget();
+ return nodeSPI.getDelegationTarget();*/
}
protected NodeSPI lookupForEviction(InvocationContext ctx, Fqn fqn)
Modified:
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -44,8 +44,6 @@
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.mvcc.MVCCNodeHelper;
-import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.CacheException;
@@ -80,9 +78,7 @@
protected boolean isActivation = false;
// protected boolean usingVersionedInvalidation = false;
- protected MVCCNodeHelper helper;
-
/**
* True if CacheStoreInterceptor is in place.
* This allows us to skip loading keys for remove(Fqn, key) and put(Fqn, key).
@@ -92,7 +88,7 @@
@Inject
protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm,
Configuration configuration,
- DataContainer dataContainer, Notifier notifier,
MVCCNodeHelper helper)
+ DataContainer dataContainer, Notifier notifier)
{
this.txTable = txTable;
this.clm = clm;
@@ -100,7 +96,6 @@
// usingVersionedInvalidation = mode.isInvalidation();
this.dataContainer = dataContainer;
this.notifier = notifier;
- this.helper = helper;
}
@Start
@@ -259,12 +254,12 @@
private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys,
boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean
bypassLoadingData, boolean shouldLoadIfNodeIsNull) throws Throwable
{
- NodeSPI n = helper.wrapNodeForReading(ctx, fqn, true);
- if (n instanceof NullMarkerNode)
- {
- ctx.getLookedUpNodes().remove(fqn);
- n = null;
- }
+ NodeSPI n = null;//helper.wrapNodeForReading(ctx, fqn, true);
+// if (n instanceof NullMarkerNode)
+// {
+// ctx.getLookedUpNodes().remove(fqn);
+// n = null;
+// }
boolean mustLoad = mustLoad(n, key, allKeys || isMove, shouldLoadIfNodeIsNull);
if (trace) log.trace("load element " + fqn + " mustLoad=" +
mustLoad);
@@ -274,7 +269,7 @@
if (acquireWriteLock || initNode)
{
boolean isNew = n == null;
- n = helper.wrapNodeForWriting(ctx, fqn, true, false, true, false, true); //
won't create any nodes but will acquire locks.
+// n = helper.wrapNodeForWriting(ctx, fqn, true, false, true, false, true); //
won't create any nodes but will acquire locks.
if (isNew && n != null) n.setDataLoaded(false);
}
@@ -283,7 +278,7 @@
if (n == null && loader.exists(fqn))
{
// just create a dummy node in memory
- n = helper.wrapNodeForWriting(ctx, fqn, true, true, true, false, false);
+// n = helper.wrapNodeForWriting(ctx, fqn, true, true, true, false,
false);
n.setDataLoaded(false);
}
if (!bypassLoadingData)
@@ -348,7 +343,7 @@
// Create if node had not been created already
if (node == null)
{
- NodeSPI temp = helper.wrapNodeForWriting(ctxt, fqn, true, true, true, false,
false);
+ NodeSPI temp = null;//helper.wrapNodeForWriting(ctxt, fqn, true, true, true,
false, false);
node = temp.getDelegationTarget();
}
@@ -358,7 +353,7 @@
Fqn childFqn = Fqn.fromRelativeElements(fqn, name);
// create child if it didn't exist
- NodeSPI child = helper.wrapNodeForWriting(ctxt, childFqn, true, true, true,
false, false);
+ NodeSPI child = null;//helper.wrapNodeForWriting(ctxt, childFqn, true, true,
true, false, false);
if (child.isCreated()) child.setDataLoaded(false);
if ((isMove || isActivation) && recursive)
{
Deleted:
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -1,262 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.cache.interceptors;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-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.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.starobrno.config.Option;
-import org.jboss.starobrno.factories.annotations.Inject;
-
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Always place this interceptor at the start of the interceptor chain to ensure
invocation contexts and set up and cleaned up correctly.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
- */
-public class InvocationContextInterceptor extends BaseTransactionalContextInterceptor
-{
- private RPCManager rpcManager;
-
- @Inject
- public void setDependencies(RPCManager rpcManager)
- {
- this.rpcManager = rpcManager;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command)
throws Throwable
- {
- return handleAll(ctx, command, null, false);
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx,
PutForExternalReadCommand command) throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), false);
- }
-
- @Override
- public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), true);
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command)
throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), true);
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws
Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), true);
- }
-
- @Override
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws
Throwable
- {
- return handleAll(ctx, command, null, false);
- }
-
- @SuppressWarnings("deprecation")
- private Object handleAll(InvocationContext ctx, VisitableCommand command,
GlobalTransaction gtx, boolean scrubContextOnCompletion) throws Throwable
- {
- Option optionOverride = ctx.getOptionOverrides();
- boolean suppressExceptions = false;
- Transaction suspendedTransaction = null;
- boolean resumeSuspended = false;
-
- if (trace) log.trace("Invoked with command " + command + " and
InvocationContext [" + ctx + "]");
-
- try
- {
- if (txManager != null)
- {
- Transaction tx = getTransaction();
- GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
- if (tx == null && realGtx != null && realGtx.isRemote()) tx =
txTable.getLocalTransaction(gtx);
- setTransactionalContext(tx, realGtx, null, ctx);
- }
- else
- {
- setTransactionalContext(null, null, null, ctx);
- }
-
- if (optionOverride != null)
- {
- if (optionOverride.isFailSilently())
- {
- log.debug("FAIL_SILENTLY Option is present - suspending any ongoing
transaction.");
- suppressExceptions = true;
- if (ctx.getTransaction() != null)
- {
- suspendedTransaction = txManager.suspend();
- setTransactionalContext(null, null, null, ctx);
- if (trace) log.trace("Suspending transaction " +
suspendedTransaction);
- resumeSuspended = true;
- }
- else
- {
- if (trace) log.trace("No ongoing transaction to suspend");
- }
- }
- }
-
- Object retval;
- try
- {
- return invokeNextInterceptor(ctx, command);
- }
- catch (Throwable th)
- {
- retval = th;
- // if fail silently return a null
- if (suppressExceptions) return null;
- Throwable t = (Throwable) retval;
- if (t instanceof RuntimeException && t.getCause() != null)
- {
- throw t.getCause();
- }
- else
- {
- throw t;
- }
- }
- // assume we're the first interceptor in the chain. Handle the
exception-throwing.
- }
- finally
- {
- // TODO: scope upgrading should happen transparently
- /*
- * we should scrub txs after every call to prevent race conditions
- * basically any other call coming in on the same thread and hijacking any
running tx's
- * was highlighted in JBCACHE-606
- */
- if (scrubContextOnCompletion) setTransactionalContext(null, null, null, ctx);
-
- // clean up any invocation-scope options set up
- if (trace) log.trace("Resetting invocation-scope options");
- ctx.getOptionOverrides().reset();
-
- // if this is a prepare, opt prepare or
-
- if (resumeSuspended)
- {
- txManager.resume(suspendedTransaction);
- }
- else
- {
- if (ctx.getTransaction() != null &&
(TransactionTable.isValid(ctx.getTransaction())))
- {
- copyInvocationScopeOptionsToTxScope(ctx);
- }
- }
-
- // reset the context to prevent leakage of internals
- ctx.setCommand(null);
- ctx.setMethodCall(null);
-
- // TODO: Calling ctx.reset() here breaks stuff. Check whether this is just
becuse UTs expect stuff in the ctx or whether this really breaks functionality.
-// ctx.reset();
- // instead, for now, just wipe contents of the looked up node map
- ctx.clearLookedUpNodes();
- }
- }
-
- private GlobalTransaction getGlobalTransaction(Transaction tx, GlobalTransaction gtx)
- {
- if (gtx == null) gtx = txTable.getCurrentTransaction(tx, false);
- if (gtx != null) gtx.setRemote(isRemoteGlobalTx(gtx));
- return gtx;
- }
-
- private Transaction getTransaction() throws SystemException
- {
- // this creates a context if one did not exist.
- if (txManager == null)
- {
- if (trace) log.trace("no transaction manager configured, setting tx as
null.");
- return null;
- }
- else
- {
- return txManager.getTransaction();
- }
- }
-
- /**
- * Tests if a global transaction originated from a different cache in the cluster
- *
- * @param gtx
- * @return true if the gtx is remote, false if it originated locally.
- */
- private boolean isRemoteGlobalTx(GlobalTransaction gtx)
- {
- return gtx != null && (gtx.getAddress() != null) &&
(!gtx.getAddress().equals(rpcManager.getLocalAddress()));
- }
-}
Modified:
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -34,7 +34,6 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.Version;
-import org.jboss.starobrno.batch.BatchContainer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CommandsFactory;
@@ -55,21 +54,19 @@
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.mvcc.MVCCNodeHelper;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.batch.BatchContainer;
import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.Configuration.NodeLockingScheme;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
-import org.jboss.starobrno.factories.annotations.Start;
import org.jgroups.Address;
import javax.transaction.Transaction;
@@ -103,7 +100,6 @@
private Marshaller marshaller;
private DataContainer dataContainer;
private CommandsFactory commandsFactory;
- private MVCCNodeHelper mvccHelper;
private boolean usingMvcc;
private BatchContainer batchContainer;
@@ -111,7 +107,7 @@
public void initialize(StateTransferManager stateTransferManager, CacheLoaderManager
cacheLoaderManager, Notifier notifier,
TransactionManager transactionManager, BuddyManager
buddyManager, TransactionTable transactionTable,
RPCManager rpcManager, RegionManager regionManager, Marshaller
marshaller,
- CommandsFactory commandsFactory, DataContainer dataContainer,
MVCCNodeHelper mvccHelper, BatchContainer batchContainer)
+ CommandsFactory commandsFactory, DataContainer dataContainer,
BatchContainer batchContainer)
{
this.stateTransferManager = stateTransferManager;
this.cacheLoaderManager = cacheLoaderManager;
@@ -124,16 +120,9 @@
this.marshaller = marshaller;
this.dataContainer = dataContainer;
this.commandsFactory = commandsFactory;
- this.mvccHelper = mvccHelper;
this.batchContainer = batchContainer;
}
- @Start
- private void setNodeLockingScheme()
- {
- usingMvcc = configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC;
- }
-
private void reset()
{
this.usingMvcc = false;
@@ -317,15 +306,15 @@
@SuppressWarnings("unchecked")
private NodeSPI<K, V> mvccPeek(Fqn f)
{
- NodeSPI<K, V> n;
- try
- {
- n = mvccHelper.wrapNodeForReading(getInvocationContext(), f, false);
- }
- catch (InterruptedException e)
- {
- throw new CacheException(e);
- }
+ NodeSPI<K, V> n = null;
+// try
+// {
+// n = mvccHelper.wrapNodeForReading(getInvocationContext(), f, false);
+// }
+// catch (InterruptedException e)
+// {
+// throw new CacheException(e);
+// }
if (n == null || n.isNullNode()) return null;
return n;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -322,11 +322,6 @@
return getConfiguration().getRuntimeConfig().getMuxChannelFactory();
}
- public String getNodeLockingScheme()
- {
- return getConfiguration().getNodeLockingSchemeString();
- }
-
public long getReplQueueInterval()
{
return getConfiguration().getReplQueueInterval();
@@ -513,11 +508,6 @@
getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
}
- public void setNodeLockingScheme(String nodeLockingScheme)
- {
- getConfiguration().setNodeLockingSchemeString(nodeLockingScheme);
- }
-
public void setReplQueueInterval(long interval)
{
getConfiguration().setReplQueueInterval(interval);
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -300,10 +300,6 @@
void setTransactionManager(TransactionManager manager);
- void setNodeLockingScheme(String nodeLockingScheme);
-
- String getNodeLockingScheme();
-
/**
* Gets whether the entire tree is inactive upon startup, only responding
* to replication messages after activateRegion is
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -1,24 +1,24 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.jboss.cache.jmx;
import org.apache.commons.logging.Log;
@@ -89,11 +89,7 @@
attrInfo = new MBeanAttributeInfo[atts.size()];
int i = 0;
- if (log.isInfoEnabled())
- {
- log.trace("Processing class " + instance.getClass());
- log.trace("Number of attributes: " + atts.size());
- }
+
MBeanAttributeInfo info;
for (AttributeEntry entry : atts.values())
{
@@ -178,15 +174,7 @@
if (name == null || name.length() == 0)
throw new NullPointerException("Invalid attribute requested " +
name);
- if (log.isDebugEnabled())
- {
- log.debug("getAttribute called for " + name);
- }
Attribute attr = getNamedAttribute(name);
- if (log.isDebugEnabled())
- {
- log.debug("getAttribute value found " + attr.getValue());
- }
return attr.getValue();
}
@@ -223,11 +211,6 @@
{
Attribute attr = (Attribute) list.get(i);
- if (log.isDebugEnabled())
- {
- log.debug("Attribute name " + attr.getName() + " new value is
" + attr.getValue());
- }
-
if (setNamedAttribute(attr))
{
results.add(attr);
@@ -236,7 +219,7 @@
{
if (log.isWarnEnabled())
{
- log.debug("Failed to update attribute name " + attr.getName()
+ log.warn("Failed to update attribute name " + attr.getName()
+ " with value "
+ attr.getValue());
}
@@ -367,11 +350,6 @@
}
}
- if (log.isDebugEnabled())
- {
- log.debug("@Attr found for method " + method.getName() +
" and registered as " + attributeName);
- }
-
AttributeEntry ae = atts.get(attributeName);
//is it a read method?
if (!writeAttribute)
@@ -457,10 +435,6 @@
if (!isAlreadyExposed)
{
ops.add(new MBeanOperationInfo(op != null ? op.description() :
"", method));
- if (log.isDebugEnabled())
- {
- log.debug("@Operation found for method " +
method.getName());
- }
}
}
}
@@ -508,10 +482,6 @@
false);
atts.put(fieldName, new FieldAttributeEntry(info, field));
- if (log.isDebugEnabled())
- {
- log.debug("@Attr found for field " + field.getName());
- }
}
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -24,7 +24,6 @@
import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.DataContainerImpl;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -57,9 +56,7 @@
*/
public static String printCacheLockingInfo(Cache_Legacy c)
{
- // internal cast
- DataContainerImpl cd = (DataContainerImpl) ((CacheInvocationDelegate)
c).getDataContainer();
- return cd.printLockInfo();
+ return "Fix me";
}
public static String printCacheInterceptors(CacheSPI_Legacy<?, ?> cache)
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -69,16 +69,20 @@
protected InterceptorChain invoker;
protected Configuration config;
protected Notifier notifier;
- private BatchContainer batchContainer;
+ protected BatchContainer batchContainer;
protected ComponentRegistry componentRegistry;
+ protected TransactionManager transactionManager;
+
@Inject
private void injectDependencies(InvocationContextContainer
invocationContextContainer,
CommandsFactory commandsFactory,
InterceptorChain interceptorChain,
Configuration configuration,
Notifier notifier,
- ComponentRegistry componentRegistry)
+ ComponentRegistry componentRegistry,
+ TransactionManager transactionManager,
+ BatchContainer batchContainer)
{
this.invocationContextContainer = invocationContextContainer;
this.commandsFactory = commandsFactory;
@@ -86,6 +90,8 @@
this.config = configuration;
this.notifier = notifier;
this.componentRegistry = componentRegistry;
+ this.transactionManager = transactionManager;
+ this.batchContainer = batchContainer;
}
public V putIfAbsent(K key, V value)
@@ -248,7 +254,7 @@
public TransactionManager getTransactionManager()
{
- return null; //TODO: Autogenerated. Implement me properly
+ return transactionManager;
}
public List<CommandInterceptor> getInterceptorChain()
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -94,7 +94,7 @@
public EvictCommand buildEvictCommand(Object key)
{
- return new EvictCommand();
+ return new EvictCommand(key);
}
public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications,
Address localAddress, boolean onePhaseCommit)
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -33,6 +33,11 @@
{
public static final int METHOD_ID = 3000;
+ public EvictCommand(Object key)
+ {
+ this.key = key;
+ }
+
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
return visitor.visitEvictCommand(ctx, this);
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -57,7 +57,7 @@
for (Entry<Object, Object> e : map.entrySet())
{
MVCCEntry me = ctx.lookupEntry(e.getKey());
- if (e != null) e.setValue(me.getValue());
+ if (me != null) me.setValue(e.getValue());
}
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -135,19 +135,6 @@
}
/**
- * Cache node locking scheme.
- */
- public static enum NodeLockingScheme
- {
- /**
- * Data is locked using the MVCC locking scheme. This is the default locking
scheme in JBoss Cache 3.0.0.
- *
- * @see <a
href="http://wiki.jboss.org/wiki/JBossCacheMVCC">http://wiki...
- */
- MVCC
- }
-
- /**
* Default replication version, from {@link Version#getVersionShort}.
*/
public static final short DEFAULT_REPLICATION_VERSION = Version.getVersionShort();
@@ -189,7 +176,6 @@
private boolean syncRollbackPhase = false;
private BuddyReplicationConfig buddyReplicationConfig;
- private NodeLockingScheme nodeLockingScheme = NodeLockingScheme.MVCC;
private String muxStackName = null;
private boolean usingMultiplexer = false;
private transient RuntimeConfig runtimeConfig;
@@ -208,18 +194,15 @@
private void correctIsolationLevels()
{
// ensure the correct isolation level upgrades and/or downgrades are performed.
- if (nodeLockingScheme == NodeLockingScheme.MVCC)
+ switch (isolationLevel)
{
- switch (isolationLevel)
- {
- case NONE:
- case READ_UNCOMMITTED:
- isolationLevel = IsolationLevel.READ_COMMITTED;
- break;
- case SERIALIZABLE:
- isolationLevel = IsolationLevel.REPEATABLE_READ;
- break;
- }
+ case NONE:
+ case READ_UNCOMMITTED:
+ isolationLevel = IsolationLevel.READ_COMMITTED;
+ break;
+ case SERIALIZABLE:
+ isolationLevel = IsolationLevel.REPEATABLE_READ;
+ break;
}
}
@@ -444,13 +427,6 @@
this.buddyReplicationConfig = config;
}
- public void setNodeLockingScheme(NodeLockingScheme nodeLockingScheme)
- {
- testImmutability("nodeLockingScheme");
- testImmutability("nodeLockingOptimistic");
- this.nodeLockingScheme = nodeLockingScheme;
- }
-
public void setUseReplQueue(boolean useReplQueue)
{
testImmutability("useReplQueue");
@@ -469,26 +445,6 @@
this.stateRetrievalTimeout = stateRetrievalTimeout;
}
- public void setNodeLockingScheme(String nodeLockingScheme)
- {
- testImmutability("nodeLockingScheme");
- if (nodeLockingScheme == null)
- {
- throw new ConfigurationException("Node locking scheme cannot be null",
"NodeLockingScheme");
- }
- this.nodeLockingScheme = NodeLockingScheme.valueOf(uc(nodeLockingScheme));
- }
-
- public String getNodeLockingSchemeString()
- {
- return nodeLockingScheme == null ? null : nodeLockingScheme.toString();
- }
-
- public void setNodeLockingSchemeString(String nodeLockingScheme)
- {
- setNodeLockingScheme(nodeLockingScheme);
- }
-
private static String uc(String s)
{
return s.toUpperCase(Locale.ENGLISH);
@@ -758,11 +714,6 @@
return buddyReplicationConfig;
}
- public NodeLockingScheme getNodeLockingScheme()
- {
- return nodeLockingScheme;
- }
-
public long getStateRetrievalTimeout()
{
return stateRetrievalTimeout;
@@ -898,7 +849,6 @@
if (marshallerClass != null ? !marshallerClass.equals(that.marshallerClass) :
that.marshallerClass != null)
return false;
if (muxStackName != null ? !muxStackName.equals(that.muxStackName) :
that.muxStackName != null) return false;
- if (nodeLockingScheme != that.nodeLockingScheme) return false;
if (runtimeConfig != null ? !runtimeConfig.equals(that.runtimeConfig) :
that.runtimeConfig != null) return false;
if (shutdownHookBehavior != that.shutdownHookBehavior) return false;
if (transactionManagerLookupClass != null ?
!transactionManagerLookupClass.equals(that.transactionManagerLookupClass) :
that.transactionManagerLookupClass != null)
@@ -936,7 +886,6 @@
result = 31 * result + (syncCommitPhase ? 1 : 0);
result = 31 * result + (syncRollbackPhase ? 1 : 0);
result = 31 * result + (buddyReplicationConfig != null ?
buddyReplicationConfig.hashCode() : 0);
- result = 31 * result + (nodeLockingScheme != null ? nodeLockingScheme.hashCode() :
0);
result = 31 * result + (muxStackName != null ? muxStackName.hashCode() : 0);
result = 31 * result + (usingMultiplexer ? 1 : 0);
result = 31 * result + (runtimeConfig != null ? runtimeConfig.hashCode() : 0);
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -374,7 +374,6 @@
String lockAcquisitionTimeout = getAttributeValue(element,
"lockAcquisitionTimeout");
if (existsAttribute(lockAcquisitionTimeout))
config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
String nodeLockingScheme = getAttributeValue(element,
"nodeLockingScheme");
- if (existsAttribute(nodeLockingScheme))
config.setNodeLockingScheme(nodeLockingScheme);
String writeSkewCheck = getAttributeValue(element, "writeSkewCheck");
if (existsAttribute(writeSkewCheck))
config.setWriteSkewCheck(getBoolean(writeSkewCheck));
String concurrencyLevel = getAttributeValue(element,
"concurrencyLevel");
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/container/RepeatableReadEntry.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/container/RepeatableReadEntry.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/container/RepeatableReadEntry.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.mvcc.RepeatableReadNode;
import org.jboss.starobrno.CacheException;
import static org.jboss.starobrno.container.ReadCommittedEntry.Flags.CHANGED;
@@ -35,7 +34,7 @@
*/
public class RepeatableReadEntry extends ReadCommittedEntry
{
- private static final Log log = LogFactory.getLog(RepeatableReadNode.class);
+ private static final Log log = LogFactory.getLog(RepeatableReadEntry.class);
public RepeatableReadEntry(Object key, Object value)
{
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -124,9 +124,10 @@
*/
public void clearLookedUpEntries()
{
- if (transactionContext != null)
- transactionContext.clearLookedUpEntries();
- else if (lookedUpEntries != null) lookedUpEntries.clear();
+// if (transactionContext != null)
+// transactionContext.clearLookedUpEntries();
+// else if (lookedUpEntries != null) lookedUpEntries.clear();
+ if (lookedUpEntries != null) lookedUpEntries.clear();
}
/**
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -30,6 +30,7 @@
import org.jboss.starobrno.commands.write.PutKeyValueCommand;
import org.jboss.starobrno.commands.write.PutMapCommand;
import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.commands.write.ReplaceCommand;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -75,6 +76,12 @@
}
@Override
+ public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command)
throws Throwable
+ {
+ return handleAll(ctx, command, ctx.getGlobalTransaction(), false);
+ }
+
+ @Override
public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
throws Throwable
{
return handleAll(ctx, command, command.getGlobalTransaction(), true);
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-10-09
13:45:15 UTC (rev 6898)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -164,7 +164,8 @@
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
{
entryWrapper.wrapEntryForWriting(ctx, command.getKey(), true, false);
- return invokeNextInterceptor(ctx, command);
+ Object o = invokeNextInterceptor(ctx, command);
+ return o;
}
@Override
@@ -219,6 +220,7 @@
{
if (useReadCommitted)
{
+ if (trace) log.trace("Wiping unnecessary entries from context");
// wipe all unchanged entries from context, to force subsequent reads to go
to the container,
// hence providing R_C semantics.
Set<Object> keysToRemove = new HashSet<Object>();
@@ -277,7 +279,10 @@
if (ctx.getTransactionContext() != null)
{
List<Object> locks = ctx.getTransactionContext().getKeysLocked();
- if (!locks.isEmpty()) cleanupLocks(locks, ctx, ctx.getGlobalTransaction(),
commit);
+ if (!locks.isEmpty())
+ cleanupLocks(locks, ctx, ctx.getGlobalTransaction(), commit);
+ else if (trace)
+ log.trace("At transaction boundary (" + (commit ?
"commit" : "rollback") + "), and we have no locks in
context!");
}
else
{
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java 2008-10-09
13:45:15 UTC (rev 6898)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -25,12 +25,6 @@
import org.jboss.starobrno.manager.CacheManager;
import org.testng.annotations.Test;
-/**
- * // TODO: MANIK: Document this
- *
- * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
- * @since 3.0
- */
@Test(groups = "functional")
public class BasicTest
{
@@ -67,14 +61,4 @@
cm.stop();
}
}
-
- public void concurrentMapMethodTest()
- {
-
- }
-
- public void transactionalTest()
- {
-
- }
}
Added: core/branches/flat/src/test/java/org/jboss/starobrno/tx/LocalModeTxTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/tx/LocalModeTxTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/jboss/starobrno/tx/LocalModeTxTest.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.starobrno.tx;
+
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.manager.CacheManager;
+import org.jboss.starobrno.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+@Test(groups = "functional")
+public class LocalModeTxTest
+{
+ private CacheSPI<String, String> createCache()
+ {
+ Configuration cfg = new Configuration();
+
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ CacheManager cm = new CacheManager(cfg);
+ return (CacheSPI<String, String>) cm.createCache("test");
+ }
+
+ public void testTxCommit1() throws Exception
+ {
+ CacheSPI c = null;
+ try
+ {
+ c = createCache();
+ TransactionManager tm = c.getTransactionManager();
+ tm.begin();
+ c.put("key", "value");
+ Transaction t = tm.suspend();
+ assert c.isEmpty();
+ tm.resume(t);
+ tm.commit();
+ assert !c.isEmpty();
+ }
+ finally
+ {
+ TestingUtil.killCaches(c);
+ }
+ }
+
+ public void testTxCommit2() throws Exception
+ {
+ CacheSPI c = null;
+ try
+ {
+ c = createCache();
+ TransactionManager tm = c.getTransactionManager();
+ c.put("key", "old");
+ tm.begin();
+ assert c.get("key").equals("old");
+ c.put("key", "value");
+ assert c.get("key").equals("value");
+ Transaction t = tm.suspend();
+ assert c.get("key").equals("old");
+ tm.resume(t);
+ tm.commit();
+ assert c.get("key").equals("value");
+ assert !c.isEmpty();
+ }
+ finally
+ {
+ TestingUtil.killCaches(c);
+ }
+ }
+}
Added:
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java
===================================================================
---
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java
(rev 0)
+++
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java 2008-10-09
16:51:41 UTC (rev 6899)
@@ -0,0 +1,55 @@
+package org.jboss.starobrno.util.internals;
+
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.ViewChanged;
+import org.jboss.cache.notifications.event.ViewChangedEvent;
+import org.jboss.starobrno.Cache;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A class that registers a cache listener with a given cache, and waits for a view
change on the cache.
+ * <p/>
+ * Sample usage:
+ * <pre>
+ * Cache c = getCache();
+ * ViewChangeListener vcl = new ViewChangeListener(c);
+ * assert vcl.waitForViewChange(60, TimeUnit.SECONDS); // will block for up to 60
seconds for a view change on cache c
+ * </pre>
+ */
+@CacheListener
+public class ViewChangeListener
+{
+ CountDownLatch latch;
+
+ /**
+ * Constructs a view change listener
+ *
+ * @param cache cache to listen on for view change events
+ */
+ public ViewChangeListener(Cache cache)
+ {
+ this.latch = new CountDownLatch(1);
+ cache.addCacheListener(this);
+ }
+
+ @ViewChanged
+ public void handleViewChange(ViewChangedEvent e)
+ {
+ if (!e.isPre()) latch.countDown();
+ }
+
+ /**
+ * Waits for up to millis milliseconds for a view change to be received.
+ *
+ * @param timeout length of time to wait for a view change
+ * @param unit time unit to use
+ * @return true if a view change is received, false otherwise.
+ * @throws InterruptedException
+ */
+ public boolean waitForViewChange(long timeout, TimeUnit unit) throws
InterruptedException
+ {
+ return latch.await(timeout, unit);
+ }
+}
\ No newline at end of file