commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Zeigermann" <oli...@zeigermann.de>
Subject [transaction 2.0] stripping to its very core (WAS Re: svn commit: r556345 - in /jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction: ./ file/ locking/ memory/ xa/)
Date Sat, 14 Jul 2007 22:25:38 GMT
I am proposing to strip Commons Transaction to its very core. That is
what people have used in the past and what can be implemented well.

Core:
- lock management
- Tx file access

Deleted:
- no more memory classes: questionable usefulness, plus awkward implementation
- no more XA classes: We really can not an implement an XA resource
with the existing implementation
- TransactionalResource-Manager now only has methods one would call as
a user. More details ones still are available in the abstract
implementation.

Especially for a Commons component one needs to make sure not to run
out of focus.

Comments appreciated.

Oliver

2007/7/15, ozeigermann@apache.org <ozeigermann@apache.org>:
> Author: ozeigermann
> Date: Sat Jul 14 15:18:19 2007
> New Revision: 556345
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=556345
> Log: (empty)
>
> Added:
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
>       - copied, changed from r556197, jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResource.java
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
>       - copied, changed from r556197, jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResource.java
> Removed:
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResource.java
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResource.java
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/memory/
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/xa/
> Modified:
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/TxFileResourceManager.java
>     jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/ReadWriteLockManager.java
>
> Copied: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
(from r556197, jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResource.java)
> URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java?view=diff&rev=556345&p1=jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResource.java&r1=556197&p2=jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java&r2=556345
> ==============================================================================
> --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResource.java
(original)
> +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/AbstractTransactionalResourceManager.java
Sat Jul 14 15:18:19 2007
> @@ -22,7 +22,6 @@
>  import java.util.concurrent.locks.ReadWriteLock;
>
>  import org.apache.commons.transaction.locking.LockException;
> -import org.apache.commons.transaction.locking.LockManager;
>  import org.apache.commons.transaction.locking.ReadWriteLockManager;
>  import org.apache.commons.transaction.locking.LockException.Code;
>
> @@ -33,7 +32,7 @@
>   *
>   * @param <T>
>   */
> -public abstract class AbstractTransactionalResource<T extends AbstractTransactionalResource.AbstractTxContext>
implements TransactionalResource {
> +public abstract class AbstractTransactionalResourceManager<T extends AbstractTransactionalResourceManager.AbstractTxContext>
implements TransactionalResourceManager {
>      protected ThreadLocal<T> activeTx = new ThreadLocal<T>();
>
>      protected Set<T> activeTransactions = new HashSet<T>();
> @@ -42,7 +41,18 @@
>
>      protected abstract T createContext();
>
> -    @Override
> +    /**
> +     * Checks whether this transaction has been marked to allow a rollback as
> +     * the only valid outcome. This can be set my method
> +     * {@link #markTransactionForRollback()} or might be set internally be any
> +     * fatal error. Once a transaction is marked for rollback there is no way to
> +     * undo this. A transaction that is marked for rollback can not be
> +     * committed, also rolled back.
> +     *
> +     * @return <code>true</code> if this transaction has been marked for
a
> +     *         roll back
> +     * @see #markTransactionForRollback()
> +     */
>      public boolean isTransactionMarkedForRollback() {
>          T txContext = getActiveTx();
>
> @@ -160,7 +170,10 @@
>          setActiveTx(null);
>      }
>
> -    @Override
> +    /**
> +     * Prepares the changes done inside this transaction reasource.
> +     *
> +     */
>      public boolean prepareTransaction() {
>          T txContext = getActiveTx();
>
> @@ -201,6 +214,11 @@
>          return false;
>      }
>
> +    /**
> +     * Marks the current transaction to allow only a rollback as valid outcome.
> +     *
> +     * @see #isTransactionMarkedForRollback()
> +     */
>      public void markTransactionForRollback() {
>          // TODO Auto-generated method stub
>
>
> Copied: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
(from r556197, jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResource.java)
> URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java?view=diff&rev=556345&p1=jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResource.java&r1=556197&p2=jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java&r2=556345
> ==============================================================================
> --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResource.java
(original)
> +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/TransactionalResourceManager.java
Sat Jul 14 15:18:19 2007
> @@ -16,14 +16,12 @@
>   */
>  package org.apache.commons.transaction;
>
> -import javax.transaction.xa.XAException;
>
>  /**
> - * Interface for something that makes up a transactional resource.
> + * Interface for something that makes up a transactional resource manager.
>   *
> - * @version $Id: TransactionalResource.java 493628 2007-01-07 01:42:48Z joerg $
>   */
> -public interface TransactionalResource {
> +public interface TransactionalResourceManager {
>      /**
>       * TODO
>       *
> @@ -32,12 +30,6 @@
>      public void setTransactionTimeout(long mSecs);
>
>      /**
> -     * Prepares the changes done inside this transaction reasource.
> -     *
> -     */
> -    public boolean prepareTransaction();
> -
> -    /**
>       * Starts a new transaction and associates it with the current thread. All
>       * subsequent changes in the same thread made to the map are invisible from
>       * other threads until {@link #commitTransaction()} is called. Use
> @@ -53,26 +45,6 @@
>       */
>      public void startTransaction();
>
> -    /**
> -     * Checks whether this transaction has been marked to allow a rollback as
> -     * the only valid outcome. This can be set my method
> -     * {@link #markTransactionForRollback()} or might be set internally be any
> -     * fatal error. Once a transaction is marked for rollback there is no way to
> -     * undo this. A transaction that is marked for rollback can not be
> -     * committed, also rolled back.
> -     *
> -     * @return <code>true</code> if this transaction has been marked for
a
> -     *         roll back
> -     * @see #markTransactionForRollback()
> -     */
> -    public boolean isTransactionMarkedForRollback();
> -
> -    /**
> -     * Marks the current transaction to allow only a rollback as valid outcome.
> -     *
> -     * @see #isTransactionMarkedForRollback()
> -     */
> -    public void markTransactionForRollback();
>
>      /**
>       * Discards all changes made in the current transaction and deletes the
> @@ -91,9 +63,5 @@
>       * @see #rollbackTransaction()
>       */
>      public void commitTransaction();
> -
> -    boolean isReadOnlyTransaction();
> -    boolean isTransactionPrepared();
> -
>
>  }
>
> Modified: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/TxFileResourceManager.java
> URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/TxFileResourceManager.java?view=diff&rev=556345&r1=556344&r2=556345
> ==============================================================================
> --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/TxFileResourceManager.java
(original)
> +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/TxFileResourceManager.java
Sat Jul 14 15:18:19 2007
> @@ -28,14 +28,14 @@
>
>  import org.apache.commons.logging.Log;
>  import org.apache.commons.logging.LogFactory;
> -import org.apache.commons.transaction.AbstractTransactionalResource;
> -import org.apache.commons.transaction.TransactionalResource;
> -import org.apache.commons.transaction.AbstractTransactionalResource.AbstractTxContext;
> +import org.apache.commons.transaction.AbstractTransactionalResourceManager;
> +import org.apache.commons.transaction.TransactionalResourceManager;
> +import org.apache.commons.transaction.AbstractTransactionalResourceManager.AbstractTxContext;
>  import org.apache.commons.transaction.locking.LockException;
>  import org.apache.commons.transaction.util.FileHelper;
>
>  public class TxFileResourceManager extends
> -        AbstractTransactionalResource<TxFileResourceManager.FileTxContext> implements
> +        AbstractTransactionalResourceManager<TxFileResourceManager.FileTxContext>
implements
>          FileResourceManager {
>
>      private Log logger = LogFactory.getLog(getClass());
> @@ -44,7 +44,7 @@
>
>      protected PathManager idMapper;
>
> -    protected TransactionalResource tm;
> +    protected TransactionalResourceManager tm;
>
>      public static void applyDeletes(File removeDir, File targetDir, File rootDir)
>              throws IOException {
>
> Modified: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/ReadWriteLockManager.java
> URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/ReadWriteLockManager.java?view=diff&rev=556345&r1=556344&r2=556345
> ==============================================================================
> --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/ReadWriteLockManager.java
(original)
> +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/ReadWriteLockManager.java
Sat Jul 14 15:18:19 2007
> @@ -3,7 +3,10 @@
>  import java.util.concurrent.locks.ReadWriteLock;
>  import java.util.concurrent.locks.ReentrantReadWriteLock;
>
> -
> +// TODO: Add wrappers to include failfast deadlock check
> +// possible actions after deadlock detected (done by user)
> +// I rollback
> +// II do not acquire the lock, but wait for a while
>  public class ReadWriteLockManager extends GenericLockManager<Object, ReadWriteLock>
implements LockManager<Object, ReadWriteLock> {
>
>      public ReadWriteLock create() {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message