JBoss Cache SVN: r6059 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-26 12:32:57 -0400 (Thu, 26 Jun 2008)
New Revision: 6059
Removed:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
Log:
Deleted: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-26 15:44:26 UTC (rev 6058)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-26 16:32:57 UTC (rev 6059)
@@ -1,609 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-import org.jboss.cache.transaction.TransactionTable;
-
-import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This context holds information specific to a method invocation.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@SuppressWarnings("deprecation")
-public class InvocationContext
-{
- private static final Log log = LogFactory.getLog(InvocationContext.class);
- private static final boolean trace = log.isTraceEnabled();
-
- private Transaction transaction;
- private GlobalTransaction globalTransaction;
- private TransactionContext transactionContext;
- private Option optionOverrides;
- // defaults to true.
- private boolean originLocal = true;
- private boolean txHasMods;
- private boolean localRollbackOnly;
- @Deprecated
- private MethodCall methodCall;
- @Deprecated
- private VisitableCommand command;
-
- /**
- * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
- */
- private LinkedHashSet invocationLocks;
-
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
-
- /**
- * Retrieves a node from the registry of looked up nodes in the current scope.
- * <p/>
- * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#lookUpNode(Fqn)}
- * <p/>
- *
- * @param fqn fqn to look up
- * @return a node, or null if it cannot be found.
- * @since 3.0.
- */
- public NodeSPI lookUpNode(Fqn fqn)
- {
- if (transactionContext != null) return transactionContext.lookUpNode(fqn);
- return lookedUpNodes.get(fqn);
- }
-
- /**
- * Puts an entry in the registry of looked up nodes in the current scope.
- * <p/>
- * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#putLookedUpNode(Fqn, NodeSPI)}
- * <p/>
- *
- * @param f fqn to add
- * @param n node to add
- * @since 3.0.
- */
- public void putLookedUpNode(Fqn f, NodeSPI n)
- {
- if (transactionContext != null)
- transactionContext.putLookedUpNode(f, n);
- else
- lookedUpNodes.put(f, n);
- }
-
- /**
- * Clears the registry of looked up nodes.
- * <p/>
- * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#clearLookedUpNodes()}.
- * <p/>
- *
- * @since 3.0.
- */
- public void clearLookedUpNodes()
- {
- if (transactionContext != null)
- transactionContext.clearLookedUpNodes();
- else
- lookedUpNodes.clear();
- }
-
- /**
- * Retrieves a map of nodes looked up within the current invocation's scope.
- * <p/>
- * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#getLookedUpNodes()}.
- * <p/>
- *
- * @return a map of looked up nodes.
- * @since 3.0
- */
- public Map<Fqn, NodeSPI> getLookedUpNodes()
- {
- if (transactionContext != null) return transactionContext.getLookedUpNodes();
- return lookedUpNodes;
- }
-
- public void setLocalRollbackOnly(boolean localRollbackOnly)
- {
- this.localRollbackOnly = localRollbackOnly;
- }
-
- /**
- * Retrieves the transaction associated with this invocation
- *
- * @return The transaction associated with this invocation
- */
- public Transaction getTransaction()
- {
- return transaction;
- }
-
- /**
- * Sets the transaction associated with this invocation
- *
- * @param transaction
- */
- public void setTransaction(Transaction transaction)
- {
- this.transaction = transaction;
- }
-
- /**
- * @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
- * @since 2.2.0
- */
- public TransactionContext getTransactionContext()
- {
- return transactionContext;
- }
-
- /**
- * Sets the transaction entry to be associated with the current thread.
- *
- * @param transactionContext transaction entry to set
- * @since 2.2.0
- */
- public void setTransactionContext(TransactionContext transactionContext)
- {
- this.transactionContext = transactionContext;
- }
-
- /**
- * Retrieves the global transaction associated with this invocation
- *
- * @return the global transaction associated with this invocation
- */
- public GlobalTransaction getGlobalTransaction()
- {
- return globalTransaction;
- }
-
- /**
- * Sets the global transaction associated with this invocation
- *
- * @param globalTransaction
- */
- public void setGlobalTransaction(GlobalTransaction globalTransaction)
- {
- this.globalTransaction = globalTransaction;
- }
-
- /**
- * Retrieves the option overrides associated with this invocation
- *
- * @return the option overrides associated with this invocation
- */
- public Option getOptionOverrides()
- {
- if (optionOverrides == null)
- {
- optionOverrides = new Option();
- }
- return optionOverrides;
- }
-
- public boolean isOptionsUninitialised()
- {
- return optionOverrides == null;
- }
-
- /**
- * Sets the option overrides associated with this invocation
- *
- * @param optionOverrides
- */
- public void setOptionOverrides(Option optionOverrides)
- {
- this.optionOverrides = optionOverrides;
- }
-
- /**
- * Tests if this invocation originated locally or from a remote cache.
- *
- * @return true if the invocation originated locally.
- */
- public boolean isOriginLocal()
- {
- return originLocal;
- }
-
- /**
- * Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
- * <p/>
- * Note that if a transaction is in scope, these locks are retrieved from the {@link org.jboss.cache.transaction.TransactionContext} rather than
- * this {@link org.jboss.cache.InvocationContext}. Retrieving locks from here will ensure they are retrieved from the appropriate
- * scope.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
- *
- * @return locks held in current scope.
- */
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- // first check transactional scope
- if (transactionContext != null) return transactionContext.getLocks();
- return invocationLocks == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(invocationLocks));
- }
-
- /**
- * Adds a List of locks to the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, these locks are recorded on the {@link org.jboss.cache.transaction.TransactionContext} rather than
- * this {@link org.jboss.cache.InvocationContext}. Adding locks here will ensure they are promoted to the appropriate
- * scope.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
- *
- * @param locks locks to add
- */
- @SuppressWarnings("unchecked")
- public void addAllLocks(List locks)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addAllLocks(locks);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(5);
- invocationLocks.addAll(locks);
- }
- }
-
- /**
- * Adds a lock to the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, this lock is recorded on the {@link org.jboss.cache.transaction.TransactionContext} rather than
- * this {@link org.jboss.cache.InvocationContext}. Adding a lock here will ensure it is promoted to the appropriate
- * scope.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to add
- */
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.addLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks == null) invocationLocks = new LinkedHashSet(5);
- invocationLocks.add(lock);
- }
- }
-
- /**
- * Removes a lock from the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, this lock is removed from the {@link org.jboss.cache.transaction.TransactionContext} rather than
- * this {@link org.jboss.cache.InvocationContext}. Removing a lock here will ensure it is removed in the appropriate
- * scope.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to remove
- */
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.removeLock(lock);
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks != null) invocationLocks.remove(lock);
- }
- }
-
- /**
- * Clears all locks from the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, locks are cleared from the {@link org.jboss.cache.transaction.TransactionContext} rather than
- * this {@link org.jboss.cache.InvocationContext}. Clearing locks here will ensure they are cleared in the appropriate
- * scope.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- */
- public void clearLocks()
- {
- // first check transactional scope
- if (transactionContext != null)
- {
- transactionContext.clearLocks();
- }
- else
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (invocationLocks != null) invocationLocks.clear();
- }
- }
-
- /**
- * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
- */
- public boolean isLockingSuppressed()
- {
- return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
- }
-
- /**
- * If set to true, the invocation is assumed to have originated locally. If set to false,
- * assumed to have originated from a remote cache.
- *
- * @param originLocal
- */
- public void setOriginLocal(boolean originLocal)
- {
- this.originLocal = originLocal;
- }
-
- @Override
- public String toString()
- {
- return "InvocationContext{" +
- "transaction=" + transaction +
- ", globalTransaction=" + globalTransaction +
- ", optionOverrides=" + optionOverrides +
- ", originLocal=" + originLocal +
- ", txHasMods=" + txHasMods +
- '}';
- }
-
- public boolean isTxHasMods()
- {
- return txHasMods;
- }
-
- public void setTxHasMods(boolean b)
- {
- txHasMods = b;
- }
-
- public boolean isLocalRollbackOnly()
- {
- return localRollbackOnly;
- }
-
- /**
- * Resets this to the defaults used when constructing an invocation context object
- */
- public void reset()
- {
- transaction = null;
- globalTransaction = null;
- optionOverrides = null;
- originLocal = true;
- txHasMods = false;
- invocationLocks = null;
- methodCall = null;
- command = null;
- }
-
- /**
- * This is a "copy-factory-method" that should be used whenever a clone of this class is needed. The resulting instance
- * is equal() to, but not ==, to the InvocationContext invoked on. Note that this is a shallow copy with the exception
- * of the Option object, which is deep, as well as any collections held on the context such as locks. Note that the reference
- * to a TransactionEntry, if any, is maintained.
- *
- * @return a new InvocationContext
- */
- @SuppressWarnings("unchecked")
- public InvocationContext copy()
- {
- InvocationContext copy = new InvocationContext();
- copy.command = command;
- copy.globalTransaction = globalTransaction;
- copy.invocationLocks = invocationLocks == null ? null : new LinkedHashSet(invocationLocks);
- copy.localRollbackOnly = localRollbackOnly;
- copy.lookedUpNodes.putAll(lookedUpNodes);
- copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
- copy.originLocal = originLocal;
- copy.transaction = transaction;
- copy.transactionContext = transactionContext;
- copy.txHasMods = txHasMods;
- return null;
- }
-
- /**
- * Sets the state of the InvocationContext based on the template context passed in
- *
- * @param template
- */
- public void setState(InvocationContext template)
- {
- if (template == null)
- {
- throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null");
- }
-
- this.setGlobalTransaction(template.getGlobalTransaction());
- this.setLocalRollbackOnly(template.isLocalRollbackOnly());
- this.setOptionOverrides(template.getOptionOverrides());
- this.setOriginLocal(template.isOriginLocal());
- this.setTransaction(template.getTransaction());
- this.setTxHasMods(template.isTxHasMods());
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final InvocationContext that = (InvocationContext) o;
-
- if (localRollbackOnly != that.localRollbackOnly) return false;
- if (originLocal != that.originLocal) return false;
- if (txHasMods != that.txHasMods) return false;
- if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
- {
- return false;
- }
- if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) : that.optionOverrides != null)
- {
- return false;
- }
- if (transaction != null ? !transaction.equals(that.transaction) : that.transaction != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = (transaction != null ? transaction.hashCode() : 0);
- result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
- result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
- result = 29 * result + (originLocal ? 1 : 0);
- result = 29 * result + (txHasMods ? 1 : 0);
- result = 29 * result + (localRollbackOnly ? 1 : 0);
- return result;
- }
-
- /**
- * @return the method call associated with this invocation
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- public MethodCall getMethodCall()
- {
- if (methodCall == null)
- {
- methodCall = createMethodCall();
- }
- return methodCall;
- }
-
- @SuppressWarnings("deprecation")
- private MethodCall createMethodCall()
- {
- if (command == null) return null;
- MethodCall call = new MethodCall();
- call.setMethodId(command.getCommandId());
- call.setArgs(command.getParameters());
- return call;
- }
-
-
- /**
- * Sets the method call associated with this invocation.
- *
- * @param methodCall methodcall to set
- * @deprecated not used anymore. Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
- */
- @Deprecated
- public void setMethodCall(MethodCall methodCall)
- {
- this.methodCall = methodCall;
- }
-
- /**
- * Factory method that creates a context with a given method call.
- *
- * @param methodCall methodcall to use
- * @return invocation context
- */
- public static InvocationContext fromMethodCall(MethodCall methodCall)
- {
- InvocationContext ctx = new InvocationContext();
- ctx.methodCall = methodCall;
- return ctx;
- }
-
- /**
- * If the acq timeout if overwritten for current call, then return that one.
- * If not overwritten return default value.
- */
- public long getContextLockAcquisitionTimeout(long timeout)
- {
- if (getOptionOverrides() != null
- && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
- {
- timeout = getOptionOverrides().getLockAcquisitionTimeout();
- }
- return timeout;
- }
-
- /**
- * This is only used for backward compatibility with old interceptors implementation and should <b>NOT</b> be
- * use by any new custom interceptors. The commands is now passed in as the second param in each implementing
- * handlers (handler = method in ChainedInterceptor class)
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- public void setCommand(VisitableCommand cacheCommand)
- {
- this.command = cacheCommand;
- }
-
- /**
- * @see #setCommand(org.jboss.cache.commands.VisitableCommand)
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- public VisitableCommand getCommand()
- {
- return command;
- }
-
- public boolean isValidTransaction()
- {
- return transaction != null && TransactionTable.isValid(transaction);
- }
-
- public void throwIfNeeded(Throwable e) throws Throwable
- {
- Option optionOverride = getOptionOverrides();
- boolean shouldRethtrow = optionOverride == null || !optionOverride.isFailSilently();
- if (!shouldRethtrow)
- {
- if (trace)
- log.trace("There was a problem handling this request, but failSilently was set, so suppressing exception", e);
- return;
- }
- throw e;
- }
-}
16 years, 6 months
JBoss Cache SVN: r6058 - in core/trunk/src: test/java/org/jboss/cache/config and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-26 11:44:26 -0400 (Thu, 26 Jun 2008)
New Revision: 6058
Removed:
core/trunk/src/main/etc/META-INF/config2to3.xslt
Modified:
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
Log:
updated ut to use relative path to the xslt. Also moved the xslt so that it is grabbed in the class path
Deleted: core/trunk/src/main/etc/META-INF/config2to3.xslt
===================================================================
--- core/trunk/src/main/etc/META-INF/config2to3.xslt 2008-06-26 14:57:18 UTC (rev 6057)
+++ core/trunk/src/main/etc/META-INF/config2to3.xslt 2008-06-26 15:44:26 UTC (rev 6058)
@@ -1,425 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="xml" indent="yes"/>
-
- <xsl:template match="/">
- <xsl:element name="jbosscache">
- <xsl:call-template name="locking"/>
- <xsl:call-template name="transaction"/>
- <xsl:call-template name="serialization"/>
- <xsl:call-template name="startup"/>
- <xsl:call-template name="transport"/>
- <xsl:apply-templates select="//attribute"/>
- <!--<xsl:call-template name="invalidation"/> -->
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="//attribute"/>
-
- <xsl:template name="locking">
- <xsl:if
- test="//attribute[@name='IsolationLevel'] | //attribute[@name='LockAcquisitionTimeout'] | //attribute[@name='LockParentForChildInsertRemove']">
- <xsl:element name="locking">
- <xsl:if test="//attribute[@name='IsolationLevel']">
- <xsl:attribute name="isolationLevel">
- <xsl:value-of select="normalize-space(//attribute[@name='IsolationLevel'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='LockAcquisitionTimeout']">
- <xsl:attribute name="lockAcquisitionTimeout">
- <xsl:value-of select="normalize-space(//attribute[@name='LockAcquisitionTimeout'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='LockParentForChildInsertRemove']">
- <xsl:attribute name="lockParentForChildInsertRemove">
- <xsl:value-of select="normalize-space(//attribute[@name='LockParentForChildInsertRemove'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='NodeLockingScheme']">
- <xsl:attribute name="optimistic">
- <xsl:value-of select="normalize-space(//attribute[@name='NodeLockingScheme'])"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="transaction">
- <xsl:if
- test="//attribute[@name='TransactionManagerLookupClass'] | //attribute[@name='SyncRollbackPhase'] | //attribute[@name='SyncCommitPhase']">
- <xsl:element name="transaction">
- <xsl:if test="//attribute[@name='TransactionManagerLookupClass']">
- <xsl:attribute name="transactionManagerLookupClass">
- <xsl:value-of select="normalize-space(//attribute[@name='TransactionManagerLookupClass'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='SyncCommitPhase']">
- <xsl:attribute name="syncCommitPhase">
- <xsl:value-of select="normalize-space(//attribute[@name='SyncCommitPhase'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='SyncRollbackPhase']">
- <xsl:attribute name="syncRollbackPhase">
- <xsl:value-of select="normalize-space(//attribute[@name='SyncRollbackPhase'])"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="serialization">
- <xsl:if
- test="//attribute[@name='ObjectInputStreamPoolSize'] | //attribute[@name='ObjectOutputStreamPoolSize'] | //attribute[@name='ReplicationVersion'] | //attribute[@name='MarshallerClass'] | //attribute[@name='UseLazyDeserialization'] | //attribute[@name='UseRegionBasedMarshalling']">
- <serialization>
- <xsl:if test="//attribute[@name='ObjectInputStreamPoolSize']">
- <xsl:attribute name="objectInputStreamPoolSize">
- <xsl:value-of select="normalize-space(//attribute[@name='ObjectInputStreamPoolSize'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='ObjectOutputStreamPoolSize']">
- <xsl:attribute name="objectOutputStreamPoolSize">
- <xsl:value-of select="normalize-space(//attribute[@name='ObjectOutputStreamPoolSize'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='ReplicationVersion']">
- <xsl:attribute name="version">
- <xsl:value-of select="normalize-space(//attribute[@name='ReplicationVersion'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='MarshallerClass']">
- <xsl:attribute name="marshallerClass">
- <xsl:value-of select="normalize-space(//attribute[@name='MarshallerClass'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='UseLazyDeserialization']">
- <xsl:attribute name="useLazyDeserialization">
- <xsl:value-of select="normalize-space(//attribute[@name='UseLazyDeserialization'])"/>
- </xsl:attribute>
- </xsl:if>
-
- <xsl:if test="//attribute[@name='UseRegionBasedMarshalling']">
- <xsl:attribute name="useRegionBasedMarshalling">
- <xsl:value-of select="normalize-space(//attribute[@name='UseRegionBasedMarshalling'])"/>
- </xsl:attribute>
- </xsl:if>
- </serialization>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="//attribute[@name='CacheMode']">
- <xsl:if test="(normalize-space(.) = 'INVALIDATION_ASYNC') or (normalize-space(.) = 'INVALIDATION_SYNC')">
- <invalidation>
- <xsl:if test="(normalize-space(.) = 'INVALIDATION_ASYNC')">
- <xsl:element name="async">
- <xsl:call-template name="asyncAttributes"/>
- </xsl:element>
- </xsl:if>
- <xsl:if test="(normalize-space(.) = 'INVALIDATION_SYNC')">
- <xsl:element name="sync">
- <xsl:call-template name="syncAttributes"/>
- </xsl:element>
- </xsl:if>
- </invalidation>
- </xsl:if>
- <xsl:if test="(normalize-space(.) = 'REPL_ASYNC') or (normalize-space(.) = 'REPL_SYNC')">
- <replication>
- <xsl:if test="(normalize-space(.) = 'REPL_ASYNC')">
- <xsl:element name="async">
- <xsl:call-template name="asyncAttributes"/>
- </xsl:element>
- </xsl:if>
- <xsl:if test="(normalize-space(.) = 'REPL_SYNC')">
- <xsl:element name="sync">
- <xsl:call-template name="syncAttributes"/>
- </xsl:element>
- </xsl:if>
- <xsl:call-template name="buddy"/>
- </replication>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="buddy">
- <xsl:if test="//attribute[@name='BuddyReplicationConfig']">
- <buddy>
- <xsl:if test="//buddyReplicationEnabled">
- <xsl:attribute name="enabled">
- <xsl:value-of select="//buddyReplicationEnabled"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//buddyPoolName">
- <xsl:attribute name="poolName">
- <xsl:value-of select="//buddyPoolName"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//buddyCommunicationTimeout">
- <xsl:attribute name="communicationTimeout">
- <xsl:value-of select="//buddyCommunicationTimeout"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//autoDataGravitation | //dataGravitationRemoveOnFind | //dataGravitationSearchBackupTrees">
- <dataGravitation>
- <xsl:if test="//autoDataGravitation">
- <xsl:attribute name="auto">
- <xsl:value-of select="//autoDataGravitation"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//dataGravitationRemoveOnFind">
- <xsl:attribute name="removeOnFind">
- <xsl:value-of select="//dataGravitationRemoveOnFind"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//dataGravitationSearchBackupTrees">
- <xsl:attribute name="searchBackupTrees">
- <xsl:value-of select="//dataGravitationSearchBackupTrees"/>
- </xsl:attribute>
- </xsl:if>
- </dataGravitation>
- </xsl:if>
- <xsl:if test="//buddyLocatorProperties">
- <locator>
- <xsl:if test="//buddyLocatorClass">
- <xsl:attribute name="class">
- <xsl:value-of select="//buddyLocatorClass"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//buddyLocatorProperties">
- <properties>
- <xsl:value-of select="//buddyLocatorProperties"/>
- </properties>
- </xsl:if>
- </locator>
- </xsl:if>
- </buddy>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="asyncAttributes">
- <xsl:if test="//attribute[@name='UseReplQueue']">
- <xsl:attribute name="useReplQueue">
- <xsl:value-of select="//attribute[@name='UseReplQueue']"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='ReplQueueInterval']">
- <xsl:attribute name="replQueueInterval">
- <xsl:value-of select="//attribute[@name='ReplQueueInterval']"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='ReplQueueMaxElements']">
- <xsl:attribute name="replQueueMaxElements">
- <xsl:value-of select="//attribute[@name='ReplQueueMaxElements']"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="syncAttributes">
- <xsl:if test="//attribute[@name='SyncReplTimeout']">
- <xsl:attribute name="replTimeout">
- <xsl:value-of select="//attribute[@name='SyncReplTimeout']"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="startup">
- <xsl:if
- test="//attribute[@name='FetchInMemoryState'] | //attribute[@name='StateRetrievalTimeout'] | //attribute[@name='InactiveOnStartup']">
- <xsl:element name="startup">
- <xsl:if test="//attribute[@name='FetchInMemoryState']">
- <xsl:attribute name="fetchInMemoryState">
- <xsl:value-of select="normalize-space(//attribute[@name='FetchInMemoryState'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='StateRetrievalTimeout']">
- <xsl:attribute name="stateRetrievalTimeout">
- <xsl:value-of select="normalize-space(//attribute[@name='StateRetrievalTimeout'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='InactiveOnStartup']">
- <xsl:attribute name="inactiveOnStartup">
- <xsl:value-of select="normalize-space(//attribute[@name='InactiveOnStartup'])"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="//attribute[@name='ShutdownHookBehavior']">
- <shutdown>
- <xsl:attribute name="hookBehavior">
- <xsl:value-of select="normalize-space(.)"/>
- </xsl:attribute>
- </shutdown>
- </xsl:template>
-
- <xsl:template match="//attribute[@name='ExposeManagementStatistics']">
- <jmxStatistics>
- <xsl:attribute name="enabled">
- <xsl:value-of select="normalize-space(.)"/>
- </xsl:attribute>
- </jmxStatistics>
- </xsl:template>
-
- <xsl:template match="//attribute[@name='EvictionPolicyConfig']">
- <eviction>
- <xsl:if test="./config/attribute[@name='wakeUpIntervalSeconds']">
- <xsl:attribute name="wakeUpInterval">
- <xsl:value-of select="concat(normalize-space(./config/attribute[@name='wakeUpIntervalSeconds']), '000')"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./config/attribute[@name='policyClass'] | ./config/attribute[@name='policyClass']">
- <defaults>
- <xsl:if test="./config/attribute[@name='policyClass']">
- <xsl:attribute name="policyClass">
- <xsl:value-of select="normalize-space(./config/attribute[@name='policyClass'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./config/attribute[@name='eventQueueSize']">
- <xsl:attribute name="eventQueueSize">
- <xsl:value-of select="normalize-space(./config/attribute[@name='eventQueueSize'])"/>
- </xsl:attribute>
- </xsl:if>
- </defaults>
- </xsl:if>
- <xsl:if test="./config/region[@name='/_default_']">
- <root>
- <xsl:copy-of select="./config/region[@name='/_default_']/*"/>
- </root>
- </xsl:if>
- <xsl:for-each select="./config/region[@name!='/_default_']">
- <region>
- <xsl:if test="@name">
- <xsl:attribute name="name">
- <xsl:value-of select="@name"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:copy-of select="./*"/>
- </region>
- </xsl:for-each>
- </eviction>
- </xsl:template>
-
- <xsl:template match="//attribute[@name='CacheLoaderConfiguration']">
- <loaders>
- <xsl:if test="./config/passivation">
- <xsl:attribute name="passivation">
- <xsl:value-of select="./config/passivation"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./config/shared">
- <xsl:attribute name="shared">
- <xsl:value-of select="./config/shared"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./config/preload">
- <preload>
- <xsl:call-template name="preloadTokenizer">
- <xsl:with-param name="string" select="./config/preload"/>
- <xsl:with-param name="delimiter" select="','"/>
- </xsl:call-template>
- </preload>
- </xsl:if>
- <xsl:for-each select="./config/cacheloader">
- <loader>
- <xsl:if test="./class">
- <xsl:attribute name="class">
- <xsl:value-of select="./class"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./async">
- <xsl:attribute name="async">
- <xsl:value-of select="./async"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./fetchPersistentState">
- <xsl:attribute name="fetchPersistentState">
- <xsl:value-of select="./fetchPersistentState"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./ignoreModifications">
- <xsl:attribute name="ignoreModifications">
- <xsl:value-of select="./ignoreModifications"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./purgeOnStartup">
- <xsl:attribute name="purgeOnStartup">
- <xsl:value-of select="./purgeOnStartup"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./properties">
- <xsl:copy-of select="./properties"/>
- </xsl:if>
- <xsl:if test="./singletonStore">
- <singletonStore>
- <xsl:if test="./singletonStore/enabled">
- <xsl:attribute name="enabled">
- <xsl:value-of select="./singletonStore/enabled"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./singletonStore/enabled">
- <xsl:attribute name="enabled">
- <xsl:value-of select="./singletonStore/enabled"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="./singletonStore/class">
- <xsl:attribute name="class">
- <xsl:value-of select="./singletonStore/class"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:copy-of select="./singletonStore/properties"/>
- </singletonStore>
- </xsl:if>
- </loader>
- </xsl:for-each>
- </loaders>
- </xsl:template>
-
- <xsl:template name="preloadTokenizer">
- <xsl:param name="string"/>
- <xsl:param name="delimiter" select="' '"/>
- <xsl:choose>
- <xsl:when test="$delimiter and contains($string, $delimiter)">
- <node>
- <xsl:attribute name="fqn">
- <xsl:value-of select="substring-before($string,$delimiter)"/>
- </xsl:attribute>
- </node>
- <xsl:call-template name="preloadTokenizer">
- <xsl:with-param name="string" select="substring-after($string,$delimiter)"/>
- <xsl:with-param name="delimiter" select="$delimiter"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <node>
- <xsl:attribute name="fqn">
- <xsl:value-of select="$string"/>
- </xsl:attribute>
- </node>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="transport">
- <xsl:if
- test="//attribute[@name='ClusterName'] | //attribute[@name='MultiplexerStack'] | //attribute[@name='ClusterConfig']">
- <transport>
- <xsl:if test="//attribute[@name='ClusterName']">
- <xsl:attribute name="clusterName">
- <xsl:value-of select="normalize-space(//attribute[@name='ClusterName'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='MultiplexerStack']">
- <xsl:attribute name="multiplexerStack">
- <xsl:value-of select="normalize-space(//attribute[@name='MultiplexerStack'])"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="//attribute[@name='ClusterConfig']">
- <jgroupsConfig>
- <xsl:copy-of select="//attribute[@name='ClusterConfig']/config/*"/>
- </jgroupsConfig>
- </xsl:if>
- </transport>
- </xsl:if>
- </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-06-26 14:57:18 UTC (rev 6057)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-06-26 15:44:26 UTC (rev 6058)
@@ -1,14 +1,14 @@
package org.jboss.cache.config;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
import org.jboss.cache.config.parsing.ConfigFilesConvertor;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import java.io.File;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
/**
* Test how xsl for migrating config files from 2.x to 3.x works.
@@ -18,27 +18,18 @@
* <li> it parses the file with 2.x parser
* <li> it parses the transform with a 3.x parser
* <li> checks that the two resulting <tt>Configuration</tt> objects are equal.
- * </ol>
+ * </ol>
*
* @author Mircea.Markus(a)jboss.com
* @since 3.0
*/
-@Test(groups = "functional")
+@Test(groups = "unit")
public class ConfigurationTransformerTest
{
- //TODO - make this reference relative
- public static final String XSLT_FILE = "C:\\projects\\cache\\branches\\za_trunk\\src\\main\\etc\\META-INF\\config2to3.xslt";
+ public static final String XSLT_FILE = "config2to3.xslt";
private static final String BASE_DIR = "META-INF/config2.x";
- File xsltFile;
ConfigFilesConvertor convertor = new ConfigFilesConvertor();
- @BeforeMethod
- public void setUp()
- {
- xsltFile = new File(XSLT_FILE);
- assert xsltFile.exists();
- }
-
/**
* Useful when {@link testEqualityOnTransformedFiles} fails and you need to isolate a failure.
*/
@@ -54,16 +45,14 @@
Configuration newConfig = newParser.parse(new ByteArrayInputStream(baos.toByteArray()));
Configuration oldConfig = oldParser.parseFile(fileName);
- assert oldConfig.getNodeLockingScheme().equals(newConfig.getNodeLockingScheme());
- assert oldConfig.getNodeLockingScheme() == newConfig.getNodeLockingScheme();
assert oldConfig.equals(newConfig);
}
public void testEqualityOnTransformedFiles() throws Exception
{
String[] fileNames = {"buddy-replication-cache-service.xml", "cacheloader-enabled-cache-service.xml",
- "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
- "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
+ "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
+ "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
for (String file : fileNames)
{
System.out.println("Processing file = " + file);
16 years, 6 months
JBoss Cache SVN: r6057 - searchable/trunk/src/test/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-06-26 10:57:18 -0400 (Thu, 26 Jun 2008)
New Revision: 6057
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
Log:
QueryResultIteratorImpl test written.
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-06-26 14:44:44 UTC (rev 6056)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-06-26 14:57:18 UTC (rev 6057)
@@ -24,7 +24,7 @@
QueryResultIterator iterator;
@BeforeMethod
- public void SetUp()
+ public void setUp()
{
// create a set of dummy cache entity IDs
ids = new ArrayList();
@@ -46,7 +46,7 @@
for (CacheEntityId id : ids)
{
// for each cache entity ID, create a dummy result that will be returned when loading it.
- dummyResults.put(id, "Result number " + counter);
+ dummyResults.put(id, "Result number " + counter++);
}
// now create a dummy entity loader
@@ -63,94 +63,221 @@
iterator = null;
}
- public void jumpToResultTest(int index) throws IndexOutOfBoundsException
+ public void testJumpToResult() throws IndexOutOfBoundsException
{
- //To change body of implemented methods use File | Settings | File Templates.
+ iterator.jumpToResult(0);
+ assert iterator.isFirst();
+
+ iterator.jumpToResult(1);
+ assert iterator.isAfterFirst();
+
+ iterator.jumpToResult((ids.size() - 1));
+ assert iterator.isLast();
+
+ iterator.jumpToResult(ids.size() - 2);
+ assert iterator.isBeforeLast();
}
- public void firstTest()
+ public void testFirst()
{
- //To change body of implemented methods use File | Settings | File Templates.
+ assert iterator.isFirst() : "We should be pointing at the first element";
+ Object next = iterator.next();
+ assert next == dummyResults.get(ids.get(0));
+ assert !iterator.isFirst();
+
+ iterator.first();
+
+ assert iterator.isFirst() : "We should be pointing at the first element";
+ next = iterator.next();
+ assert next == dummyResults.get(ids.get(0));
+ assert !iterator.isFirst();
+
}
- public void lastTest()
+ public void testLast()
{
- //To change body of implemented methods use File | Settings | File Templates.
+ //Jumps to the last element
+ iterator.last();
+
+ //Makes sure that the iterator is pointing at the last element.
+ assert iterator.isLast();
+
+ //Iterator points at the previous element.
+ Object previous = iterator.previous();
+
+ //Returns the size of the list of ids.
+ int size = ids.size();
+
+ //Makes sure that previous is the last element.
+ assert previous == dummyResults.get(ids.get(size - 1));
+
+ //Check that the iterator is NOT pointing at the last element.
+ assert !iterator.isLast();
}
- public void afterFirstTest()
+ public void testAfterFirst()
{
- //To change body of implemented methods use File | Settings | File Templates.
+ //Jump to the second element.
+ iterator.afterFirst();
+
+ //Check this
+ assert iterator.isAfterFirst();
+
+ //Previous element in the list
+ Object previous = iterator.previous();
+
+ //Check that previous is the second element.
+ assert previous == dummyResults.get(ids.get(0));
+
+ //Make sure that the iterator isn't pointing at the second element.
+ assert !iterator.isAfterFirst();
+
}
- public void beforeLastTest()
+ public void testBeforeLast()
{
- //To change body of implemented methods use File | Settings | File Templates.
+ //Jump to the penultimate element.
+ iterator.beforeLast();
+
+ //Check this
+ assert iterator.isBeforeLast();
+
+ //Next element - which should be the last.
+ Object next = iterator.next();
+
+ //Check that next is the penultimate element.
+ int size = ids.size();
+ assert next == dummyResults.get(ids.get(size - 1));
+
+ //Make sure that the iterator is not pointing at the penultimate element.
+ assert !iterator.isAfterFirst();
}
- public boolean isFirstTest()
+ public void testIsFirst()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ iterator.first();
+ assert iterator.isFirst();
+
+ iterator.next();
+ assert !iterator.isFirst();
}
- public boolean isLastTest()
+ public void testIsLast()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ iterator.last();
+ assert iterator.isLast();
+
+ iterator.previous();
+ assert !iterator.isLast();
}
- public boolean isAfterFirstTest()
+ public void testIsAfterFirst()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ iterator.afterFirst();
+ assert iterator.isAfterFirst();
+
+ iterator.previous();
+ assert !iterator.isAfterFirst();
}
- public boolean isBeforeLastTest()
+ public void testIsBeforeLast()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ iterator.beforeLast();
+ assert iterator.isBeforeLast();
}
- public boolean hasNextTest()
+ public void testHasNext()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ int size = ids.size();
+
+ if (size > 1)
+ {
+ iterator.first();
+ assert iterator.hasNext();
+
+ iterator.last();
+ assert !iterator.hasNext();
+
+ }
+
+ else
+ {
+ assert false;
+ }
+
}
- public Object nextTest()
+ public void testNext()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ iterator.first();
+ if (iterator.hasNext())
+ {
+ iterator.next();
+
+ assert iterator.isAfterFirst();
+ assert !iterator.isFirst();
+ }
+
+ else
+ {
+ assert false;
+ }
}
- public boolean hasPreviousTest()
+ public void testHasPrevious()
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ int size = ids.size();
+
+ if (size > 1)
+ {
+ iterator.first();
+ assert !iterator.hasPrevious();
+
+ iterator.last();
+ assert iterator.hasPrevious();
+
+ }
+
+ else
+ {
+ assert false;
+ }
}
- public Object previousTest()
+ public void testPrevious()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
+ iterator.last();
+ if(iterator.hasPrevious())
+ {
+ iterator.previous();
+ assert iterator.isBeforeLast();
+ assert !iterator.isLast();
+
+ }
+ else
+ {
+ assert false;
+ }
- public int nextIndexTest()
- {
- return 0; //To change body of implemented methods use File | Settings | File Templates.
}
- public int previousIndexTest()
+ public void testNextIndex()
{
- return 0; //To change body of implemented methods use File | Settings | File Templates.
- }
+ iterator.first();
+ assert iterator.nextIndex() == 1;
- public void removeTest()
- {
- //To change body of implemented methods use File | Settings | File Templates.
+ iterator.last();
+ assert iterator.nextIndex() == ids.size();
+
}
- public void setTest(Object o)
+ public void previousIndexTest()
{
- //To change body of implemented methods use File | Settings | File Templates.
- }
+ iterator.first();
+ assert iterator.previousIndex() == -1;
- public void addTest(Object o)
- {
- //To change body of implemented methods use File | Settings | File Templates.
+ iterator.last();
+ assert iterator.previousIndex() == (ids.size() - 1);
}
public static class DummyEntityLoader extends CacheEntityLoader
16 years, 6 months
JBoss Cache SVN: r6056 - in core/trunk/src: main/java/org/jboss/cache/commands/write and 8 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-26 10:44:44 -0400 (Thu, 26 Jun 2008)
New Revision: 6056
Added:
core/trunk/src/main/java/org/jboss/cache/commands/write/VersionedInvalidateCommand.java
core/trunk/src/test/java/org/jboss/cache/commands/write/VersionedInvalidateCommandTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
Log:
Removed use of deprecated Configuration.isNodeLockingOptimistic
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -165,7 +165,7 @@
NodeSPI toReturn = peek(fqn, false, includeInvalidNodes);
- if (toReturn != null && version != null && configuration.isNodeLockingOptimistic())
+ if (toReturn != null && version != null && configuration.getNodeLockingScheme().isVersionedScheme())
{
// we need to check the version of the data node...
DataVersion nodeVersion = toReturn.getVersion();
Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/VersionedInvalidateCommand.java (from rev 6055, core/trunk/src/main/java/org/jboss/cache/commands/write/OptimisticInvalidateCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/VersionedInvalidateCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/VersionedInvalidateCommand.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -0,0 +1,188 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.VersionedDataCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.Collections;
+
+/**
+ * Behaves like {@link org.jboss.cache.commands.write.InvalidateCommand}. Also, potentially throws a cache exception if
+ * data versioning is used and the node in memory has a newer data version than what is passed in.
+ * <p/>
+ * Finally, the data version of the in-memory node is updated to the version being evicted to prevent versions
+ * going out of sync.
+ * <p/>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public class VersionedInvalidateCommand extends InvalidateCommand implements VersionedDataCommand
+{
+ private static final Log log = LogFactory.getLog(VersionedInvalidateCommand.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ /*
+ dependencies
+ */
+ private TransactionManager transactionManager;
+
+ /**
+ * Params.
+ */
+ protected GlobalTransaction globalTransaction;
+ private DataVersion dataVersion;
+
+ public VersionedInvalidateCommand(Fqn fqn)
+ {
+ super(fqn);
+ }
+
+ public VersionedInvalidateCommand()
+ {
+ }
+
+ public void initialize(TransactionManager txManager)
+ {
+ this.transactionManager = txManager;
+ }
+
+ @Override
+ public Object perform(InvocationContext ctx)
+ {
+ NodeSPI node = enforceNodeLoading();
+ if (trace) log.trace("Invalidating fqn:" + fqn);
+ if (node == null)
+ {
+ // check if a tombstone already exists
+ NodeSPI nodeSPI = dataContainer.peek(fqn, false, true);
+ if (nodeSPI == null)
+ {
+ if (dataVersion == null)
+ {
+ if (trace)
+ log.trace("Would have created a tombstone since the node doesn't exist, but the version to invalidate is null and hence cannot create a tombstone!");
+ return null;
+ }
+ createTombstone(ctx);
+ nodeSPI = (NodeSPI) dataContainer.getRoot().getChild(fqn);
+ }
+ node = nodeSPI;
+ }
+ removeData(ctx);
+ invalidateNode(node);
+ updateDataVersion();
+ return null;
+ }
+
+ protected void createTombstone(InvocationContext ctx)
+ {
+ if (trace)
+ log.trace("Node doesn't exist; creating a tombstone with data version " + dataVersion);
+ // create the node we need.
+ Option o = ctx.getOptionOverrides();
+ boolean origCacheModeLocal = o.isCacheModeLocal();
+ o.setCacheModeLocal(true);
+ o.setDataVersion(dataVersion);
+ // if we are in a tx this call should happen outside of any tx
+ try
+ {
+ Transaction suspended = null;
+ if (transactionManager != null)
+ {
+ suspended = transactionManager.suspend();
+ }
+ spi.put(fqn, Collections.emptyMap());
+ if (suspended != null) transactionManager.resume(suspended);
+ ctx.getOptionOverrides().setCacheModeLocal(origCacheModeLocal);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to create tombstone!", e);
+ }
+ }
+
+ private void updateDataVersion()
+ {
+ if (dataVersion != null)
+ {
+ NodeSPI n = dataContainer.peek(fqn, false, true);
+ n.setVersion(dataVersion);
+ }
+ }
+
+ protected void removeData(InvocationContext ctx) throws CacheException
+ {
+ NodeSPI n = dataContainer.peekVersioned(fqn, dataVersion);
+ if (n == null)
+ {
+ log.warn("node " + fqn + " not found");
+ return;
+ }
+ notifier.notifyNodeEvicted(fqn, true, ctx);
+ n.clearDataDirect();
+ n.setDataLoaded(false);
+ notifier.notifyNodeEvicted(fqn, false, ctx);
+ }
+
+ public DataVersion getDataVersion()
+ {
+ return dataVersion;
+ }
+
+ public void setDataVersion(DataVersion dataVersion)
+ {
+ this.dataVersion = dataVersion;
+ }
+
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return globalTransaction;
+ }
+
+ public void setGlobalTransaction(GlobalTransaction gtx)
+ {
+ this.globalTransaction = gtx;
+ }
+
+ public boolean isVersioned()
+ {
+ return dataVersion != null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OptimisticInvalidateCommand{" +
+ "dataVersion=" + dataVersion +
+ " ,fqn=" + fqn +
+ '}';
+ }
+
+ @Override
+ public Object[] getParameters()
+ {
+ return new Object[]{fqn, dataVersion};
+ }
+
+ @Override
+ public void setParameters(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ dataVersion = (DataVersion) args[1];
+ }
+
+ public void rollback()
+ {
+ //no op
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -148,7 +148,15 @@
*
* @see <a href="http://en.wikipedia.org/wiki/Optimistic_concurrency_control">http://en.wikipedia.org/wiki/Optimistic_concurrency_control</a>
*/
- OPTIMISTIC
+ OPTIMISTIC;
+
+ /**
+ * @return true if the node locking scheme uses versioning.
+ */
+ public boolean isVersionedScheme()
+ {
+ return this == MVCC || this == OPTIMISTIC;
+ }
}
/**
@@ -541,6 +549,12 @@
return this.shutdownHookBehavior;
}
+ /**
+ * This helper method is deprecated and will be removed when optimistic and pessimistic locking support is dropped.
+ *
+ * @return true if node locking scheme is optimistic.
+ * @deprecated use {@link #getNodeLockingScheme()} to determine node locking scheme used.
+ */
@Deprecated
public boolean isNodeLockingOptimistic()
{
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -82,7 +82,7 @@
// hacky temp solution till we have an ioc fwk to inject configuration elements as needed
Configuration c = region.getCacheConfiguration();
Configuration.CacheMode cm = c != null ? c.getCacheMode() : Configuration.CacheMode.LOCAL;
- allowTombstones = c != null && c.isNodeLockingOptimistic() &&
+ allowTombstones = c != null && c.getNodeLockingScheme().isVersionedScheme() &&
(cm == Configuration.CacheMode.INVALIDATION_ASYNC || cm == Configuration.CacheMode.INVALIDATION_SYNC);
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -177,9 +177,9 @@
public InvalidateCommand buildInvalidateCommand(Fqn fqn)
{
- if (configuration.isNodeLockingOptimistic())
+ if (configuration.getNodeLockingScheme().isVersionedScheme())
{
- OptimisticInvalidateCommand command = new OptimisticInvalidateCommand(fqn);
+ VersionedInvalidateCommand command = new VersionedInvalidateCommand(fqn);
command.initialize(txManager);
command.initialize(cacheSpi, dataContainer, notifier);
return command;
@@ -450,9 +450,9 @@
case InvalidateCommand.METHOD_ID:
{
- if (configuration.isNodeLockingOptimistic())
+ if (configuration.getNodeLockingScheme().isVersionedScheme())
{
- OptimisticInvalidateCommand returnValue = new OptimisticInvalidateCommand();
+ VersionedInvalidateCommand returnValue = new VersionedInvalidateCommand();
returnValue.initialize(txManager);
returnValue.initialize(cacheSpi, dataContainer, notifier);
command = returnValue;
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -52,7 +52,7 @@
public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
{
- boolean optimistic = configuration.isNodeLockingOptimistic();
+ boolean optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
// load the icInterceptor first
CommandInterceptor first = createInterceptor(InvocationContextInterceptor.class);
InterceptorChain interceptorChain = new InterceptorChain(first);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -20,6 +20,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
import static org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
@@ -59,7 +60,7 @@
protected Notifier notifier;
protected boolean isActivation = false;
- protected boolean usingOptimisticInvalidation = false;
+ protected boolean usingVersionedInvalidation = false;
/**
@@ -76,7 +77,7 @@
this.txTable = txTable;
this.clm = clm;
CacheMode mode = configuration.getCacheMode();
- usingOptimisticInvalidation = configuration.isNodeLockingOptimistic() && mode.isInvalidation();
+ usingVersionedInvalidation = configuration.getNodeLockingScheme().isVersionedScheme() && mode.isInvalidation();
this.dataContainer = dataContainer;
this.lockManager = lockManager;
this.notifier = notifier;
@@ -144,7 +145,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), false, false, !usingOptimisticInvalidation);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), false, false, !usingVersionedInvalidation);
}
return invokeNextInterceptor(ctx, command);
}
@@ -213,7 +214,7 @@
@Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- if (configuration.isNodeLockingOptimistic() && command.getFqn() != null)
+ if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC && command.getFqn() != null)
{
loadIfNeeded(ctx, command.getFqn(), null, false, false, false, ctx.getTransactionContext(), false, false, false);
}
@@ -397,7 +398,7 @@
}
// check this first!!!
- if (!n.isValid() && configuration.isNodeLockingOptimistic())
+ if (!n.isValid() && configuration.getNodeLockingScheme().isVersionedScheme())
{
// attempt to load again; this only happens if we have tombstones lying around, or we are using invalidation.
if (trace) log.trace("loading again from cache loader since in-memory node is marked as invalid");
@@ -455,7 +456,7 @@
protected void lock(Fqn fqn, LockType lockType, boolean recursive, InvocationContext ctx) throws Throwable
{
- if (configuration.isNodeLockingOptimistic()) return;
+ if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC) return;
if (recursive)
lockManager.lockAllAndRecord(fqn, lockType, ctx);
@@ -504,7 +505,7 @@
n.setInternalState(nodeData);
// set this node as valid?
- if (usingOptimisticInvalidation) n.setValid(true, false);
+ if (usingVersionedInvalidation) n.setValid(true, false);
notifier.notifyNodeLoaded(fqn, false, nodeData, ctx);
if (isActivation)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -285,7 +285,7 @@
private void storeInternalState(Set<Fqn> affectedFqns) throws Exception
{
- if (configuration.isNodeLockingOptimistic())
+ if (configuration.getNodeLockingScheme().isVersionedScheme())
{
for (Fqn f : affectedFqns)
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -14,6 +14,8 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -33,6 +35,14 @@
*/
public class CallInterceptor extends CommandInterceptor
{
+ private boolean notOptimisticLocking;
+
+ @Start
+ protected void start()
+ {
+ notOptimisticLocking = configuration.getNodeLockingScheme() != NodeLockingScheme.OPTIMISTIC;
+ }
+
@Override
public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
@@ -140,7 +150,7 @@
throws Throwable
{
Object result = invokeCommand(ctx, command);
- if (ctx.isValidTransaction() && !configuration.isNodeLockingOptimistic())
+ if (notOptimisticLocking && ctx.isValidTransaction())
{
GlobalTransaction gtx = ctx.getGlobalTransaction();
if (gtx == null)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -17,12 +17,13 @@
import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.OptimisticInvalidateCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.VersionedInvalidateCommand;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
@@ -75,7 +76,7 @@
@Start
private void initTxMap()
{
- optimistic = configuration.isNodeLockingOptimistic();
+ optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<ReversibleCommand>>();
}
@@ -261,7 +262,7 @@
{
try
{
- TransactionWorkspace workspace = configuration.isNodeLockingOptimistic() ? getWorkspace(ctx) : null;
+ TransactionWorkspace workspace = optimistic ? getWorkspace(ctx) : null;
for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
}
catch (Throwable t)
@@ -376,7 +377,7 @@
incrementInvalidations();
InvalidateCommand command = commandsFactory.buildInvalidateCommand(fqn);
DataVersion dataVersion = getNodeVersion(workspace, fqn);
- if (dataVersion != null) ((OptimisticInvalidateCommand) command).setDataVersion(dataVersion);
+ if (dataVersion != null) ((VersionedInvalidateCommand) command).setDataVersion(dataVersion);
if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + command);
// voila, invalidated!
replicateCall(ctx, command, synchronous, ctx.getOptionOverrides());
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -7,6 +7,7 @@
package org.jboss.cache.lock;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
@@ -36,7 +37,7 @@
@Start(priority = 1)
public void start()
{
- lockingLevel = configuration.isNodeLockingOptimistic() ? IsolationLevel.REPEATABLE_READ : configuration.getIsolationLevel();
+ lockingLevel = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC ? IsolationLevel.REPEATABLE_READ : configuration.getIsolationLevel();
}
public LockStrategy getLockStrategy()
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -50,12 +50,12 @@
private Set<Fqn> internalFqns;
- public DefaultStateTransferIntegrator(Fqn targetFqn, CacheSPI cache)
+ public DefaultStateTransferIntegrator(Fqn targetFqn, CacheSPI<?, ?> cache)
{
this.targetFqn = targetFqn;
this.cache = cache;
this.factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
- this.nodeType = cache.getConfiguration().isNodeLockingOptimistic()
+ this.nodeType = cache.getConfiguration().getNodeLockingScheme().isVersionedScheme()
? NodeFactory.NodeType.VERSIONED_NODE
: NodeFactory.NodeType.UNVERSIONED_NODE;
this.internalFqns = cache.getInternalFqns();
Copied: core/trunk/src/test/java/org/jboss/cache/commands/write/VersionedInvalidateCommandTest.java (from rev 6055, core/trunk/src/test/java/org/jboss/cache/commands/write/OptimisticInvalidateCommandTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/VersionedInvalidateCommandTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/VersionedInvalidateCommandTest.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -0,0 +1,139 @@
+package org.jboss.cache.commands.write;
+
+import static org.easymock.EasyMock.createStrictControl;
+import static org.easymock.EasyMock.expect;
+import org.easymock.IMocksControl;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.commands.read.AbstractDataCommandTest;
+import org.jboss.cache.mock.MockNodesFixture;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.optimistic.DefaultDataVersion;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.Collections;
+
+/**
+ * tester class for {@link VersionedInvalidateCommand}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+@Test(groups = "unit")
+public class VersionedInvalidateCommandTest extends AbstractDataCommandTest
+{
+ DataVersion dataVersion;
+ VersionedInvalidateCommand command;
+ IMocksControl control;
+
+ Notifier notifier;
+ TransactionManager tmMock;
+
+ MockNodesFixture nodes;
+ CacheSPI spiMock;
+
+ protected void moreSetup()
+ {
+ control = createStrictControl();
+ notifier = control.createMock(Notifier.class);
+ container = control.createMock(DataContainer.class);
+ tmMock = control.createMock(TransactionManager.class);
+ spiMock = control.createMock(CacheSPI.class);
+ nodes = new MockNodesFixture();
+
+ command = new VersionedInvalidateCommand(testFqn);
+ dataVersion = new DefaultDataVersion(10);
+ command.setDataVersion(dataVersion);
+ command.initialize(spiMock, container, notifier);
+ command.initialize(tmMock);
+ }
+
+ public void testWithExistingNode()
+ {
+ nodes.adfNode.put("key", "value");
+ nodes.adfNode.setDataLoaded(true);
+ expect(spiMock.getNode(testFqn)).andReturn(nodes.adfNode);
+ expect(container.peekVersioned(testFqn, dataVersion)).andReturn(nodes.adfNode);
+ notifier.notifyNodeEvicted(testFqn, true, ctx);
+ notifier.notifyNodeEvicted(testFqn, false, ctx);
+ expect(container.peek(testFqn, false, true)).andReturn(nodes.adfNode);
+
+ control.replay();
+ assert null == command.perform(ctx);
+ assert nodes.adfNode.getData().isEmpty();
+ assert !nodes.adfNode.isDataLoaded();
+ assert !nodes.adfNode.isValid();
+ assert nodes.adfNode.getVersion().equals(dataVersion);
+
+ control.verify();
+ }
+
+ public void testWithExistingNodeInvalidVersion()
+ {
+ nodes.adfNode.put("key", "value");
+ nodes.adfNode.setDataLoaded(true);
+ expect(spiMock.getNode(testFqn)).andReturn(nodes.adfNode);
+ expect(container.peekVersioned(testFqn, dataVersion)).andThrow(new RuntimeException());
+ control.replay();
+
+ try
+ {
+ command.perform(ctx);
+ assert false : "exception expected";
+ }
+ catch (Exception e)
+ {
+ //expected as there is a version mismatch
+ }
+ assert !nodes.adfNode.getData().isEmpty();
+ assert nodes.adfNode.isDataLoaded();
+ assert nodes.adfNode.isValid();
+ assert !dataVersion.equals(nodes.adfNode.getVersion());
+
+ control.verify();
+ }
+
+ public void testExistingTumbstone()
+ {
+ nodes.adfNode.setValid(false, true);
+ expect(spiMock.getNode(testFqn)).andReturn(null);
+ expect(container.peek(testFqn, false, true)).andReturn(nodes.adfNode);
+ expect(container.peekVersioned(testFqn, dataVersion)).andReturn(nodes.adfNode);
+ notifier.notifyNodeEvicted(testFqn, true, ctx);
+ notifier.notifyNodeEvicted(testFqn, false, ctx);
+ expect(container.peek(testFqn, false, true)).andReturn(nodes.adfNode);
+
+ control.replay();
+ assert null == command.perform(ctx);
+ assert nodes.adfNode.getData().isEmpty();
+ assert !nodes.adfNode.isDataLoaded();
+ assert !nodes.adfNode.isValid();
+ assert nodes.adfNode.getVersion().equals(dataVersion);
+ control.verify();
+ }
+
+ public void testCreateTumbstone() throws Exception
+ {
+ Transaction tx = control.createMock(Transaction.class);
+ expect(tmMock.suspend()).andReturn(tx);
+ spiMock.put(testFqn, Collections.emptyMap());
+ tmMock.resume(tx);
+
+ control.replay();
+ command.createTombstone(ctx);
+ control.verify();
+ }
+
+ public void testCreateTumbstoneNoTx() throws Exception
+ {
+ expect(tmMock.suspend()).andReturn(null);
+ spiMock.put(testFqn, Collections.EMPTY_MAP);
+
+ control.replay();
+ command.createTombstone(ctx);
+ control.verify();
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-06-26 14:18:49 UTC (rev 6055)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-06-26 14:44:44 UTC (rev 6056)
@@ -1,14 +1,14 @@
package org.jboss.cache.config;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
import org.jboss.cache.config.parsing.ConfigFilesConvertor;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import java.io.File;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
/**
* Test how xsl for migrating config files from 2.x to 3.x works.
@@ -55,15 +55,15 @@
Configuration oldConfig = oldParser.parseFile(fileName);
assert oldConfig.getNodeLockingScheme().equals(newConfig.getNodeLockingScheme());
- assert oldConfig.isNodeLockingOptimistic() == newConfig.isNodeLockingOptimistic();
+ assert oldConfig.getNodeLockingScheme() == newConfig.getNodeLockingScheme();
assert oldConfig.equals(newConfig);
}
public void testEqualityOnTransformedFiles() throws Exception
{
String[] fileNames = {"buddy-replication-cache-service.xml", "cacheloader-enabled-cache-service.xml",
- "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
- "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
+ "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
+ "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
for (String file : fileNames)
{
System.out.println("Processing file = " + file);
16 years, 6 months
JBoss Cache SVN: r6055 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 26 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-26 10:18:49 -0400 (Thu, 26 Jun 2008)
New Revision: 6055
Added:
core/trunk/src/main/java/org/jboss/cache/factories/context/
core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
Removed:
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
Modified:
core/trunk/src/main/java/org/jboss/cache/Cache.java
core/trunk/src/main/java/org/jboss/cache/CacheSPI.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/buddyreplication/Fqn2BuddyFqnVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/OptimisticInvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
Invocation and Transaction Context refactoring.
- introduced interfaces in front of each context
- introduced factories to construct them
- introduced better javadocs
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,6 +8,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
import java.util.List;
@@ -352,7 +353,7 @@
InvocationContext getInvocationContext();
/**
- * Sets the passed in {@link org.jboss.cache.InvocationContext} as current.
+ * Sets the passed in {@link org.jboss.cache.invocation.InvocationContext} as current.
*
* @param ctx invocation context to use
* @throws IllegalStateException if the cache has been destroyed.
Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -10,6 +10,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -16,6 +16,7 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.LockUtil;
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -11,6 +11,7 @@
import static org.jboss.cache.AbstractNode.NodeFlags.*;
import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.factories.CommandsFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.marshall.MarshalledValue;
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,6 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.read.ExistsCommand;
@@ -17,6 +16,7 @@
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.*;
import org.jboss.cache.factories.CommandsFactory;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.commands;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -13,6 +12,7 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.*;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,6 @@
package org.jboss.cache.commands;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContext;
/**
* The core of the command-based cache framework. Commands correspond to specific areas of functionality in the cache,
Modified: core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,6 @@
package org.jboss.cache.commands;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContext;
/**
* A type of command that can accept {@link org.jboss.cache.commands.Visitor}s, such as {@link org.jboss.cache.interceptors.base.CommandInterceptor}s.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.commands;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -13,6 +12,7 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.*;
+import org.jboss.cache.invocation.InvocationContext;
/**
* This interface is the core of JBoss Cache, where each {@link VisitableCommand} can be visited by a Visitor implementation.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,8 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Checks whether a given node exists in current in-memory state of the cache.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
import java.util.Collections;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.MapCopy;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,8 +2,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,13 +1,10 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)}
* <p/>
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,11 +2,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.NodeData;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,9 +2,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.remote;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Arrays;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,13 +3,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.Collections;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
@@ -13,6 +12,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.remote;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Removes a buddy from a group. This is not a {@link org.jboss.cache.commands.VisitableCommand} and hence
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,12 +2,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.tx;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.tx;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,9 +3,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -78,8 +78,9 @@
NodeSPI nodeSpi = dataContainer.peek(fqn, false, true);
if (nodeSpi == null)
{
- if (trace) log.trace("Not rolling back node clearance for node: " + fqn + " as it does not exist in the cache. " +
- "This might be the result of an NoOp clear operation");
+ if (trace)
+ log.trace("Not rolling back node clearance for node: " + fqn + " as it does not exist in the cache. " +
+ "This might be the result of an NoOp clear operation");
return;
}
nodeSpi.putAllDirect(originalData);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,11 +1,11 @@
package org.jboss.cache.commands.write;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.LinkedList;
@@ -50,7 +50,7 @@
/**
* Creates a node in the cache, specified by the given Fqn.
*/
- public Object perform(InvocationContext ctx)
+ public Object perform(InvocationContext ctx)
{
Object[] results = dataContainer.createNodes(fqn);
List<NodeSPI> created = (List<NodeSPI>) results[0];
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,12 +1,12 @@
package org.jboss.cache.commands.write;
+import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.notifications.Notifier;
import java.util.List;
@@ -43,7 +43,7 @@
/**
* Evicts a node.
* <p/>
- * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext, EvictCommand)}
+ * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.invocation.InvocationContext , EvictCommand)}
* which is where the return value is used
*
* @return true if the node was removed from the tree or if it is resident. Returns false if the node still exists; i.e. was only data removed because it still has children.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,21 +2,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
-import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.notifications.Notifier;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.Collections;
-import java.util.Map;
-
/**
* Removes a node's content from memory - never removes the node.
- * It also clenups data for resident nodes - which are not being touched by eviction.
+ * It also clenups data for resident nodes - which are not being touched by eviction.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
@@ -82,7 +79,7 @@
/**
* //TODO: 2.2.0: rather than using CacheSPI this should use peek(). The other interceptors should obtain locks and load nodes if necessary for this InvalidateCommand.
- //Even better - this can be handles in the interceptors before call interceptor
+ * //Even better - this can be handles in the interceptors before call interceptor
*/
protected NodeSPI enforceNodeLoading()
{
@@ -91,8 +88,8 @@
/**
- * mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
- be aware that it is no longer valid.
+ * mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
+ * be aware that it is no longer valid.
*/
protected void invalidateNode(NodeSPI node)
{
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,10 +2,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/OptimisticInvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/OptimisticInvalidateCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/OptimisticInvalidateCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,17 +4,16 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Collections;
-import java.util.Map;
/**
* Behaves like {@link org.jboss.cache.commands.write.InvalidateCommand}. Also, potentially throws a cache exception if
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,9 +3,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -104,7 +104,8 @@
if (isVersioned())
{
return VERSIONED_METHOD_ID;
- } else
+ }
+ else
{
return METHOD_ID;
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.write;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,9 +4,9 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,10 +3,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,9 +3,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -15,6 +15,7 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.factories.context.ContextMetaFactory;
import org.jboss.cache.util.BeanUtils;
import org.jboss.cache.util.reflect.ReflectionUtil;
@@ -173,6 +174,7 @@
s.add(TransactionManagerFactory.class);
s.add(ReplicationQueueFactory.class);
s.add(LockManagerFactory.class);
+ s.add(ContextMetaFactory.class);
return s;
}
Added: core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,33 @@
+package org.jboss.cache.factories.context;
+
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * This is the factory responsible for creating {@link org.jboss.cache.invocation.InvocationContext}s and {@link org.jboss.cache.transaction.TransactionContext}s
+ * for requests, based on the configuration used.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface ContextFactory
+{
+ /**
+ * @return a new invocation context
+ */
+ InvocationContext createInvocationContext();
+
+ /**
+ * @param tx JTA transaction to associate the new context with
+ * @return a new transaction context
+ * @throws javax.transaction.RollbackException
+ * in the event of an invalid transaaction
+ * @throws javax.transaction.SystemException
+ * in the event of an invalid transaction
+ */
+ TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException;
+}
Added: core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,30 @@
+package org.jboss.cache.factories.context;
+
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.factories.ComponentFactory;
+import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+
+/**
+ * Responsible for creating the appropriate {@link ContextFactory} based on configuration used.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = ContextFactory.class)
+public class ContextMetaFactory extends ComponentFactory
+{
+ @SuppressWarnings("unchecked")
+ protected <T> T construct(Class<T> componentType)
+ {
+ switch (configuration.getNodeLockingScheme())
+ {
+ case MVCC:
+ return (T) new MVCCContextFactory();
+ case OPTIMISTIC:
+ return (T) new OptimisticContextFactory();
+ case PESSIMISTIC:
+ return (T) new PessimisticContextFactory();
+ }
+ throw new ConfigurationException("Unknown configuration node locking scheme");
+ }
+}
Added: core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,29 @@
+package org.jboss.cache.factories.context;
+
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.MVCCInvocationContext;
+import org.jboss.cache.transaction.MVCCTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Constructs contexts for MVCC locking
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MVCCContextFactory implements ContextFactory
+{
+ public InvocationContext createInvocationContext()
+ {
+ return new MVCCInvocationContext();
+ }
+
+ public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ return new MVCCTransactionContext(tx);
+ }
+}
Added: core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,25 @@
+package org.jboss.cache.factories.context;
+
+import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Constructs contexts for optimistic locking
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@NonVolatile
+public class OptimisticContextFactory extends PessimisticContextFactory
+{
+ @Override
+ public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ return new OptimisticTransactionContext(tx);
+ }
+}
Added: core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,41 @@
+package org.jboss.cache.factories.context;
+
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
+import org.jboss.cache.transaction.PessimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Constructs contexts for pessimistic locking
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@NonVolatile
+public class PessimisticContextFactory implements ContextFactory
+{
+ DataContainer container;
+
+ @Inject
+ public void inject(DataContainer container)
+ {
+ this.container = container;
+ }
+
+ public InvocationContext createInvocationContext()
+ {
+ return new LegacyInvocationContext(container);
+ }
+
+ public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ return new PessimisticTransactionContext(tx);
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.AbstractVisitor;
@@ -20,6 +19,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,7 +3,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.cluster.ReplicationQueue;
@@ -14,6 +13,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,7 +3,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -24,6 +23,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.lock.LockManager;
@@ -546,7 +546,7 @@
node.setDataLoaded(false);
if (transactionContext != null)
{
- transactionContext.loadUninitialisedNode(node.getFqn());
+ transactionContext.addDummyNodeCreatedByCacheLoader(node.getFqn());
}
lastCreated = node;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -22,7 +22,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.read.GetKeyValueCommand;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
@@ -30,6 +29,7 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.HashMap;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,7 +3,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.AbstractVisitor;
@@ -24,6 +23,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -15,11 +14,9 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -36,22 +33,6 @@
*/
public class CallInterceptor extends CommandInterceptor
{
- private TransactionTable transactionTable;
- private boolean cacheLoadingEnabled;
-
- @Inject
- public void injectDependencies(TransactionTable transactionTable)
- {
- this.transactionTable = transactionTable;
- }
-
- @Start
- public void startInterceptor()
- {
- cacheLoadingEnabled = configuration.getCacheLoaderConfig() != null &&
- configuration.getCacheLoaderConfig().getFirstCacheLoaderConfig() != null;
- }
-
@Override
public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -10,7 +10,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
@@ -28,6 +27,7 @@
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -9,7 +9,6 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
@@ -27,6 +26,7 @@
import org.jboss.cache.eviction.NodeEventType;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Eviction Interceptor.
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -21,15 +21,12 @@
*/
package org.jboss.cache.interceptors;
-import org.apache.commons.logging.Log;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Class representing an interceptor.
@@ -65,7 +62,7 @@
/**
* Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors
* extending other interceptors. This metod rather refers to interceptor doing its business operations rather than
- * delegating to the nextInterceptor interceptor in chain. For delegation please use {@link #nextInterceptor(org.jboss.cache.InvocationContext)}
+ * delegating to the nextInterceptor interceptor in chain. For delegation please use {@link #nextInterceptor(org.jboss.cache.invocation.InvocationContext)}
*/
public Object invoke(InvocationContext ctx) throws Throwable
{
@@ -90,23 +87,6 @@
+ "}";
}
- /**
- * First checks the invocation context for previously obtained reference to a node, if this doesn't exist, performs
- * a cache.peek() and holds on to the node reference.
- *
- * @param ctx invocation context
- * @param f fqn to find
- * @param forceRefresh forces calling cache.peek() even if we hold a reference to the relevant node.
- * @param includeDeletedNodes includes nodes marked for deletion if this is true
- * @param includeInvalidNodes includes nodes marked as invalid if this is true
- * @return a node, or null if one cannot be found.
- * @since 2.1.0
- */
- public NodeSPI peekNode(InvocationContext ctx, Fqn f, boolean forceRefresh, boolean includeDeletedNodes, boolean includeInvalidNodes)
- {
- return cache.peek(f, includeDeletedNodes, includeInvalidNodes);
- }
-
@Override
@SuppressWarnings("deprecation")
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,18 +3,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.CachePrinter;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import java.util.ArrayList;
/**
* Knows how to build and manage an chain of interceptors. Also in charge with invoking methods on the chain.
@@ -229,7 +229,7 @@
}
/**
- * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}, but
+ * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
* constructs a invocation context on the fly, using {@link InvocationContextContainer#get()}
*/
public Object invokeRemote(VisitableCommand cacheCommand) throws Throwable
@@ -240,7 +240,7 @@
}
/**
- * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}, but
+ * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
* constructs a invocation context on the fly, using {@link InvocationContextContainer#get()} and setting the origin local flag to it's default value.
*/
public Object invoke(VisitableCommand cacheCommand) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -7,7 +7,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -28,6 +27,7 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -6,21 +6,21 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,7 +2,6 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
@@ -19,6 +18,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -8,8 +7,12 @@
import org.jboss.cache.commands.read.GetKeysCommand;
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.*;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.MarshalledValue;
import org.jboss.cache.marshall.MarshalledValueHelper;
import org.jboss.cache.marshall.MarshalledValueMap;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,10 +1,10 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -10,7 +10,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.MoveCommand;
@@ -19,6 +18,7 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,11 +8,11 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.READ;
import org.jboss.cache.lock.TimeoutException;
@@ -74,9 +74,9 @@
}
/**
- * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, extracted from the current {@link org.jboss.cache.InvocationContext}.
+ * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, extracted from the current {@link org.jboss.cache.invocation.InvocationContext}.
* @throws CacheException if the {@link org.jboss.cache.transaction.GlobalTransaction} or {@link javax.transaction.Transaction} associated with the
- * {@link org.jboss.cache.InvocationContext} is null.
+ * {@link org.jboss.cache.invocation.InvocationContext} is null.
*/
protected GlobalTransaction getGlobalTransaction(InvocationContext ctx) throws CacheException
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -7,13 +7,13 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import static org.jboss.cache.lock.LockType.READ;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -10,7 +10,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
@@ -30,6 +29,7 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import static org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType.*;
import org.jboss.cache.optimistic.DataVersion;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,7 +8,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
@@ -28,6 +27,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -45,8 +45,8 @@
* Replication interceptor for the optimistically locked interceptor chain. Responsible for replicating
* state to remote nodes. Unlike it's cousin, the {@link org.jboss.cache.interceptors.ReplicationInterceptor}, this interceptor
* only deals with transactional calls. Just like all things to do with Optimistic Locking, it is a requirement that
- * everything is done in a transaction and the transaction context is available via {@link org.jboss.cache.InvocationContext#getTransaction()}
- * and {@link org.jboss.cache.InvocationContext#getGlobalTransaction()}.
+ * everything is done in a transaction and the transaction context is available via {@link org.jboss.cache.invocation.InvocationContext#getTransaction()}
+ * and {@link org.jboss.cache.invocation.InvocationContext#getGlobalTransaction()}.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -12,6 +11,7 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
@@ -150,12 +150,6 @@
}
}
- @Override
- protected TransactionContext createNewTransactionContext(Transaction tx) throws Exception
- {
- return new OptimisticTransactionContext(tx);
- }
-
private class ModificationsReplayVisitor extends AbstractVisitor
{
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -9,13 +9,13 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import static org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersioningException;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,11 +2,11 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.notifications.Notifier;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,7 +8,6 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -30,6 +29,7 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.READ;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -14,6 +13,7 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -7,7 +7,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.ReplicationException;
import org.jboss.cache.commands.AbstractVisitor;
@@ -29,6 +28,8 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.context.ContextFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.notifications.Notifier;
@@ -66,6 +67,7 @@
private Notifier notifier;
private InvocationContextContainer invocationContextContainer;
private ComponentRegistry componentRegistry;
+ private ContextFactory contextFactory;
/**
* List <Transaction>that we have registered for
@@ -79,10 +81,11 @@
private LockManager lockManager;
@Inject
- public void intialize(RPCManager rpcManager,
+ public void intialize(RPCManager rpcManager, ContextFactory contextFactory,
Notifier notifier, InvocationContextContainer icc,
CommandsFactory factory, ComponentRegistry componentRegistry, LockManager lockManager)
{
+ this.contextFactory = contextFactory;
this.commandsFactory = factory;
this.rpcManager = rpcManager;
this.notifier = notifier;
@@ -367,7 +370,7 @@
{
// create a new transaction transactionContext
if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
- transactionContext = createNewTransactionContext(ltx);
+ transactionContext = contextFactory.createTransactionContext(ltx);
txTable.put(gtx, transactionContext);
}
@@ -448,11 +451,6 @@
return retval;
}
- protected TransactionContext createNewTransactionContext(Transaction tx) throws Exception
- {
- return new TransactionContext(tx);
- }
-
private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable
{
if (trace)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,13 +2,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.InterceptorMBean;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Collections;
import java.util.Map;
@@ -22,11 +22,11 @@
* public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
* are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
* <p/>
- * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.InvocationContext, org.jboss.cache.commands.read.GetKeyValueCommand)})
- * or the more generic {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
- * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.read.GetKeyValueCommand)})
+ * or the more generic {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
+ * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
* <p/>
- * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}
* and then write a series of if statements or a switch block, if command-specific behaviour is needed.
* <p/>
*
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors.base;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -14,16 +13,17 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.*;
+import org.jboss.cache.invocation.InvocationContext;
/**
- * This interceptor will call {@link #doAfterCall(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} after invoking each visit method
- * (and the {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} method) in
+ * This interceptor will call {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} after invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method) in
* a <tt>finally</tt> block.
* <p/>
* It is useful if common cleanup code is required at the end of each call.
* <p/>
* Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
- * instead, as well as the {@link #doAfterCall(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} method.
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors.base;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -14,18 +13,26 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.*;
+import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.invocation.InvocationContext;
/**
- * This interceptor will call {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
- * (and the {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} method). If
- * {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
+ * This interceptor will call {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method). If
+ * {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
* and passed up the interceptor chain instead.
* <p/>
* Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
- * instead, as well as the {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} method.
- * Also, instead of overriding {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}, implementors
- * should override {@link #handleAll(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * instead, as well as the {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
+ * Also, instead of overriding {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, implementors
+ * should override {@link #handleAll(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Copied: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java (from rev 6048, core/trunk/src/main/java/org/jboss/cache/InvocationContext.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.invocation;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.cache.transaction.TransactionTable;
+
+import javax.transaction.Transaction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+/**
+ * This context holds information specific to a method invocation. This is used for Optimistic and Pessimisic Node Locking Schemes.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@SuppressWarnings("deprecation")
+public abstract class AbstractInvocationContext implements InvocationContext
+{
+ private static final Log log = LogFactory.getLog(AbstractInvocationContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ private Transaction transaction;
+ private GlobalTransaction globalTransaction;
+ protected TransactionContext transactionContext;
+ private Option optionOverrides;
+ // defaults to true.
+ private boolean originLocal = true;
+ private boolean txHasMods;
+ private boolean localRollbackOnly;
+ @Deprecated
+ private MethodCall methodCall;
+ @Deprecated
+ private VisitableCommand command;
+
+ /**
+ * LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
+ */
+ private LinkedHashSet invocationLocks;
+
+ public void setLocalRollbackOnly(boolean localRollbackOnly)
+ {
+ this.localRollbackOnly = localRollbackOnly;
+ }
+
+ public Transaction getTransaction()
+ {
+ return transaction;
+ }
+
+ public void setTransaction(Transaction transaction)
+ {
+ this.transaction = transaction;
+ }
+
+ public TransactionContext getTransactionContext()
+ {
+ return transactionContext;
+ }
+
+ public void setTransactionContext(TransactionContext transactionContext)
+ {
+ this.transactionContext = transactionContext;
+ }
+
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return globalTransaction;
+ }
+
+ public void setGlobalTransaction(GlobalTransaction globalTransaction)
+ {
+ this.globalTransaction = globalTransaction;
+ }
+
+ public Option getOptionOverrides()
+ {
+ if (optionOverrides == null)
+ {
+ optionOverrides = new Option();
+ }
+ return optionOverrides;
+ }
+
+ public boolean isOptionsUninitialised()
+ {
+ return optionOverrides == null;
+ }
+
+ public void setOptionOverrides(Option optionOverrides)
+ {
+ this.optionOverrides = optionOverrides;
+ }
+
+ public boolean isOriginLocal()
+ {
+ return originLocal;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null) return transactionContext.getLocks();
+ return invocationLocks == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(invocationLocks));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addAllLocks(List locks)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addAllLocks(locks);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(5);
+ invocationLocks.addAll(locks);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.addLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks == null) invocationLocks = new LinkedHashSet(5);
+ invocationLocks.add(lock);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeLock(Object lock)
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.removeLock(lock);
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks != null) invocationLocks.remove(lock);
+ }
+ }
+
+ public void clearLocks()
+ {
+ // first check transactional scope
+ if (transactionContext != null)
+ {
+ transactionContext.clearLocks();
+ }
+ else
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (invocationLocks != null) invocationLocks.clear();
+ }
+ }
+
+ public boolean isLockingSuppressed()
+ {
+ return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
+ }
+
+ public void setOriginLocal(boolean originLocal)
+ {
+ this.originLocal = originLocal;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "InvocationContext{" +
+ "transaction=" + transaction +
+ ", globalTransaction=" + globalTransaction +
+ ", optionOverrides=" + optionOverrides +
+ ", originLocal=" + originLocal +
+ ", txHasMods=" + txHasMods +
+ '}';
+ }
+
+ public boolean isTxHasMods()
+ {
+ return txHasMods;
+ }
+
+ public void setTxHasMods(boolean b)
+ {
+ txHasMods = b;
+ }
+
+ public boolean isLocalRollbackOnly()
+ {
+ return localRollbackOnly;
+ }
+
+ public void reset()
+ {
+ transaction = null;
+ globalTransaction = null;
+ optionOverrides = null;
+ originLocal = true;
+ txHasMods = false;
+ invocationLocks = null;
+ methodCall = null;
+ command = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void doCopy(AbstractInvocationContext copy)
+ {
+ copy.command = command;
+ copy.globalTransaction = globalTransaction;
+ copy.invocationLocks = invocationLocks == null ? null : new LinkedHashSet(invocationLocks);
+ copy.localRollbackOnly = localRollbackOnly;
+ copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
+ copy.originLocal = originLocal;
+ copy.transaction = transaction;
+ copy.transactionContext = transactionContext;
+ copy.txHasMods = txHasMods;
+ }
+
+ public void setState(InvocationContext template)
+ {
+ if (template == null)
+ {
+ throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null");
+ }
+
+ this.setGlobalTransaction(template.getGlobalTransaction());
+ this.setLocalRollbackOnly(template.isLocalRollbackOnly());
+ this.setOptionOverrides(template.getOptionOverrides());
+ this.setOriginLocal(template.isOriginLocal());
+ this.setTransaction(template.getTransaction());
+ this.setTxHasMods(template.isTxHasMods());
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final AbstractInvocationContext that = (AbstractInvocationContext) o;
+
+ if (localRollbackOnly != that.localRollbackOnly) return false;
+ if (originLocal != that.originLocal) return false;
+ if (txHasMods != that.txHasMods) return false;
+ if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+ {
+ return false;
+ }
+ if (optionOverrides != null ? !optionOverrides.equals(that.optionOverrides) : that.optionOverrides != null)
+ {
+ return false;
+ }
+ if (transaction != null ? !transaction.equals(that.transaction) : that.transaction != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (transaction != null ? transaction.hashCode() : 0);
+ result = 29 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+ result = 29 * result + (optionOverrides != null ? optionOverrides.hashCode() : 0);
+ result = 29 * result + (originLocal ? 1 : 0);
+ result = 29 * result + (txHasMods ? 1 : 0);
+ result = 29 * result + (localRollbackOnly ? 1 : 0);
+ return result;
+ }
+
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public MethodCall getMethodCall()
+ {
+ if (methodCall == null)
+ {
+ methodCall = createMethodCall();
+ }
+ return methodCall;
+ }
+
+ @SuppressWarnings("deprecation")
+ private MethodCall createMethodCall()
+ {
+ if (command == null) return null;
+ MethodCall call = new MethodCall();
+ call.setMethodId(command.getCommandId());
+ call.setArgs(command.getParameters());
+ return call;
+ }
+
+ @Deprecated
+ public void setMethodCall(MethodCall methodCall)
+ {
+ this.methodCall = methodCall;
+ }
+
+ public long getLockAcquisitionTimeout(long timeout)
+ {
+ if (getOptionOverrides() != null
+ && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
+ {
+ timeout = getOptionOverrides().getLockAcquisitionTimeout();
+ }
+ return timeout;
+ }
+
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public void setCommand(VisitableCommand cacheCommand)
+ {
+ this.command = cacheCommand;
+ }
+
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public VisitableCommand getCommand()
+ {
+ return command;
+ }
+
+ public boolean isValidTransaction()
+ {
+ return transaction != null && TransactionTable.isValid(transaction);
+ }
+
+ public void throwIfNeeded(Throwable e) throws Throwable
+ {
+ Option optionOverride = getOptionOverrides();
+ boolean shouldRethtrow = optionOverride == null || !optionOverride.isFailSilently();
+ if (!shouldRethtrow)
+ {
+ if (trace)
+ log.trace("There was a problem handling this request, but failSilently was set, so suppressing exception", e);
+ return;
+ }
+ throw e;
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -11,13 +11,10 @@
* The JBoss Cache hand-wired interceptor stack. A "minimal" AOP framework which uses delegation through an
* interceptor chain rather than any bytecode manipulation.
* <p/>
- * This class provides some generic behaviour such as the construction of an {@link org.jboss.cache.InvocationContext}
- * which is passed up the interceptor chain.
- * <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @see org.jboss.cache.interceptors.base.CommandInterceptor
- * @see org.jboss.cache.InvocationContext
+ * @see InvocationContext
* @since 2.1.0
*/
public abstract class AbstractInvocationDelegate
Added: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,319 @@
+package org.jboss.cache.invocation;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.Transaction;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A context that holds information regarding the scope of a single invocation. May delegate some calls to a {@link org.jboss.cache.transaction.TransactionContext}
+ * if one is in scope.
+ * <p/>
+ * Note that prior to 3.0.0, InvocationContext was a concrete class and not an interface.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see org.jboss.cache.transaction.TransactionContext
+ */
+@SuppressWarnings("deprecation")
+public interface InvocationContext
+{
+ /**
+ * Retrieves a node from the registry of looked up nodes in the current scope.
+ *
+ * @param fqn fqn to look up
+ * @return a node, or null if it cannot be found.
+ * @since 3.0.
+ */
+ NodeSPI lookUpNode(Fqn fqn);
+
+ /**
+ * Puts an entry in the registry of looked up nodes in the current scope.
+ *
+ * @param f fqn to add
+ * @param n node to add
+ * @since 3.0.
+ */
+ void putLookedUpNode(Fqn f, NodeSPI n);
+
+ /**
+ * Clears the registry of looked up nodes.
+ *
+ * @since 3.0.
+ */
+ void clearLookedUpNodes();
+
+ /**
+ * Retrieves a map of nodes looked up within the current invocation's scope.
+ *
+ * @return a map of looked up nodes.
+ * @since 3.0
+ */
+ Map<Fqn, NodeSPI> getLookedUpNodes();
+
+ /**
+ * Marks teh context as only rolling back.
+ *
+ * @param localRollbackOnly if true, the context is only rolling back.
+ */
+ void setLocalRollbackOnly(boolean localRollbackOnly);
+
+ /**
+ * Retrieves the transaction associated with this invocation
+ *
+ * @return The transaction associated with this invocation
+ */
+ Transaction getTransaction();
+
+ /**
+ * Sets a transaction object on the invocation context.
+ *
+ * @param transaction transaction to set
+ */
+ void setTransaction(Transaction transaction);
+
+ /**
+ * @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
+ * @since 2.2.0
+ */
+ TransactionContext getTransactionContext();
+
+ /**
+ * Sets the transaction context to be associated with the current thread.
+ *
+ * @param transactionContext transaction context to set
+ * @since 2.2.0
+ */
+ void setTransactionContext(TransactionContext transactionContext);
+
+ /**
+ * Retrieves the global transaction associated with this invocation
+ *
+ * @return the global transaction associated with this invocation
+ */
+ GlobalTransaction getGlobalTransaction();
+
+ /**
+ * Sets the global transaction associated with this invocation
+ *
+ * @param globalTransaction global transaction to set
+ */
+ void setGlobalTransaction(GlobalTransaction globalTransaction);
+
+ /**
+ * Retrieves the option overrides associated with this invocation
+ *
+ * @return the option overrides associated with this invocation
+ */
+ Option getOptionOverrides();
+
+ /**
+ * @return true of no options have been set on this context, false otherwise.
+ */
+ boolean isOptionsUninitialised();
+
+ /**
+ * Sets the option overrides to be associated with this invocation
+ *
+ * @param optionOverrides options to set
+ */
+ void setOptionOverrides(Option optionOverrides);
+
+ /**
+ * Tests if this invocation originated locally or from a remote cache.
+ *
+ * @return true if the invocation originated locally.
+ */
+ boolean isOriginLocal();
+
+ /**
+ * Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should retrieve these locks from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Retrieving locks from this method should always ensure they are retrieved from the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
+ *
+ * @return locks held in current scope.
+ */
+ @SuppressWarnings("unchecked")
+ List getLocks();
+
+ /**
+ * Adds a List of locks to the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should record locks on the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Adding locks using this method should always ensure they are applied to the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
+ *
+ * @param locks locks to add
+ */
+ @SuppressWarnings("unchecked")
+ void addAllLocks(List locks);
+
+ /**
+ * Adds a lock to the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should record this lock on the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure that the appropriate scope is used.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ *
+ * @param lock lock to add
+ */
+ @SuppressWarnings("unchecked")
+ void addLock(Object lock);
+
+ /**
+ * Removes a lock from the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should remove this lock from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure that the lock is removed from the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ *
+ * @param lock lock to remove
+ */
+ @SuppressWarnings("unchecked")
+ void removeLock(Object lock);
+
+ /**
+ * Clears all locks from the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should clear locks from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure locks are cleared in the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ */
+ void clearLocks();
+
+ /**
+ * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
+ */
+ boolean isLockingSuppressed();
+
+ /**
+ * If set to true, the invocation is assumed to have originated locally. If set to false,
+ * assumed to have originated from a remote cache.
+ *
+ * @param originLocal flag to set
+ */
+ void setOriginLocal(boolean originLocal);
+
+ /**
+ * @return true if the current transaction has any modifications, false otherwise.
+ */
+ boolean isTxHasMods();
+
+ /**
+ * Sets whether modifications have been detected on the current transaction.
+ *
+ * @param b flag to set
+ */
+ void setTxHasMods(boolean b);
+
+ /**
+ * @return true if the current transaction is set to rollback only.
+ */
+ boolean isLocalRollbackOnly();
+
+ /**
+ * Resets the context, freeing up any references.
+ */
+ void reset();
+
+ /**
+ * This is a "copy-factory-method" that should be used whenever a clone of this class is needed. The resulting instance
+ * is equal() to, but not ==, to the InvocationContext invoked on. Note that this is a shallow copy with the exception
+ * of the Option object, which is deep, as well as any collections held on the context such as locks. Note that the reference
+ * to a {@link org.jboss.cache.transaction.TransactionContext}, if any, is maintained.
+ *
+ * @return a new InvocationContext
+ */
+ @SuppressWarnings("unchecked")
+ InvocationContext copy();
+
+ /**
+ * Sets the state of the InvocationContext based on the template context passed in
+ *
+ * @param template template to copy from
+ */
+ void setState(InvocationContext template);
+
+ /**
+ * @return the method call associated with this invocation
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ MethodCall getMethodCall();
+
+
+ /**
+ * Sets the method call associated with this invocation.
+ *
+ * @param methodCall methodcall to set
+ * @deprecated not used anymore. Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
+ */
+ @Deprecated
+ void setMethodCall(MethodCall methodCall);
+
+ /**
+ * If the lock acquisition timeout is overridden for current call using an option, then return that one.
+ * If not overridden, return default value.
+ *
+ * @param defaultTimeout timeout to fall back to
+ * @return timeout to use
+ */
+ long getLockAcquisitionTimeout(long defaultTimeout);
+
+ /**
+ * This is only used for backward compatibility with old interceptors implementation and should <b>NOT</b> be
+ * use by any new custom interceptors. The commands is now passed in as the second param in each implementing
+ * handlers (handler = method in ChainedInterceptor class)
+ *
+ * @param cacheCommand command to set
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ void setCommand(VisitableCommand cacheCommand);
+
+ /**
+ * @return command that is in scope
+ * @see #setCommand(org.jboss.cache.commands.VisitableCommand)
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ VisitableCommand getCommand();
+
+ /**
+ * @return true if there is current transaction associated with the invocation, and this transaction is in a valid state.
+ */
+ boolean isValidTransaction();
+
+ /**
+ * Throws the given throwable provided no options suppress or prevent this from happening.
+ *
+ * @param throwable throwable to throw
+ * @throws Throwable if allowed to throw one.
+ */
+ void throwIfNeeded(Throwable throwable
+ ) throws Throwable;
+}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,8 @@
package org.jboss.cache.invocation;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.cache.factories.context.ContextFactory;
/**
* Container and factory for thread locals
@@ -12,10 +13,18 @@
@NonVolatile
public class InvocationContextContainer extends ThreadLocal<InvocationContext>
{
+ ContextFactory contextFactory;
+
+ @Inject
+ public void injectContextFactory(ContextFactory contextFactory)
+ {
+ this.contextFactory = contextFactory;
+ }
+
@Override
protected InvocationContext initialValue()
{
// create if this is initially unset
- return new InvocationContext();
+ return contextFactory.createInvocationContext();
}
}
Added: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,51 @@
+package org.jboss.cache.invocation;
+
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+
+import java.util.Map;
+
+/**
+ * This is to provide backward compatibility with legacy locking schemes.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class LegacyInvocationContext extends AbstractInvocationContext
+{
+ DataContainer container;
+
+ public LegacyInvocationContext(DataContainer container)
+ {
+ this.container = container;
+ }
+
+ public NodeSPI lookUpNode(Fqn fqn)
+ {
+ return container.peek(fqn);
+ }
+
+ public void putLookedUpNode(Fqn f, NodeSPI n)
+ {
+ throw new UnsupportedOperationException("Should not be called on legacy locking schemes!");
+ }
+
+ public void clearLookedUpNodes()
+ {
+ throw new UnsupportedOperationException("Should not be called on legacy locking schemes!");
+ }
+
+ public Map<Fqn, NodeSPI> getLookedUpNodes()
+ {
+ throw new UnsupportedOperationException("Should not be called on legacy locking schemes!");
+ }
+
+ @SuppressWarnings("unchecked")
+ public InvocationContext copy()
+ {
+ LegacyInvocationContext copy = new LegacyInvocationContext(container);
+ doCopy(copy);
+ return copy;
+ }
+}
Added: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,103 @@
+package org.jboss.cache.invocation;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.transaction.MVCCTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * An invocation context that is specific to MVCC locking
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MVCCInvocationContext extends AbstractInvocationContext
+{
+ private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
+ private MVCCTransactionContext mvccTCtx;
+
+ @Override
+ public void setTransactionContext(TransactionContext transactionContext)
+ {
+ super.setTransactionContext(transactionContext);
+ mvccTCtx = (MVCCTransactionContext) transactionContext;
+ }
+
+ /**
+ * Retrieves a node from the registry of looked up nodes in the current scope.
+ * <p/>
+ * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#lookUpNode(Fqn)}
+ * <p/>
+ *
+ * @param fqn fqn to look up
+ * @return a node, or null if it cannot be found.
+ */
+ public NodeSPI lookUpNode(Fqn fqn)
+ {
+ if (mvccTCtx != null) return mvccTCtx.lookUpNode(fqn);
+ return lookedUpNodes.get(fqn);
+ }
+
+ /**
+ * Puts an entry in the registry of looked up nodes in the current scope.
+ * <p/>
+ * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#putLookedUpNode(Fqn, NodeSPI)}
+ * <p/>
+ *
+ * @param f fqn to add
+ * @param n node to add
+ */
+ public void putLookedUpNode(Fqn f, NodeSPI n)
+ {
+ if (mvccTCtx != null)
+ mvccTCtx.putLookedUpNode(f, n);
+ else
+ lookedUpNodes.put(f, n);
+ }
+
+ /**
+ * Clears the registry of looked up nodes.
+ * <p/>
+ * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#clearLookedUpNodes()}.
+ */
+ public void clearLookedUpNodes()
+ {
+ if (mvccTCtx != null)
+ mvccTCtx.clearLookedUpNodes();
+ else
+ lookedUpNodes.clear();
+ }
+
+ /**
+ * Retrieves a map of nodes looked up within the current invocation's scope.
+ * <p/>
+ * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#getLookedUpNodes()}.
+ * <p/>
+ *
+ * @return a map of looked up nodes.
+ */
+ public Map<Fqn, NodeSPI> getLookedUpNodes()
+ {
+ if (mvccTCtx != null) return mvccTCtx.getLookedUpNodes();
+ return lookedUpNodes;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ lookedUpNodes.clear();
+ }
+
+ @SuppressWarnings("unchecked")
+ public InvocationContext copy()
+ {
+ MVCCInvocationContext copy = new MVCCInvocationContext();
+ doCopy(copy);
+ copy.lookedUpNodes.putAll(lookedUpNodes);
+ return copy;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.lock;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
/**
* Common lock manager functionality
Modified: core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,7 +1,7 @@
package org.jboss.cache.lock;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.lock;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
@@ -73,9 +73,9 @@
* is specified in {@link org.jboss.cache.config.Option#getLockAcquisitionTimeout()} and, if this is unset, the default timeout
* set in {@link org.jboss.cache.config.Configuration#getLockAcquisitionTimeout()} is used.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
* <p/>
*
* @param fqn Fqn to lock
@@ -91,9 +91,9 @@
* is specified in {@link org.jboss.cache.config.Option#getLockAcquisitionTimeout()} and, if this is unset, the default timeout
* set in {@link org.jboss.cache.config.Configuration#getLockAcquisitionTimeout()} is used.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
* <p/>
*
* @param node Fqn to lock
@@ -125,7 +125,7 @@
* <p/>
* Locks are released in reverse order of which they are acquired and registered.
* <p/>
- * Lock owner is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}
+ * Lock owner is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}
* <p/>
*
* @param ctx invocation context to inspect
@@ -176,9 +176,9 @@
* Locks the node and all child nodes, acquiring lock of type specified for the owner specified. If only some locks are
* acquired, all locks are released and the method returns false.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
* <p/>
*
* @param node Node to lock
@@ -192,9 +192,9 @@
* Locks the node and all child nodes, acquiring lock of type specified for the owner specified. If only some locks are
* acquired, all locks are released and the method returns false.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
* <p/>
*
* @param fqn Node to lock
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,10 +3,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.factories.CommandsFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -6,11 +6,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLock;
@@ -49,7 +49,7 @@
private CacheSPI cache;
private TransactionManager transactionManager;
private InvocationContextContainer invocationContextContainer;
- private static final int DEFAULT_CONCURRENCY = 20;
+ private static final int DEFAULT_CONCURRENCY = 100;
private static final Log log = LogFactory.getLog(MVCCLockManager.class);
private static final boolean trace = log.isTraceEnabled();
@@ -103,7 +103,7 @@
assertIsWriteLock(lockType);
if (trace) log.trace("Attempting to lock " + fqn);
Lock lock = lockContainer.getLock(fqn);
- if (lock.tryLock(ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout), MILLISECONDS))
+ if (lock.tryLock(ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout), MILLISECONDS))
{
ctx.addLock(fqn);
return true;
@@ -205,7 +205,7 @@
public boolean lockAllAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx) throws InterruptedException
{
assertIsWriteLock(lockType);
- return lockRecursively(node, ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout), false, ctx);
+ return lockRecursively(node, ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout), false, ctx);
}
public boolean lockAllAndRecord(Fqn fqn, LockType lockType, InvocationContext ctx) throws InterruptedException
Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,10 +4,10 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.Collection;
@@ -101,7 +101,7 @@
public boolean lockAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx)
{
- NodeLock lock = acquireLock(node, lockType, getLockOwner(ctx), ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout));
+ NodeLock lock = acquireLock(node, lockType, getLockOwner(ctx), ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout));
if (lock != null)
{
ctx.addLock(lock);
@@ -196,7 +196,7 @@
public boolean lockAllAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx)
{
- List<NodeLock> locks = lockAllNodes(node, lockType, getLockOwner(ctx), ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout), false);
+ List<NodeLock> locks = lockAllNodes(node, lockType, getLockOwner(ctx), ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout), false);
if (locks == null) return false;
if (locks.size() > 0)
Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,10 +3,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.InvocationContext;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
@@ -61,7 +61,7 @@
return false;
boolean created;
- long timeout = zeroLockTimeout ? 0 : ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
+ long timeout = zeroLockTimeout ? 0 : ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout);
// make sure we can bail out of this loop
long cutoffTime = System.currentTimeMillis() + timeout;
boolean firstTry = true;
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,6 +1,5 @@
package org.jboss.cache.marshall;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
@@ -8,6 +7,7 @@
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jgroups.Address;
import org.jgroups.Channel;
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,8 +1,8 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jgroups.View;
@@ -74,7 +74,7 @@
* Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
* immediately.
*/
- void notifyViewChange(View new_view, InvocationContext ctx);
+ void notifyViewChange(View view, InvocationContext ctx);
/**
* Notifies all registered listeners of a buddy group change event. Note that buddy group change notifications are ALWAYS sent
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -12,7 +12,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Destroy;
@@ -20,6 +19,7 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.MarshalledValueMap;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.*;
@@ -550,7 +550,7 @@
/**
* Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can
- * be restored later using {@link #restoreInvocationContext(org.jboss.cache.InvocationContext)}
+ * be restored later using {@link #restoreInvocationContext(org.jboss.cache.invocation.InvocationContext)}
*
* @param ctx the current context to be reset
* @return a clone of ctx, before it was reset
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -11,7 +11,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
@@ -19,6 +18,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.eviction.EvictedEventNode;
import org.jboss.cache.eviction.NodeEventType;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.NodeData;
Added: core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,89 @@
+package org.jboss.cache.transaction;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A transaction context specially geared to dealing with MVCC.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class MVCCTransactionContext extends PessimisticTransactionContext
+{
+ private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
+
+ public MVCCTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ super(tx);
+ }
+
+ /**
+ * Retrieves a node from the registry of looked up nodes in the current scope.
+ * <p/>
+ * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#lookUpNode(org.jboss.cache.Fqn)}
+ * would delegate to this method if a transaction is in scope.
+ * <p/>
+ *
+ * @param fqn fqn to look up
+ * @return a node, or null if it cannot be found.
+ */
+ public NodeSPI lookUpNode(Fqn fqn)
+ {
+ return lookedUpNodes.get(fqn);
+ }
+
+ /**
+ * Puts an entry in the registry of looked up nodes in the current scope.
+ * <p/>
+ * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSPI)}
+ * would delegate to this method if a transaction is in scope.
+ * <p/>
+ *
+ * @param f fqn to add
+ * @param n node to add
+ */
+ public void putLookedUpNode(Fqn f, NodeSPI n)
+ {
+ lookedUpNodes.put(f, n);
+ }
+
+ /**
+ * Clears the registry of looked up nodes.
+ * <p/>
+ * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#clearLookedUpNodes()}
+ * would delegate to this method if a transaction is in scope.
+ * <p/>
+ */
+ public void clearLookedUpNodes()
+ {
+ lookedUpNodes.clear();
+ }
+
+ /**
+ * Retrieves a map of nodes looked up within the current invocation's scope.
+ * <p/>
+ * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#getLookedUpNodes()}
+ * would delegate to this method if a transaction is in scope.
+ * <p/>
+ *
+ * @return a map of looked up nodes.
+ */
+ public Map<Fqn, NodeSPI> getLookedUpNodes()
+ {
+ return lookedUpNodes;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ lookedUpNodes.clear();
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -14,14 +14,14 @@
import javax.transaction.Transaction;
/**
- * Subclasses the {@link TransactionContext} class to add a {@link TransactionWorkspace}. Used with optimistic locking
+ * Subclasses the {@link PessimisticTransactionContext} class to add a {@link TransactionWorkspace}. Used with optimistic locking
* where each call is assigned a trasnaction and a transaction workspace.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
*/
-public class OptimisticTransactionContext extends TransactionContext
+public class OptimisticTransactionContext extends PessimisticTransactionContext
{
private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
Copied: core/trunk/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java (from rev 6048, core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,297 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.transaction;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Information associated with a {@link GlobalTransaction} about the transaction state.
+ * <p/>
+ * A TransactionContext maintains:
+ * <ul>
+ * <li>Handle to the local Transaction</li>
+ * <li>List of {@link org.jboss.cache.commands.ReversibleCommand}s that make up this transaction</li>
+ * <li>List of locks acquired</li>
+ * <li>Any transaction-scope options</li>
+ * </ul>
+ *
+ * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
+ * @author Manik Surtani
+ * @version $Revision$
+ */
+public class PessimisticTransactionContext implements TransactionContext
+{
+
+ private static final Log log = LogFactory.getLog(PessimisticTransactionContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ /**
+ * Local transaction
+ */
+ private Transaction ltx = null;
+ private Option option;
+ private OrderedSynchronizationHandler orderedSynchronizationHandler;
+
+ private boolean forceAsyncReplication = false;
+ private boolean forceSyncReplication = false;
+
+ /**
+ * List<ReversibleCommand> of modifications ({@link ReversibleCommand}). They will be replicated on TX commit
+ */
+ private List<ReversibleCommand> modificationList;
+ /**
+ * A list of modifications that have been encountered with a LOCAL mode option. These will be removed from the modification list during replication.
+ */
+ private List<ReversibleCommand> localModifications;
+
+ /**
+ * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
+ */
+ private LinkedHashSet transactionLocks;
+
+ /**
+ * A list of dummy uninitialised nodes created by the cache loader interceptor to load data for a
+ * given node in this tx.
+ */
+ private List<Fqn> dummyNodesCreatedByCacheLoader;
+
+ /**
+ * List<Fqn> of nodes that have been removed by the transaction
+ */
+ private List<Fqn> removedNodes = null;
+
+ public PessimisticTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ ltx = tx;
+ orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
+ }
+
+ public void addModification(ReversibleCommand command)
+ {
+ if (command == null) return;
+ if (modificationList == null) modificationList = new LinkedList<ReversibleCommand>();
+ modificationList.add(command);
+ }
+
+ public List<ReversibleCommand> getModifications()
+ {
+ if (modificationList == null) return Collections.emptyList();
+ return modificationList;
+ }
+
+ public void addLocalModification(ReversibleCommand command)
+ {
+ if (command == null) throw new NullPointerException("Command is null!");
+ if (localModifications == null) localModifications = new LinkedList<ReversibleCommand>();
+ localModifications.add(command);
+ }
+
+ public List<ReversibleCommand> getLocalModifications()
+ {
+ if (localModifications == null) return Collections.emptyList();
+ return localModifications;
+ }
+
+
+ public void addRemovedNode(Fqn fqn)
+ {
+ if (fqn == null) throw new NullPointerException("Fqn is null!");
+ if (removedNodes == null) removedNodes = new LinkedList<Fqn>();
+ removedNodes.add(fqn);
+ }
+
+ public List<Fqn> getRemovedNodes()
+ {
+ if (removedNodes == null) return Collections.emptyList();
+ return new ArrayList<Fqn>(removedNodes);
+ }
+
+ public void setTransaction(Transaction tx)
+ {
+ ltx = tx;
+ }
+
+ public Transaction getTransaction()
+ {
+ return ltx;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.add(lock);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks != null) transactionLocks.remove(lock);
+ }
+
+ public void clearLocks()
+ {
+ if (transactionLocks != null) transactionLocks.clear();
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public void addAllLocks(List newLocks)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.addAll(newLocks);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getLocks()
+ {
+ return transactionLocks == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(transactionLocks));
+ }
+
+
+ public boolean isForceAsyncReplication()
+ {
+ return forceAsyncReplication;
+ }
+
+ public void setForceAsyncReplication(boolean forceAsyncReplication)
+ {
+ this.forceAsyncReplication = forceAsyncReplication;
+ if (forceAsyncReplication)
+ {
+ forceSyncReplication = false;
+ }
+ }
+
+ public boolean isForceSyncReplication()
+ {
+ return forceSyncReplication;
+ }
+
+ public void setForceSyncReplication(boolean forceSyncReplication)
+ {
+ this.forceSyncReplication = forceSyncReplication;
+ if (forceSyncReplication)
+ {
+ forceAsyncReplication = false;
+ }
+ }
+
+
+ public void undoOperations()
+ {
+ if (modificationList == null)
+ {
+ if (trace) log.trace("Modification list is null, no modifications in this transaction!");
+ return;
+ }
+
+ if (trace) log.trace("undoOperations " + modificationList);
+
+ ArrayList<ReversibleCommand> copy;
+// synchronized (modificationList)
+// {
+ // no need to sync? Only one thread would access a transaction at any given time?
+ copy = new ArrayList<ReversibleCommand>(modificationList);
+// }
+ for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
+ {
+ Object undoOp = i.previous();
+ ReversibleCommand txCommand = (ReversibleCommand) undoOp;
+ if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
+ txCommand.rollback();
+ }
+ }
+
+ /**
+ * Returns debug information about this transaction.
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TransactionEntry\nmodificationList: ").append(modificationList);
+ return sb.toString();
+ }
+
+ public void addDummyNodeCreatedByCacheLoader(Fqn fqn)
+ {
+ if (dummyNodesCreatedByCacheLoader == null)
+ dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
+ dummyNodesCreatedByCacheLoader.add(fqn);
+ }
+
+ public List<Fqn> getDummyNodesCreatedByCacheLoader()
+ {
+ if (dummyNodesCreatedByCacheLoader == null) return Collections.emptyList();
+ return dummyNodesCreatedByCacheLoader;
+ }
+
+ public void setOption(Option o)
+ {
+ this.option = o;
+ }
+
+ public Option getOption()
+ {
+ return this.option;
+ }
+
+ public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
+ {
+ return orderedSynchronizationHandler;
+ }
+
+ public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
+ {
+ this.orderedSynchronizationHandler = orderedSynchronizationHandler;
+ }
+
+ public boolean hasModifications()
+ {
+ return modificationList != null && !modificationList.isEmpty();
+ }
+
+ public boolean hasLocalModifications()
+ {
+ return localModifications != null && !localModifications.isEmpty();
+ }
+
+ public void reset()
+ {
+ orderedSynchronizationHandler = null;
+ if (modificationList != null) modificationList = null;
+ if (localModifications != null) localModifications = null;
+ option = null;
+ if (transactionLocks != null) transactionLocks.clear();
+ if (dummyNodesCreatedByCacheLoader != null) dummyNodesCreatedByCacheLoader.clear();
+ if (removedNodes != null) removedNodes.clear();
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,502 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.transaction;
-
-
-import net.jcip.annotations.ThreadSafe;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.cache.lock.NodeLock;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * Information associated with a {@link GlobalTransaction} about the transaction state.
- * <p/>
- * A TransactionContext maintains:
- * <ul>
- * <li>Handle to the local Transaction</li>
- * <li>List of {@link org.jboss.cache.commands.ReversibleCommand}s that make up this transaction</li>
- * <li>List of locks acquired</li>
- * <li>Any transaction-scope options</li>
- * </ul>
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
- * @author Manik Surtani
- * @version $Revision$
- */
-@ThreadSafe
-public class TransactionContext
-{
-
- private static final Log log = LogFactory.getLog(TransactionContext.class);
- private static final boolean trace = log.isTraceEnabled();
-
- /**
- * Local transaction
- */
- private Transaction ltx = null;
- private Option option;
- private OrderedSynchronizationHandler orderedSynchronizationHandler;
-
- private boolean forceAsyncReplication = false;
- private boolean forceSyncReplication = false;
-
- /**
- * List<ReversibleCommand> of modifications ({@link ReversibleCommand}). They will be replicated on TX commit
- */
- private List<ReversibleCommand> modificationList;
- /**
- * A list of modifications that have been encountered with a LOCAL mode option. These will be removed from the modification list during replication.
- */
- private List<ReversibleCommand> localModifications;
-
- /**
- * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
- */
- private LinkedHashSet transactionLocks;
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
-
-
- /**
- * A list of dummy uninitialised nodes created by the cache loader interceptor to load data for a
- * given node in this tx.
- */
- private List<Fqn> dummyNodesCreatedByCacheLoader;
-
- /**
- * List<Fqn> of nodes that have been removed by the transaction
- */
- private final List<Fqn> removedNodes = new LinkedList<Fqn>();
-
- public TransactionContext(Transaction tx) throws SystemException, RollbackException
- {
- ltx = tx;
- orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
- }
-
- /**
- * Adds a modification to the modification list.
- */
- public void addModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (modificationList == null) modificationList = new LinkedList<ReversibleCommand>();
- modificationList.add(command);
- }
-
- /**
- * Returns all modifications.
- */
- public List<ReversibleCommand> getModifications()
- {
- if (modificationList == null) return Collections.emptyList();
- return modificationList;
- }
-
- /**
- * Adds a modification to the local modification list.
- */
- public void addLocalModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (localModifications == null) localModifications = new LinkedList<ReversibleCommand>();
- localModifications.add(command);
- }
-
- /**
- * Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.
- */
- public List<ReversibleCommand> getLocalModifications()
- {
- if (localModifications == null) return Collections.emptyList();
- return localModifications;
- }
-
-
- /**
- * Adds the node that has been removed.
- *
- * @param fqn
- */
- public void addRemovedNode(Fqn fqn)
- {
- removedNodes.add(fqn);
- }
-
- /**
- * Gets the list of removed nodes.
- */
- public List<Fqn> getRemovedNodes()
- {
- return new ArrayList<Fqn>(removedNodes);
- }
-
- /**
- * Sets the local transaction for this entry.
- */
- public void setTransaction(Transaction tx)
- {
- ltx = tx;
- }
-
- /**
- * Returns a local transaction associated with this TransactionEntry
- */
- public Transaction getTransaction()
- {
- return ltx;
- }
-
- /**
- * Adds a lock to the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addLock(Object)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to add
- * @see org.jboss.cache.InvocationContext#addLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.add(lock);
- }
-
- /**
- * Removes a lock from the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#removeLock(Object)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to remove
- * @see org.jboss.cache.InvocationContext#removeLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks != null) transactionLocks.remove(lock);
- }
-
- /**
- * Clears all locks from the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#clearLocks()} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @see org.jboss.cache.InvocationContext#clearLocks()
- */
- public void clearLocks()
- {
- if (transactionLocks != null) transactionLocks.clear();
- }
-
-
- /**
- * Adds a List of locks to the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addAllLocks(java.util.List)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
- *
- * @param newLocks locks to add
- * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
- */
- @SuppressWarnings("unchecked")
- public void addAllLocks(List newLocks)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.addAll(newLocks);
- }
-
- /**
- * Returns an immutable, defensive copy of the List of locks currently maintained for the transaction.
- * <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#getLocks()} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
- *
- * @return locks held in current scope.
- * @see org.jboss.cache.InvocationContext#getLocks()
- */
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- return transactionLocks == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(transactionLocks));
- }
-
-
- /**
- * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceAsyncReplication()
- {
- return forceAsyncReplication;
- }
-
- /**
- * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context. Also used by OptimisticReplicationInterceptor when dealing
- * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
- * non-transactional context (i.e. with an implicit transaction).
- *
- * @param forceAsyncReplication value of forceAsyncReplication
- */
- public void setForceAsyncReplication(boolean forceAsyncReplication)
- {
- this.forceAsyncReplication = forceAsyncReplication;
- if (forceAsyncReplication)
- {
- forceSyncReplication = false;
- }
- }
-
- /**
- * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceSyncReplication()
- {
- return forceSyncReplication;
- }
-
- /**
- * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @param forceSyncReplication value of forceSyncReplication
- */
- public void setForceSyncReplication(boolean forceSyncReplication)
- {
- this.forceSyncReplication = forceSyncReplication;
- if (forceSyncReplication)
- {
- forceAsyncReplication = false;
- }
- }
-
-
- /**
- * Posts all undo operations to the CacheImpl.
- */
- public void undoOperations()
- {
- if (modificationList == null)
- {
- if (trace) log.trace("Modification list is null, no modifications in this transaction!");
- return;
- }
-
- if (trace) log.trace("undoOperations " + modificationList);
-
- ArrayList<ReversibleCommand> copy;
-// synchronized (modificationList)
-// {
- // no need to sync? Only one thread would access a transaction at any given time?
- copy = new ArrayList<ReversibleCommand>(modificationList);
-// }
- for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
- {
- Object undoOp = i.previous();
- ReversibleCommand txCommand = (ReversibleCommand) undoOp;
- if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
- txCommand.rollback();
- }
- }
-
- /**
- * Returns debug information about this transaction.
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("TransactionEntry\nmodificationList: ").append(modificationList);
- return sb.toString();
- }
-
- public void loadUninitialisedNode(Fqn fqn)
- {
- if (dummyNodesCreatedByCacheLoader == null)
- dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
- dummyNodesCreatedByCacheLoader.add(fqn);
- }
-
- public List<Fqn> getDummyNodesCreatedByCacheLoader()
- {
- return dummyNodesCreatedByCacheLoader;
- }
-
- /**
- * Sets a transaction-scope option override
- *
- * @param o
- */
- public void setOption(Option o)
- {
- this.option = o;
- }
-
- /**
- * Retrieves a transaction scope option override
- */
- public Option getOption()
- {
- return this.option;
- }
-
- public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
- {
- return orderedSynchronizationHandler;
- }
-
- public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
- {
- this.orderedSynchronizationHandler = orderedSynchronizationHandler;
- }
-
- /**
- * Returns true if modifications were registered to either modificationList or to class loader modifications list.
- */
- public boolean hasModifications()
- {
- return modificationList != null && !modificationList.isEmpty();
- }
-
- /**
- * @return true if any modifications have been invoked with cache mode being LOCAL.
- */
- public boolean hasLocalModifications()
- {
- return localModifications != null && !localModifications.isEmpty();
- }
-
- /**
- * Retrieves a node from the registry of looked up nodes in the current scope.
- * <p/>
- * This is not normally called directly since {@link org.jboss.cache.InvocationContext#lookUpNode(org.jboss.cache.Fqn)}
- * would delegate to this method if a transaction is in scope.
- * <p/>
- *
- * @param fqn fqn to look up
- * @return a node, or null if it cannot be found.
- * @since 3.0.
- */
- public NodeSPI lookUpNode(Fqn fqn)
- {
- return lookedUpNodes.get(fqn);
- }
-
- /**
- * Puts an entry in the registry of looked up nodes in the current scope.
- * <p/>
- * This is not normally called directly since {@link org.jboss.cache.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSPI)}
- * would delegate to this method if a transaction is in scope.
- * <p/>
- *
- * @param f fqn to add
- * @param n node to add
- * @since 3.0.
- */
- public void putLookedUpNode(Fqn f, NodeSPI n)
- {
- lookedUpNodes.put(f, n);
- }
-
- /**
- * Clears the registry of looked up nodes.
- * <p/>
- * This is not normally called directly since {@link org.jboss.cache.InvocationContext#clearLookedUpNodes()}
- * would delegate to this method if a transaction is in scope.
- * <p/>
- *
- * @since 3.0.
- */
- public void clearLookedUpNodes()
- {
- lookedUpNodes.clear();
- }
-
- /**
- * Retrieves a map of nodes looked up within the current invocation's scope.
- * <p/>
- * This is not normally called directly since {@link org.jboss.cache.InvocationContext#getLookedUpNodes()}
- * would delegate to this method if a transaction is in scope.
- * <p/>
- *
- * @return a map of looked up nodes.
- * @since 3.0
- */
- public Map<Fqn, NodeSPI> getLookedUpNodes()
- {
- return lookedUpNodes;
- }
-
- /**
- * Cleans up internal state
- */
- public void reset()
- {
- orderedSynchronizationHandler = null;
- if (modificationList != null) modificationList = null;
- if (localModifications != null) localModifications = null;
- option = null;
- if (transactionLocks != null) transactionLocks.clear();
- if (dummyNodesCreatedByCacheLoader != null) dummyNodesCreatedByCacheLoader.clear();
- removedNodes.clear();
- }
-}
Added: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -0,0 +1,253 @@
+package org.jboss.cache.transaction;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+
+import javax.transaction.Transaction;
+import java.util.List;
+
+/**
+ * Captures information pertaining to a specific JTA transaction.
+ * <p/>
+ * This was a concrete class called TransactionEntry prior to 3.0.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see org.jboss.cache.invocation.InvocationContext
+ */
+public interface TransactionContext
+{
+ /**
+ * Adds a modification to the modification list.
+ *
+ * @param command modification
+ */
+ void addModification(ReversibleCommand command);
+
+ /**
+ * Returns all modifications. If there are no modifications in this transaction this method will return an empty list.
+ *
+ * @return list of modifications.
+ */
+ List<ReversibleCommand> getModifications();
+
+ /**
+ * Adds a modification to the local modification list.
+ *
+ * @param command command to add to list. Should not be null.
+ * @throws NullPointerException if the command to be added is null.
+ */
+ void addLocalModification(ReversibleCommand command);
+
+ /**
+ * Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.
+ *
+ * @return list of LOCAL modifications, or an empty list.
+ */
+ List<ReversibleCommand> getLocalModifications();
+
+ /**
+ * Adds the node that has been removed in the scope of the current transaction.
+ *
+ * @param fqn fqn that has been removed.
+ * @throws NullPointerException if the Fqn is null.
+ */
+ void addRemovedNode(Fqn fqn);
+
+ /**
+ * Gets the list of removed nodes.
+ *
+ * @return list of nodes removed in the current transaction scope. Note that this method will return an empty list if nothing has been removed. The list returned is defensively copied.
+ */
+ List<Fqn> getRemovedNodes();
+
+ /**
+ * Sets the local transaction to be associated with this transaction context.
+ *
+ * @param tx JTA transaction to associate with.
+ */
+ void setTransaction(Transaction tx);
+
+ /**
+ * Returns a local transaction associated with this context.
+ *
+ * @return a JTA transaction
+ */
+ Transaction getTransaction();
+
+ /**
+ * Adds a lock to the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+ *
+ * @param lock lock to add
+ * @see org.jboss.cache.invocation.InvocationContext#addLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ void addLock(Object lock);
+
+ /**
+ * Removes a lock from the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#removeLock(Object)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+ *
+ * @param lock lock to remove
+ * @see org.jboss.cache.invocation.InvocationContext#removeLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ void removeLock(Object lock);
+
+ /**
+ * Clears all locks from the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#clearLocks()} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
+ *
+ * @see org.jboss.cache.invocation.InvocationContext#clearLocks()
+ */
+ void clearLocks();
+
+ /**
+ * Adds a List of locks to the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#addAllLocks(java.util.List)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
+ *
+ * @param newLocks locks to add
+ * @see org.jboss.cache.invocation.InvocationContext#addAllLocks(java.util.List)
+ */
+ @SuppressWarnings("unchecked")
+ void addAllLocks(List newLocks);
+
+ /**
+ * Returns an immutable, defensive copy of the List of locks currently maintained for the transaction.
+ * <p/>
+ * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#getLocks()} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
+ *
+ * @return locks held in current scope.
+ * @see org.jboss.cache.invocation.InvocationContext#getLocks()
+ */
+ @SuppressWarnings("unchecked")
+ List getLocks();
+
+ /**
+ * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ boolean isForceAsyncReplication();
+
+ /**
+ * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context. Also used by OptimisticReplicationInterceptor when dealing
+ * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
+ * non-transactional context (i.e. with an implicit transaction).
+ *
+ * @param forceAsyncReplication value of forceAsyncReplication
+ */
+ void setForceAsyncReplication(boolean forceAsyncReplication);
+
+ /**
+ * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ boolean isForceSyncReplication();
+
+ /**
+ * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @param forceSyncReplication value of forceSyncReplication
+ */
+ void setForceSyncReplication(boolean forceSyncReplication);
+
+ /**
+ * Calls a rollback on all modifications in reverse order.
+ */
+ void undoOperations();
+
+ /**
+ * Adds an Fqn to the list of uninitialized nodes created by the cache loader.
+ *
+ * @param fqn fqn to add. Must not be null.
+ */
+ void addDummyNodeCreatedByCacheLoader(Fqn fqn);
+
+ /**
+ * @return a list of uninitialized nodes created by the cache loader, or an empty list.
+ */
+ List<Fqn> getDummyNodesCreatedByCacheLoader();
+
+ /**
+ * Sets a transaction-scope option override
+ *
+ * @param o option to set
+ */
+ void setOption(Option o);
+
+ /**
+ * Retrieves a transaction scope option override
+ *
+ * @return option
+ */
+ Option getOption();
+
+ /**
+ * @return the ordered sync handler associated with this transaction
+ */
+ OrderedSynchronizationHandler getOrderedSynchronizationHandler();
+
+ /**
+ * Associates an ordered sync handler with this transaction.
+ *
+ * @param orderedSynchronizationHandler to set
+ */
+ void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler);
+
+ /**
+ * @return true if modifications were registered to either modificationList or to class loader modifications list.
+ */
+ boolean hasModifications();
+
+ /**
+ * @return true if any modifications have been invoked with cache mode being LOCAL.
+ */
+ boolean hasLocalModifications();
+
+ /**
+ * Cleans up internal state, freeing up references.
+ */
+ void reset();
+}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -9,12 +9,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.factories.context.ContextFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
import javax.transaction.Status;
@@ -55,23 +54,16 @@
private RPCManager rpcManager;
- private boolean isOptimisticLocking;
- private Configuration configuration;
+ private ContextFactory contextFactory;
@Inject
- public void initialize(TransactionManager transactionManager, RPCManager rpcManager, Configuration configuration)
+ public void initialize(TransactionManager transactionManager, RPCManager rpcManager, ContextFactory contextFactory)
{
this.transactionManager = transactionManager;
this.rpcManager = rpcManager;
- this.configuration = configuration;
+ this.contextFactory = contextFactory;
}
- @Start
- public void start()
- {
- isOptimisticLocking = configuration.isNodeLockingOptimistic();
- }
-
/**
* Returns the number of local transactions.
*/
@@ -401,7 +393,7 @@
TransactionContext transactionContext;
try
{
- transactionContext = isOptimisticLocking ? new OptimisticTransactionContext(tx) : new TransactionContext(tx);
+ transactionContext = contextFactory.createTransactionContext(tx);
}
catch (Exception e)
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -5,7 +5,6 @@
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -336,18 +335,6 @@
assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
}
- /**
- * BES 2008/03/22. I don't know what the correct behavior should be.
- * The test checks the call succeeds, which is one possibility and is
- * what the current impl does. Can be something else, just not NPE.
- */
- public void testInvocationContext()
- {
- InvocationContext ctx = new InvocationContext();
- cache.setInvocationContext(ctx);
- assertSame(ctx, cache.getInvocationContext());
- }
-
public void testGetVersion()
{
assertEquals(version, cache.getVersion());
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -11,11 +11,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -11,11 +11,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -150,4 +150,12 @@
assertNoLocks();
}
+
+ // TODO: Test other major API methods - remove, etc.
+ // TODO: Test that writes don't block reads.
+ // TODO: Test write conflicts - with and without allowing write skew. Multiple cases involving concurrent removes, concurrent put + remove, etc.
+ // TODO: Test Replication with MVCC
+ // TODO: Test state transfer with MVCC
+ // TODO: Test Cache loading with MVCC
+ // TODO: Test spreading of Fqns among locks. Need a better algorithm?
}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,7 +3,8 @@
import static org.easymock.EasyMock.createMock;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -24,7 +25,7 @@
final public void setUp()
{
container = createMock(DataContainer.class);
- ctx = new InvocationContext();
+ ctx = new LegacyInvocationContext(container);
moreSetup();
}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,11 +1,17 @@
package org.jboss.cache.commands.read;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.createStrictControl;
+import static org.easymock.EasyMock.expect;
import org.easymock.IMocksControl;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.mock.NodeSpiMock;
import org.jgroups.stack.IpAddress;
@@ -21,7 +27,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups="unit")
+@Test(groups = "unit")
public class GravitateDataCommandTest
{
GravitateDataCommand command;
@@ -40,7 +46,7 @@
spiMock = control.createMock(CacheSPI.class);
command = new GravitateDataCommand(fqn, true, new IpAddress());
command.initialize(containerMock, spiMock, new BuddyFqnTransformer());
- ctx = new InvocationContext();
+ ctx = new LegacyInvocationContext(containerMock);
}
public void testNonexistentNode()
@@ -81,7 +87,7 @@
control.replay();
GravitateResult result = (GravitateResult) command.perform(ctx);
- assert result.getNodeData()== listReference;
+ assert result.getNodeData() == listReference;
control.verify();
}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,7 +4,8 @@
import org.easymock.IMocksControl;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
@@ -42,7 +43,7 @@
nodes = new MockNodesFixture();
globalTransaction = new GlobalTransaction();
dataVersion = new DefaultDataVersion(10);
- ctx = new InvocationContext();
+ ctx = new LegacyInvocationContext(container);
AbstractVersionedDataCommand command = moreSetUp();
command.initialize(notifier, container);
Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -4,9 +4,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,16 +1,16 @@
package org.jboss.cache.lock;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
+import org.jboss.cache.factories.context.ContextFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.transaction.DummyTransaction;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -23,6 +23,7 @@
LockManager lm;
InvocationContextContainer icc;
protected boolean fqnBasedLocking = true;
+ protected ContextFactory contextFactory;
@AfterMethod
public void tearDown()
@@ -52,7 +53,7 @@
InvocationContext ctx = icc.get();
ctx.setGlobalTransaction(new GlobalTransaction());
ctx.setTransaction(new DummyTransaction(DummyTransactionManager.getInstance()));
- ctx.setTransactionContext(new TransactionContext(ctx.getTransaction()));
+ ctx.setTransactionContext(contextFactory.createTransactionContext(ctx.getTransaction()));
// lock and record.
lm.lockAndRecord(node, WRITE, ctx);
Modified: core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,11 +1,17 @@
package org.jboss.cache.lock;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.context.MVCCContextFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.cache.lock.MVCCLockManager.LockContainer;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
@@ -23,6 +29,20 @@
mvccLockManager.injectDataContainer(null, null, tm, icc);
mvccLockManager.startLockManager();
lm = mvccLockManager;
+ contextFactory = new MVCCContextFactory();
+ icc.injectContextFactory(contextFactory);
}
+ public void testFqnHashing()
+ {
+ LockContainer lc = (LockContainer) TestingUtil.extractField(lm, "lockContainer");
+ List<Fqn> fqns = new ArrayList<Fqn>();
+ fqns.add(Fqn.ROOT);
+ fqns.add(Fqn.fromString("/1"));
+ fqns.add(Fqn.fromString("/1/2"));
+ fqns.add(Fqn.fromString("/1/2/3"));
+ fqns.add(Fqn.fromString("/a/b/c/d"));
+
+ for (Fqn f : fqns) System.out.println("Fqn: " + f + "; hash = " + lc.hashToIndex(f));
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,5 +1,6 @@
package org.jboss.cache.lock;
+import org.jboss.cache.factories.context.PessimisticContextFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -16,6 +17,9 @@
{
icc = new InvocationContextContainer();
lm = new NodeBasedLockManager();
+ PessimisticContextFactory pcf = new PessimisticContextFactory();
+ icc.injectContextFactory(pcf);
+ contextFactory = pcf;
fqnBasedLocking = false;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -3,9 +3,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -15,10 +13,12 @@
import org.jboss.cache.interceptors.MarshalledValueInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,19 +1,20 @@
package org.jboss.cache.notifications;
-import static org.easymock.EasyMock.*;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
+import static org.easymock.EasyMock.createNiceMock;
import org.jboss.cache.Cache;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.*;
import org.jgroups.View;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.transaction.Transaction;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
/**
* Tester class for {@link org.jboss.cache.notifications.NotifierImpl}.
@@ -35,7 +36,7 @@
{
cache = createNiceMock(Cache.class);
notifier = new NotifierImpl(cache);
- ctx = new InvocationContext();
+ ctx = new LegacyInvocationContext(null);
allEventsListener = new AllEventsListener();
notifier.addCacheListener(allEventsListener);
}
@@ -211,7 +212,7 @@
public void testNotifyCacheUnblocked()
{
- assert allEventsListener.cacheUnblockedEvent== null;
+ assert allEventsListener.cacheUnblockedEvent == null;
notifier.notifyCacheUnblocked(false);
assert allEventsListener.cacheUnblockedEvent != null;
assert !allEventsListener.cacheUnblockedEvent.isPre();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,14 +8,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.TxInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -294,7 +294,8 @@
final String fastThreadName = "FAST";
CommandInterceptor slowdownInterceptor = new CommandInterceptor()
{
- public Object hanldeDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ @Override
+ public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
if (Thread.currentThread().getName().equals(slowThreadName) && ctx.getMethodCall().getMethodId() == OptimisticPrepareCommand.METHOD_ID)
{
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.optimistic;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,9 +1,9 @@
package org.jboss.cache.optimistic;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -2,16 +2,16 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.OptimisticInterceptor;
import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockType;
import static org.jboss.cache.lock.LockType.READ;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.util.TestingUtil;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -8,7 +8,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -19,6 +18,7 @@
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionContext;
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -9,13 +9,13 @@
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-06-26 12:10:31 UTC (rev 6054)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-06-26 14:18:49 UTC (rev 6055)
@@ -1,29 +1,29 @@
package org.jboss.cache.util.internals;
import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Fqn;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.RegionalizedMethodCall;
-import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.blocks.RpcDispatcher;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.InputStream;
/**
* Utility class that notifies when certain commands were asynchronously replicated on secondary cache.
16 years, 6 months
JBoss Cache SVN: r6054 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-26 08:10:31 -0400 (Thu, 26 Jun 2008)
New Revision: 6054
Added:
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
core/trunk/src/test/resources/META-INF/config2.x/
core/trunk/src/test/resources/META-INF/config2.x/buddy-replication-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/cacheloader-enabled-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/eviction-enabled-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/local-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/multiplexer-enabled-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/optimistically-locked-cache-service.xml
core/trunk/src/test/resources/META-INF/config2.x/total-replication-cache-service.xml
Removed:
core/trunk/src/main/etc/META-INF/buddy-replication-cache-service.xml
core/trunk/src/main/etc/META-INF/cacheloader-enabled-cache-service.xml
core/trunk/src/main/etc/META-INF/eviction-enabled-cache-service.xml
core/trunk/src/main/etc/META-INF/local-cache-service.xml
core/trunk/src/main/etc/META-INF/multiplexer-enabled-cache-service.xml
core/trunk/src/main/etc/META-INF/optimistically-locked-cache-service.xml
core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml
Modified:
core/trunk/src/main/etc/META-INF/config2to3.xslt
core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
Log:
added an UT for xslt transformation. Also fixed some bugs in xslt file and new parser
Deleted: core/trunk/src/main/etc/META-INF/buddy-replication-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/buddy-replication-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/buddy-replication-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample TreeCache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
-
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=testTreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">REPL_SYNC</attribute>
-
- <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
- cluster in order to find each other.
- -->
- <attribute name="ClusterName">JBossCache-Cluster</attribute>
-
- <!--Uncomment next three statements to enable JGroups multiplexer.
-This configuration is dependent on the JGroups multiplexer being
-registered in an MBean server such as JBossAS. -->
- <!--
- <depends>jgroups.mux:name=Multiplexer</depends>
- <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
- <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
- -->
-
- <!-- JGroups protocol stack properties.
- ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
- -->
- <attribute name="ClusterConfig">
- <config>
- <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"/>
-
- <!--<PING timeout="2000" num_initial_members="3"/>-->
- <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"/>
- <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
- <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.STATE_TRANSFER/> -->
- <pbcast.FLUSH timeout="0"/>
- </config>
- </attribute>
-
-
-
- <!--
- The max amount of time (in milliseconds) we wait until the
- state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <attribute name="StateRetrievalTimeout">20000</attribute>
-
- <!--
- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <attribute name="SyncReplTimeout">15000</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">10000</attribute>
-
-
- <!-- Buddy Replication config -->
- <attribute name="BuddyReplicationConfig">
- <config>
- <buddyReplicationEnabled>true</buddyReplicationEnabled>
- <!-- these are the default values anyway -->
- <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
- <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
- each node will *try* to select a buddy on a different physical host. If not able to do so though,
- it will fall back to colocated nodes. -->
- <buddyLocatorProperties>
- numBuddies = 1
- ignoreColocatedBuddies = true
- </buddyLocatorProperties>
-
- <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
- the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
- backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
- or power supply for added fault tolerance. -->
- <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
- <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
- from groups -->
- <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
-
- <!-- the following three elements, all relating to data gravitation, default to false -->
- <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
-If false, data will only be gravitated if an Option is set enabling it -->
- <autoDataGravitation>false</autoDataGravitation>
- <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
- <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
- <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
- answer data gravitation requests. -->
- <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
-
- </config>
- </attribute>
- </mbean>
-
-
-</server>
Deleted: core/trunk/src/main/etc/META-INF/cacheloader-enabled-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/cacheloader-enabled-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/cacheloader-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample TreeCache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=TreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- -->
- <attribute name="CacheMode">LOCAL</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
- <!-- Specific eviction policy configurations. This is LRU -->
- <attribute name="EvictionPolicyConfig">
- <config>
- <attribute name="wakeUpIntervalSeconds">5</attribute>
- <!-- This defaults to 200000 if not specified -->
- <attribute name="eventQueueSize">200000</attribute>
- <!-- Name of the DEFAULT eviction policy class. -->
- <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
-
-
- <!-- Cache wide default -->
- <region name="/_default_">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">3</attribute>
- </region>
- <region name="/org/jboss/test/data">
- <attribute name="maxNodes">100</attribute>
- <attribute name="timeToLiveSeconds">3</attribute>
- </region>
- </config>
- </attribute>
-
- <!-- Cache Passivation for Tree Cache
- On pasivation, The objects are written to the backend store on eviction if CacheLoaderPassivation
- is true, otheriwse the objects are persisted.
- On activation, the objects are restored in the memory cache and removed from the cache loader
- if CacheLoaderPassivation is true, otherwise the objects are only loaded from the cache loader -->
- <attribute name="CacheLoaderConfiguration">
- <config>
- <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
- <passivation>false</passivation>
- <preload>/</preload>
- <shared>false</shared>
-
- <!-- we can now have multiple cache loaders, which get chained -->
- <cacheloader>
- <class>org.jboss.cache.loader.JDBCCacheLoader</class>
- <!-- same as the old CacheLoaderConfig attribute -->
- <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.driver=com.mysql.jdbc.Driver
- cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
- cache.jdbc.user=root
- cache.jdbc.password=
- cache.jdbc.sql-concat=concat(1,2)
- </properties>
- <!-- whether the cache loader writes are asynchronous -->
- <async>false</async>
- <!-- only one cache loader in the chain may set fetchPersistentState to true.
- An exception is thrown if more than one cache loader sets this to true. -->
- <fetchPersistentState>true</fetchPersistentState>
- <!-- determines whether this cache loader ignores writes - defaults to false. -->
- <ignoreModifications>false</ignoreModifications>
- <!-- if set to true, purges the contents of this cache loader when the cache starts up.
- Defaults to false. -->
- <purgeOnStartup>false</purgeOnStartup>
- </cacheloader>
- </config>
- </attribute>
-
- </mbean>
-
-
-</server>
Modified: core/trunk/src/main/etc/META-INF/config2to3.xslt
===================================================================
--- core/trunk/src/main/etc/META-INF/config2to3.xslt 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/config2to3.xslt 2008-06-26 12:10:31 UTC (rev 6054)
@@ -36,6 +36,11 @@
<xsl:value-of select="normalize-space(//attribute[@name='LockParentForChildInsertRemove'])"/>
</xsl:attribute>
</xsl:if>
+ <xsl:if test="//attribute[@name='NodeLockingScheme']">
+ <xsl:attribute name="optimistic">
+ <xsl:value-of select="normalize-space(//attribute[@name='NodeLockingScheme'])"/>
+ </xsl:attribute>
+ </xsl:if>
</xsl:element>
</xsl:if>
</xsl:template>
@@ -257,8 +262,8 @@
<xsl:template match="//attribute[@name='EvictionPolicyConfig']">
<eviction>
<xsl:if test="./config/attribute[@name='wakeUpIntervalSeconds']">
- <xsl:attribute name="wakeUpIntervalSeconds">
- <xsl:value-of select="normalize-space(./config/attribute[@name='wakeUpIntervalSeconds'])"/>
+ <xsl:attribute name="wakeUpInterval">
+ <xsl:value-of select="concat(normalize-space(./config/attribute[@name='wakeUpIntervalSeconds']), '000')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="./config/attribute[@name='policyClass'] | ./config/attribute[@name='policyClass']">
Deleted: core/trunk/src/main/etc/META-INF/eviction-enabled-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/eviction-enabled-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/eviction-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,233 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!--
-Sample JBoss Cache Service Configuration that hightlights various
-eviction configurations. By default LRUPolicy is enabled, by this can be
-changed by commenting it out and uncommenting another present
-eviction policy.
--->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <!-- ==================================================================== -->
- <!-- Defines JBoss Cache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=Cache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">LOCAL</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
- <!-- Specific eviction policy configurations. This is LRU -->
- <attribute name="EvictionPolicyConfig">
- <config>
- <attribute name="wakeUpIntervalSeconds">5</attribute>
- <!-- This defaults to 200000 if not specified -->
- <attribute name="eventQueueSize">200000</attribute>
- <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
-
- <!-- Cache wide default -->
- <region name="/_default_">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
- </region>
- <region name="/org/jboss/data">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
- </region>
- <region name="/org/jboss/test/data">
- <attribute name="maxNodes">5</attribute>
- <attribute name="timeToLiveSeconds">4</attribute>
- </region>
- <region name="/test">
- <attribute name="maxNodes">10000</attribute>
- <attribute name="timeToLiveSeconds">4</attribute>
- </region>
- <region name="/maxAgeTest">
- <attribute name="maxNodes">10000</attribute>
- <attribute name="timeToLiveSeconds">8</attribute>
- <attribute name="maxAgeSeconds">10</attribute>
- </region>
- </config>
- </attribute>
-
-
- <!--ElementSizePolicy eviction config-->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
- <!-- Name of the DEFAULT eviction policy class. -->
- <!--<attribute name="policyClass">org.jboss.cache.eviction.ElementSizePolicy</attribute>-->
-
- <!-- Cache wide default -->
- <!--<region name="/_default_">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--<attribute name="maxElementsPerNode">100</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/data">-->
- <!--<attribute name="maxNodes">10</attribute>-->
- <!--<attribute name="maxElementsPerNode">20</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/test/data">-->
- <!--<attribute name="maxElementsPerNode">5</attribute>-->
- <!--</region>-->
- <!--<region name="/test/">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--<attribute name="maxElementsPerNode">1</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- <!-- ExpirationPolicy eviction policy configurations. -->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!-- One second is a good default -->
- <!--<attribute name="wakeUpIntervalSeconds">1</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
- <!-- Name of the DEFAULT eviction policy class. -->
- <!--<attribute name="policyClass">org.jboss.cache.eviction.ExpirationPolicy</attribute>-->
-
- <!-- Cache wide default -->
- <!--<region name="/_default_">-->
- <!--</region>-->
- <!--<region name="/org/jboss/data">-->
- <!-- Removes the soonest to expire nodes to reduce the region size to at most 250 nodes -->
- <!--<attribute name="maxNodes">250</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- <!-- Specific eviction policy configurations. This is FIFOPolicy -->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
- <!-- Name of the DEFAULT eviction policy class. -->
- <!--<attribute name="policyClass">org.jboss.cache.eviction.FIFOPolicy</attribute>-->
-
- <!-- Cache wide default -->
- <!--<region name="/_default_">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/data">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/test/data">-->
- <!--<attribute name="maxNodes">5</attribute>-->
- <!--</region>-->
- <!--<region name="/test/">-->
- <!--<attribute name="maxNodes">10000</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- <!-- Specific eviction policy configurations. This is LFUPolicy -->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
-
- <!-- Cache wide default -->
- <!--<region name="/_default_" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--<attribute name="minNodes">10</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--<attribute name="minNodes">4000</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/test/data" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
- <!--<attribute name="minNodes">5</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- <!-- Specific eviction policy configurations. This is MRUPolicy -->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
- <!-- Name of the DEFAULT eviction policy class. -->
- <!--<attribute name="policyClass">org.jboss.cache.eviction.MRUPolicy</attribute>-->
-
-
- <!-- Cache wide default -->
- <!--<region name="/_default_">-->
- <!--<attribute name="maxNodes">100</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/data">-->
- <!--<attribute name="maxNodes">250</attribute>-->
- <!--</region>-->
- <!--<region name="/org/jboss/test/data">-->
- <!--<attribute name="maxNodes">6</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- <!-- Specific eviction policy configurations. This is LRU -->
- <!--<attribute name="EvictionPolicyConfig">-->
- <!--<config>-->
- <!--<attribute name="wakeUpIntervalSeconds">1</attribute>-->
- <!-- This defaults to 200000 if not specified -->
- <!--<attribute name="eventQueueSize">200000</attribute>-->
- <!--<attribute name="policyClass">org.jboss.cache.eviction.NullEvictionPolicy</attribute>-->
-
- <!-- Cache wide default -->
- <!--<region name="/_default_">-->
- <!--<attribute name="maxNodes">5000</attribute>-->
- <!--<attribute name="timeToLiveSeconds">1</attribute>-->
- <!--</region>-->
- <!--<region name="/test" policyClass="org.jboss.cache.eviction.NullEvictionPolicy">-->
- <!--<attribute name="maxNodes">10000</attribute>-->
- <!--<attribute name="timeToLiveSeconds">1</attribute>-->
- <!--</region>-->
- <!--<region name="/lru" policyClass="org.jboss.cache.eviction.LRUPolicy">-->
- <!--<attribute name="maxNodes">10000</attribute>-->
- <!--<attribute name="timeToLiveSeconds">1</attribute>-->
- <!--</region>-->
- <!--</config>-->
- <!--</attribute>-->
-
- </mbean>
-
-
-</server>
Deleted: core/trunk/src/main/etc/META-INF/local-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/local-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/local-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample TreeCache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=TreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
-
- <!-- Configure the TransactionManager -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">LOCAL</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
- </mbean>
-</server>
Deleted: core/trunk/src/main/etc/META-INF/multiplexer-enabled-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/multiplexer-enabled-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/multiplexer-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample TreeCache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
-
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=testTreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">REPL_SYNC</attribute>
-
- <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
- cluster in order to find each other.
- -->
- <attribute name="ClusterName">JBossCache-Cluster</attribute>
-
- <depends>jgroups.mux:name=Multiplexer</depends>
- <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
-
- <!-- JGroups protocol stack properties.
- ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
- -->
- <attribute name="ClusterConfig">
- <config>
- <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"/>
-
- <!--<PING timeout="2000" num_initial_members="3"/>-->
- <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"/>
- <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
- <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.STATE_TRANSFER/> -->
- <pbcast.FLUSH timeout="0"/>
- </config>
- </attribute>
-
-
-
- <!--
- The max amount of time (in milliseconds) we wait until the
- state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <attribute name="StateRetrievalTimeout">20000</attribute>
-
- <!--
- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <attribute name="SyncReplTimeout">15000</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">10000</attribute>
-
-
- <!-- Buddy Replication config -->
- <attribute name="BuddyReplicationConfig">
- <config>
- <buddyReplicationEnabled>true</buddyReplicationEnabled>
- <!-- these are the default values anyway -->
- <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
- <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
- each node will *try* to select a buddy on a different physical host. If not able to do so though,
- it will fall back to colocated nodes. -->
- <buddyLocatorProperties>
- numBuddies = 1
- ignoreColocatedBuddies = true
- </buddyLocatorProperties>
-
- <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
- the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
- backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
- or power supply for added fault tolerance. -->
- <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
- <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
- from groups -->
- <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
-
- <!-- the following three elements, all relating to data gravitation, default to false -->
- <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
-If false, data will only be gravitated if an Option is set enabling it -->
- <autoDataGravitation>false</autoDataGravitation>
- <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
- <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
- <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
- answer data gravitation requests. -->
- <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
-
- </config>
- </attribute>
- </mbean>
-
-
-</server>
Deleted: core/trunk/src/main/etc/META-INF/optimistically-locked-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/optimistically-locked-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/optimistically-locked-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample TreeCache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=TreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
- <attribute name="FetchInMemoryState">false</attribute>
-
- <!-- Whether each interceptor should have an mbean
-registered to capture and display its statistics. -->
- <attribute name="UseInterceptorMbeans">true</attribute>
-
- <!--
- Node locking scheme:
- OPTIMISTIC
- PESSIMISTIC (default)
- -->
- <attribute name="NodeLockingScheme">Optimistic</attribute>
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">READ_COMMITTED</attribute>
-
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- -->
- <attribute name="CacheMode">LOCAL</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">10000</attribute>
-
- <attribute name="EvictionPolicyConfig">
- <config>
- <attribute name="wakeUpIntervalSeconds">1</attribute>
- <!-- Name of the DEFAULT eviction policy class.-->
- <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
-
- <region name="/_default_">
- <attribute name="maxNodes">10</attribute>
- <attribute name="timeToLiveSeconds">0</attribute>
- <attribute name="maxAgeSeconds">0</attribute>
- </region>
- <region name="/testingRegion">
- <attribute name="maxNodes">10</attribute>
- <attribute name="timeToLiveSeconds">0</attribute>
- <attribute name="maxAgeSeconds">0</attribute>
- </region>
- <region name="/timeBased">
- <attribute name="maxNodes">10</attribute>
- <attribute name="timeToLiveSeconds">1</attribute>
- <attribute name="maxAgeSeconds">1</attribute>
- </region>
- </config>
- </attribute>
-
- </mbean>
-</server>
Deleted: core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample for total replication. -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<server>
-
- <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
-
-
- <!-- ==================================================================== -->
- <!-- Defines TreeCache configuration -->
- <!-- ==================================================================== -->
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
- name="jboss.cache:service=testTreeCache">
-
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
-
- <!--
- Configure the TransactionManager
- -->
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
-
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
-
- <!--
- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC
- -->
- <attribute name="CacheMode">REPL_SYNC</attribute>
-
- <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
- cluster in order to find each other.
- -->
- <attribute name="ClusterName">JBossCache-Cluster</attribute>
-
- <!--Uncomment next three statements to enable JGroups multiplexer.
- This configuration is dependent on the JGroups multiplexer being
- registered in an MBean server such as JBossAS. -->
- <!--
- <depends>jgroups.mux:name=Multiplexer</depends>
- <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
- <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
- -->
-
- <!-- JGroups protocol stack properties.
- ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
- -->
- <attribute name="ClusterConfig">
- <config>
- <UDP mcast_addr="228.10.10.10"
- mcast_port="45588"
- tos="8"
- ucast_recv_buf_size="20000000"
- ucast_send_buf_size="640000"
- mcast_recv_buf_size="25000000"
- mcast_send_buf_size="640000"
- loopback="false"
- discard_incompatible_packets="true"
- max_bundle_size="64000"
- max_bundle_timeout="30"
- use_incoming_packet_handler="true"
- ip_ttl="2"
- enable_bundling="false"
- enable_diagnostics="true"
-
- use_concurrent_stack="true"
-
- thread_naming_pattern="pl"
-
- thread_pool.enabled="true"
- thread_pool.min_threads="1"
- thread_pool.max_threads="25"
- thread_pool.keep_alive_time="30000"
- thread_pool.queue_enabled="true"
- thread_pool.queue_max_size="10"
- thread_pool.rejection_policy="Run"
-
- oob_thread_pool.enabled="true"
- oob_thread_pool.min_threads="1"
- oob_thread_pool.max_threads="4"
- oob_thread_pool.keep_alive_time="10000"
- oob_thread_pool.queue_enabled="true"
- oob_thread_pool.queue_max_size="10"
- oob_thread_pool.rejection_policy="Run"/>
-
- <PING timeout="2000" num_initial_members="2"/>
- <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"/>
- <UNICAST timeout="300,600,1200,2400,3600"/>
- <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
- max_bytes="400000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
- view_bundling="true" view_ack_collection_timeout="5000"/>
- <FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
- <!-- <pbcast.STATE_TRANSFER/> -->
- <pbcast.FLUSH timeout="0"/>
- </config>
- </attribute>
-
- <!--
- Whether or not to fetch state on joining a cluster
- NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
- -->
- <attribute name="FetchInMemoryState">true</attribute>
-
-
- <!--
- The max amount of time (in milliseconds) we wait until the
- state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <attribute name="StateRetrievalTimeout">20000</attribute>
-
- <!--
- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <attribute name="SyncReplTimeout">15000</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">10000</attribute>
-
-
- </mbean>
-</server>
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-06-26 12:10:31 UTC (rev 6054)
@@ -1,16 +1,19 @@
package org.jboss.cache.config.parsing;
import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.File;
+import java.io.*;
+import java.net.URL;
/**
* Class used for converting a config file from from 2.x version to 3.x verison.
@@ -20,9 +23,70 @@
*/
public class ConfigFilesConvertor
{
- static Document document;
-
+ public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception
+ {
+ InputStream xsltInStream = getFileAsStream(xsltFile);
+
+ Document document = getInputDocument(is);
+
+ // Use a Transformer for output
+ Transformer transformer = getTransformer(xsltInStream);
+
+ DOMSource source = new DOMSource(document);
+ StreamResult result = new StreamResult(os);
+ transformer.transform(source, result);
+ xsltInStream.close();
+ }
+
+ public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception
+ {
+ InputStream stream = getFileAsStream(inputFile);
+ try
+ {
+ parse(stream, os, xsltFile);
+ } finally {
+ stream.close();
+ }
+ }
+
+ private Transformer getTransformer(InputStream xsltInStream)
+ throws TransformerConfigurationException
+ {
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ StreamSource stylesource = new StreamSource(xsltInStream);
+ return tFactory.newTransformer(stylesource);
+ }
+
+ private Document getInputDocument(InputStream is)
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse(is);
+ }
+
+ private InputStream getFileAsStream(String fileName) throws Exception
+ {
+ File xsltConvertorFile = new File(fileName);
+ if (!xsltConvertorFile.exists())
+ {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ URL resource = ccl.getResource(fileName);
+ if (resource == null)
+ {
+ resource = getClass().getClassLoader().getResource(fileName);
+ if (resource == null)
+ throw new IllegalArgumentException("File " + fileName + " does not exist on disk or on class path");
+ }
+ return ccl.getResourceAsStream(fileName);
+ }
+ else
+ {
+ return new FileInputStream(xsltConvertorFile);
+ }
+ }
+
public static void main(String[] argv) throws Exception
{
if (argv.length != 2)
@@ -30,24 +94,10 @@
System.err.println("Usage: java Stylizer stylesheet xmlfile");
System.exit(1);
}
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
- //factory.setNamespaceAware(true);
- //factory.setValidating(true);
- File stylesheet = new File(argv[0]);
File datafile = new File(argv[1]);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- document = builder.parse(datafile);
-
- // Use a Transformer for output
- TransformerFactory tFactory = TransformerFactory.newInstance();
- StreamSource stylesource = new StreamSource(stylesheet);
- Transformer transformer = tFactory.newTransformer(stylesource);
-
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(System.out);
- transformer.transform(source, result);
+ ConfigFilesConvertor convertor = new ConfigFilesConvertor();
+ FileInputStream is = new FileInputStream(datafile);
+ convertor.parse(is, System.out, argv[0]);
+ is.close();
}
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-06-26 12:10:31 UTC (rev 6054)
@@ -182,6 +182,7 @@
private void configureTransport(Element element)
{
+ if (element == null) return; //transport might be missing
String clusterName = element.getAttribute("clusterName");
config.setClusterName(clusterName);
String multiplexerStack = element.getAttribute("multiplexerStack");
@@ -199,11 +200,11 @@
{
if (element == null) return; //we might not have this configured
String fetchInMemoryState = element.getAttribute("fetchInMemoryState");
- if (fetchInMemoryState != null) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
+ if (existsAttribute(fetchInMemoryState)) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
String stateRetrievalTimeout = element.getAttribute("stateRetrievalTimeout");
- if (stateRetrievalTimeout != null) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
+ if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
String inactiveOnStartup = element.getAttribute("inactiveOnStartup");
- if (inactiveOnStartup != null) config.setInactiveOnStartup(getBoolean(inactiveOnStartup));
+ if (existsAttribute(inactiveOnStartup)) config.setInactiveOnStartup(getBoolean(inactiveOnStartup));
}
private void configureInvalidation(Element element)
@@ -260,12 +261,13 @@
private void configureLocking(Element locking)
{
String isolationLevel = locking.getAttribute("isolationLevel");
- if (isolationLevel != null) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
+ if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
String lockParentForChildInsertRemove = locking.getAttribute("lockParentForChildInsertRemove");
- if (lockParentForChildInsertRemove != null)
- config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
+ if (existsAttribute(lockParentForChildInsertRemove)) config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
String lockAcquisitionTimeout = locking.getAttribute("lockAcquisitionTimeout");
- if (lockAcquisitionTimeout != null) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
+ if (existsAttribute(lockAcquisitionTimeout)) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
+ String optimistic = locking.getAttribute("optimistic");
+ if (existsAttribute(optimistic)) config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
}
private Element getSingleElement(String elementName)
Added: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,88 @@
+package org.jboss.cache.config;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.jboss.cache.config.parsing.ConfigFilesConvertor;
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
+
+import java.io.File;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Test how xsl for migrating config files from 2.x to 3.x works.
+ * For each existing config file in 2.x it does the following:
+ * <ol>
+ * <li> it transforms it into an 3.x file using the xslt transformer
+ * <li> it parses the file with 2.x parser
+ * <li> it parses the transform with a 3.x parser
+ * <li> checks that the two resulting <tt>Configuration</tt> objects are equal.
+ * </ol>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "functional")
+public class ConfigurationTransformerTest
+{
+ //TODO - make this reference relative
+ public static final String XSLT_FILE = "C:\\projects\\cache\\branches\\za_trunk\\src\\main\\etc\\META-INF\\config2to3.xslt";
+ private static final String BASE_DIR = "META-INF/config2.x";
+ File xsltFile;
+ ConfigFilesConvertor convertor = new ConfigFilesConvertor();
+
+ @BeforeMethod
+ public void setUp()
+ {
+ xsltFile = new File(XSLT_FILE);
+ assert xsltFile.exists();
+ }
+
+ /**
+ * Useful when {@link testEqualityOnTransformedFiles} fails and you need to isolate a failure.
+ */
+ public void testSingleFile() throws Exception
+ {
+ String fileName = getFileName("/optimistically-locked-cache-service.xml");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ convertor.parse(fileName, baos, XSLT_FILE);
+
+ XmlConfigurationParser newParser = new XmlConfigurationParser();
+ XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
+
+ Configuration newConfig = newParser.parse(new ByteArrayInputStream(baos.toByteArray()));
+ Configuration oldConfig = oldParser.parseFile(fileName);
+
+ assert oldConfig.getNodeLockingScheme().equals(newConfig.getNodeLockingScheme());
+ assert oldConfig.isNodeLockingOptimistic() == newConfig.isNodeLockingOptimistic();
+ assert oldConfig.equals(newConfig);
+ }
+
+ public void testEqualityOnTransformedFiles() throws Exception
+ {
+ String[] fileNames = {"buddy-replication-cache-service.xml", "cacheloader-enabled-cache-service.xml",
+ "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
+ "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
+ for (String file : fileNames)
+ {
+ System.out.println("Processing file = " + file);
+ String fileName = getFileName(file);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ convertor.parse(fileName, baos, XSLT_FILE);
+
+ XmlConfigurationParser newParser = new XmlConfigurationParser();
+ XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
+
+ Configuration newConfig = newParser.parse(new ByteArrayInputStream(baos.toByteArray()));
+ Configuration oldConfig = oldParser.parseFile(fileName);
+
+ assert newConfig.equals(oldConfig);
+ }
+ }
+
+ private String getFileName(String s)
+ {
+ return BASE_DIR + File.separator + s;
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-26 12:10:31 UTC (rev 6054)
@@ -238,4 +238,5 @@
assert singlStoreConf.getProperties().get("pushStateWhenCoordinatorTimeout").equals("20000");
}
+
}
Modified: core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -2,7 +2,8 @@
<jbosscache>
- <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"/>
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
+ optimistic="false"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
Modified: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml 2008-06-26 11:31:23 UTC (rev 6053)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -75,7 +75,9 @@
<attribute name="ExposeManagementStatistics">false</attribute>
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+
<attribute name="EvictionPolicyConfig">
<config>
<attribute name="wakeUpIntervalSeconds">5</attribute>
Added: core/trunk/src/test/resources/META-INF/config2.x/buddy-replication-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/buddy-replication-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/buddy-replication-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <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"/>
+
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <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"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
+ <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.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ <!-- Buddy Replication config -->
+ <attribute name="BuddyReplicationConfig">
+ <config>
+ <buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
+ <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
+ <buddyLocatorProperties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </buddyLocatorProperties>
+
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
+ <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
+ <autoDataGravitation>false</autoDataGravitation>
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
+ <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
+ <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/cacheloader-enabled-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/cacheloader-enabled-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/cacheloader-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=TreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">5</attribute>
+ <!-- This defaults to 200000 if not specified -->
+ <attribute name="eventQueueSize">200000</attribute>
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+
+ <!-- Cache wide default -->
+ <region name="/_default_">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLiveSeconds">3</attribute>
+ </region>
+ <region name="/org/jboss/test/data">
+ <attribute name="maxNodes">100</attribute>
+ <attribute name="timeToLiveSeconds">3</attribute>
+ </region>
+ </config>
+ </attribute>
+
+ <!-- Cache Passivation for Tree Cache
+ On pasivation, The objects are written to the backend store on eviction if CacheLoaderPassivation
+ is true, otheriwse the objects are persisted.
+ On activation, the objects are restored in the memory cache and removed from the cache loader
+ if CacheLoaderPassivation is true, otherwise the objects are only loaded from the cache loader -->
+ <attribute name="CacheLoaderConfiguration">
+ <config>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <passivation>false</passivation>
+ <preload>/</preload>
+ <shared>false</shared>
+
+ <!-- we can now have multiple cache loaders, which get chained -->
+ <cacheloader>
+ <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+ <!-- same as the old CacheLoaderConfig attribute -->
+ <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.driver=com.mysql.jdbc.Driver
+ cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
+ cache.jdbc.user=root
+ cache.jdbc.password=
+ cache.jdbc.sql-concat=concat(1,2)
+ </properties>
+ <!-- whether the cache loader writes are asynchronous -->
+ <async>false</async>
+ <!-- only one cache loader in the chain may set fetchPersistentState to true.
+ An exception is thrown if more than one cache loader sets this to true. -->
+ <fetchPersistentState>true</fetchPersistentState>
+ <!-- determines whether this cache loader ignores writes - defaults to false. -->
+ <ignoreModifications>false</ignoreModifications>
+ <!-- if set to true, purges the contents of this cache loader when the cache starts up.
+ Defaults to false. -->
+ <purgeOnStartup>false</purgeOnStartup>
+ </cacheloader>
+ </config>
+ </attribute>
+
+ </mbean>
+
+
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/eviction-enabled-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/eviction-enabled-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/eviction-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!--
+Sample JBoss Cache Service Configuration that hightlights various
+eviction configurations. By default LRUPolicy is enabled, by this can be
+changed by commenting it out and uncommenting another present
+eviction policy.
+-->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Defines JBoss Cache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=Cache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">5</attribute>
+ <!-- This defaults to 200000 if not specified -->
+ <attribute name="eventQueueSize">200000</attribute>
+ <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+ <!-- Cache wide default -->
+ <region name="/_default_">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLiveSeconds">1000</attribute>
+ </region>
+ <region name="/org/jboss/data">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLiveSeconds">1000</attribute>
+ </region>
+ <region name="/org/jboss/test/data">
+ <attribute name="maxNodes">5</attribute>
+ <attribute name="timeToLiveSeconds">4</attribute>
+ </region>
+ <region name="/test">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">4</attribute>
+ </region>
+ <region name="/maxAgeTest">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">8</attribute>
+ <attribute name="maxAgeSeconds">10</attribute>
+ </region>
+ </config>
+ </attribute>
+
+
+ <!--ElementSizePolicy eviction config-->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <!--<attribute name="policyClass">org.jboss.cache.eviction.ElementSizePolicy</attribute>-->
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--<attribute name="maxElementsPerNode">100</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/data">-->
+ <!--<attribute name="maxNodes">10</attribute>-->
+ <!--<attribute name="maxElementsPerNode">20</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/test/data">-->
+ <!--<attribute name="maxElementsPerNode">5</attribute>-->
+ <!--</region>-->
+ <!--<region name="/test/">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--<attribute name="maxElementsPerNode">1</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ <!-- ExpirationPolicy eviction policy configurations. -->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!-- One second is a good default -->
+ <!--<attribute name="wakeUpIntervalSeconds">1</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <!--<attribute name="policyClass">org.jboss.cache.eviction.ExpirationPolicy</attribute>-->
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_">-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/data">-->
+ <!-- Removes the soonest to expire nodes to reduce the region size to at most 250 nodes -->
+ <!--<attribute name="maxNodes">250</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ <!-- Specific eviction policy configurations. This is FIFOPolicy -->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <!--<attribute name="policyClass">org.jboss.cache.eviction.FIFOPolicy</attribute>-->
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/data">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/test/data">-->
+ <!--<attribute name="maxNodes">5</attribute>-->
+ <!--</region>-->
+ <!--<region name="/test/">-->
+ <!--<attribute name="maxNodes">10000</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ <!-- Specific eviction policy configurations. This is LFUPolicy -->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--<attribute name="minNodes">10</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--<attribute name="minNodes">4000</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/test/data" policyClass="org.jboss.cache.eviction.LFUPolicy">-->
+ <!--<attribute name="minNodes">5</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ <!-- Specific eviction policy configurations. This is MRUPolicy -->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!--<attribute name="wakeUpIntervalSeconds">3</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <!--<attribute name="policyClass">org.jboss.cache.eviction.MRUPolicy</attribute>-->
+
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_">-->
+ <!--<attribute name="maxNodes">100</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/data">-->
+ <!--<attribute name="maxNodes">250</attribute>-->
+ <!--</region>-->
+ <!--<region name="/org/jboss/test/data">-->
+ <!--<attribute name="maxNodes">6</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <!--<attribute name="EvictionPolicyConfig">-->
+ <!--<config>-->
+ <!--<attribute name="wakeUpIntervalSeconds">1</attribute>-->
+ <!-- This defaults to 200000 if not specified -->
+ <!--<attribute name="eventQueueSize">200000</attribute>-->
+ <!--<attribute name="policyClass">org.jboss.cache.eviction.NullEvictionPolicy</attribute>-->
+
+ <!-- Cache wide default -->
+ <!--<region name="/_default_">-->
+ <!--<attribute name="maxNodes">5000</attribute>-->
+ <!--<attribute name="timeToLiveSeconds">1</attribute>-->
+ <!--</region>-->
+ <!--<region name="/test" policyClass="org.jboss.cache.eviction.NullEvictionPolicy">-->
+ <!--<attribute name="maxNodes">10000</attribute>-->
+ <!--<attribute name="timeToLiveSeconds">1</attribute>-->
+ <!--</region>-->
+ <!--<region name="/lru" policyClass="org.jboss.cache.eviction.LRUPolicy">-->
+ <!--<attribute name="maxNodes">10000</attribute>-->
+ <!--<attribute name="timeToLiveSeconds">1</attribute>-->
+ <!--</region>-->
+ <!--</config>-->
+ <!--</attribute>-->
+
+ </mbean>
+
+
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/local-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/local-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/local-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=TreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+
+ <!-- Configure the TransactionManager -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ </mbean>
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/multiplexer-enabled-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/multiplexer-enabled-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/multiplexer-enabled-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <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"/>
+
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <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"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
+ <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.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ <!-- Buddy Replication config -->
+ <attribute name="BuddyReplicationConfig">
+ <config>
+ <buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
+ <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
+ <buddyLocatorProperties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </buddyLocatorProperties>
+
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
+ <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
+ <autoDataGravitation>false</autoDataGravitation>
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
+ <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
+ <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/optimistically-locked-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/optimistically-locked-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/optimistically-locked-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=TreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+ <attribute name="FetchInMemoryState">false</attribute>
+
+ <!-- Whether each interceptor should have an mbean
+registered to capture and display its statistics. -->
+ <attribute name="UseInterceptorMbeans">true</attribute>
+
+ <!--
+ Node locking scheme:
+ OPTIMISTIC
+ PESSIMISTIC (default)
+ -->
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">READ_COMMITTED</attribute>
+
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">1</attribute>
+ <!-- Name of the DEFAULT eviction policy class.-->
+ <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+ <region name="/_default_">
+ <attribute name="maxNodes">10</attribute>
+ <attribute name="timeToLiveSeconds">0</attribute>
+ <attribute name="maxAgeSeconds">0</attribute>
+ </region>
+ <region name="/testingRegion">
+ <attribute name="maxNodes">10</attribute>
+ <attribute name="timeToLiveSeconds">0</attribute>
+ <attribute name="maxAgeSeconds">0</attribute>
+ </region>
+ <region name="/timeBased">
+ <attribute name="maxNodes">10</attribute>
+ <attribute name="timeToLiveSeconds">1</attribute>
+ <attribute name="maxAgeSeconds">1</attribute>
+ </region>
+ </config>
+ </attribute>
+
+ </mbean>
+</server>
Added: core/trunk/src/test/resources/META-INF/config2.x/total-replication-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/config2.x/total-replication-cache-service.xml (rev 0)
+++ core/trunk/src/test/resources/META-INF/config2.x/total-replication-cache-service.xml 2008-06-26 12:10:31 UTC (rev 6054)
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <UDP mcast_addr="228.10.10.10"
+ mcast_port="45588"
+ tos="8"
+ ucast_recv_buf_size="20000000"
+ ucast_send_buf_size="640000"
+ mcast_recv_buf_size="25000000"
+ mcast_send_buf_size="640000"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ ip_ttl="2"
+ enable_bundling="false"
+ enable_diagnostics="true"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10"
+ thread_pool.rejection_policy="Run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000" num_initial_members="2"/>
+ <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"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+ <!--
+ Whether or not to fetch state on joining a cluster
+ NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+ -->
+ <attribute name="FetchInMemoryState">true</attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ </mbean>
+</server>
16 years, 6 months
JBoss Cache SVN: r6053 - searchable/trunk/src/test/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-26 07:31:23 -0400 (Thu, 26 Jun 2008)
New Revision: 6053
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
Log:
Added a mock loader
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-06-26 11:18:41 UTC (rev 6052)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-06-26 11:31:23 UTC (rev 6053)
@@ -6,7 +6,9 @@
import org.testng.annotations.Test;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Navin Surtani - navin(a)surtani.org
@@ -17,32 +19,48 @@
@Test
public class QueryResultIteratorImplTest
{
- CacheEntityLoader entityLoader;
- List<CacheEntityId> list;
+ List<CacheEntityId> ids;
+ Map<CacheEntityId, Object> dummyResults;
+ QueryResultIterator iterator;
@BeforeMethod
public void SetUp()
{
- list = new ArrayList();
- list.add(new CacheEntityId(Fqn.fromString("/a"), "key1"));
- list.add(new CacheEntityId(Fqn.fromString("/b"), "key2"));
- list.add(new CacheEntityId(Fqn.fromString("/c"), "key3"));
- list.add(new CacheEntityId(Fqn.fromString("/d"), "key4"));
- list.add(new CacheEntityId(Fqn.fromString("/e"), "key5"));
- list.add(new CacheEntityId(Fqn.fromString("/f"), "key6"));
- list.add(new CacheEntityId(Fqn.fromString("/g"), "key7"));
- list.add(new CacheEntityId(Fqn.fromString("/h"), "key8"));
- list.add(new CacheEntityId(Fqn.fromString("/i"), "key9"));
- list.add(new CacheEntityId(Fqn.fromString("/j"), "key10"));
+ // create a set of dummy cache entity IDs
+ ids = new ArrayList();
+ ids.add(new CacheEntityId(Fqn.fromString("/a"), "key1"));
+ ids.add(new CacheEntityId(Fqn.fromString("/b"), "key2"));
+ ids.add(new CacheEntityId(Fqn.fromString("/c"), "key3"));
+ ids.add(new CacheEntityId(Fqn.fromString("/d"), "key4"));
+ ids.add(new CacheEntityId(Fqn.fromString("/e"), "key5"));
+ ids.add(new CacheEntityId(Fqn.fromString("/f"), "key6"));
+ ids.add(new CacheEntityId(Fqn.fromString("/g"), "key7"));
+ ids.add(new CacheEntityId(Fqn.fromString("/h"), "key8"));
+ ids.add(new CacheEntityId(Fqn.fromString("/i"), "key9"));
+ ids.add(new CacheEntityId(Fqn.fromString("/j"), "key10"));
- QueryResultIteratorImpl iterator = new QueryResultIteratorImpl(list, entityLoader);
+ // create some dummy data
+ dummyResults = new HashMap<CacheEntityId, Object>();
+ int counter = 0;
+ for (CacheEntityId id : ids)
+ {
+ // for each cache entity ID, create a dummy result that will be returned when loading it.
+ dummyResults.put(id, "Result number " + counter);
+ }
+
+ // now create a dummy entity loader
+ CacheEntityLoader dummyLoader = new DummyEntityLoader(ids, dummyResults);
+
+ iterator = new QueryResultIteratorImpl(ids, dummyLoader);
}
@AfterMethod
public void tearDown()
{
- list = null;
+ ids = null;
+ dummyResults = null;
+ iterator = null;
}
public void jumpToResultTest(int index) throws IndexOutOfBoundsException
@@ -134,4 +152,38 @@
{
//To change body of implemented methods use File | Settings | File Templates.
}
+
+ public static class DummyEntityLoader extends CacheEntityLoader
+ {
+ private List<CacheEntityId> allKnownIds;
+ private Map<CacheEntityId, Object> dummyValues;
+
+ public DummyEntityLoader(List<CacheEntityId> allKnownIds, Map<CacheEntityId, Object> dummyValues)
+ {
+ // use a null as a cache since we won't ever need to refer to the cache
+ super(null);
+
+ this.allKnownIds = allKnownIds;
+ this.dummyValues = dummyValues;
+ }
+
+ @Override
+ public List<Object> load(List<CacheEntityId> ids)
+ {
+ List<Object> resultsToReturn = new ArrayList<Object>(ids.size());
+ // iterate through the list of ids we are looking for
+ for (CacheEntityId id : ids)
+ {
+ resultsToReturn.add(dummyValues.get(id));
+ }
+
+ return resultsToReturn;
+ }
+
+ @Override
+ public Object load(CacheEntityId id)
+ {
+ return dummyValues.get(id);
+ }
+ }
}
16 years, 6 months
JBoss Cache SVN: r6052 - searchable/trunk/src/main/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-06-26 07:18:41 -0400 (Thu, 26 Jun 2008)
New Revision: 6052
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
Log:
Cleaned up CacheQueryImpl a bit
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-06-26 11:06:55 UTC (rev 6051)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-06-26 11:18:41 UTC (rev 6052)
@@ -14,7 +14,7 @@
{
List<Object> list();
- QueryResultIterator iterate();
+ QueryResultIterator iterator();
void setFirstResult(int index);
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-06-26 11:06:55 UTC (rev 6051)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-06-26 11:18:41 UTC (rev 6052)
@@ -7,10 +7,7 @@
import org.apache.lucene.search.*;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.ScrollableResults;
import org.hibernate.search.FullTextFilter;
-import org.hibernate.search.FullTextQuery;
import org.hibernate.search.SearchException;
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.engine.DocumentExtractor;
@@ -76,11 +73,6 @@
this.classes = classes;
}
- public FullTextQuery setResultTransformer(ResultTransformer transformer)
- {
- // TODO: Do we need to impl this? What does HS do?
- return null;
- }
/**
* @return The result size of the query.
@@ -130,28 +122,9 @@
sort = s;
}
- /**
- * This method is not supported in JBossCache Searchable and should not be called.
- */
- public FullTextQuery setCriteriaQuery(Criteria criteria)
- {
- throw new UnsupportedOperationException("This method is not supported in JBossCache Searchable");
- }
- /**
- * Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation,
- * an Object[] being returned for each "row" (similar to an HQL or a Criteria API projection).
- *
- * @param strings
- * @return
- */
- public FullTextQuery setProjection(String... strings)
- {
- throw new UnsupportedOperationException("Not supported in SearchableCache!");
- }
-
private void closeSearcher(Searcher searcher, ReaderProvider readerProvider)
{
Set<IndexReader> indexReaders = getIndexReaders(searcher);
@@ -213,9 +186,9 @@
this.firstResult = firstResult;
}
- public QueryResultIterator iterate() throws HibernateException
+ public QueryResultIterator iterator() throws HibernateException
{
- List list;
+ List<CacheEntityId> ids = null;
IndexSearcher searcher = buildSearcher(searchFactory);
if (searcher == null)
{
@@ -228,7 +201,7 @@
int first = first();
int max = max(first, hits);
int size = max - first + 1 < 0 ? 0 : max - first + 1;
- List<CacheEntityId> ids = new ArrayList<CacheEntityId>(size);
+ ids = new ArrayList<CacheEntityId>(size);
DocumentExtractor extractor = new DocumentExtractor(searchFactory, indexProjection);
for (int index = first; index <= max; index++)
@@ -238,7 +211,6 @@
ids.add(id);
}
- list = entityLoader.load(ids);
}
catch (IOException e)
{
@@ -253,46 +225,9 @@
}
- return new QueryResultIteratorImpl(list, entityLoader);
+ return new QueryResultIteratorImpl(ids, entityLoader);
}
- public ScrollableResults scroll() throws HibernateException
- {
- IndexSearcher searcher = buildSearcher(searchFactory);
-
- Hits hits;
-
- try
- {
- hits = getHits(searcher);
- int first = first();
- int max = max(first, hits);
- int size = max - first + 1 < 0 ? 0 : max - first + 1;
-
- DocumentExtractor extractor = new DocumentExtractor(searchFactory, indexProjection);
-
- List<CacheEntityId> ids = new ArrayList<CacheEntityId>(size);
-
- for (int index = first; index <= max; index++)
- {
-
- String documentId = (String) extractor.extract(hits, index).id;
- CacheEntityId id = new CacheEntityId(documentId);
- ids.add(id);
- }
-
- List<Object> list = entityLoader.load(ids);
-
- }
-
- catch (IOException e)
- {
- throw new HibernateException("Unable to query Lucene index", e);
- }
-
- return null;
- }
-
/**
* Returns a the results from the query as a List object.
*
@@ -349,48 +284,6 @@
}
-// private Loader getLoader(Session session)
-// {
-// if (indexProjection != null) {
-// ProjectionLoader loader = new ProjectionLoader();
-// loader.init(session, searchFactory, resultTransformer, indexProjection);
-// return loader;
-// }
-// if (criteria != null) {
-// if (classes.length > 1) throw new SearchException("Cannot mix criteria and multiple entity types");
-// if (criteria instanceof CriteriaImpl) {
-// String targetEntity = ((CriteriaImpl) criteria).getEntityOrClassName();
-// if (classes.length == 1 && !classes[0].getName().equals(targetEntity)) {
-// throw new SearchException("Criteria query entity should match query entity");
-// }
-// else {
-// try {
-// Class entityType = ReflectHelper.classForName(targetEntity);
-// classes = new Class[]{entityType};
-// }
-// catch (ClassNotFoundException e) {
-// throw new SearchException("Unable to load entity class from criteria: " + targetEntity, e);
-// }
-// }
-// }
-// QueryLoader loader = new QueryLoader();
-// loader.init(session, searchFactory);
-// loader.setEntityType(classes[0]);
-// loader.setCriteria(criteria);
-// return loader;
-// }
-// else if (classes.length == 1) {
-// QueryLoader loader = new QueryLoader();
-// loader.init(session, searchFactory);
-// loader.setEntityType(classes[0]);
-// return loader;
-// }
-// else {
-// final ObjectLoader objectLoader = new ObjectLoader();
-// objectLoader.init(session, searchFactory);
-// return objectLoader;
-// }
-// }
private int max(int first, Hits hits)
{
@@ -408,11 +301,6 @@
0;
}
- public int executeUpdate() throws HibernateException
- {
- throw new UnsupportedOperationException(" This method is not supported in JBossCache Searchable");
- }
-
public void setMaxResults(int maxResults)
{
if (maxResults < 0)
@@ -431,16 +319,6 @@
this.fetchSize = fetchSize;
}
- public org.hibernate.Query setLockMode(String alias, LockMode lockMode)
- {
- throw new UnsupportedOperationException(" This method is not supported in JBossCache Searchable");
- }
-
- protected Map getLockModes()
- {
- throw new UnsupportedOperationException(" This method is not supported in JBossCache Searchable");
- }
-
private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor)
{
Map<Class, DocumentBuilder<Object>> builders = searchFactoryImplementor.getDocumentBuilders();
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:06:55 UTC (rev 6051)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:18:41 UTC (rev 6052)
@@ -79,7 +79,7 @@
public Object next()
{
- if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
+ if (!hasNext()) throw new NoSuchElementException("Out of boundaries");
index++;
return next;
}
@@ -106,15 +106,16 @@
public void remove()
{
+ throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
}
- public void set(Object o)
+ public void set(Object o) throws UnsupportedOperationException
{
- //TODO: Implement
+ throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
}
public void add(Object o)
{
- idList.add(o);
+ throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
}
}
16 years, 6 months
JBoss Cache SVN: r6051 - searchable/trunk/src/main/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-06-26 07:06:55 -0400 (Thu, 26 Jun 2008)
New Revision: 6051
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
Log:
Changed some var names
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:03:51 UTC (rev 6050)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:06:55 UTC (rev 6051)
@@ -18,12 +18,12 @@
//private final int size;
private Object next;
private int nextObjectIndex = -1;
- private List list;
+ private List<CacheEntityId> idList;
private CacheEntityLoader entityLoader;
- public QueryResultIteratorImpl(List list, CacheEntityLoader entityLoader)
+ public QueryResultIteratorImpl(List<CacheEntityId> idList, CacheEntityLoader entityLoader)
{
- this.list = list;
+ this.idList = idList;
this.entityLoader = entityLoader;
}
@@ -115,6 +115,6 @@
public void add(Object o)
{
- list.add(o);
+ idList.add(o);
}
}
16 years, 6 months
JBoss Cache SVN: r6050 - in searchable/trunk/src: test/java/org/jboss/cache/search and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-06-26 07:03:51 -0400 (Thu, 26 Jun 2008)
New Revision: 6050
Added:
searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java
Log:
Created QueryResultIteratorImpl and fixed CacheQueryImpl
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:02:27 UTC (rev 6049)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-06-26 11:03:51 UTC (rev 6050)
@@ -3,6 +3,7 @@
import org.jboss.cache.Cache;
import java.util.List;
+import java.util.NoSuchElementException;
/**
* This is the implementation class for the interface QueryResultIterator. It is what is returned when the iterate()
@@ -17,11 +18,13 @@
//private final int size;
private Object next;
private int nextObjectIndex = -1;
- private List<Object> list;
+ private List list;
+ private CacheEntityLoader entityLoader;
public QueryResultIteratorImpl(List list, CacheEntityLoader entityLoader)
{
this.list = list;
+ this.entityLoader = entityLoader;
}
public void jumpToResult(int index) throws IndexOutOfBoundsException
@@ -71,12 +74,14 @@
public boolean hasNext()
{
- return false; //TODO: Implement
+ return false; //TODO: Implement
}
public Object next()
{
- return null; //TODO: Implement
+ if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
+ index++;
+ return next;
}
public boolean hasPrevious()
@@ -101,7 +106,6 @@
public void remove()
{
- //TODO: Implement
}
public void set(Object o)
@@ -111,6 +115,6 @@
public void add(Object o)
{
- //TODO: Implement
+ list.add(o);
}
}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java 2008-06-26 11:02:27 UTC (rev 6049)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java 2008-06-26 11:03:51 UTC (rev 6050)
@@ -1,15 +1,14 @@
package org.jboss.cache.search;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.search.test.Person;
import org.testng.annotations.Test;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.search.Query;
-import org.hibernate.search.FullTextQuery;
import java.util.List;
@@ -28,7 +27,7 @@
sc.put(Fqn.fromString("/a/b/c"), "Navin", p1);
QueryParser qp = new QueryParser("field", new StandardAnalyzer());
Query luceneQuery = qp.parse("playing");
- FullTextQuery query = sc.createQuery(luceneQuery);
+ CacheQuery query = sc.createQuery(luceneQuery);
List found = query.list();
Added: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java 2008-06-26 11:03:51 UTC (rev 6050)
@@ -0,0 +1,137 @@
+package org.jboss.cache.search;
+
+import org.jboss.cache.Fqn;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ * <p/>
+ * Test class for the QueryResultIteratorImpl
+ */
+
+@Test
+public class QueryResultIteratorImplTest
+{
+ CacheEntityLoader entityLoader;
+ List<CacheEntityId> list;
+
+ @BeforeMethod
+ public void SetUp()
+ {
+ list = new ArrayList();
+ list.add(new CacheEntityId(Fqn.fromString("/a"), "key1"));
+ list.add(new CacheEntityId(Fqn.fromString("/b"), "key2"));
+ list.add(new CacheEntityId(Fqn.fromString("/c"), "key3"));
+ list.add(new CacheEntityId(Fqn.fromString("/d"), "key4"));
+ list.add(new CacheEntityId(Fqn.fromString("/e"), "key5"));
+ list.add(new CacheEntityId(Fqn.fromString("/f"), "key6"));
+ list.add(new CacheEntityId(Fqn.fromString("/g"), "key7"));
+ list.add(new CacheEntityId(Fqn.fromString("/h"), "key8"));
+ list.add(new CacheEntityId(Fqn.fromString("/i"), "key9"));
+ list.add(new CacheEntityId(Fqn.fromString("/j"), "key10"));
+
+ QueryResultIteratorImpl iterator = new QueryResultIteratorImpl(list, entityLoader);
+
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ list = null;
+ }
+
+ public void jumpToResultTest(int index) throws IndexOutOfBoundsException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void firstTest()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void lastTest()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void afterFirstTest()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void beforeLastTest()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isFirstTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isLastTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isAfterFirstTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isBeforeLastTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean hasNextTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Object nextTest()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean hasPreviousTest()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Object previousTest()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public int nextIndexTest()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public int previousIndexTest()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeTest()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setTest(Object o)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addTest(Object o)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
16 years, 6 months