JBoss Cache SVN: r6749 - 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-09-18 07:02:45 -0400 (Thu, 18 Sep 2008)
New Revision: 6749
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/DataContainer.java
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/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.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/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:
Optimised for performance, minimising additional node lookups on completion of an update
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -227,6 +227,11 @@
throw new UnsupportedOperationException("Not supported in " + getClass().getSimpleName());
}
+ public void addChild(InternalNode<K, V> child, boolean safe)
+ {
+ throw new UnsupportedOperationException("Not supported in " + getClass().getSimpleName());
+ }
+
public void setChildrenMap(ConcurrentMap<Object, InternalNode<K, V>> children)
{
throw new UnsupportedOperationException("Not supported in " + getClass().getSimpleName());
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -105,7 +105,7 @@
throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
}
- public ReadCommittedNode createWrappedNode(InternalNode<K, V> node)
+ public ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K, V> parent)
{
throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
}
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -192,6 +192,15 @@
InternalNode peekInternalNode(Fqn f, boolean includeInvalidNodes);
/**
+ * Similar to {@link #peekInternalNode(Fqn, boolean)} except that the node AND it's *direct* parent are retrieved.
+ *
+ * @param fqn fqn to find
+ * @param includeInvalidNodes if true, invalid nodes are considered.
+ * @return an array of InternalNodes, containing 2 elements. Element [0] is the node being peeked, and element [1] is it's direct parent.
+ */
+ public InternalNode[] peekInternalNodeAndDirectParent(Fqn fqn, boolean includeInvalidNodes);
+
+ /**
* Sets a new root node
*
* @param nodeInvocationDelegate
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -47,6 +47,7 @@
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)
@@ -724,6 +725,36 @@
return n;
}
+ /**
+ * Similar to {@link #peekInternalNode(Fqn, boolean)} except that the node AND it's *direct* parent are retrieved.
+ *
+ * @param fqn fqn to find
+ * @param includeInvalidNodes if true, invalid nodes are considered.
+ * @return an array of InternalNodes, containing 2 elements. Element [0] is the node being peeked, and element [1] is it's direct parent.
+ */
+ 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/trunk/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -117,6 +117,15 @@
void addChild(InternalNode<K, V> child);
+ /**
+ * Same as above, except that if safe is true, any Fqn ancestry checking is skipped. Don't set safe to true unless
+ * you really know what you are doing!
+ *
+ * @param child child to add
+ * @param safe safety flag
+ */
+ void addChild(InternalNode<K, V> child, boolean safe);
+
// *****************End new methods *****************
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -15,7 +15,7 @@
*/
public interface NodeFactory<K, V>
{
- ReadCommittedNode createWrappedNode(InternalNode<K, V> node);
+ ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K, V> parent);
WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace);
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -18,6 +18,9 @@
import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.cache.jmx.annotations.MBean;
+import org.jboss.cache.jmx.annotations.ManagedAttribute;
+import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.TimeoutException;
@@ -31,9 +34,6 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.ThreadGate;
import org.jboss.cache.util.reflect.ReflectionUtil;
-import org.jboss.cache.jmx.annotations.ManagedOperation;
-import org.jboss.cache.jmx.annotations.ManagedAttribute;
-import org.jboss.cache.jmx.annotations.MBean;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelException;
@@ -42,14 +42,15 @@
import org.jgroups.JChannel;
import org.jgroups.StateTransferException;
import org.jgroups.View;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.RspFilter;
import org.jgroups.protocols.TP;
import org.jgroups.stack.ProtocolStack;
-import org.jgroups.blocks.GroupRequest;
-import org.jgroups.blocks.RspFilter;
import org.jgroups.util.Rsp;
import org.jgroups.util.RspList;
import javax.transaction.TransactionManager;
+import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -57,14 +58,13 @@
import java.util.List;
import java.util.Set;
import java.util.Vector;
-import java.text.NumberFormat;
/**
* Manager that handles all RPC calls between JBoss Cache instances
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@MBean (objectName = "RPCManager")
+@MBean(objectName = "RPCManager")
public class RPCManagerImpl implements RPCManager
{
private Channel channel;
@@ -72,7 +72,7 @@
private List<Address> members;
private long replicationCount;
private long replicationFailures;
- private boolean statisticsEnabled;
+ private boolean statisticsEnabled = false;
private final Object coordinatorLock = new Object();
/**
@@ -417,7 +417,8 @@
public List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand command, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
{
boolean success = true;
- try {
+ try
+ {
// short circuit if we don't have an RpcDispatcher!
if (rpcDispatcher == null) return null;
int modeToUse = mode;
@@ -469,10 +470,14 @@
}
}
return retval;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
success = false;
throw e;
- } finally {
+ }
+ finally
+ {
computeStats(success);
}
}
@@ -538,7 +543,7 @@
}
catch (Exception transferFailed)
{
- if (log.isTraceEnabled()) log.trace("Error while fetching state",transferFailed);
+ if (log.isTraceEnabled()) log.trace("Error while fetching state", transferFailed);
successfulTransfer = false;
}
}
@@ -707,17 +712,18 @@
}
-
//jmx operations
- private void computeStats(boolean success) {
- if (this.isStatisticsEnabled() && rpcDispatcher != null)
+ private void computeStats(boolean success)
+ {
+ if (statisticsEnabled && rpcDispatcher != null)
{
if (success)
{
- replicationCount ++;
- } else
+ replicationCount++;
+ }
+ else
{
- replicationFailures ++;
+ replicationFailures++;
}
}
}
@@ -730,22 +736,26 @@
}
@ManagedAttribute(description = "number of successful replications")
- public long getReplicationCount() {
+ public long getReplicationCount()
+ {
return replicationCount;
}
- @ManagedAttribute (description = "number of failed replications")
- public long getReplicationFailures() {
+ @ManagedAttribute(description = "number of failed replications")
+ public long getReplicationFailures()
+ {
return replicationFailures;
}
- @ManagedAttribute (description = "whether or not jmx statistics are enabled")
- public boolean isStatisticsEnabled() {
+ @ManagedAttribute(description = "whether or not jmx statistics are enabled")
+ public boolean isStatisticsEnabled()
+ {
return statisticsEnabled;
}
@ManagedAttribute
- public void setStatisticsEnabled(boolean statisticsEnabled) {
+ public void setStatisticsEnabled(boolean statisticsEnabled)
+ {
this.statisticsEnabled = statisticsEnabled;
}
@@ -757,8 +767,8 @@
return "N/A";
}
double totalCount = replicationCount + replicationFailures;
- double ration = (double)replicationCount / totalCount * 100d;
- return NumberFormat.getInstance().format(ration) +"%";
+ double ration = (double) replicationCount / totalCount * 100d;
+ return NumberFormat.getInstance().format(ration) + "%";
}
/**
@@ -773,7 +783,7 @@
Configuration.CacheMode cacheMode = configuration.getCacheMode();
if (!cacheMode.equals(Configuration.CacheMode.LOCAL) && configuration.getCacheMode().isSynchronous())
{
- ProtocolStack stack = ((JChannel)channel).getProtocolStack();
+ ProtocolStack stack = ((JChannel) channel).getProtocolStack();
TP transport = stack.getTransport();
if (transport.isEnableBundling())
{
@@ -784,7 +794,7 @@
//bundling is good for async caches
if (!cacheMode.isSynchronous())
{
- ProtocolStack stack = ((JChannel)channel).getProtocolStack();
+ ProtocolStack stack = ((JChannel) channel).getProtocolStack();
TP transport = stack.getTransport();
if (!transport.isEnableBundling())
{
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -245,8 +245,14 @@
@Override
public void addChild(InternalNode<K, V> child)
{
- Fqn childFqn = child.getFqn();
- if (childFqn.isDirectChildOf(fqn))
+ addChild(child, false);
+ }
+
+ @Override
+ public void addChild(InternalNode<K, V> child, boolean safe)
+ {
+ Fqn<?> childFqn = child.getFqn();
+ if (safe || childFqn.isDirectChildOf(fqn))
{
children().put(childFqn.getLastElement(), child);
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -22,7 +22,7 @@
public class MVCCNodeFactory<K, V> extends AbstractNodeFactory<K, V>
{
private boolean useRepeatableRead;
- private static final NullMarkerNode NULL_MARKER = new NullMarkerNode(null);
+ private static final NullMarkerNode NULL_MARKER = new NullMarkerNode();
private static final Log log = LogFactory.getLog(MVCCNodeFactory.class);
private static final boolean trace = log.isTraceEnabled();
private boolean lockChildForInsertRemove;
@@ -48,10 +48,10 @@
*/
@Override
@SuppressWarnings("unchecked")
- public ReadCommittedNode createWrappedNode(InternalNode<K, V> node)
+ public ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K, V> parent)
{
if (node == null) return useRepeatableRead ? NULL_MARKER : null;
- ReadCommittedNode rcn = useRepeatableRead ? new RepeatableReadNode(node) : new ReadCommittedNode(node);
+ ReadCommittedNode rcn = useRepeatableRead ? new RepeatableReadNode(node, parent) : new ReadCommittedNode(node, parent);
rcn.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
rcn.injectDependencies(cache);
return rcn;
@@ -73,7 +73,7 @@
@SuppressWarnings("unchecked")
public NodeSPI<K, V> createRootNode()
{
- return createWrappedNode(createInternalNode(Fqn.ROOT));
+ return createWrappedNode(createInternalNode(Fqn.ROOT), null);
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -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 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)}
+ * {@link InternalNode}s are wrapped using {@link org.jboss.cache.NodeFactory#createWrappedNode(org.jboss.cache.InternalNode, 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, 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,8 +113,8 @@
{
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.createWrappedNode(node);
+ InternalNode[] nodes = dataContainer.peekInternalNodeAndDirectParent(f, false);
+ ReadCommittedNode wrapped = nodeFactory.createWrappedNode(nodes[0], nodes[1]); // even though parents aren't needed for reading, we hold on to this ref in case the node is later written to.
if (wrapped != null) ctx.putLookedUpNode(f, wrapped);
return wrapped;
}
@@ -170,10 +170,10 @@
* @throws InterruptedException if interrupted
*/
@SuppressWarnings("unchecked")
- public NodeSPI wrapNodeForWriting(InvocationContext context, Fqn fqn, boolean lockForWriting, boolean createIfAbsent, boolean includeInvalidNodes, boolean forRemoval, boolean force) throws InterruptedException
+ public ReadCommittedNode wrapNodeForWriting(InvocationContext context, Fqn fqn, boolean lockForWriting, boolean createIfAbsent, boolean includeInvalidNodes, boolean forRemoval, boolean force) throws InterruptedException
{
Fqn parentFqn = null;
- NodeSPI n = context.lookUpNode(fqn);
+ ReadCommittedNode n = (ReadCommittedNode) context.lookUpNode(fqn);
if (createIfAbsent && n != null && n.isNullNode()) n = null;
if (n != null) // exists in context! Just acquire lock if needed, and wrap.
{
@@ -194,7 +194,8 @@
else
{
// else, fetch from dataContainer.
- InternalNode in = dataContainer.peekInternalNode(fqn, includeInvalidNodes);
+ InternalNode[] nodes = dataContainer.peekInternalNodeAndDirectParent(fqn, includeInvalidNodes);
+ InternalNode in = nodes[0];
if (in != null)
{
// exists in cache! Just acquire lock if needed, and wrap.
@@ -204,7 +205,7 @@
{
needToCopy = true;
}
- n = nodeFactory.createWrappedNode(in);
+ n = nodeFactory.createWrappedNode(in, nodes[1]);
context.putLookedUpNode(fqn, n);
if (needToCopy) n.markForUpdate(dataContainer, writeSkewCheck);
}
@@ -225,7 +226,7 @@
acquireLock(context, fqn);
in = nodeFactory.createChildNode(fqn, null, context, false);
- n = nodeFactory.createWrappedNode(in);
+ n = nodeFactory.createWrappedNode(in, parent.getDelegationTarget());
n.setCreated(true);
context.putLookedUpNode(fqn, n);
n.markForUpdate(dataContainer, writeSkewCheck);
@@ -255,7 +256,7 @@
* @throws InterruptedException if interrupted
*/
@SuppressWarnings("unchecked")
- public NodeSPI wrapNodeForWriting(InvocationContext context, InternalNode node) throws InterruptedException
+ public NodeSPI wrapNodeForWriting(InvocationContext context, InternalNode node, InternalNode parent) throws InterruptedException
{
Fqn fqn = node.getFqn();
NodeSPI n = context.lookUpNode(fqn);
@@ -278,7 +279,7 @@
{
needToCopy = true;
}
- n = nodeFactory.createWrappedNode(node);
+ n = nodeFactory.createWrappedNode(node, parent);
context.putLookedUpNode(fqn, n);
if (needToCopy) n.markForUpdate(dataContainer, writeSkewCheck);
}
@@ -361,12 +362,13 @@
if (fqnList != null) fqnList.add(fqn);
// now wrap and add to the context
- NodeSPI rcn = wrapNodeForWriting(ctx, fqn, true, false, true, false, false);
+ ReadCommittedNode rcn = wrapNodeForWriting(ctx, fqn, true, false, true, false, false);
if (rcn != null)
{
rcn.markForUpdate(dataContainer, writeSkewCheck);
Map<Object, InternalNode<?, ?>> children = rcn.getDelegationTarget().getChildrenMap();
- for (InternalNode child : children.values()) lockForWritingRecursive(child, ctx, fqnList);
+ for (InternalNode child : children.values())
+ lockForWritingRecursive(child, rcn.getInternalParent(), ctx, fqnList);
}
}
@@ -380,19 +382,19 @@
* @throws InterruptedException if interrupted
*/
@SuppressWarnings("unchecked")
- private void lockForWritingRecursive(InternalNode node, InvocationContext ctx, List<Fqn> fqnList) throws InterruptedException
+ private void lockForWritingRecursive(InternalNode node, InternalNode parent, InvocationContext ctx, List<Fqn> fqnList) throws InterruptedException
{
Fqn fqn = node.getFqn();
acquireLock(ctx, fqn); // lock node
if (fqnList != null) fqnList.add(fqn);
// now wrap and add to the context
- NodeSPI rcn = wrapNodeForWriting(ctx, node);
+ NodeSPI rcn = wrapNodeForWriting(ctx, node, parent);
if (rcn != null)
{
rcn.markForUpdate(dataContainer, writeSkewCheck);
- Map<Object, InternalNode<?, ?>> children = rcn.getDelegationTarget().getChildrenMap();
- for (InternalNode child : children.values()) lockForWritingRecursive(child, ctx, fqnList);
+ Map<Object, InternalNode<?, ?>> children = node.getChildrenMap();
+ for (InternalNode child : children.values()) lockForWritingRecursive(child, node, ctx, fqnList);
}
}
@@ -413,8 +415,8 @@
ReadCommittedNode node = (ReadCommittedNode) ctx.lookUpNode(fqn);
if (node == null)
{
- InternalNode in = dataContainer.peekInternalNode(fqn, false);
- node = nodeFactory.createWrappedNode(in);
+ InternalNode[] nodes = dataContainer.peekInternalNodeAndDirectParent(fqn, false);
+ node = nodeFactory.createWrappedNode(nodes[0], nodes[1]);
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-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -136,6 +136,11 @@
delegate.addChild(child);
}
+ public final void addChild(InternalNode<K, V> child, boolean safe)
+ {
+ delegate.addChild(child, safe);
+ }
+
public final V remove(K key)
{
return delegate.remove(key);
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -1,7 +1,6 @@
package org.jboss.cache.mvcc;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.InternalNode;
/**
* A marker node to represent a null node for repeatable read, so that a read that returns a null can continue to return
@@ -12,9 +11,9 @@
*/
public class NullMarkerNode extends RepeatableReadNode
{
- public NullMarkerNode(InternalNode node)
+ public NullMarkerNode()
{
- super(node);
+ super(null, null);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -24,7 +24,11 @@
protected volatile InternalNode backup;
protected byte flags = 0;
+ protected Fqn fqn;
+ protected InternalNode parent;
+ protected Fqn parentFqn;
+
protected static enum Flags
{
CHANGED(0x1), CREATED(0x2), DELETED(0x4);
@@ -37,11 +41,18 @@
}
@SuppressWarnings("unchecked")
- public ReadCommittedNode(InternalNode node)
+ public ReadCommittedNode(InternalNode node, InternalNode parent)
{
super(node);
+ this.parent = parent;
+ if (parent != null) parentFqn = parent.getFqn();
}
+ public InternalNode getInternalParent()
+ {
+ return parent;
+ }
+
/**
* Tests whether a flag is set.
*
@@ -79,6 +90,13 @@
return false;
}
+ // convenience fqn retrieval method
+ protected final Fqn fqn()
+ {
+ if (fqn == null) fqn = getFqn();
+ return fqn;
+ }
+
@Override
public void markForUpdate(DataContainer container, boolean writeSkewCheck)
{
@@ -101,7 +119,7 @@
// only do stuff if there are changes.
if (isFlagSet(CHANGED))
{
- Fqn fqn = getFqn();
+ Fqn fqn = fqn();
if (trace)
log.trace("Updating node [" + fqn + "]. deleted=" + isDeleted() + " valid=" + isValid() + " changed=" + isChanged() + " created=" + isFlagSet(CREATED));
@@ -125,7 +143,7 @@
{
// add newly created nodes to parents.
InternalNode parent = lookupParent(fqn, ctx, container);
- parent.addChild(node);
+ parent.addChild(node, true); // we know this is safe since we calculated the parent from the child. No need to have the parent re-do checks when adding the child again.
}
else
{
@@ -156,8 +174,10 @@
*/
protected final InternalNode lookupParent(Fqn fqn, InvocationContext ctx, DataContainer container) throws NodeNotExistsException
{
+ if (parent != null) return parent;
+
InternalNode retval;
- Fqn parentFqn = fqn.getParent();
+ Fqn parentFqn = this.parentFqn == null ? fqn.getParent() : this.parentFqn; // use the class-level parentFqn where possible since this will already have a hashcode computed.
NodeSPI parent = ctx.lookUpNode(parentFqn);
// first check if the parent is cached in the context.
if (parent != null)
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-09-18 11:01:52 UTC (rev 6748)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-09-18 11:02:45 UTC (rev 6749)
@@ -6,7 +6,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
-
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.CHANGED;
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.DELETED;
import org.jboss.cache.optimistic.DataVersioningException;
@@ -21,9 +20,9 @@
{
private static final Log log = LogFactory.getLog(RepeatableReadNode.class);
- public RepeatableReadNode(InternalNode node)
+ public RepeatableReadNode(InternalNode node, InternalNode parent)
{
- super(node);
+ super(node, parent);
}
@Override
@@ -31,7 +30,7 @@
{
if (isFlagSet(CHANGED)) return; // already copied
- Fqn fqn = getFqn();
+ Fqn fqn = fqn();
// mark node as changed.
setFlag(CHANGED);
@@ -58,7 +57,7 @@
@SuppressWarnings("unchecked")
protected void updateNode(InvocationContext ctx, DataContainer dataContainer)
{
- Fqn fqn = getFqn();
+ Fqn fqn = fqn();
if (fqn.isRoot())
{
dataContainer.setRoot(node);
@@ -66,7 +65,7 @@
else if (!isFlagSet(DELETED))
{
InternalNode parent = lookupParent(fqn, ctx, dataContainer);
- parent.addChild(node);
+ parent.addChild(node, true); // we know this is safe since we calculated the parent from the child. No need to have the parent re-do checks when adding the child again.
}
}
}
16 years, 5 months
JBoss Cache SVN: r6748 - core/trunk/src/test/java/org/jboss/cache/profiling.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-09-18 07:01:52 -0400 (Thu, 18 Sep 2008)
New Revision: 6748
Modified:
core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Better throughput measurement
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java 2008-09-17 23:24:20 UTC (rev 6747)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java 2008-09-18 11:01:52 UTC (rev 6748)
@@ -63,27 +63,27 @@
boolean anycasting, boolean oob, RspFilter filter) throws NotSerializableException
{
// make sure we do the marshalling though
- if (m == null && m2 == null)
- {
- m = getRequestMarshaller();
- if (m instanceof Marshaller2)
- {
- m2 = (Marshaller2) m;
- m = null;
- }
- }
+// if (m == null && m2 == null)
+// {
+// m = getRequestMarshaller();
+// if (m instanceof Marshaller2)
+// {
+// m2 = (Marshaller2) m;
+// m = null;
+// }
+// }
+//
+// try
+// {
+// if (m2 == null) m.objectToByteBuffer(command);
+// else m2.objectToBuffer(command);
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// throw new NotSerializableException(e.getMessage());
+// }
- try
- {
- if (m2 == null) m.objectToByteBuffer(command);
- else m2.objectToBuffer(command);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new NotSerializableException(e.getMessage());
- }
-
int i = ai.incrementAndGet();
if (i % 1000 == 0) log.warn("Dispatching operation #" + i);
// no-op
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-17 23:24:20 UTC (rev 6747)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-18 11:01:52 UTC (rev 6748)
@@ -17,6 +17,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
/**
* Test to use with a profiler to profile replication. To be used in conjunction with ProfileSlaveTest.
@@ -53,7 +54,7 @@
Log log = LogFactory.getLog(ProfileTest.class);
- @Test(enabled = false)
+ @Test(enabled = true)
public void testLocalModePess() throws Exception
{
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
@@ -249,24 +250,28 @@
private void doTest() throws Exception
{
ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
- // Executor exec = new DirectExecutor();
- long startTime = System.currentTimeMillis();
log.warn("Starting test");
int i;
long print = NUM_OPERATIONS / 10;
+
+ AtomicLong durationPuts = new AtomicLong();
+ AtomicLong durationGets = new AtomicLong();
+ AtomicLong durationRemoves = new AtomicLong();
+
+ long stElapsed = System.nanoTime();
for (i = 0; i < NUM_OPERATIONS; i++)
{
MyRunnable r = null;
switch (i % 3)
{
case 0:
- r = new Putter(i);
+ r = new Putter(i, durationPuts);
break;
case 1:
- r = new Getter(i);
+ r = new Getter(i, durationGets);
break;
case 2:
- r = new Remover(i);
+ r = new Remover(i, durationRemoves);
break;
}
if (i % print == 0)
@@ -278,12 +283,33 @@
log.warn("Finished generating runnables; awaiting executor completion");
// wait for executors to complete!
exec.shutdown();
- exec.awaitTermination(((long) i), TimeUnit.SECONDS); // wait up to 1 sec for each call?
- long duration = System.currentTimeMillis() - startTime;
- log.warn("Finished test. " + printDuration(duration));
- log.warn("Throughput: " + (NUM_OPERATIONS * 1000 / duration) + " operations per second (roughly equal numbers of PUT, GET and REMOVE)");
+ while (!exec.awaitTermination(((long) i), TimeUnit.SECONDS))
+ {
+ Thread.sleep(1);
+ }
+ ; // wait up to 1 sec for each call?
+ long elapsedTimeNanos = System.nanoTime() - stElapsed;
+
+ log.warn("Finished test. " + printDuration((long) toMillis(elapsedTimeNanos)));
+ log.warn("Throughput: " + ((double) NUM_OPERATIONS * 1000 / toMillis(elapsedTimeNanos)) + " operations per second (roughly equal numbers of PUT, GET and REMOVE)");
+ log.warn("Average GET time: " + printAvg(durationGets.get()));
+ log.warn("Average PUT time: " + printAvg(durationPuts.get()));
+ log.warn("Average REMOVE time: " + printAvg(durationRemoves.get()));
}
+ private String printAvg(long totalNanos)
+ {
+ double nOps = (double) (NUM_OPERATIONS / 3);
+ double avg = ((double) totalNanos) / nOps;
+ double avgMicros = avg / 1000;
+ return avgMicros + " �s";
+ }
+
+ private double toMillis(long nanos)
+ {
+ return ((double) nanos / (double) 1000000);
+ }
+
enum Mode
{
PUT, GET, REMOVE
@@ -293,53 +319,61 @@
{
int id;
Mode mode;
+ AtomicLong duration;
-
public void run()
{
String k = getRandomString();
Fqn f = fqns.get(r.nextInt(MAX_OVERALL_NODES));
+ long d = 0, st = 0;
switch (mode)
{
case PUT:
+ st = System.nanoTime();
cache.put(f, k, getRandomString());
- // cache.put(BELAS_FQN, BELAS_KEY, new byte[10000]);
+ d = System.nanoTime() - st;
break;
case GET:
- // cache.get(BELAS_FQN, BELAS_KEY);
+ st = System.nanoTime();
cache.get(f, k);
+ d = System.nanoTime() - st;
break;
case REMOVE:
- // cache.remove(BELAS_FQN, BELAS_KEY);
+ st = System.nanoTime();
cache.remove(f, k);
+ d = System.nanoTime() - st;
break;
}
+ duration.getAndAdd(d);
}
}
private class Putter extends MyRunnable
{
- private Putter(int id)
+ private Putter(int id, AtomicLong duration)
{
this.id = id;
+ this.duration = duration;
mode = Mode.PUT;
}
}
private class Getter extends MyRunnable
{
- private Getter(int id)
+ private Getter(int id, AtomicLong duration)
{
this.id = id;
+ this.duration = duration;
mode = Mode.GET;
}
}
private class Remover extends MyRunnable
{
- private Remover(int id)
+ private Remover(int id, AtomicLong duration)
{
this.id = id;
+ this.duration = duration;
mode = Mode.REMOVE;
}
}
16 years, 5 months
JBoss Cache SVN: r6747 - in pojo/trunk: src/main/java/org/jboss/cache/pojo and 21 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-09-17 19:24:20 -0400 (Wed, 17 Sep 2008)
New Revision: 6747
Modified:
pojo/trunk/pom.xml
pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/eviction/AopLRUPolicy.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/BuddyReplicationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/EnumTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedByteTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedCircularGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedPutWithBulkRemoveTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedSerializableTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/annotation/ReplicatedAnnotationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncMapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncSetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedNetworkManagementTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedPropagationManagerlTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/InterceptorRegistrationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/NotificationTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTestBase.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedListTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedMapTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedObjectTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedSetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/region/ReplicatedTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ReplicatedTxTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java
pojo/trunk/src/test/resources/META-INF/unit-test-cache-service.xml
pojo/trunk/src/test/resources/log4j.xml
Log:
Numerous changes to make tests work against MVCC and 3.0
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/pom.xml 2008-09-17 23:24:20 UTC (rev 6747)
@@ -127,6 +127,7 @@
<!-- This seems to fail in some cases on 2.3 as well, disable for now -->
<useSystemClassLoader>true</useSystemClassLoader>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<!-- the docbook generation plugin for the user guide -->
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -83,7 +83,7 @@
* @return Existing POJO or null if there is none.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object attach(Fqn id, Object pojo) throws PojoCacheException;
+ Object attach(Fqn<?> id, Object pojo) throws PojoCacheException;
/**
* Remove POJO object from the cache.
@@ -102,7 +102,7 @@
* @return Original value object from this node.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object detach(Fqn id) throws PojoCacheException;
+ Object detach(Fqn<?> id) throws PojoCacheException;
/**
* Return the <code>Fqn</code> of the internal node containing the data of this attached object.
@@ -116,7 +116,7 @@
* @return <code>Fqn</code> of the internal data node. <code>null</code> if the object is
* immediate, serializable, or not in the cache.
*/
- Fqn getInternalFqn(Object object);
+ Fqn<?> getInternalFqn(Object object);
/**
* Return a list of the references from attached objects to this object. For each reference it
@@ -147,7 +147,7 @@
* @param id the location in the cache to examine
* @return true if an attached object exists, false if not
*/
- boolean exists(Fqn id);
+ boolean exists(Fqn<?> id);
/**
* Retrieve POJO from the cache system. Return null if object does not exist in the cache.
@@ -168,7 +168,7 @@
* @return Current content value. Null if does not exist.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Object find(Fqn id) throws PojoCacheException;
+ Object find(Fqn<?> id) throws PojoCacheException;
/**
* Query all managed POJO objects under the id recursively. Note that this will not return
@@ -181,7 +181,7 @@
* @return Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Map<Fqn, Object> findAll(String id) throws PojoCacheException;
+ Map<Fqn<?>, Object> findAll(String id) throws PojoCacheException;
/**
* Query all managed POJO objects under the id recursively. Note that this will not return
@@ -195,7 +195,7 @@
* @return Map of all POJOs found with (id, POJO) pair. Return size of 0, if not found.
* @throws PojoCacheException Throws if there is an error related to the cache operation.
*/
- Map<Fqn, Object> findAll(Fqn id) throws PojoCacheException;
+ Map<Fqn<?>, Object> findAll(Fqn<?> id) throws PojoCacheException;
/**
* Lifecycle method to start PojoCache.
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -37,7 +37,7 @@
*
* @return <code>Fqn</code> of the referring node.
*/
- public Fqn getFqn();
+ public Fqn<?> getFqn();
/**
* Returns the name of the node key which references the attached object, or null
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -37,18 +37,18 @@
{
private static final String LENGTH = "ARRAY.LENGTH";
protected PojoCacheImpl cache;
- protected Fqn fqn;
+ protected Fqn<?> fqn;
private int length = -1;
private Class<?> type;
- public static CachedArray load(Fqn fqn, PojoCacheImpl cache, Class<?> type)
+ public static CachedArray load(Fqn<?> fqn, PojoCacheImpl cache, Class<?> type)
{
boolean primitive = CachedType.isImmediate(type.getComponentType());
CachedArray array = primitive ? new CachedPrimitiveArray(fqn, type, cache) : new CachedObjectArray(fqn, type, cache);
return array;
}
- public static CachedArray create(Fqn fqn, PojoCacheImpl cache, Object originalArray)
+ public static CachedArray create(Fqn<?> fqn, PojoCacheImpl cache, Object originalArray)
{
Class<?> type = originalArray.getClass();
assert type.isArray();
@@ -67,14 +67,14 @@
return array;
}
- protected CachedArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
{
this.fqn = fqn;
this.type = type;
this.cache = cache;
}
- public Fqn getFqn()
+ public Fqn<?> getFqn()
{
return fqn;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -54,7 +54,7 @@
throw new PojoCacheException("Non-serializable for " + relative.getClass().getName());
}
- return Fqn.fromRelativeElements(baseFqn, relative);
+ return new Fqn(baseFqn, relative);
}
private Fqn getFqn()
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArray.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -40,14 +40,14 @@
// so that multi-dimensional arrays can be handled properly
private static ArrayInterceptable arraySource = new ArrayInterceptable() {};
- protected CachedObjectArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedObjectArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
{
super(fqn, type, cache);
}
public void set(int index, Object element)
{
- Fqn fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
+ Fqn<?> fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
cache.attach(fqn, Null.toNullObject(element), null, arraySource);
cache.getCache().put(fqn, InternalConstant.POJOCACHE_OPERATION, "SET");
@@ -55,7 +55,7 @@
public Object get(int index)
{
- Fqn fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
+ Fqn<?> fqn = AopUtil.constructFqn(this.fqn, IntegerCache.toString(index));
return Null.toNullValue(cache.find(fqn, null, arraySource));
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiveArray.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -34,7 +34,7 @@
{
private static final String ELEMENT = "ARRAY.PELEMENT.";
- protected CachedPrimitiveArray(Fqn fqn, Class<?> type, PojoCacheImpl cache)
+ protected CachedPrimitiveArray(Fqn<?> fqn, Class<?> type, PojoCacheImpl cache)
{
super(fqn, type, cache);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/eviction/AopLRUPolicy.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/eviction/AopLRUPolicy.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/eviction/AopLRUPolicy.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -15,7 +15,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.EvictionAlgorithm;
import org.jboss.cache.eviction.LRUPolicy;
-import org.jboss.cache.eviction.NodeEventType;
/**
@@ -45,8 +44,8 @@
*
* @param fqn
*/
- public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
- {
- return false;
- }
+// public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+// {
+// return false;
+// }
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -34,11 +34,11 @@
protected abstract boolean handles(Class<?> clazz);
- protected abstract Object remove(Fqn fqn, Reference reference, Object result);
+ protected abstract Object remove(Fqn<?> fqn, Reference reference, Object result);
- protected abstract void put(Fqn fqn, Reference reference, Object obj);
+ protected abstract void put(Fqn<?> fqn, Reference reference, Object obj);
- protected abstract Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance);
+ protected abstract Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance);
- protected abstract Fqn getFqn(Object obj);
+ protected abstract Fqn<?> getFqn(Object obj);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -64,7 +64,7 @@
}
@Override
- protected Fqn getFqn(Object obj)
+ protected Fqn<?> getFqn(Object obj)
{
if (obj instanceof Advised)
{
@@ -82,7 +82,7 @@
}
@Override
- protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
+ protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
{
CachedType type = pCache_.getCachedType(clazz);
Object obj = Instantiator.newInstance(clazz);
@@ -117,7 +117,7 @@
}
@Override
- protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
{
CachedType type = pCache_.getCachedType(obj.getClass());
// We have a clean slate then.
@@ -202,7 +202,7 @@
}
@Override
- protected Object remove(Fqn fqn, Reference referencingFqn, Object result) throws CacheException
+ protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object result) throws CacheException
{
CachedType type = pCache_.getCachedType(result.getClass());
InstanceAdvisor advisor = ((Advised) result)._getInstanceAdvisor();
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -41,14 +41,14 @@
this.cache = cache;
}
- protected Fqn getFqn(Object array)
+ protected Fqn<?> getFqn(Object array)
{
CachedArray cached = CachedArrayRegistry.lookup(array);
return cached != null ? cached.getFqn() : null;
}
@Override
- protected void put(Fqn fqn, Reference reference, Object obj)
+ protected void put(Fqn<?> fqn, Reference reference, Object obj)
{
// Always initialize the ref count so that we can mark this as an AopNode.
PojoInstance pojoInstance = InternalHelper.initializeAopInstance(reference);
@@ -61,7 +61,7 @@
}
@Override
- protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojo)
+ protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojo)
{
CachedArray cached = CachedArray.load(fqn, cache, clazz);
Object array = cached.toArray();
@@ -71,7 +71,7 @@
}
@Override
- protected Object remove(Fqn fqn, Reference referencingFqn, Object obj)
+ protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object obj)
{
CachedArray cached = CachedArrayRegistry.lookup(obj);
if (cached != null) {
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -42,7 +42,7 @@
internal_ = internal;
}
- protected Fqn getFqn(Object collection)
+ protected Fqn<?> getFqn(Object collection)
{
if (! (collection instanceof ClassProxy))
return null;
@@ -266,7 +266,7 @@
}
@Override
- protected Object remove(Fqn fqn, Reference referencingFqn, Object obj) throws CacheException
+ protected Object remove(Fqn<?> fqn, Reference referencingFqn, Object obj) throws CacheException
{
if (!(obj instanceof ClassProxy))
{
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -21,9 +21,9 @@
public static final String SERIALIZED = "__SERIALIZED__";
public static final String JBOSS_INTERNAL_STRING = "__JBossInternal__";
public static final String JBOSS_INTERNAL_ID_SEP_STRING = "_ID_";
- public static final Fqn JBOSS_INTERNAL = Fqn.fromString(JBOSS_INTERNAL_STRING);
- public static final Fqn JBOSS_INTERNAL_ID_SEP = Fqn.fromString(JBOSS_INTERNAL_ID_SEP_STRING);
- public static final Fqn JBOSS_INTERNAL_MAP = Fqn.fromRelativeElements(InternalConstant.JBOSS_INTERNAL, "__RefMap__");
+ public static final Fqn<String> JBOSS_INTERNAL = new Fqn<String>(JBOSS_INTERNAL_STRING);
+ public static final Fqn<String> JBOSS_INTERNAL_ID_SEP = new Fqn<String>(JBOSS_INTERNAL_ID_SEP_STRING);
+ public static final Fqn<String> JBOSS_INTERNAL_MAP = new Fqn<String>(InternalConstant.JBOSS_INTERNAL, "__RefMap__");
public static final String JBOSS_INTERNAL_STATIC = "__jboss:static__";
public static final String POJOCACHE_KEY_PREFIX = "POJOCache.";
public static final String POJOCACHE_STATUS = POJOCACHE_KEY_PREFIX + "Status";
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -279,7 +279,7 @@
throw new IllegalStateException("InternalDelegate.getInternalFqn(). fqn is either null or empty!");
String indirectFqn = getIndirectFqn(fqn);
- return Fqn.fromRelativeElements(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn);
+ return new Fqn(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn);
// return JBOSS_INTERNAL_MAP;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -33,7 +33,7 @@
internal_ = internal;
}
- protected Fqn getFqn(Object obj)
+ protected Fqn<?> getFqn(Object obj)
{
return null;
}
@@ -44,7 +44,7 @@
}
@Override
- protected Object get(Fqn fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
+ protected Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance) throws CacheException
{
// Note this is actually the aliasFqn, not the real fqn!
Object obj;
@@ -58,12 +58,12 @@
}
@Override
- protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
{
setupRefCounting(fqn, reference);
}
- boolean isMultipleReferenced(Fqn internalFqn)
+ boolean isMultipleReferenced(Fqn<?> internalFqn)
{
// Note this is actually the aliasFqn, not the real fqn!
PojoInstance pojoInstance = null;
@@ -81,7 +81,7 @@
}
@Override
- protected Object remove(Fqn fqn, Reference reference, Object pojo)
+ protected Object remove(Fqn<?> fqn, Reference reference, Object pojo)
throws CacheException
{
if (log.isDebugEnabled())
@@ -97,7 +97,7 @@
/**
* Remove the object from the the reference fqn, meaning just decrement the ref counter.
*/
- private void removeFromReference(Fqn originalFqn, Reference reference) throws CacheException
+ private void removeFromReference(Fqn<?> originalFqn, Reference reference) throws CacheException
{
if (decrementRefCount(originalFqn, reference) == PojoInstance.INITIAL_COUNTER_VALUE)
{
@@ -114,18 +114,18 @@
* @param fqn The original fqn node
* @param refFqn The new internal fqn node
*/
- private void setupRefCounting(Fqn fqn, Reference reference) throws CacheException
+ private void setupRefCounting(Fqn<?> fqn, Reference reference) throws CacheException
{
// increment the reference counting
incrementRefCount(fqn, reference);
}
- private int incrementRefCount(Fqn originalFqn, Reference reference) throws CacheException
+ private int incrementRefCount(Fqn<?> originalFqn, Reference reference) throws CacheException
{
return internal_.incrementRefCount(originalFqn, reference);
}
- private int decrementRefCount(Fqn originalFqn, Reference reference) throws CacheException
+ private int decrementRefCount(Fqn<?> originalFqn, Reference reference) throws CacheException
{
return internal_.decrementRefCount(originalFqn, reference);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -120,7 +120,7 @@
return oldValue;// we are done
AbstractHandler handler = getHandler(obj.getClass(), allowArray);
- Fqn internalFqn = handler.getFqn(obj);
+ Fqn<?> internalFqn = handler.getFqn(obj);
Reference reference = new ReferenceImpl(fqn, field);
if (internalFqn != null)
@@ -232,7 +232,7 @@
return null;
}
- Fqn internalFqn = pojoReference.getFqn();
+ Fqn<?> internalFqn = pojoReference.getFqn();
@@ -285,9 +285,9 @@
return map;
}
- private Object getObjectInternal(Fqn fqn, String field, Object source) throws CacheException
+ private Object getObjectInternal(Fqn<?> fqn, String field, Object source) throws CacheException
{
- Fqn internalFqn = fqn;
+ Fqn<?> internalFqn = fqn;
PojoReference pojoReference = internal_.getPojoReference(fqn, field);
if (pojoReference != null)
{
@@ -347,21 +347,21 @@
}
}
- public boolean exists(Fqn id)
+ public boolean exists(Fqn<?> id)
{
return internal_.getPojoReference(id, null) != null || internal_.getPojoInstance(id) != null;
}
- public Fqn getInternalFqn(Object object)
+ public Fqn<?> getInternalFqn(Object object)
{
AbstractHandler handler = getHandler(object.getClass(), true);
- Fqn internalFqn = handler.getFqn(object);
+ Fqn<?> internalFqn = handler.getFqn(object);
return internalFqn;
}
public Collection<Reference> getReferences(Object object)
{
- Fqn fqn = getInternalFqn(object);
+ Fqn<?> fqn = getInternalFqn(object);
if (fqn == null)
return Collections.emptyList();
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -8,6 +8,7 @@
package org.jboss.cache.pojo.impl;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.regex.Pattern;
@@ -25,9 +26,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.OldFileFormatException;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.PojoCacheThreadContext;
@@ -57,20 +55,9 @@
{
try
{
- // cache_ = new PojoTreeCache();
- // cache_.setConfiguration(new XmlConfigurationParser().parseFile(configStr));
-
- XmlConfigurationParser parser = new XmlConfigurationParser();
- Configuration expected = parser.parseFile(configStr);
-
- init(expected, toStart);
+ cache = (CacheSPI<Object, Object>)DefaultCacheFactory.getInstance().createCache(configStr, toStart);
+ delegate_ = new PojoCacheDelegate(this);
}
- catch (OldFileFormatException e)
- {
- log_.warn("Detected legacy configuration file format when parsing [" + configStr + "]. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
- XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
- init(oldParser.parseFile(configStr), toStart);
- }
catch (Exception e)
{
throw new PojoCacheException("Failed to start " + configStr, e);
@@ -79,14 +66,9 @@
public PojoCacheImpl(Configuration config, boolean toStart)
{
- init(config, toStart);
- }
-
- private void init(Configuration config, boolean toStart)
- {
try
{
- cache = (CacheSPI<Object, Object>) (new DefaultCacheFactory()).createCache(config, toStart);
+ cache = (CacheSPI<Object, Object>) DefaultCacheFactory.getInstance().createCache(config, toStart);
}
catch (Exception e)
{
@@ -106,12 +88,12 @@
return attach(Fqn.fromString(id), pojo);
}
- public Object attach(Fqn id, Object pojo) throws PojoCacheException
+ public Object attach(Fqn<?> id, Object pojo) throws PojoCacheException
{
return attach(id, pojo, null, null);
}
- public Object attach(Fqn id, Object pojo, String field, Object source) throws PojoCacheException
+ public Object attach(Fqn<?> id, Object pojo, String field, Object source) throws PojoCacheException
{
TransactionManager tm = getTransactionManager();
boolean createdTransaction = setupTransaction(tm);
@@ -123,6 +105,9 @@
catch (Throwable t)
{
setRollbackOnly(tm);
+ if (t instanceof PojoCacheException)
+ throw (PojoCacheException)t;
+
throw new PojoCacheException("attach failed " + id, t);
}
finally
@@ -132,7 +117,7 @@
}
}
- public Object detach(Fqn id, String field, Object source) throws PojoCacheException
+ public Object detach(Fqn<?> id, String field, Object source) throws PojoCacheException
{
TransactionManager tm = getTransactionManager();
boolean createdTransaction = setupTransaction(tm);
@@ -144,6 +129,8 @@
catch (Throwable t)
{
setRollbackOnly(tm);
+ if (t instanceof PojoCacheException)
+ throw (PojoCacheException)t;
throw new PojoCacheException("detach failed " + id, t);
}
finally
@@ -153,7 +140,7 @@
}
}
- private void endTransaction(TransactionManager tm, Fqn id)
+ private void endTransaction(TransactionManager tm, Fqn<?> id)
{
try
{
@@ -229,12 +216,12 @@
- public Object detach(Fqn id) throws PojoCacheException
+ public Object detach(Fqn<?> id) throws PojoCacheException
{
return detach(id, null, null);
}
- public Fqn getInternalFqn(Object object)
+ public Fqn<?> getInternalFqn(Object object)
{
return delegate_.getInternalFqn(object);
}
@@ -244,7 +231,7 @@
return delegate_.getReferences(object);
}
- public boolean exists(Fqn id)
+ public boolean exists(Fqn<?> id)
{
return delegate_.exists(id);
}
@@ -254,7 +241,7 @@
return find(Fqn.fromString(id));
}
- public Object find(Fqn id) throws PojoCacheException
+ public Object find(Fqn<?> id) throws PojoCacheException
{
try
{
@@ -266,18 +253,18 @@
}
}
- public Object find(Fqn id, String field, Object source) throws CacheException
+ public Object find(Fqn<?> id, String field, Object source) throws CacheException
{
return delegate_.getObject(id, field, source);
}
- public Map<Fqn, Object> findAll(String id) throws PojoCacheException
+ public Map<Fqn<?>, Object> findAll(String id) throws PojoCacheException
{
return findAll(Fqn.fromString(id));
}
- public Map<Fqn, Object> findAll(Fqn id) throws PojoCacheException
+ public Map<Fqn<?>, Object> findAll(Fqn<?> id) throws PojoCacheException
{
// Should produce "/"
if (id == null) id = Fqn.ROOT;
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -40,10 +40,10 @@
{
private static final long serialVersionUID = 2647262858847953704L;
- private Fqn fqn;
+ private Fqn<?> fqn;
private String key;
- public ReferenceImpl(Fqn fqn)
+ public ReferenceImpl(Fqn<?> fqn)
{
this(fqn, null);
}
@@ -52,7 +52,7 @@
* @param fqn <code>Fqn</code> of the referring node. Cannot be <code>null</code>.
* @param key Name of the field, index in the field or key in the collection that is containing the reference.
*/
- public ReferenceImpl(Fqn fqn, String key)
+ public ReferenceImpl(Fqn<?> fqn, String key)
{
if (fqn == null)
throw new IllegalArgumentException("Fqn can not be null!!");
@@ -66,7 +66,7 @@
return key;
}
- public Fqn getFqn()
+ public Fqn<?> getFqn()
{
return fqn;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHandler.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -38,7 +38,7 @@
internal_ = internal;
}
- protected Fqn getFqn(Object obj)
+ protected Fqn<?> getFqn(Object obj)
{
// Not supported
return null;
@@ -59,7 +59,7 @@
@Override
- protected void put(Fqn fqn, Reference reference, Object obj) throws CacheException
+ protected void put(Fqn<?> fqn, Reference reference, Object obj) throws CacheException
{
// Note that JBoss Serialization can serialize any type now.
if (log_.isDebugEnabled())
@@ -87,7 +87,7 @@
}
@Override
- protected Object remove(Fqn fqn, Reference reference, Object result) throws CacheException
+ protected Object remove(Fqn<?> fqn, Reference reference, Object result) throws CacheException
{
cache.removeNode(fqn);
return result;
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInterceptor.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -12,7 +12,7 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
/**
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -859,7 +859,7 @@
private CacheJmxWrapper buildPlainCacheWrapper(PojoCache pojoCache)
{
CacheJmxWrapper plainCache = new CacheJmxWrapper();
- plainCache.setRegisterInterceptors(getRegisterInterceptors());
+ //plainCache.setRegisterInterceptors(getRegisterInterceptors());
plainCache.setCache(pojoCache.getCache());
// It shouldn't send out lifecycle state change notifications for itself;
// we do it
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -134,7 +134,7 @@
// TODO Don't know why. But this will fail the CachedSetAopTest clear() method since look up is always
// Null at the last index. But why?
// TODO also see JBCACHE-282
- return Fqn.fromRelativeElements(baseFqn, relative.toString());
+ return new Fqn(baseFqn, relative.toString());
// String tmp = baseFqn.toString() +"/" + relative.toString();
// return Fqn.fromString(tmp);
@@ -154,7 +154,7 @@
Fqn trueId = null;
if (fqn.hasElement(InternalConstant.JBOSS_INTERNAL_ID_SEP_STRING))
{
- List<Object> list = new ArrayList<Object>();
+ List list = new ArrayList();
for (int i = 0; i < fqn.size(); i++)
{
if (fqn.get(i).equals(InternalConstant.JBOSS_INTERNAL_STRING))
@@ -168,7 +168,7 @@
}
list.add(fqn.get(i));
}
- trueId = Fqn.fromList(list);
+ trueId = new Fqn(list);
}
else
{
@@ -183,9 +183,9 @@
if (region == null || region.getFqn().equals(Fqn.ROOT))
{
// Move id under JBInternal to promote concurrency
- Fqn f0 = Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, trueId);
- Fqn f = Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
- return Fqn.fromRelativeElements(f, guid.toString());
+ Fqn f0 = new Fqn(InternalConstant.JBOSS_INTERNAL, trueId);
+ Fqn f = new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
+ return new Fqn(f, Fqn.fromString(guid.toString()));
}
else
{
@@ -193,10 +193,10 @@
Fqn rf = region.getFqn();
// Extract rest of fqn id
Fqn childf = trueId.getSubFqn(rf.size(), trueId.size());
- Fqn f0 = Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, childf);
- Fqn f = Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
- Fqn f1 = Fqn.fromRelativeFqn(rf, f);
- return Fqn.fromRelativeElements(f1, guid.toString());
+ Fqn f0 = new Fqn(InternalConstant.JBOSS_INTERNAL, childf);
+ Fqn f = new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP);
+ Fqn f1 = new Fqn(rf, f);
+ return new Fqn(f1, Fqn.fromString(guid.toString()));
}
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -56,7 +56,7 @@
cache1.start();
cache2 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache2.getCache().addCacheListener(new MyCacheListener(false));
+ //cache2.getCache().addCacheListener(new MyCacheListener(false));
cache2.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/BuddyReplicationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/BuddyReplicationTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/BuddyReplicationTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -34,6 +34,7 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.pojo.test.Person;
import org.testng.annotations.AfterMethod;
@@ -47,7 +48,7 @@
* @version $Revision$
*/
@Test(groups = {"functional"})
-public class BuddyReplicationTest
+public class BuddyReplicationTest
{
Log log = LogFactory.getLog(ReplicatedTest.class);
PojoCache cache, cache1;
@@ -60,12 +61,17 @@
Configuration cfg1 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
addBuddyReplication(cfg1);
cache = PojoCacheFactory.createCache(cfg1, toStart);
- cache.start();
+
Configuration cfg2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
addBuddyReplication(cfg2);
cache1 = PojoCacheFactory.createCache(cfg2, toStart);
+
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
+
+ cache.start();
cache1.start();
-
+
// Enable gravitation
cache.getThreadContext().setGravitationEnabled(true);
cache1.getThreadContext().setGravitationEnabled(true);
@@ -88,6 +94,8 @@
brc.setBuddyLocatorConfig(blc);
cfg.setBuddyReplicationConfig(brc);
+ //FIXME
+ cfg.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
}
private Person createPerson(String id, String name, int age)
@@ -101,6 +109,7 @@
private Person getReplicatedPerson(String id) throws PojoCacheException
{
+ log.info("getting replicant: " + id);
Person repl = (Person) cache1.find(id);
assertNotNull("Person found at " + id, repl);
return repl;
@@ -120,28 +129,23 @@
public void testDynamicRefSwapping() throws Exception
{
Person person = createPerson("/person/test3", "Joe", 32);
- try
- {
- person.setAge(30);
- List<String> med = person.getMedication();
- assertNull("Medication should be null ", med);
- person.setAge(61);
- med = person.getMedication();
- assertEquals("Medication ", (Object) "Lipitor", (Object) med.get(0));
- assertEquals("Medication on cache1 ", "Lipitor",
- person.getMedication().get(0));
+ person.setAge(30);
+ List<String> med = person.getMedication();
+ assertNull("Medication should be null ", med);
+ person.setAge(61);
+ med = person.getMedication();
+ assertEquals("Medication ", (Object) "Lipitor", (Object) med.get(0));
+ assertEquals("Medication on cache1 ", "Lipitor",
+ person.getMedication().get(0));
- person.setAge(71);
- assertEquals("Medication ", "Vioxx", med.get(1));
- Person repl = getReplicatedPerson("/person/test3");
- assertEquals("Medication on cache1 ", "Vioxx",
- repl.getMedication().get(1));
- cache.detach("/person/test3");
-
- } catch (Exception e)
- {
- // should be thrown
- }
+ person.setAge(71);
+ assertEquals("Medication ", "Vioxx", med.get(1));
+ Person repl = getReplicatedPerson("/person/test3");
+ List<String> medication = repl.getMedication();
+ log.info("Got medication!");
+ assertEquals("Medication on cache1 ", "Vioxx",
+ medication.get(1));
+ cache.detach("/person/test3");
}
public void testTransient() throws Exception
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -40,7 +40,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/EnumTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/EnumTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/EnumTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -42,7 +42,7 @@
*/
@Test(groups = {"functional"})
-public class EnumTest
+public class EnumTest
{
Log log = LogFactory.getLog(EnumTest.class);
PojoCache cache_, cache1_;
@@ -50,12 +50,12 @@
@Replicable
public static class EnumContainer
{
- private EnumPlanet planet = EnumPlanet.EARTH;
+ private EnumPlanet planet = EnumPlanet.EARTH;
- public void setPlanet(EnumPlanet planet)
- {
- this.planet = planet;
- }
+ public void setPlanet(EnumPlanet planet)
+ {
+ this.planet = planet;
+ }
public EnumPlanet getPlanet()
{
@@ -77,9 +77,13 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- boolean toStart = true;
+ boolean toStart = false;
cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache_.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1_.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache_.start();
+ cache1_.start();
}
@AfterMethod(alwaysRun = true)
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -28,7 +28,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -82,7 +82,7 @@
log.info("testNoReferences() ....");
Person joe = createPerson("/person/joe", "Joe Black", 32, null);
- Fqn joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
assertTrue("Internal Fqn not null", joesInternalFqn != null);
Collection<Reference> addressReferences = cache_.getReferences(joe);
@@ -97,7 +97,7 @@
Address address = createAddress();
Person joe = createPerson("/person/joe", "Joe Black", 32, address);
- Fqn joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
Collection<Reference> addressReferences = cache_.getReferences(address);
assertEquals("Size", 1, addressReferences.size());
@@ -112,8 +112,8 @@
Person joe = createPerson("/person/joe", "Joe Black", 32, address);
Person jane = createPerson("/person/jane", "Jane Black", 32, address);
- Fqn joesInternalFqn = cache_.getInternalFqn(joe);
- Fqn janesInternalFqn = cache_.getInternalFqn(jane);
+ Fqn<?> joesInternalFqn = cache_.getInternalFqn(joe);
+ Fqn<?> janesInternalFqn = cache_.getInternalFqn(jane);
HashSet<Reference> expectedReferences = new HashSet<Reference>(Arrays.<Reference> asList(
new ReferenceImpl(joesInternalFqn, "address"), new ReferenceImpl(janesInternalFqn, "address")));
@@ -129,7 +129,7 @@
DoubleRef doubleRef = new DoubleRef();
cache_.attach("/doubleref", doubleRef);
- Fqn sourceFqn = cache_.getInternalFqn(doubleRef);
+ Fqn<?> sourceFqn = cache_.getInternalFqn(doubleRef);
HashSet<Reference> expectedReferences = new HashSet<Reference>(Arrays.<Reference> asList(
new ReferenceImpl(sourceFqn, "one"), new ReferenceImpl(sourceFqn, "two")));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -16,12 +16,14 @@
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
+import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.lock.UpgradeException;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -35,7 +37,7 @@
* @author<a href="mailto:bwang@jboss.org">Ben Wang</a> December 2004
*/
@Test(groups = {"functional"})
-public class LocalConcurrentTest
+public class LocalConcurrentTest
{
static PojoCache cache_;
Configuration.CacheMode cachingMode_ = Configuration.CacheMode.LOCAL;
@@ -89,7 +91,8 @@
{
cachingMode_ = caching_mode;
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache("configs/local-tx.xml", toStart);
+ cache_ = PojoCacheFactory.createCache("META-INF/local-service.xml", toStart);
+ System.out.println(cache_.getCache().getConfiguration().getConcurrencyLevel());
cache_.start();
}
@@ -198,13 +201,22 @@
// Operation 1
private void op1()
{
- int i = random_.nextInt(nodeList_.size() - 1);
- if (i == 0) return;// it is meaningless to test root
- String node = nodeList_.get(i) + "/aop";
- cache_.attach(node, person_);
- TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
- TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
- cache_.detach(node);
+ try
+ {
+ int i = random_.nextInt(nodeList_.size() - 1);
+ if (i == 0) return;// it is meaningless to test root
+ String node = nodeList_.get(i) + "/aop";
+ cache_.attach(node, person_);
+ TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
+ TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
+
+ cache_.detach(node);
+ }
+ catch (PojoCacheException e)
+ {
+ if (! (e.getCause() instanceof TimeoutException))
+ throw e;
+ }
}
}
@@ -256,7 +268,8 @@
break;
}
}
- log("Nodes generated: " + strList.size());
+ log("Nodes generated: " + strList);
+
return strList;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -47,12 +47,10 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
- XmlConfigurationParser parser = new XmlConfigurationParser();
- Configuration expected = parser.parseFile(configFile);
+ String configFile = "META-INF/local-service.xml";
//expected.setNodeLockingScheme(NodeLockingScheme.MVCC);
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache(expected, toStart);
+ cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
}
@@ -406,7 +404,7 @@
public void testExists() throws Exception
{
- Fqn fqn = Fqn.fromString("/person/test1");
+ Fqn<String> fqn = Fqn.fromString("/person/test1");
createPerson(fqn.toString(), "Joe Black", 32);
assertTrue(cache_.exists(fqn));
assertFalse(cache_.exists(Fqn.fromString("/blah")));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -24,10 +25,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -36,7 +37,7 @@
*/
@Test(groups = {"functional"})
-public class LocalTxTest
+public class LocalTxTest
{
Log log = LogFactory.getLog(LocalTxTest.class);
PojoCache cache;
@@ -51,7 +52,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
@@ -131,6 +132,8 @@
public void testConcurrentSimplePuts() throws Exception
{
+ final CountDownLatch t2Start = new CountDownLatch(1);
+ final CountDownLatch t2Finished = new CountDownLatch(1);
Thread t1 = new Thread("t1")
{
public void run()
@@ -144,7 +147,8 @@
tx.begin();
// Note that this will create a write lock on p (on the JBossInternal node)
p.setAddress(addr);
- TestingUtil.sleepThread(17000);
+ t2Start.countDown();
+ t2Finished.await();
tx.commit();
}
catch (RollbackException rollback)
@@ -165,7 +169,7 @@
UserTransaction tx = null;
try
{
- TestingUtil.sleepThread(1000); // give Thread1 time to createPerson
+ t2Start.await();
Person p = (Person) cache.find("/person/test6");
Address addr = new Address();
addr.setCity("Santa Clara");
@@ -200,6 +204,10 @@
t2_ex = ex;
ex.printStackTrace();
}
+ finally
+ {
+ t2Finished.countDown();
+ }
}
};
@@ -268,6 +276,10 @@
{
//
}
+ catch (PojoCacheException e)
+ {
+
+ }
catch (Exception ex)
{
if (tx != null)
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -38,7 +38,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -177,7 +177,7 @@
addr.addResidents("Ben");
addr.addResidents("Joe");
// Test serialization first
- Fqn fqn = Fqn.fromString("/plain");
+ Fqn<String> fqn = Fqn.fromString("/plain");
cache_.getCache().put(fqn, "test", addr);
cache_.getCache().remove(fqn, "test");
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -27,8 +27,10 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
cache1.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -28,7 +28,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -27,7 +27,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -13,7 +13,7 @@
@Test(groups = {"functional"})
public class RecursiveRefTest
{
- private static final String CONFIG_FILENAME = "configs/local-tx.xml";
+ private static final String CONFIG_FILENAME = "META-INF/local-service.xml";
private PojoCache cache;
Log log = LogFactory.getLog(RecursiveRefTest.class);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedByteTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedByteTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedByteTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -39,7 +39,7 @@
* @author Ben Wang
*/
@Test(groups = {"functional"})
-public class ReplicatedByteTest
+public class ReplicatedByteTest
{
Log log = LogFactory.getLog(ReplicatedByteTest.class);
PojoCache cache, cache1;
@@ -52,8 +52,10 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache1.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedCircularGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedCircularGraphTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedCircularGraphTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -34,7 +34,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedCircularGraphTest
+public class ReplicatedCircularGraphTest
{
Log log = LogFactory.getLog(ReplicatedCircularGraphTest.class);
PojoCache cache1;
@@ -61,6 +61,7 @@
{
boolean toStart = false;
PojoCache tree = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ tree.getCache().getConfiguration().setSyncCommitPhase(true);
tree.start();
return tree;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -21,7 +21,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedObjectGraphTest
+public class ReplicatedObjectGraphTest
{
Log log = LogFactory.getLog(ReplicatedObjectGraphTest.class);
PojoCache cache1;
@@ -48,6 +48,7 @@
{
boolean toStart = false;
PojoCache tree = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ tree.getCache().getConfiguration().setSyncCommitPhase(true);
tree.start();
return tree;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedPutWithBulkRemoveTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedPutWithBulkRemoveTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedPutWithBulkRemoveTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -32,7 +32,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedPutWithBulkRemoveTest
+public class ReplicatedPutWithBulkRemoveTest
{
Log log_ = LogFactory.getLog(ReplicatedPutWithBulkRemoveTest.class);
PojoCache cache_;
@@ -47,6 +47,8 @@
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache_.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1_.getCache().getConfiguration().setSyncCommitPhase(true);
cache_.start();
cache1_.start();
}
@@ -176,7 +178,7 @@
assertEquals("Age should be ", 10, result.getAge());
assertEquals("Zip should be ", 95123, result.getAddress().getZip());
assertEquals("English", result.getLanguages().get(0));
- assertEquals("Spanish", result.getLanguages().get(1));
+ assertEquals("Spanish", result.getLanguages().get(1));
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedSerializableTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedSerializableTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedSerializableTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -47,6 +47,8 @@
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache_.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1_.getCache().getConfiguration().setSyncCommitPhase(true);
cache_.start();
cache1_.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -24,7 +24,7 @@
* @author Ben Wang
*/
@Test(groups = {"functional"})
-public class ReplicatedTest
+public class ReplicatedTest
{
Log log = LogFactory.getLog(ReplicatedTest.class);
PojoCache cache, cache1;
@@ -35,8 +35,12 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
+
cache.start();
- cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
cache1.start();
}
@@ -53,7 +57,7 @@
{
return createPerson(id, name, age, null);
}
-
+
private Person createPerson(String id, String name, int age, Map<String, String> map)
{
Person p = new Person(map);
@@ -119,13 +123,13 @@
((Person) cache1.find("/person/test1")).getCurrentStatus());
cache.detach("/person/test1");
}
-
+
public void testFinal() throws Exception
{
Person jason = createPerson("/person/test1", "Jason Greene", 28, new HashMap<String, String>());
jason.getFinalMap().put("test1", "testa");
jason.getFinalMap().put("test2", "testb");
-
+
Person jason2 = (Person) cache1.find("/person/test1");
assertEquals("testa", jason2.getFinalMap().get("test1"));
assertEquals("testb", jason2.getFinalMap().get("test2"));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTxTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ReplicatedTxTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -30,7 +30,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedTxTest
+public class ReplicatedTxTest
{
Log log = LogFactory.getLog(ReplicatedTxTest.class);
PojoCache cache, cache1;
@@ -47,8 +47,10 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
cache1.start();
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/annotation/ReplicatedAnnotationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/annotation/ReplicatedAnnotationTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/annotation/ReplicatedAnnotationTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -38,7 +38,7 @@
* @author Ben Wang
*/
@Test(groups = {"functional"})
-public class ReplicatedAnnotationTest
+public class ReplicatedAnnotationTest
{
Log log_ = LogFactory.getLog(ReplicatedAnnotationTest.class);
PojoCache cache_;
@@ -54,6 +54,8 @@
cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache_.getCache().getConfiguration().setSyncCommitPhase(true);
+ cache1_.getCache().getConfiguration().setSyncCommitPhase(true);
cache_.start();
cache1_.start();
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -42,7 +42,7 @@
public void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -40,7 +40,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -48,7 +48,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -376,10 +376,6 @@
}
catch (PojoCacheException e)
{
- Throwable t = e;
-
- assertTrue("we got expected PojoCacheException "
- + t.getCause().getClass().getName(), t.getCause() instanceof PojoCacheException);
}
map.clear();
cache_.attach("/keytest", map); // this should succeed
@@ -392,12 +388,8 @@
ref.put(key, add1); // this should throw RuntimeException with cause of java.io.NotSerializableException
fail("failed to get expected runtimeException when putting nonserializable key to pojocache map");
}
- catch (RuntimeException e)
+ catch (PojoCacheException e)
{
- Throwable t = e;
-
- assertTrue("we got expected PojoCacheException "
- + t.getClass().getName(), t instanceof PojoCacheException);
}
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -50,7 +50,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -34,7 +34,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -39,7 +39,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncMapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncMapTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncMapTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -35,7 +35,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedSyncMapTest
+public class ReplicatedSyncMapTest
{
Log log = LogFactory.getLog(ReplicatedSyncMapTest.class);
PojoCache cache1;
@@ -62,6 +62,7 @@
{
boolean toStart = false;
PojoCache cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
return cache;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncSetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncSetTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ReplicatedSyncSetTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -29,7 +29,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedSyncSetTest
+public class ReplicatedSyncSetTest
{
Log log = LogFactory.getLog(ReplicatedSyncSetTest.class);
PojoCache cache1;
@@ -56,6 +56,7 @@
{
boolean toStart = false;
PojoCache cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
return cache;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -595,9 +595,9 @@
private Node getNode(Object[] path)
{
- Fqn fqnToPath;
+ Fqn<String> fqnToPath;
if (path.length == 0) fqnToPath = Fqn.ROOT;
- List<Object> elements = convertMyNodeArrayToStringArray(path);
+ List<String> elements = convertMyNodeArrayToStringArray(path);
fqnToPath = Fqn.fromList(elements);
if (root.hasChild(fqnToPath))
{
@@ -610,9 +610,9 @@
}
}
- private List<Object> convertMyNodeArrayToStringArray(Object[] path)
+ private List<String> convertMyNodeArrayToStringArray(Object[] path)
{
- List<Object> list = new LinkedList<Object>();
+ List<String> list = new LinkedList<String>();
for (Object o : path)
{
JBossCacheGUI.DisplayNode n = (JBossCacheGUI.DisplayNode) o;
@@ -741,7 +741,7 @@
}
}
- private void load(Fqn fqn)
+ private void load(Fqn<String> fqn)
{
try
{
@@ -1153,19 +1153,19 @@
* Adds a new node to the view. Intermediary nodes will be created if they don't yet exist.
* Returns the first node that was created or null if node already existed
*/
- public JBossCacheGUI.DisplayNode add(Fqn fqn)
+ public JBossCacheGUI.DisplayNode add(Fqn<String> fqn)
{
JBossCacheGUI.DisplayNode curr, n, ret = null;
if (fqn == null) return null;
curr = this;
- for (Object child_name : fqn.peekElements())
+ for (String child_name : fqn.peekElements())
{
- n = curr.findChild(child_name.toString());
+ n = curr.findChild(child_name);
if (n == null)
{
- n = new JBossCacheGUI.DisplayNode(child_name.toString());
+ n = new JBossCacheGUI.DisplayNode(child_name);
if (ret == null) ret = n;
curr.add(n);
}
@@ -1184,16 +1184,16 @@
}
- private JBossCacheGUI.DisplayNode findNode(Fqn fqn)
+ private JBossCacheGUI.DisplayNode findNode(Fqn<String> fqn)
{
JBossCacheGUI.DisplayNode curr, n;
if (fqn == null) return null;
curr = this;
- for (Object child_name : fqn.peekElements())
+ for (String child_name : fqn.peekElements())
{
- n = curr.findChild(child_name.toString());
+ n = curr.findChild(child_name);
if (n == null)
{
return null;
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedNetworkManagementTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedNetworkManagementTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedNetworkManagementTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -33,7 +33,7 @@
*/
@Test(groups = {"functional"})
-public class ReplicatedNetworkManagementTest
+public class ReplicatedNetworkManagementTest
{
Log log = LogFactory.getLog(ReplicatedNetworkManagementTest.class);
PojoCache cache1;
@@ -60,6 +60,7 @@
{
boolean toStart = false;
PojoCache cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
return cache;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedPropagationManagerlTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedPropagationManagerlTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/integrated/ReplicatedPropagationManagerlTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -14,7 +14,7 @@
import org.testng.annotations.Test;
@Test(groups = {"functional"})
-public class ReplicatedPropagationManagerlTest
+public class ReplicatedPropagationManagerlTest
{
private PropagationManager pm_;
private PojoCache cache1_;
@@ -39,6 +39,7 @@
{
boolean toStart = false;
PojoCache cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
return cache;
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/InterceptorRegistrationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/InterceptorRegistrationTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/InterceptorRegistrationTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -29,422 +29,422 @@
/**
* Tests the interceptor registration function of CacheJmxWrapper.
- *
+ *
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled = false)
public class InterceptorRegistrationTest extends PojoCacheJmxWrapperTestBase
{
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * cache.start();
+// * wrapper creation and registration.
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans1() throws Exception
+// {
+// // have to start the cache to have any interceptors
+// createCache(createConfiguration());
+// cache.start();
+//
+// PojoCacheJmxWrapperMBean wrapper = registerWrapper(cache);
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// // Should still be registered
+// interceptorRegistrationTest(true);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * cache.start();
+// * wrapper creation and and start
+// * wrapper registration.
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans2() throws Exception
+// {
+// // have to start the cache to have any interceptors
+// createCache(createConfiguration());
+// cache.start();
+//
+// PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(cache);
+// wrapper.start();
+// wrapper = registerWrapper(wrapper);
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// // Should still be registered
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * Cache not injected
+// * wrapper registered;
+// * wrapper created and started.
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans3() throws Exception
+// {
+// PojoCacheJmxWrapperMBean wrapper = registerWrapper(createConfiguration());
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// // have to start the cache to have any interceptors
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// // Destroy should unregister if we are managing
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * Cache not injected
+// * wrapper created and started.
+// * wrapper registered
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans4() throws Exception
+// {
+// PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
+//
+// // have to start the cache to have any interceptors
+// wrapper.create();
+// wrapper.start();
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// // Destroy should unregister if we are managing
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * cache constructed;
+// * wrapper constructed and registered with manageCacheLifecycle=true
+// * wrapper created and started
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans5() throws Exception
+// {
+// PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(createCache(createConfiguration()));
+//// wrapper.setManageCacheLifecycle(true);
+// wrapper = registerWrapper(wrapper);
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// // have to start the cache to have any interceptors
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// // Destroy should unregister if we are managing
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * cache constructed;
+// * wrapper constructed and registered
+// * wrapper created and started
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans6() throws Exception
+// {
+// PojoCacheJmxWrapperMBean wrapper = registerWrapper();
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// // have to start the cache to have any interceptors
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Confirms interceptor mbeans are registered if the following events
+// * occur:
+// *
+// * cache constructed;
+// * wrapper created and started
+// * wrapper registered
+// *
+// * @throws Exception
+// */
+// public void testInterceptorMBeans7() throws Exception
+// {
+// PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(createCache(createConfiguration()));
+//
+// // have to start the cache to have any interceptors
+// wrapper.create();
+// wrapper.start();
+//
+// wrapper = registerWrapper(wrapper);
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(true);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Tests that setting registerInterceptors=false disables interceptor
+// * registration when the wrapper is registered before create/start
+// * are called.
+// *
+// * @throws Exception
+// */
+// public void testRegisterInterceptors1() throws Exception
+// {
+// PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
+// wrapper.setRegisterInterceptors(false);
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Tests that setting registerInterceptors=false disables interceptor
+// * registration when the wrapper is registered after create/start
+// * are called.
+// *
+// * @throws Exception
+// */
+// public void testRegisterInterceptors2() throws Exception
+// {
+// PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
+// wrapper.setRegisterInterceptors(false);
+//
+// wrapper.create();
+// wrapper.start();
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Tests that setting registerPlainCache=false disables interceptor
+// * registration when the wrapper is registered before create/start
+// * are called.
+// *
+// * @throws Exception
+// */
+// public void testRegisterPlainCache1() throws Exception
+// {
+// PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
+// wrapper.setRegisterPlainCache(false);
+// wrapper.setRegisterInterceptors(true);
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// /**
+// * Tests that setting registerPlainCache=false disables interceptor
+// * registration when the wrapper is registered after create/start
+// * are called.
+// *
+// * @throws Exception
+// */
+// public void testRegisterPlainCache2() throws Exception
+// {
+// PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
+// wrapper.setRegisterPlainCache(false);
+// wrapper.setRegisterInterceptors(true);
+//
+// wrapper.create();
+// wrapper.start();
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// public void testExposeManagementStatistics1() throws Exception
+// {
+// Configuration cfg = createConfiguration();
+// cfg.setExposeManagementStatistics(false);
+//
+// PojoCacheJmxWrapper wrapper = createWrapper(cfg);
+// registerWrapper(cfg);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// wrapper.create();
+// wrapper.start();
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+// }
+//
+// public void testExposeManagementStatistics2() throws Exception
+// {
+// Configuration cfg = createConfiguration();
+// cfg.setExposeManagementStatistics(false);
+//
+// PojoCacheJmxWrapper wrapper = createWrapper(cfg);
+//
+// wrapper.create();
+// wrapper.start();
+//
+// registerWrapper(wrapper);
+//
+// assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
+//
+// interceptorRegistrationTest(false);
+//
+// wrapper.stop();
+// wrapper.destroy();
+//
+// interceptorRegistrationTest(false);
+//
+// unregisterWrapper();
+//
+// interceptorRegistrationTest(false);
+//
+// }
+//
+//
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * cache.start();
- * wrapper creation and registration.
- *
- * @throws Exception
- */
- public void testInterceptorMBeans1() throws Exception
- {
- // have to start the cache to have any interceptors
- createCache(createConfiguration());
- cache.start();
-
- PojoCacheJmxWrapperMBean wrapper = registerWrapper(cache);
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- // Should still be registered
- interceptorRegistrationTest(true);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * cache.start();
- * wrapper creation and and start
- * wrapper registration.
- *
- * @throws Exception
- */
- public void testInterceptorMBeans2() throws Exception
- {
- // have to start the cache to have any interceptors
- createCache(createConfiguration());
- cache.start();
-
- PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(cache);
- wrapper.start();
- wrapper = registerWrapper(wrapper);
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- // Should still be registered
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * Cache not injected
- * wrapper registered;
- * wrapper created and started.
- *
- * @throws Exception
- */
- public void testInterceptorMBeans3() throws Exception
- {
- PojoCacheJmxWrapperMBean wrapper = registerWrapper(createConfiguration());
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- // have to start the cache to have any interceptors
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- // Destroy should unregister if we are managing
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * Cache not injected
- * wrapper created and started.
- * wrapper registered
- *
- * @throws Exception
- */
- public void testInterceptorMBeans4() throws Exception
- {
- PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
-
- // have to start the cache to have any interceptors
- wrapper.create();
- wrapper.start();
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- // Destroy should unregister if we are managing
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * cache constructed;
- * wrapper constructed and registered with manageCacheLifecycle=true
- * wrapper created and started
- *
- * @throws Exception
- */
- public void testInterceptorMBeans5() throws Exception
- {
- PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(createCache(createConfiguration()));
-// wrapper.setManageCacheLifecycle(true);
- wrapper = registerWrapper(wrapper);
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- // have to start the cache to have any interceptors
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- // Destroy should unregister if we are managing
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * cache constructed;
- * wrapper constructed and registered
- * wrapper created and started
- *
- * @throws Exception
- */
- public void testInterceptorMBeans6() throws Exception
- {
- PojoCacheJmxWrapperMBean wrapper = registerWrapper();
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- // have to start the cache to have any interceptors
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Confirms interceptor mbeans are registered if the following events
- * occur:
- *
- * cache constructed;
- * wrapper created and started
- * wrapper registered
- *
- * @throws Exception
- */
- public void testInterceptorMBeans7() throws Exception
- {
- PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(createCache(createConfiguration()));
-
- // have to start the cache to have any interceptors
- wrapper.create();
- wrapper.start();
-
- wrapper = registerWrapper(wrapper);
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(true);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Tests that setting registerInterceptors=false disables interceptor
- * registration when the wrapper is registered before create/start
- * are called.
- *
- * @throws Exception
- */
- public void testRegisterInterceptors1() throws Exception
- {
- PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
- wrapper.setRegisterInterceptors(false);
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Tests that setting registerInterceptors=false disables interceptor
- * registration when the wrapper is registered after create/start
- * are called.
- *
- * @throws Exception
- */
- public void testRegisterInterceptors2() throws Exception
- {
- PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
- wrapper.setRegisterInterceptors(false);
-
- wrapper.create();
- wrapper.start();
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Tests that setting registerPlainCache=false disables interceptor
- * registration when the wrapper is registered before create/start
- * are called.
- *
- * @throws Exception
- */
- public void testRegisterPlainCache1() throws Exception
- {
- PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
- wrapper.setRegisterPlainCache(false);
- wrapper.setRegisterInterceptors(true);
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- /**
- * Tests that setting registerPlainCache=false disables interceptor
- * registration when the wrapper is registered after create/start
- * are called.
- *
- * @throws Exception
- */
- public void testRegisterPlainCache2() throws Exception
- {
- PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
- wrapper.setRegisterPlainCache(false);
- wrapper.setRegisterInterceptors(true);
-
- wrapper.create();
- wrapper.start();
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- public void testExposeManagementStatistics1() throws Exception
- {
- Configuration cfg = createConfiguration();
- cfg.setExposeManagementStatistics(false);
-
- PojoCacheJmxWrapper wrapper = createWrapper(cfg);
- registerWrapper(cfg);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- wrapper.create();
- wrapper.start();
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
- }
-
- public void testExposeManagementStatistics2() throws Exception
- {
- Configuration cfg = createConfiguration();
- cfg.setExposeManagementStatistics(false);
-
- PojoCacheJmxWrapper wrapper = createWrapper(cfg);
-
- wrapper.create();
- wrapper.start();
-
- registerWrapper(wrapper);
-
- assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
-
- interceptorRegistrationTest(false);
-
- wrapper.stop();
- wrapper.destroy();
-
- interceptorRegistrationTest(false);
-
- unregisterWrapper();
-
- interceptorRegistrationTest(false);
-
- }
-
-
-
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -181,7 +181,7 @@
assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toString(), wrapper.getEvictionPolicyConfig().toString());
EvictionConfig ec = c.getEvictionConfig();
- assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize());
+ //assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize());
assertEquals("EC wakeup", 5, ec.getWakeupIntervalSeconds());
assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefaultEvictionPolicyClass());
List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
@@ -248,7 +248,7 @@
" </properties>\n" +
" </locator>\n" +
" </buddy>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getCacheLoaderConfig() throws Exception
@@ -273,7 +273,7 @@
" <singletonStore enabled=\"false\" /> \n" +
" </loader>\n" +
" </loaders>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getEvictionPolicyConfig() throws Exception
@@ -296,7 +296,7 @@
" <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
"</region>\n" +
" </eviction>";
- return XmlConfigHelper.stringToElement(xmlStr);
+ return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
protected static Element getClusterConfig() throws Exception
@@ -352,7 +352,7 @@
" <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
" <pbcast.FLUSH timeout=\"0\"/>\n" +
"</jgroupsConfig>";
-return XmlConfigHelper.stringToElement(xml);
+return XmlConfigHelper.stringToElementInCoreNS(xml);
}
class MockInvocationHandler implements InvocationHandler
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/NotificationTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/NotificationTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/NotificationTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -16,7 +16,7 @@
* @version $Id$
*/
@Test(groups = {"functional"})
-public class NotificationTest extends org.jboss.cache.jmx.NotificationTest
+public class NotificationTest extends org.jboss.cache.jmx.deprecated.NotificationTest
{
private PojoCache pojoCache;
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTestBase.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTestBase.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTestBase.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -22,7 +22,7 @@
* @author Brian Stansberry
*/
@Test(groups = {"functional"})
-public class PojoCacheJmxWrapperTestBase
+public class PojoCacheJmxWrapperTestBase
{
public static final String PC_PREFIX = JmxUtil.POJO_CACHE_DOMAIN + ":" +
JmxUtil.SERVICE_KEY_NAME + "=PojoCacheJmxWrapperTest," +
@@ -151,6 +151,7 @@
mBeanServer.unregisterMBean(mBeanName);
}
+ /*
protected void interceptorRegistrationTest(boolean expectMbeans) throws MalformedObjectNameException, NullPointerException
{
interceptorRegistrationTest(plainCacheMBeanNameStr, expectMbeans);
@@ -173,4 +174,5 @@
assertFalse(n + " should not be registered", mBeanServer.isRegistered(n));
}
}
+ */
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -72,13 +72,13 @@
ClassLoader cla = getClassLoader();
WeakReference<ClassLoader> refa = new WeakReference<ClassLoader>(cla);
- cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(cla);
+ cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(cla);
ClassLoader clb = getClassLoader();
WeakReference<ClassLoader> refb = new WeakReference<ClassLoader>(clb);
- cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clb);
+ cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clb);
- Fqn fqn = Fqn.fromString("/aop");
- cache_.getCache().put(Fqn.fromString("/aop"), "add", add);
+ Fqn<String> fqn = new Fqn<String>("/aop");
+ cache_.getCache().put(new Fqn<String>("/aop"), "add", add);
TestingUtil.sleepThread(100);
try
@@ -97,8 +97,8 @@
ClassLoader clc = getClassLoader();
cla = null;
clb = null;
- cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
- cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
+ cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
+ cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
System.gc(); // force gc
Thread.sleep(1000);
assertNull("Classloader should be gced ", refa.get());
@@ -140,9 +140,9 @@
ClassLoader cla = getClassLoader();
WeakReference<ClassLoader> refa = new WeakReference<ClassLoader>(cla);
- cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(cla);
+ cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(cla);
ClassLoader clb = getClassLoader();
- cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clb);
+ cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clb);
WeakReference<ClassLoader> refb = new WeakReference<ClassLoader>(clb);
cache_.attach("/aop", p);
@@ -161,8 +161,8 @@
cache_.detach("/aop");
ClassLoader clc = getClassLoader();
- cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
- cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerContextClassLoader(clc);
+ cache_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
+ cache1_.getCache().getRegion(new Fqn<String>("/aop"), true).registerContextClassLoader(clc);
cla = null;
clb = null;
forceOutOfMemoryError();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -55,7 +55,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCountTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -31,7 +31,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -54,7 +54,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -40,7 +40,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedListTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedListTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedListTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -52,8 +52,10 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config.setFetchInMemoryState(false);
+ config.setSyncCommitPhase(true);
Configuration config2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config2.setFetchInMemoryState(false);
+ config2.setSyncCommitPhase(true);
cache = PojoCacheFactory.createCache(config, false);
cache.start();
listenerCache = PojoCacheFactory.createCache(config2, false);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedMapTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedMapTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedMapTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -52,8 +52,10 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config.setFetchInMemoryState(false);
+ config.setSyncCommitPhase(true);
Configuration config2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config2.setFetchInMemoryState(false);
+ config2.setSyncCommitPhase(true);
cache = PojoCacheFactory.createCache(config, false);
cache.start();
listenerCache = PojoCacheFactory.createCache(config2, false);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedObjectTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedObjectTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedObjectTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -52,8 +52,10 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config.setFetchInMemoryState(false);
+ config.setSyncCommitPhase(true);
Configuration config2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config2.setFetchInMemoryState(false);
+ config2.setSyncCommitPhase(true);
cache = PojoCacheFactory.createCache(config, false);
cache.start();
listenerCache = PojoCacheFactory.createCache(config2, false);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedSetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedSetTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedSetTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -52,8 +52,10 @@
{
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config.setFetchInMemoryState(false);
+ config.setSyncCommitPhase(true);
Configuration config2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
config2.setFetchInMemoryState(false);
+ config2.setSyncCommitPhase(true);
cache = PojoCacheFactory.createCache(config, false);
cache.start();
listenerCache = PojoCacheFactory.createCache(config2, false);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -55,7 +55,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -58,7 +58,7 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache = PojoCacheFactory.createCache(configFile, toStart);
cache.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -142,7 +142,7 @@
{
log.info("testFailure1() ....");
UserTransaction tx = getTransaction();
- Fqn f = Fqn.fromString("/person/test2");
+ Fqn<String> f = Fqn.fromString("/person/test2");
tx.begin();
cache.getCache().put(f, "test", "test");
tx.commit();
@@ -155,9 +155,9 @@
public void testFailure2() throws Exception
{
- Fqn f0 = Fqn.fromString("/person/test");
- Fqn f1 = Fqn.fromRelativeElements(f0, "1");
- Fqn f2 = Fqn.fromRelativeElements(f0, "2");
+ Fqn<String> f0 = Fqn.fromString("/person/test");
+ Fqn<String> f1 = new Fqn<String>(f0, "1");
+ Fqn<String> f2 = new Fqn<String>(f0, "2");
cache.getCache().put(f1, "test", "test");
cache.getCache().put(f2, "test", "test");
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-passivation.xml";
+ String configFile = "META-INF/pojocache-passivation-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.getCache().getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.BatchModeTransactionManagerLookup");
@@ -101,7 +101,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
assertEquals("age ", 20, joe.getAge());
joe.setAge(30);
@@ -118,7 +118,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
Address addr = new Address();
addr.setCity("Taipei");
@@ -137,7 +137,7 @@
cache_.attach(id, joe);
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
Person p = (Person) cache_.find(id);
@@ -182,7 +182,7 @@
Thread.sleep(9100);// default is 3 seconds so joe should have been passivated.
- assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(Fqn.fromString(id), false));
+ assertNull("Node should be evicted ", ((CacheSPI<Object, Object>) cache_.getCache()).peek(new Fqn<String>(id), false));
assertEquals("City is ", "Santa Clara", add2.getCity());
@@ -268,7 +268,7 @@
@NodeActivated
public void nodeActivated(NodeEvent ne)
{
- Fqn fqn = ne.getFqn();
+ Fqn<?> fqn = ne.getFqn();
if (!ne.isPre())
{
System.out.println("nodeActivated: " + fqn);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -16,9 +16,11 @@
import javax.transaction.UserTransaction;
import org.jboss.cache.Fqn;
+import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.lock.UpgradeException;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.Person;
@@ -35,7 +37,7 @@
* @author<a href="mailto:bwang@jboss.org">Ben Wang</a> December 2004
*/
@Test(groups = {"functional"})
-public class LocalConcurrentTest
+public class LocalConcurrentTest
{
static PojoCache cache_;
Properties p_;
@@ -47,22 +49,10 @@
static final int MAX_LOOP = 100;
static final int SLEEP_TIME = 50;
static Exception thread_ex = null;
- UserTransaction tx_ = null;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- oldFactory_ = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
- DummyTransactionManager.getInstance();
- if (p_ == null)
- {
- p_ = new Properties();
- p_.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
- }
-
- tx_ = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
-
initCaches();
nodeList_ = nodeGen(depth_, children_);
@@ -73,21 +63,14 @@
public void tearDown() throws Exception
{
thread_ex = null;
- DummyTransactionManager.destroy();
destroyCaches();
-
- if (oldFactory_ != null)
- {
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
- oldFactory_ = null;
- }
-
}
void initCaches() throws Exception
{
boolean toStart = false;
- cache_ = PojoCacheFactory.createCache("configs/local-tx.xml", toStart);
+ cache_ = PojoCacheFactory.createCache("META-INF/local-service.xml", toStart);
+ cache_.getCache().getConfiguration().setConcurrencyLevel(50);
cache_.start();
}
@@ -195,13 +178,21 @@
// Operation 1
private void op1()
{
- int i = random_.nextInt(nodeList_.size() - 1);
- if (i == 0) return; // it is meaningless to test root
- String node = nodeList_.get(i) + "/aop";
- cache_.attach(node, person_);
- TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
- TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
- cache_.detach(node);
+ try
+ {
+ int i = random_.nextInt(nodeList_.size() - 1);
+ if (i == 0) return; // it is meaningless to test root
+ String node = nodeList_.get(i) + "/aop";
+ cache_.attach(node, person_);
+ TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ cache_.detach(node);
+ }
+ catch (PojoCacheException e)
+ {
+ if (! (e.getCause() instanceof TimeoutException))
+ throw e;
+ }
}
}
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -52,7 +52,7 @@
protected void setUp() throws Exception
{
log.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
@@ -102,8 +102,8 @@
assertEquals((Object) "Joe Black", p.getName());
assertTrue("Region node should exist ",
- cache_.getCache().getRoot().hasChild(Fqn.fromString(REGION)));
- Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ cache_.getCache().getRoot().hasChild(new Fqn<String>(REGION)));
+ Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
assertTrue("Internal region node should exist ",
cache_.getCache().getRoot().hasChild(fqn));
//System.out.println("Cache content: " +((org.jboss.cache.CacheImpl<Object, Object>)cache_.getCache()).printDetails());
@@ -125,7 +125,7 @@
//String str = ((CacheImpl<Object, Object>) cache_.getCache()).printDetails();
//System.out.println("**** Details ***/n" + str);
- Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
Node<Object, Object> n = cache_.getCache().getRoot().getChild(fqn);
assertTrue("Internal region node should not exist ",
n.getChildren() != null);
@@ -200,7 +200,7 @@
cache_.detach("person/test1");
- Fqn fqn = Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
+ Fqn<String> fqn = new Fqn<String>(Fqn.fromString(REGION), InternalConstant.JBOSS_INTERNAL);
Node<Object, Object> n = cache_.getCache().getRoot().getChild(fqn);
assertTrue("Internal region node should not exist ",
n.getChildren() != null);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -41,7 +41,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/ReplicatedTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/ReplicatedTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/ReplicatedTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -44,8 +44,10 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
cache1.start();
cache.getCache().getRegion(Fqn.fromString("SESSION"), true);
cache1.getCache().getRegion(Fqn.fromString("SESSION"), true);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -47,7 +47,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -64,7 +64,7 @@
public void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.getCache().getConfiguration().setLockAcquisitionTimeout(500); // timeout to 500 ms
@@ -173,11 +173,11 @@
{
try
{
- Fqn f = Fqn.fromString(InternalConstant.JBOSS_INTERNAL_STRING);
- cache_.getCache().put(Fqn.fromRelativeElements(f, "123"), "key", "test");
- cache_.getCache().put(Fqn.fromString("a"), "key", "test");
+ Fqn<String> f = new Fqn<String>(InternalConstant.JBOSS_INTERNAL_STRING);
tx_mgr.begin();
- cache_.getCache().put(Fqn.fromRelativeElements(f, "124"), "key", "test");
+ cache_.getCache().put(new Fqn<String>(f, "123"), "key", "test");
+ cache_.getCache().put(new Fqn<String>("a"), "key", "test");
+ cache_.getCache().put(new Fqn<String>(f, "124"), "key", "test");
while (!isTrue)
{
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -45,7 +45,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRollbackTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -58,7 +58,7 @@
private void startTest() throws Exception
{
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ReplicatedTxTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ReplicatedTxTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ReplicatedTxTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -56,8 +56,10 @@
log.info("setUp() ....");
boolean toStart = false;
cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.getCache().getConfiguration().setSyncCommitPhase(true);
cache.start();
cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1.getCache().getConfiguration().setSyncCommitPhase(true);
cache1.start();
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -43,7 +43,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java 2008-09-17 23:24:20 UTC (rev 6747)
@@ -32,7 +32,7 @@
protected void setUp() throws Exception
{
log_.info("setUp() ....");
- String configFile = "configs/local-tx.xml";
+ String configFile = "META-INF/local-service.xml";
boolean toStart = false;
cache_ = PojoCacheFactory.createCache(configFile, toStart);
cache_.start();
Modified: pojo/trunk/src/test/resources/META-INF/unit-test-cache-service.xml
===================================================================
--- pojo/trunk/src/test/resources/META-INF/unit-test-cache-service.xml 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/resources/META-INF/unit-test-cache-service.xml 2008-09-17 23:24:20 UTC (rev 6747)
@@ -171,7 +171,7 @@
max_bundle_timeout="30"
use_incoming_packet_handler="true"
ip_ttl="2"
- enable_bundling="true"
+ enable_bundling="false"
enable_diagnostics="true"
use_concurrent_stack="true"
Modified: pojo/trunk/src/test/resources/log4j.xml
===================================================================
--- pojo/trunk/src/test/resources/log4j.xml 2008-09-17 15:42:17 UTC (rev 6746)
+++ pojo/trunk/src/test/resources/log4j.xml 2008-09-17 23:24:20 UTC (rev 6747)
@@ -31,7 +31,7 @@
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
- <param name="Threshold" value="DEBUG"/>
+ <param name="Threshold" value="TRACE"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
16 years, 5 months
JBoss Cache SVN: r6745 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-09-17 11:02:28 -0400 (Wed, 17 Sep 2008)
New Revision: 6745
Modified:
core/trunk/pom.xml
Log:
Updated to JGroups 2.6.4.GA
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-09-17 11:42:53 UTC (rev 6744)
+++ core/trunk/pom.xml 2008-09-17 15:02:28 UTC (rev 6745)
@@ -27,7 +27,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.4.CR1</version>
+ <version>2.6.4.GA</version>
</dependency>
<!-- For the JTA 1.1 API; consuming projects can safely
@@ -405,7 +405,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.4.CR1</version>
+ <version>2.6.4.GA</version>
</dependency>
<!-- Replaces javax.transaction/jta -->
<dependency>
16 years, 5 months
JBoss Cache SVN: r6744 - in core/trunk: src/main/docs/Cache_User_Guide/en-US and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-09-17 07:42:53 -0400 (Wed, 17 Sep 2008)
New Revision: 6744
Added:
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
core/trunk/src/test/resources/configs/repl-with-cl.xml
core/trunk/src/test/resources/configs/repl-with-cl2.xml
Modified:
core/trunk/pom.xml
core/trunk/src/main/docs/Cache_User_Guide/en-US/Cache_Loaders.xml
core/trunk/src/main/docs/Cache_User_Guide/en-US/resolved.xml
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
Log:
JBCACHE-1221 - enbled insert batching during state transfer
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/pom.xml 2008-09-17 11:42:53 UTC (rev 6744)
@@ -191,7 +191,7 @@
<profiles>
<profile>
- <!-- This profile generates Javadocs and the UserGuide, FAQs and Tutorial in the "package" phase. -->
+ <!-- This testMoreState generates Javadocs and the UserGuide, FAQs and Tutorial in the "package" phase. -->
<id>Docs</id>
<activation>
<activeByDefault>false</activeByDefault>
Modified: core/trunk/src/main/docs/Cache_User_Guide/en-US/Cache_Loaders.xml
===================================================================
--- core/trunk/src/main/docs/Cache_User_Guide/en-US/Cache_Loaders.xml 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/main/docs/Cache_User_Guide/en-US/Cache_Loaders.xml 2008-09-17 11:42:53 UTC (rev 6744)
@@ -173,7 +173,9 @@
cache.jdbc.user=root
cache.jdbc.password=
cache.jdbc.sql-concat=concat(1,2)
- </properties>
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
+ </properties>
<!-- whether the cache loader writes are asynchronous -->
<async>false</async>
@@ -814,6 +816,8 @@
cache.jdbc.user=SCOTT
cache.jdbc.password=TIGER
cache.jdbc.sql-concat=concat(1,2)
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
</properties>
<async>false</async>
@@ -872,7 +876,9 @@
cache.jdbc.sql-concat=concat(1,2)
cache.jdbc.connection.factory=org.jboss.cache.loader.C3p0ConnectionFactory
c3p0.maxPoolSize=20
- c3p0.checkoutTimeout=5000
+ c3p0.checkoutTimeout=5000
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
</properties>
<async>false</async>
Modified: core/trunk/src/main/docs/Cache_User_Guide/en-US/resolved.xml
===================================================================
--- core/trunk/src/main/docs/Cache_User_Guide/en-US/resolved.xml 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/main/docs/Cache_User_Guide/en-US/resolved.xml 2008-09-17 11:42:53 UTC (rev 6744)
@@ -3759,7 +3759,9 @@
cache.jdbc.user=root
cache.jdbc.password=
cache.jdbc.sql-concat=concat(1,2)
- </properties>
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
+ </properties>
<!-- whether the cache loader writes are asynchronous -->
<async>false</async>
@@ -4399,6 +4401,8 @@
cache.jdbc.user=SCOTT
cache.jdbc.password=TIGER
cache.jdbc.sql-concat=concat(1,2)
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
</properties>
<async>false</async>
@@ -4455,9 +4459,11 @@
cache.jdbc.user=SCOTT
cache.jdbc.password=TIGER
cache.jdbc.sql-concat=concat(1,2)
- cache.jdbc.connection.factory=org.jboss.cache.loader.C3p0ConnectionFactory
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
+ cache.jdbc.connection.factory=org.jboss.cache.loader.C3p0ConnectionFactory
c3p0.maxPoolSize=20
- c3p0.checkoutTimeout=5000
+ c3p0.checkoutTimeout=5000
</properties>
<async>false</async>
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-09-17 11:42:53 UTC (rev 6744)
@@ -404,9 +404,9 @@
* Inserts a node into the database
*
* @param name the fqn
- * @param node the node
+ * @param dataMap the node
*/
- protected void insertNode(Fqn name, Map node)
+ protected void insertNode(Fqn name, Map dataMap)
{
Connection con = null;
PreparedStatement ps = null;
@@ -420,37 +420,8 @@
con = cf.getConnection();
ps = con.prepareStatement(config.getInsertNodeSql());
- ps.setString(1, name.toString());
+ populatePreparedStatementForInsert(name, dataMap, ps);
- if (node != null)
- {
- ByteBuffer byteBuffer = marshall(node);
- ps.setBinaryStream(2, byteBuffer.getStream(), byteBuffer.getLength());
- }
- else
- {
- // a hack to handles the incomp. of SQL server jdbc driver prior to SQL SERVER 2005
- if (driverName != null && (driverName.contains("SQLSERVER")
- || driverName.contains("POSTGRESQL")))
- {
- ps.setNull(2, Types.LONGVARBINARY);
- }
- else
- {
- ps.setNull(2, Types.BLOB);
- }
- //ps.setNull(2, Types.LONGVARBINARY);
- }
-
- if (name.size() == 0)
- {
- ps.setNull(3, Types.VARCHAR);
- }
- else
- {
- ps.setString(3, name.getAncestor(name.size() - 1).toString());
- }
-
int rows = ps.executeUpdate();
if (rows != 1)
{
@@ -473,7 +444,45 @@
}
}
+ /**
+ * Expects a PreparedStatement binded to {@link org.jboss.cache.loader.JDBCCacheLoaderConfig#getInsertNodeSql()}
+ */
+ protected void populatePreparedStatementForInsert(Fqn name, Map dataMap, PreparedStatement ps)
+ throws Exception
+ {
+ ps.setString(1, name.toString());
+ if (dataMap != null)
+ {
+ ByteBuffer byteBuffer = marshall(dataMap);
+ ps.setBinaryStream(2, byteBuffer.getStream(), byteBuffer.getLength());
+ }
+ else
+ {
+ // a hack to handles the incomp. of SQL server jdbc driver prior to SQL SERVER 2005
+ if (driverName != null && (driverName.contains("SQLSERVER")
+ || driverName.contains("POSTGRESQL")))
+ {
+ ps.setNull(2, Types.LONGVARBINARY);
+ }
+ else
+ {
+ ps.setNull(2, Types.BLOB);
+ }
+ //ps.setNull(2, Types.LONGVARBINARY);
+ }
+
+ if (name.size() == 0)
+ {
+ ps.setNull(3, Types.VARCHAR);
+ }
+ else
+ {
+ ps.setString(3, name.getAncestor(name.size() - 1).toString());
+ }
+ }
+
+
/**
* Updates a node in the database.
*
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-09-17 11:42:53 UTC (rev 6744)
@@ -4,16 +4,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.util.Immutables;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.marshall.NodeData;
import java.io.InputStream;
import java.io.ObjectInputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,8 +25,19 @@
* <p/>
* <p/>
* Additional configuration info: <br>
- * cache.jdbc.sql-concat : DBMS specific function for concat strings. Most likely this will be concat(1,2), but might
- * be different for proprietary systems.
+ * <ul>
+ * <li>cache.jdbc.sql-concat : DBMS specific function for concat strings. Most likely this will be concat(1,2), but might
+ * be different for proprietary systems.</li>
+ * <li>
+ * cache.jdbc.batch.enable: whether or not to use batching on repetitive operations (e.g. inserts during state transfer).
+ * Enabling batching should give an important performance boost. It might be required to disable this if the JDBC driver
+ * does not support batching. Default set to 'true'
+ * </li>
+ <li>
+ cache.jdbc.batch.size: number of operations afer which the batching buffer will be flushed. If 'cache.jdbc.batch.enable'
+ is false, this will be ignored. Default value is 1000.
+ </li>
+ * </ul>
*
* @author Mircea.Markus(a)iquestint.com
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
@@ -82,28 +91,76 @@
@Override
protected void storeStateHelper(Fqn subtree, List nodeData, boolean moveToBuddy) throws Exception
{
- for (Object aNodeData : nodeData)
+ lock.acquireLock(subtree, true);
+ Connection con = null;
+ PreparedStatement ps = null;
+ boolean autocommitPrev = true;//this initialization is here only for making code compilable, ignore it
+ int batchCaount = 0;
+ try
{
- NodeData nd = (NodeData) aNodeData;
- if (nd.isMarker()) break;
- Fqn fqn;
- if (moveToBuddy)
+ con = cf.getConnection();
+ autocommitPrev = con.getAutoCommit();
+ if (config.isBatchEnabled()) con.setAutoCommit(false);
+ ps = con.prepareStatement(config.getInsertNodeSql());
+ for (Object aNodeData : nodeData)
{
- fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
+ NodeData nd = (NodeData) aNodeData;
+ if (nd.isMarker()) break;
+ Fqn fqn;
+ if (moveToBuddy)
+ {
+ fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
+ }
+ else
+ {
+ fqn = nd.getFqn();
+ }
+
+ Map attributes = nd.getAttributes() == null ? null : Immutables.immutableMapCopy(nd.getAttributes());
+ populatePreparedStatementForInsert(fqn, attributes, ps);
+ if (!config.isBatchEnabled())
+ {
+ if (ps.executeUpdate() != 1)
+ {
+ throw new IllegalStateException("One and only one row must have been updated!");
+ }
+ }
+ else
+ {
+ ps.addBatch();
+ batchCaount ++;
+ if (batchCaount >= config.getBatchSize())
+ {
+ int result[] = ps.executeBatch();
+ for (int aResult : result)
+ {
+ if (aResult != 1 /* one and only one row must have been updated */
+ && aResult != Statement.SUCCESS_NO_INFO)
+ {
+ throw new IllegalStateException("Failure executing batch insert during state transfer!");
+ }
+ }
+ batchCaount = 0;
+ }
+ }
}
- else
+ if (batchCaount > 0)
{
- fqn = nd.getFqn();
+ if (batchCaount > config.getBatchSize())
+ {
+ throw new IllegalStateException("batchCaount > config.getBatchSize() should never happen!");
+ }
+ ps.executeBatch();//flush the batch here
}
-
- if (nd.getAttributes() != null)
+ } finally
+ {
+ lock.releaseLock(subtree);
+ if (con != null)
{
- this.put(fqn, nd.getAttributes(), true);// creates a node with 0 or more attributes
+ con.setAutoCommit(autocommitPrev);
+ safeClose(ps);
+ cf.close(con);
}
- else
- {
- this.put(fqn, null);// creates a node with null attributes
- }
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java 2008-09-17 11:42:53 UTC (rev 6744)
@@ -28,6 +28,10 @@
private String startingWith;
private String appendSepparator;
+ private boolean batchEnabled = true;//by default enable batching during state transfer
+
+ private long batchSize = 1000; //default state transfer batch size
+
public JDBCCacheLoaderConfig(IndividualCacheLoaderConfig base)
{
super(base);
@@ -50,6 +54,12 @@
deleteNodeSql = constructDeleteNodeSql();
recursiveChildrenSql = constructRecursiveChildrenSql();
nodeCountSql = constructNodeCountSql();
+
+ batchEnabled = Boolean.valueOf(props.getProperty("cache.jdbc.batch.enable"));
+ if (props.containsKey("cache.jdbc.batch.size"))
+ {
+ batchSize = Long.parseLong(props.getProperty("cache.jdbc.batch.size"));
+ }
}
/**
@@ -136,6 +146,25 @@
this.appendSepparator = appendSepparator;
}
+ /**
+ * If batch is enabled certain operations (e.g. state transfer) will use {@link java.sql.PreparedStatement#addBatch(String)}
+ * approach for insertig data into the database. This normally brings significant performance improvements.
+ * @return
+ */
+ public boolean isBatchEnabled()
+ {
+ return batchEnabled;
+ }
+
+ /**
+ * The statement will be flushed after batching batchSize operations.
+ * @see #isBatchEnabled()
+ */
+ public long getBatchSize()
+ {
+ return batchSize;
+ }
+
private void disectSqlConcat()
{
if (sqlConcat == null)
@@ -160,5 +189,5 @@
private String constructDeleteNodeSql()
{
return "delete from " + table + " where " + appendSepparator + " like " + startingWith;
- }
+ }
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-09-16 18:05:14 UTC (rev 6743)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-09-17 11:42:53 UTC (rev 6744)
@@ -12,12 +12,15 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+
+import java.util.Properties;
+
/**
* Unit test for JDBCCacheLoaderConfigTest
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"unit"})
public class JDBCCacheLoaderConfigTest
{
private AdjListJDBCCacheLoaderConfig cacheLoaderConfig;
@@ -45,4 +48,29 @@
other.setConnectionFactoryClass("com.ibm.flaming.Gala");
assertFalse(cacheLoaderConfig.equals(other));
}
+
+ public void testSetGetBatchInfo()
+ {
+ Properties props = new Properties();
+ props.put("ache.jdbc.table.name","jbosscache");
+ props.put("cache.jdbc.table.create", "true");
+ props.put("cache.jdbc.table.drop","true");
+ props.put("cache.jdbc.table.primarykey","jbosscache_pk");
+ props.put("cache.jdbc.fqn.column","fqn");
+ props.put("cache.jdbc.fqn.type", "varchar(255)");
+ props.put("cache.jdbc.node.column","node");
+ props.put("cache.jdbc.node.type", "blob");
+ props.put("cache.jdbc.parent.column","parent");
+ props.put("cache.jdbc.sql-concat","1 || 2");
+ props.put("cache.jdbc.driver","org.apache.derby.jdbc.EmbeddedDriver");
+ props.put("cache.jdbc.url","jdbc:derby:jbossdb;create=true");
+ props.put("cache.jdbc.user","user1");
+ props.put("cache.jdbc.password","user1");
+ props.put("cache.jdbc.batch.enable","false");
+ props.put("cache.jdbc.batch.size","1001");
+ JDBCCacheLoaderConfig config = new JDBCCacheLoaderConfig();
+ config.setProperties(props);
+ assert !config.isBatchEnabled();
+ assert config.getBatchSize() == 1001;
+ }
}
Added: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-09-17 11:42:53 UTC (rev 6744)
@@ -0,0 +1,88 @@
+/*
+ * 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.cache.loader;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.AfterMethod;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+
+/**
+ * UT for testing JDBCCacheLoader during state transfer.
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "functional")
+public class JDBCCacheLoaderStateTransferTest
+{
+
+ CacheSPI first;
+ CacheSPI second;
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (first != null) first.stop();
+ if (second != null) second.stop();
+ }
+
+ public void testSimpleStateTransfer() throws Exception
+ {
+ first = (CacheSPI) new DefaultCacheFactory().createCache("configs/repl-with-cl.xml");
+ first.put("/a/b/c", "key", "value");
+ first.put("/a/b/d", "key", "value");
+ first.put("/a/b/e", "key", "value");
+
+ second = (CacheSPI) new DefaultCacheFactory().createCache("configs/repl-with-cl2.xml");
+ assert second.get("/a/b/c","key").equals("value");
+ assert second.get("/a/b/d","key").equals("value");
+ assert second.get("/a/b/e","key").equals("value");
+ JDBCCacheLoader cacheLoader = (JDBCCacheLoader) second.getCacheLoaderManager().getCacheLoader();
+ assert cacheLoader.exists(Fqn.fromString("/a"));
+ assert cacheLoader.exists(Fqn.fromString("/a/b"));
+ }
+
+
+ public void testMoreState()
+ {
+ long startTime = System.currentTimeMillis();
+ first = (CacheSPI) new DefaultCacheFactory().createCache("configs/repl-with-cl.xml");
+ long cacheStartTime = System.currentTimeMillis() - startTime;
+ System.out.println("cacheStartTime = " + cacheStartTime);
+ for (int i = 0; i < 5012; i++)
+ {
+ first.put("a/b/"+i, "k","v");
+ if (i%1000 == 0) System.out.println(i + " operations executed so far");
+ }
+ startTime = System.currentTimeMillis();
+ second = (CacheSPI) new DefaultCacheFactory().createCache("configs/repl-with-cl2.xml");
+
+ long stateTranferTime = System.currentTimeMillis() - startTime - cacheStartTime;
+ for (int i = 0; i < 5012; i+=100)
+ {
+ second.get("a/b/"+ i, "k").equals("v");
+ }
+ System.out.println("stateTranferTime = " + stateTranferTime);
+ }
+}
Added: core/trunk/src/test/resources/configs/repl-with-cl.xml
===================================================================
--- core/trunk/src/test/resources/configs/repl-with-cl.xml (rev 0)
+++ core/trunk/src/test/resources/configs/repl-with-cl.xml 2008-09-17 11:42:53 UTC (rev 6744)
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+
+ <!--
+ isolationLevel : SERIALIZABLE - (not supported in mvcc)
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED (not supported in mvcc)
+ NONE
+ lockAcquisitionTimeout: max number of milliseconds to wait for a lock acquisition
+ nodeLockingScheme : mvcc (default)
+ optimistic
+ pessimistic
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="mvcc"/>
+
+ <!-- Configure the TransactionManager -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+
+ <transport clusterName="JBossCache-Cluster">
+ <jgroupsConfig>
+ <TCP recv_buf_size="20000000" use_send_queues="false" loopback="false" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true"
+ enable_unicast_bundling="true" enable_diagnostics="true" use_concurrent_stack="true"
+ thread_naming_pattern="pl" thread_pool.enabled="true" thread_pool.min_threads="1"
+ thread_pool.max_threads="4" thread_pool.keep_alive_time="30000" thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="50000" thread_pool.rejection_policy="discard" oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="2" oob_thread_pool.max_threads="4" oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000" min_threshold="0.20"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.FLUSH timeout="0"/>
+ </jgroupsConfig>
+ </transport>
+
+
+ <!-- Cache Passivation for Tree Cache
+ On passivation, The objects are written to the backend store on eviction if passivation
+ is true, otherwise the objects are persisted. On activation, the objects are restored in
+ the memory cache and removed from the cache loader if 'passivation' attribute is true,
+ otherwise the objects are only loaded from the cache loader -->
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/"/>
+ </preload>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
+ ignoreModifications="false" purgeOnStartup="true">
+ <properties>
+ cache.jdbc.table.name=jbosscache
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=true
+ cache.jdbc.table.primarykey=jbosscache_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=varchar(255)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=blob
+ cache.jdbc.parent.column=parent
+ cache.jdbc.sql-concat=1 || 2
+ cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
+ cache.jdbc.url=jdbc:derby:jbossdb;create=true
+ cache.jdbc.user=user1
+ cache.jdbc.password=user1
+ </properties>
+ </loader>
+ </loaders>
+ <replication>
+ <sync replTimeout="30000"/>
+ </replication>
+
+</jbosscache>
Added: core/trunk/src/test/resources/configs/repl-with-cl2.xml
===================================================================
--- core/trunk/src/test/resources/configs/repl-with-cl2.xml (rev 0)
+++ core/trunk/src/test/resources/configs/repl-with-cl2.xml 2008-09-17 11:42:53 UTC (rev 6744)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+
+ <!--
+ isolationLevel : SERIALIZABLE - (not supported in mvcc)
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED (not supported in mvcc)
+ NONE
+ lockAcquisitionTimeout: max number of milliseconds to wait for a lock acquisition
+ nodeLockingScheme : mvcc (default)
+ optimistic
+ pessimistic
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="mvcc"/>
+
+ <!-- Configure the TransactionManager -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+
+ <transport clusterName="JBossCache-Cluster">
+ <jgroupsConfig>
+ <TCP recv_buf_size="20000000" use_send_queues="false" loopback="false" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true"
+ enable_unicast_bundling="true" enable_diagnostics="true" use_concurrent_stack="true"
+ thread_naming_pattern="pl" thread_pool.enabled="true" thread_pool.min_threads="1"
+ thread_pool.max_threads="4" thread_pool.keep_alive_time="30000" thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="50000" thread_pool.rejection_policy="discard" oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="2" oob_thread_pool.max_threads="4" oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000" min_threshold="0.20"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.FLUSH timeout="0"/>
+ </jgroupsConfig>
+ </transport>
+
+ <stateRetrieval fetchInMemoryState="false" timeout="0"/>
+
+
+ <!-- Cache Passivation for Tree Cache
+ On passivation, The objects are written to the backend store on eviction if passivation
+ is true, otherwise the objects are persisted. On activation, the objects are restored in
+ the memory cache and removed from the cache loader if 'passivation' attribute is true,
+ otherwise the objects are only loaded from the cache loader -->
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/"/>
+ </preload>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
+ ignoreModifications="false" purgeOnStartup="true">
+ <properties>
+ cache.jdbc.table.name=jbosscache
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=true
+ cache.jdbc.table.primarykey=jbosscache_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=varchar(255)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=blob
+ cache.jdbc.parent.column=parent
+ cache.jdbc.sql-concat=1 || 2
+ cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
+ cache.jdbc.url=jdbc:derby:jbossdb2;create=true
+ cache.jdbc.user=user1
+ cache.jdbc.password=user1
+ cache.jdbc.batch.enable=true
+ cache.jdbc.batch.size=1000
+ </properties>
+ </loader>
+ </loaders>
+
+ <replication>
+ <sync replTimeout="30000"/>
+ </replication>
+</jbosscache>
16 years, 5 months
JBoss Cache SVN: r6743 - core/branches/2.2.X/src/test/java/org/jboss/cache/profiling.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-09-16 14:05:14 -0400 (Tue, 16 Sep 2008)
New Revision: 6743
Added:
core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
Modified:
core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Added test to isolate and profile rpc manager code
Added: core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java (rev 0)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java 2008-09-16 18:05:14 UTC (rev 6743)
@@ -0,0 +1,93 @@
+package org.jboss.cache.profiling;
+
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jgroups.Address;
+import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.blocks.RspFilter;
+import org.jgroups.util.RspList;
+import org.testng.annotations.Test;
+
+import java.io.NotSerializableException;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MockAsyncReplTest extends ProfileTest
+{
+ @Override
+ @Test(enabled = true)
+ public void testReplAsync() throws Exception
+ {
+ // same as superclass, except that we use a mock RpcDispatcher that does nothing. Measure throughput to test speed of JBC stack.
+ super.testReplAsync();
+ }
+
+ @Override
+ protected void startup()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting cache");
+ cache.start();
+ // now remove the existing RpcDispatcher and replace with one that is a noop.
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
+ RPCManager rpcManager = cr.getComponent(RPCManager.class);
+ RpcDispatcher d = (RpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
+ d.stop();
+ RpcDispatcher replacement = new NoopDispatcher();
+ replacement.setRequestMarshaller(d.getRequestMarshaller());
+ replacement.setResponseMarshaller(d.getResponseMarshaller());
+ ReflectionUtil.setValue(rpcManager, "rpcDispatcher", replacement);
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Started cache. " + printDuration(duration));
+ }
+
+ public static class NoopDispatcher extends CommandAwareRpcDispatcher
+ {
+ AtomicInteger ai = new AtomicInteger();
+ Marshaller m;
+ Marshaller2 m2;
+
+ @Override
+ public RspList invokeRemoteCommands(Vector<Address> dests, ReplicableCommand command, int mode, long timeout,
+ boolean anycasting, boolean oob, RspFilter filter) throws NotSerializableException
+ {
+ // make sure we do the marshalling though
+ if (m == null && m2 == null)
+ {
+ m = getRequestMarshaller();
+ if (m instanceof Marshaller2)
+ {
+ m2 = (Marshaller2) m;
+ m = null;
+ }
+ }
+
+ try
+ {
+ if (m2 == null) m.objectToByteBuffer(command);
+ else m2.objectToBuffer(command);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new NotSerializableException(e.getMessage());
+ }
+
+ int i = ai.incrementAndGet();
+ if (i % 1000 == 0) log.warn("Dispatching operation #" + i);
+ // no-op
+ return null;
+ }
+ }
+}
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-16 18:04:46 UTC (rev 6742)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-16 18:05:14 UTC (rev 6743)
@@ -51,7 +51,7 @@
private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
private Random r = new Random();
- private Log log = LogFactory.getLog(ProfileTest.class);
+ Log log = LogFactory.getLog(ProfileTest.class);
@Test(enabled = false)
public void testLocalModePess() throws Exception
@@ -190,7 +190,7 @@
}
- private void startup()
+ protected void startup()
{
long startTime = System.currentTimeMillis();
log.warn("Starting cache");
@@ -239,7 +239,8 @@
log.warn("Finished warmup. " + printDuration(duration));
//cache.removeNode(Fqn.ROOT);
cache.stop();
- cache.start();
+
+ startup();
}
private void doTest() throws Exception
@@ -352,7 +353,7 @@
return sb.toString();
}
- private String printDuration(long duration)
+ String printDuration(long duration)
{
if (duration > 2000)
{
16 years, 5 months
JBoss Cache SVN: r6742 - core/branches/2.2.X/src/main/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-09-16 14:04:46 -0400 (Tue, 16 Sep 2008)
New Revision: 6742
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Log:
Empty ctor to aid testing
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-09-16 18:04:26 UTC (rev 6741)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-09-16 18:04:46 UTC (rev 6742)
@@ -36,6 +36,10 @@
protected ComponentRegistry componentRegistry;
protected boolean trace;
+ public CommandAwareRpcDispatcher()
+ {
+ }
+
public CommandAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object serverObj,
InvocationContextContainer container, InterceptorChain interceptorChain,
ComponentRegistry componentRegistry)
16 years, 5 months
JBoss Cache SVN: r6741 - core/trunk/src/test/java/org/jboss/cache/profiling.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-09-16 14:04:26 -0400 (Tue, 16 Sep 2008)
New Revision: 6741
Added:
core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Tests to isolate and profile rpc manager code
Added: core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/MockAsyncReplTest.java 2008-09-16 18:04:26 UTC (rev 6741)
@@ -0,0 +1,93 @@
+package org.jboss.cache.profiling;
+
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jgroups.Address;
+import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.blocks.RspFilter;
+import org.jgroups.util.RspList;
+import org.testng.annotations.Test;
+
+import java.io.NotSerializableException;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MockAsyncReplTest extends ProfileTest
+{
+ @Override
+ @Test(enabled = true)
+ public void testReplAsync() throws Exception
+ {
+ // same as superclass, except that we use a mock RpcDispatcher that does nothing. Measure throughput to test speed of JBC stack.
+ super.testReplAsync();
+ }
+
+ @Override
+ protected void startup()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting cache");
+ cache.start();
+ // now remove the existing RpcDispatcher and replace with one that is a noop.
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
+ RPCManager rpcManager = cr.getComponent(RPCManager.class);
+ RpcDispatcher d = (RpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
+ d.stop();
+ RpcDispatcher replacement = new NoopDispatcher();
+ replacement.setRequestMarshaller(d.getRequestMarshaller());
+ replacement.setResponseMarshaller(d.getResponseMarshaller());
+ ReflectionUtil.setValue(rpcManager, "rpcDispatcher", replacement);
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Started cache. " + printDuration(duration));
+ }
+
+ public static class NoopDispatcher extends CommandAwareRpcDispatcher
+ {
+ AtomicInteger ai = new AtomicInteger();
+ Marshaller m;
+ Marshaller2 m2;
+
+ @Override
+ public RspList invokeRemoteCommands(Vector<Address> dests, ReplicableCommand command, int mode, long timeout,
+ boolean anycasting, boolean oob, RspFilter filter) throws NotSerializableException
+ {
+ // make sure we do the marshalling though
+ if (m == null && m2 == null)
+ {
+ m = getRequestMarshaller();
+ if (m instanceof Marshaller2)
+ {
+ m2 = (Marshaller2) m;
+ m = null;
+ }
+ }
+
+ try
+ {
+ if (m2 == null) m.objectToByteBuffer(command);
+ else m2.objectToBuffer(command);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new NotSerializableException(e.getMessage());
+ }
+
+ int i = ai.incrementAndGet();
+ if (i % 1000 == 0) log.warn("Dispatching operation #" + i);
+ // no-op
+ return null;
+ }
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-16 18:04:06 UTC (rev 6740)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-09-16 18:04:26 UTC (rev 6741)
@@ -51,7 +51,7 @@
private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
private Random r = new Random();
- private Log log = LogFactory.getLog(ProfileTest.class);
+ Log log = LogFactory.getLog(ProfileTest.class);
@Test(enabled = false)
public void testLocalModePess() throws Exception
@@ -193,7 +193,7 @@
}
- private void startup()
+ protected void startup()
{
long startTime = System.currentTimeMillis();
log.warn("Starting cache");
@@ -242,7 +242,8 @@
log.warn("Finished warmup. " + printDuration(duration));
//cache.removeNode(Fqn.ROOT);
cache.stop();
- cache.start();
+
+ startup();
}
private void doTest() throws Exception
@@ -355,7 +356,7 @@
return sb.toString();
}
- private String printDuration(long duration)
+ protected String printDuration(long duration)
{
if (duration > 2000)
{
16 years, 5 months