geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/manager MockResource.java XATransactionTester.java
Date Tue, 08 Jun 2004 17:33:43 GMT
djencks     2004/06/08 10:33:43

  Modified:    modules/transaction/src/java/org/apache/geronimo/transaction/log
                        UnrecoverableLog.java XidImpl2.java
               modules/transaction/src/java/org/apache/geronimo/transaction/manager
                        Recovery.java TransactionImpl.java
                        TransactionLog.java XidFactory.java
                        XidFactoryImpl.java
               modules/transaction/src/test/org/apache/geronimo/transaction/log
                        AbstractLogTest.java
               modules/transaction/src/test/org/apache/geronimo/transaction/manager
                        MockResource.java XATransactionTester.java
  Added:       modules/transaction/src/java/org/apache/geronimo/transaction/manager
                        NamedXAResource.java WrapperNamedXAResource.java
  Log:
  introduce NamedXAResource so transactions can log which resource managers they use (partial
implementation, to commit changes to connector module deployment interfaces)
  
  Revision  Changes    Path
  1.5       +8 -8      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
  
  Index: UnrecoverableLog.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- UnrecoverableLog.java	6 May 2004 04:00:51 -0000	1.4
  +++ UnrecoverableLog.java	8 Jun 2004 17:33:42 -0000	1.5
  @@ -17,14 +17,14 @@
   
   package org.apache.geronimo.transaction.log;
   
  -import java.io.IOException;
  -import java.util.List;
  -import java.util.ArrayList;
  +import java.util.HashMap;
  +import java.util.Map;
   
   import javax.transaction.xa.Xid;
   
  -import org.apache.geronimo.transaction.manager.TransactionLog;
   import org.apache.geronimo.transaction.manager.LogException;
  +import org.apache.geronimo.transaction.manager.TransactionLog;
  +import org.apache.geronimo.transaction.manager.XidFactory;
   
   /**
    * A log sink that doesn't actually do anything.
  @@ -37,7 +37,7 @@
       public void begin(Xid xid) throws LogException {
       }
   
  -    public void prepare(Xid xid) throws LogException {
  +    public void prepare(Xid xid, String[] names) throws LogException {
       }
   
       public void commit(Xid xid) throws LogException {
  @@ -46,8 +46,8 @@
       public void rollback(Xid xid) throws LogException {
       }
   
  -    public List recover() throws LogException {
  -        return new ArrayList();
  +    public Map recover(XidFactory xidFactory) throws LogException {
  +        return new HashMap();
       }
   
       public String getXMLStats() {
  
  
  
  1.3       +13 -4     incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/log/XidImpl2.java
  
  Index: XidImpl2.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/log/XidImpl2.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XidImpl2.java	6 May 2004 04:15:06 -0000	1.2
  +++ XidImpl2.java	8 Jun 2004 17:33:42 -0000	1.3
  @@ -49,7 +49,7 @@
        */
       public XidImpl2(byte[] globalId) {
           System.arraycopy(FORMAT_ID_BYTES, 0, buffer, HEADER_SIZE, FORMAT_SIZE);
  -        buffer[GLOBALID_SIZE_POS] = (byte)globalId.length;
  +        buffer[GLOBALID_SIZE_POS] = (byte) globalId.length;
           System.arraycopy(globalId, 0, buffer, HEADER_SIZE + FORMAT_SIZE, Xid.MAXGTRIDSIZE);
   
           //this.hash = hash(buffer);
  @@ -62,13 +62,22 @@
        */
       public XidImpl2(Xid global, byte[] branch) {
           if (global instanceof XidImpl2) {
  -            System.arraycopy(((XidImpl2)global).buffer, 0, buffer, 0, HEADER_SIZE +FORMAT_SIZE
+ Xid.MAXGTRIDSIZE);
  +            System.arraycopy(((XidImpl2) global).buffer, 0, buffer, 0, HEADER_SIZE + FORMAT_SIZE
+ Xid.MAXGTRIDSIZE);
           } else {
               System.arraycopy(FORMAT_ID_BYTES, 0, buffer, HEADER_SIZE, FORMAT_SIZE);
               byte[] globalId = global.getGlobalTransactionId();
               System.arraycopy(globalId, 0, buffer, HEADER_SIZE + FORMAT_SIZE, globalId.length);
           }
  -        buffer[BRANCHID_SIZE_POS] = (byte)branch.length;
  +        buffer[BRANCHID_SIZE_POS] = (byte) branch.length;
  +        System.arraycopy(branch, 0, buffer, HEADER_SIZE + FORMAT_SIZE + Xid.MAXGTRIDSIZE,
Xid.MAXBQUALSIZE);
  +        //hash = hash(buffer);
  +    }
  +
  +    public XidImpl2(int formatId, byte[] globalId, byte[] branch) {
  +        //todo this is wrong, it ignores formatId supplied.  Maybe this is ok?
  +        System.arraycopy(FORMAT_ID_BYTES, 0, buffer, HEADER_SIZE, FORMAT_SIZE);
  +        System.arraycopy(globalId, 0, buffer, HEADER_SIZE + FORMAT_SIZE, globalId.length);
  +        buffer[BRANCHID_SIZE_POS] = (byte) branch.length;
           System.arraycopy(branch, 0, buffer, HEADER_SIZE + FORMAT_SIZE + Xid.MAXGTRIDSIZE,
Xid.MAXBQUALSIZE);
           //hash = hash(buffer);
       }
  
  
  
  1.2       +134 -33   incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
  
  Index: Recovery.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Recovery.java	6 May 2004 04:00:51 -0000	1.1
  +++ Recovery.java	8 Jun 2004 17:33:42 -0000	1.2
  @@ -18,16 +18,21 @@
   package org.apache.geronimo.transaction.manager;
   
   import java.util.HashMap;
  -import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
  +import java.util.ArrayList;
  +import java.util.Collections;
   
  +import javax.transaction.SystemException;
   import javax.transaction.xa.XAException;
   import javax.transaction.xa.XAResource;
   import javax.transaction.xa.Xid;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   /**
    *
    *
  @@ -35,69 +40,165 @@
    *
    * */
   public class Recovery {
  +    private static final Log log = LogFactory.getLog("Recovery");
   
       private final List xaResources;
       private final TransactionLog txLog;
  -    private XidFactory xidFactory;
  +    private final XidFactory xidFactory;
  +
  +    private final Map externalXids = new HashMap();
  +    private final Map ourXids = new HashMap();
  +    private final Map externalGlobalIdMap = new HashMap();
   
  -    private Map externalXids;
  +    private final List recoveryErrors = new ArrayList();
   
  -    public Recovery(List xaResources, TransactionLog txLog, XidFactory xidFactory) {
  +    public Recovery(final List xaResources, final TransactionLog txLog, final XidFactory
xidFactory) {
           this.xaResources = xaResources;
           this.txLog = txLog;
           this.xidFactory = xidFactory;
       }
   
       public synchronized void recover() throws XAException {
  -        Set ourXids = new HashSet();
  -        externalXids = new HashMap();
  -        Map externalGlobalIdMap = new HashMap();
  -        List preparedXids = null;
  +        recoverLog();
  +
  +        for (Iterator iterator = xaResources.iterator(); iterator.hasNext();) {
  +            NamedXAResource xaResource = (NamedXAResource) iterator.next();
  +            recoverResourceManager(xaResource);
  +        }
  +    }
  +
  +    private void recoverLog() throws XAException {
  +        Map preparedXids = null;
           try {
  -            preparedXids = txLog.recover();
  +            preparedXids = txLog.recover(xidFactory);
           } catch (LogException e) {
  -            throw (XAException)new XAException(XAException.XAER_RMERR).initCause(e);
  +            throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
           }
  -        for (Iterator iterator = preparedXids.iterator(); iterator.hasNext();) {
  -            Xid xid = (Xid) iterator.next();
  +        for (Iterator iterator = preparedXids.entrySet().iterator(); iterator.hasNext();)
{
  +            Map.Entry entry = (Map.Entry) iterator.next();
  +            Xid xid = (Xid) entry.getKey();
               if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
  -                ourXids.add(xid);
  +                XidNamesPair xidNamesPair = new XidNamesPair(xid, (Set) entry.getValue());
  +                ourXids.put(xid.getGlobalTransactionId(), xidNamesPair);
               } else {
  -                TransactionImpl externalTx = new TransactionImpl(xid, txLog);
  +                TransactionImpl externalTx = new ExternalTransaction(xid, txLog, (Set)
entry.getValue());
                   externalXids.put(xid, externalTx);
                   externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx);
               }
           }
  +    }
   
  -        for (Iterator iterator = xaResources.iterator(); iterator.hasNext();) {
  -            XAResource xaResource = (XAResource) iterator.next();
  -            Xid[] prepared = xaResource.recover(XAResource.TMSTARTRSCAN + XAResource.TMENDRSCAN);
  -            for (int i = 0; i < prepared.length; i++) {
  -                Xid xid = prepared[i];
  -                if (ourXids.contains(xid)) {
  +
  +    public synchronized void recoverResourceManager(NamedXAResource xaResource) throws
XAException {
  +        Xid[] prepared = xaResource.recover(XAResource.TMSTARTRSCAN + XAResource.TMENDRSCAN);
  +        for (int i = 0; i < prepared.length; i++) {
  +            Xid xid = prepared[i];
  +            XidNamesPair xidNamesPair = (XidNamesPair) ourXids.get(xid.getGlobalTransactionId());
  +            if (xidNamesPair != null) {
  +                try {
                       xaResource.commit(xid, false);
  -                } else if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
  -                    //ours, but prepare not logged
  +                } catch (XAException e) {
  +                    recoveryErrors.add(e);
  +                    log.error(e);
  +                }
  +                if (!xidNamesPair.resourceNames.remove(xaResource.getName())) {
  +                    log.error("XAResource named: " + xaResource.getName() + " returned
branch xid for xid: " + xid + " but was not registered with that transaction!");
  +                }
  +                if (xidNamesPair.resourceNames.isEmpty()) {
  +                    try {
  +                        txLog.commit(xidNamesPair.xid);
  +                    } catch (LogException e) {
  +                        recoveryErrors.add(e);
  +                        log.error(e);
  +                    }
  +                }
  +            } else if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
  +                //ours, but prepare not logged
  +                try {
                       xaResource.rollback(xid);
  -                } else if (xidFactory.matchesBranchId(xid.getBranchQualifier())) {
  -                    //our branch, but we did not start this tx.
  -                    TransactionImpl externalTx = (TransactionImpl)externalGlobalIdMap.get(xid.getGlobalTransactionId());
  -                    if (externalTx == null) {
  -                        //we did not prepare this branch, rollback.
  +                } catch (XAException e) {
  +                    recoveryErrors.add(e);
  +                    log.error(e);
  +                }
  +            } else if (xidFactory.matchesBranchId(xid.getBranchQualifier())) {
  +                //our branch, but we did not start this tx.
  +                TransactionImpl externalTx = (TransactionImpl) externalGlobalIdMap.get(xid.getGlobalTransactionId());
  +                if (externalTx == null) {
  +                    //we did not prepare this branch, rollback.
  +                    try {
                           xaResource.rollback(xid);
  -                    } else {
  -                        //we prepared this branch, must wait for commit/rollback command.
  -                        externalTx.addBranchXid(xaResource, xid);
  +                    } catch (XAException e) {
  +                        recoveryErrors.add(e);
  +                        log.error(e);
                       }
  +                } else {
  +                    //we prepared this branch, must wait for commit/rollback command.
  +                    externalTx.addBranchXid(xaResource, xid);
                   }
  -                //else we had nothing to do with this xid.
               }
  +            //else we had nothing to do with this xid.
           }
  +    }
  +
  +    public synchronized boolean hasRecoveryErrors() {
  +        return !recoveryErrors.isEmpty();
  +    }
   
  +    public synchronized List getRecoveryErrors() {
  +        return Collections.unmodifiableList(recoveryErrors);
  +    }
   
  +    public synchronized boolean localRecoveryComplete() {
  +        return ourXids.isEmpty();
       }
   
  -    public Map getExternalXids() {
  +    //hard to implement.. needs ExternalTransaction to have a reference to externalXids.
  +//    public boolean remoteRecoveryComplete() {
  +//    }
  +
  +    public synchronized Map getExternalXids() {
           return new HashMap(externalXids);
  +    }
  +
  +    private static class XidNamesPair {
  +        private final Xid xid;
  +        private final Set resourceNames;
  +
  +        public XidNamesPair(Xid xid, Set resourceNames) {
  +            this.xid = xid;
  +            this.resourceNames = resourceNames;
  +        }
  +    }
  +
  +    private static class ExternalTransaction extends TransactionImpl {
  +        private Set resourceNames;
  +
  +        public ExternalTransaction(Xid xid, TransactionLog txLog, Set resourceNames) {
  +            super(xid, txLog);
  +            this.resourceNames = resourceNames;
  +        }
  +
  +        public boolean hasName(String name) {
  +            return resourceNames.contains(name);
  +        }
  +
  +        public void removeName(String name) {
  +            resourceNames.remove(name);
  +        }
  +
  +        public void preparedCommit() throws SystemException {
  +            if (!resourceNames.isEmpty()) {
  +                throw new SystemException("This tx does not have all resource managers
online, commit not allowed yet");
  +            }
  +            super.preparedCommit();
  +        }
  +
  +        public void rollback() throws SystemException {
  +            if (!resourceNames.isEmpty()) {
  +                throw new SystemException("This tx does not have all resource managers
online, rollback not allowed yet");
  +            }
  +            super.rollback();
  +
  +        }
       }
   }
  
  
  
  1.6       +27 -28    incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransactionImpl.java	6 May 2004 04:00:51 -0000	1.5
  +++ TransactionImpl.java	8 Jun 2004 17:33:42 -0000	1.6
  @@ -324,29 +324,24 @@
   
       //helper method used by Transaction.commit and XATerminator prepare.
       private boolean internalPrepare() throws SystemException {
  -        try {
  -            txnLog.prepare(xid);
  -        } catch (LogException e) {
  -            try {
  -                rollbackResources(resourceManagers);
  -            } catch (Exception se) {
  -                log.error("Unable to rollback after failure to log prepare", se.getCause());
  -            }
  -            throw (SystemException) new SystemException("Error logging prepare; transaction
was rolled back)").initCause(e);
  -        }
  -        for (Iterator i = resourceManagers.iterator(); i.hasNext();) {
  +        String[] names = new String[resourceManagers.size()];
  +        int i = 0;
  +        for (Iterator rms = resourceManagers.iterator(); rms.hasNext();) {
               synchronized (this) {
                   if (status != Status.STATUS_PREPARING) {
                       // we were marked for rollback
                       break;
                   }
               }
  -            ResourceManager manager = (ResourceManager) i.next();
  +            ResourceManager manager = (ResourceManager) rms.next();
               try {
                   int vote = manager.committer.prepare(manager.branchId);
                   if (vote == XAResource.XA_RDONLY) {
                       // we don't need to consider this RM any more
  -                    i.remove();
  +                    rms.remove();
  +                } else {
  +                    names[i] = manager.committer.getName();
  +                    i++;
                   }
               } catch (XAException e) {
                   synchronized (this) {
  @@ -365,19 +360,17 @@
           }
   
           // log our decision
  -        try {
  -            if (willCommit) {
  -                txnLog.commit(xid);
  -            } else {
  -                txnLog.rollback(xid);
  -            }
  -        } catch (LogException e) {
  +        if (willCommit) {
               try {
  -                rollbackResources(resourceManagers);
  -            } catch (Exception se) {
  -                log.error("Unable to rollback after failure to log decision", se.getCause());
  +                txnLog.prepare(xid, names);
  +            } catch (LogException e) {
  +                try {
  +                    rollbackResources(resourceManagers);
  +                } catch (Exception se) {
  +                    log.error("Unable to rollback after failure to log prepare", se.getCause());
  +                }
  +                throw (SystemException) new SystemException("Error logging prepare; transaction
was rolled back)").initCause(e);
               }
  -            throw (SystemException) new SystemException("Error logging decision (outcome
is unknown)").initCause(e);
           }
           return willCommit;
       }
  @@ -400,6 +393,7 @@
           beforeCompletion();
           endResources();
           try {
  +            rollbackResources(rms);
               try {
                   txnLog.rollback(xid);
               } catch (LogException e) {
  @@ -410,7 +404,6 @@
                   }
                   throw (SystemException) new SystemException("Error logging rollback").initCause(e);
               }
  -            rollbackResources(rms);
           } finally {
               afterCompletion();
               synchronized (this) {
  @@ -522,6 +515,12 @@
                   continue;
               }
           }
  +        try {
  +            txnLog.commit(xid);
  +        } catch (LogException e) {
  +            log.error("Unexpected exception logging commit completion for xid " + xid,
e);
  +            throw (SystemException)new SystemException("Unexpected error logging commit
completion for xid " + xid).initCause(e);
  +        }
           synchronized (this) {
               status = Status.STATUS_COMMITTED;
           }
  @@ -574,11 +573,11 @@
   
   
       private static class ResourceManager {
  -        private final XAResource committer;
  +        private final NamedXAResource committer;
           private final Xid branchId;
   
           public ResourceManager(XAResource xaRes, Xid branchId) {
  -            committer = xaRes;
  +            committer = (NamedXAResource)xaRes;
               this.branchId = branchId;
           }
       }
  
  
  
  1.5       +4 -5      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java
  
  Index: TransactionLog.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TransactionLog.java	6 May 2004 04:00:51 -0000	1.4
  +++ TransactionLog.java	8 Jun 2004 17:33:42 -0000	1.5
  @@ -17,8 +17,7 @@
   
   package org.apache.geronimo.transaction.manager;
   
  -import java.io.IOException;
  -import java.util.List;
  +import java.util.Map;
   
   import javax.transaction.xa.Xid;
   
  @@ -32,13 +31,13 @@
   
       void begin(Xid xid) throws LogException;
   
  -    void prepare(Xid xid) throws LogException;
  +    void prepare(Xid xid, String[] names) throws LogException;
   
       void commit(Xid xid) throws LogException;
   
       void rollback(Xid xid) throws LogException;
   
  -    List recover() throws LogException;
  +    Map recover(XidFactory xidFactory) throws LogException;
   
       String getXMLStats();
   
  
  
  
  1.6       +3 -1      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidFactory.java
  
  Index: XidFactory.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XidFactory.java	6 May 2004 04:00:51 -0000	1.5
  +++ XidFactory.java	8 Jun 2004 17:33:43 -0000	1.6
  @@ -16,4 +16,6 @@
       boolean matchesGlobalId(byte[] globalTransactionId);
   
       boolean matchesBranchId(byte[] branchQualifier);
  +
  +    Xid recover(int formatId, byte[] globalTransactionid, byte[] branchQualifier);
   }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java
  
  Index: XidFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XidFactoryImpl.java	2 Jun 2004 05:33:05 -0000	1.2
  +++ XidFactoryImpl.java	8 Jun 2004 17:33:43 -0000	1.3
  @@ -108,6 +108,10 @@
           return true;
       }
   
  +    public Xid recover(int formatId, byte[] globalTransactionid, byte[] branchQualifier)
{
  +        return new XidImpl2(formatId, globalTransactionid, branchQualifier);
  +    }
  +
       public static final GBeanInfo GBEAN_INFO;
   
       static {
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/NamedXAResource.java
  
  Index: NamedXAResource.java
  ===================================================================
  package org.apache.geronimo.transaction.manager;
  
  import javax.transaction.xa.XAResource;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/06/08 17:33:42 $
   *
   * */
  public interface NamedXAResource extends XAResource {
  
      String getName();
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/WrapperNamedXAResource.java
  
  Index: WrapperNamedXAResource.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.transaction.manager;
  
  import javax.transaction.xa.XAResource;
  import javax.transaction.xa.Xid;
  import javax.transaction.xa.XAException;
  
  import org.apache.geronimo.transaction.manager.NamedXAResource;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/06/08 17:33:43 $
   *
   * */
  public class WrapperNamedXAResource implements NamedXAResource {
  
      private final XAResource xaResource;
      private final String name;
  
      public WrapperNamedXAResource(XAResource xaResource, String name) {
          this.xaResource = xaResource;
          this.name = name;
      }
  
      public String getName() {
          return name;
      }
  
      public void commit(Xid xid, boolean onePhase) throws XAException {
          xaResource.commit(xid, onePhase);
      }
  
      public void end(Xid xid, int flags) throws XAException {
          xaResource.end(xid, flags);
      }
  
      public void forget(Xid xid) throws XAException {
          xaResource.forget(xid);
      }
  
      public int getTransactionTimeout() throws XAException {
          return xaResource.getTransactionTimeout();
      }
  
      public boolean isSameRM(XAResource other) throws XAException {
          if (other instanceof WrapperNamedXAResource) {
              return xaResource.isSameRM(((WrapperNamedXAResource)other).xaResource);
          }
          return false;
      }
  
      public int prepare(Xid xid) throws XAException {
          return xaResource.prepare(xid);
      }
  
      public Xid[] recover(int flag) throws XAException {
          return xaResource.recover(flag);
      }
  
      public void rollback(Xid xid) throws XAException {
          xaResource.rollback(xid);
      }
  
      public boolean setTransactionTimeout(int seconds) throws XAException {
          return xaResource.setTransactionTimeout(seconds);
      }
  
      public void start(Xid xid, int flags) throws XAException {
          xaResource.start(xid, flags);
      }
  }
  
  
  
  
  
  1.2       +5 -3      incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java
  
  Index: AbstractLogTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLogTest.java	6 May 2004 04:00:51 -0000	1.1
  +++ AbstractLogTest.java	8 Jun 2004 17:33:43 -0000	1.2
  @@ -18,9 +18,9 @@
   package org.apache.geronimo.transaction.log;
   
   import java.io.File;
  -import java.io.Writer;
   import java.io.FileWriter;
   import java.io.IOException;
  +import java.io.Writer;
   
   import javax.transaction.xa.Xid;
   
  @@ -40,6 +40,7 @@
       private int stoppedThreads = 0;
       long totalDuration = 0;
       private Xid xid;
  +    private String[] names;
       final Object mutex = new Object();
       long totalXidCount = 0;
       private Writer resultsXML;
  @@ -87,6 +88,7 @@
           TransactionLog transactionLog = createTransactionLog();
   
           xid = new XidImpl2(new byte[Xid.MAXGTRIDSIZE]);
  +        names = new String[] {"SAMPLE.NAME"};
   
           long startTime = journalTest(transactionLog, workers, xidCount);
   
  @@ -123,7 +125,7 @@
   
                           for (int i = 0; i < xidCount; i++) {
                               // journalize COMMITTING record
  -                            logger.prepare(xid);
  +                            logger.prepare(xid, names);
                               //localXidCount++;
   
                               // journalize FORGET record
  
  
  
  1.5       +7 -2      incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockResource.java
  
  Index: MockResource.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockResource.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MockResource.java	10 Mar 2004 09:59:37 -0000	1.4
  +++ MockResource.java	8 Jun 2004 17:33:43 -0000	1.5
  @@ -26,7 +26,8 @@
    *
    * @version $Revision$ $Date$
    */
  -public class MockResource implements XAResource {
  +public class MockResource implements NamedXAResource {
  +    private String name = "mockResource";
       private Xid xid;
       private MockResourceManager manager;
       private int timeout = 0;
  @@ -108,6 +109,10 @@
   
       public boolean isRolledback() {
           return rolledback;
  +    }
  +
  +    public String getName() {
  +        return name;
       }
   
   }
  
  
  
  1.5       +4 -4      incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java
  
  Index: XATransactionTester.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XATransactionTester.java	6 May 2004 04:00:51 -0000	1.4
  +++ XATransactionTester.java	8 Jun 2004 17:33:43 -0000	1.5
  @@ -19,7 +19,7 @@
   
   import java.sql.Connection;
   import java.sql.Statement;
  -import java.util.List;
  +import java.util.Map;
   
   import javax.sql.XAConnection;
   import javax.sql.XADataSource;
  @@ -104,7 +104,7 @@
               XATransactionTester.this.xid = xid;
           }
   
  -        public void prepare(Xid xid) throws LogException {
  +        public void prepare(Xid xid, String[] names) throws LogException {
           }
   
           public void commit(Xid xid) throws LogException {
  @@ -113,7 +113,7 @@
           public void rollback(Xid xid) throws LogException {
           }
   
  -        public List recover() throws LogException {
  +        public Map recover(XidFactory xidFactory) throws LogException {
               return null;
           }
   
  
  
  

Mime
View raw message