geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54973 - in geronimo/trunk/modules: connector/src/java/org/apache/geronimo/connector/outbound/transactionlog transaction/src/java/org/apache/geronimo/transaction/log transaction/src/java/org/apache/geronimo/transaction/manager transaction/src/test/org/apache/geronimo/transaction/log transaction/src/test/org/apache/geronimo/transaction/manager
Date Sun, 17 Oct 2004 20:06:11 GMT
Author: djencks
Date: Sun Oct 17 13:06:11 2004
New Revision: 54973

Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/HOWLLogTest.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/HOWLLogRecoveryTest.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockLog.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java
Log:
GERONIMO-379. Use HOWL logger recovery support so we do less work

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
Sun Oct 17 13:06:11 2004
@@ -82,7 +82,7 @@
     public void begin(Xid xid) throws LogException {
     }
 
-    public long prepare(Xid xid, List branches) throws LogException {
+    public Object prepare(Xid xid, List branches) throws LogException {
         int formatId = xid.getFormatId();
         byte[] globalTransactionId = xid.getGlobalTransactionId();
         byte[] branchQualifier = xid.getBranchQualifier();
@@ -113,10 +113,10 @@
         } catch (SQLException e) {
             throw new LogException("Failure during prepare or commit", e);
         }
-        return 0L;
+        return null;
     }
 
-    public void commit(Xid xid, long logMark) throws LogException {
+    public void commit(Xid xid, Object logMark) throws LogException {
         try {
             Connection connection = dataSource.getConnection();
             try {
@@ -141,7 +141,7 @@
         }
     }
 
-    public void rollback(Xid xid, long logMark) throws LogException {
+    public void rollback(Xid xid, Object logMark) throws LogException {
         throw new LogException("JDBCLog does not support rollback of prepared transactions.
 Use it only on servers that do not import transactions");
     }
 
@@ -167,7 +167,7 @@
                             currentXid = xidFactory.recover(formatId, globalId, globalBranchId);
                             Xid branchXid = xidFactory.recover(formatId, globalId, branchBranchId);
                             if (!currentXid.equals(lastXid)) {
-                                xidBranchesPair = new Recovery.XidBranchesPair(currentXid,
0L);
+                                xidBranchesPair = new Recovery.XidBranchesPair(currentXid,
null);
                                 recovered.add(xidBranchesPair);
                                 lastXid = currentXid;
                             }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
Sun Oct 17 13:06:11 2004
@@ -24,9 +24,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
 import javax.transaction.xa.Xid;
 
 import org.apache.commons.logging.Log;
@@ -43,15 +40,16 @@
 import org.apache.geronimo.transaction.manager.TransactionLog;
 import org.apache.geronimo.transaction.manager.XidFactory;
 import org.objectweb.howl.log.Configuration;
-import org.objectweb.howl.log.InvalidLogKeyException;
 import org.objectweb.howl.log.LogClosedException;
 import org.objectweb.howl.log.LogConfigurationException;
 import org.objectweb.howl.log.LogFileOverflowException;
 import org.objectweb.howl.log.LogRecord;
 import org.objectweb.howl.log.LogRecordSizeException;
 import org.objectweb.howl.log.LogRecordType;
-import org.objectweb.howl.log.Logger;
 import org.objectweb.howl.log.ReplayListener;
+import org.objectweb.howl.log.xa.XACommittingTx;
+import org.objectweb.howl.log.xa.XALogger;
+import org.objectweb.howl.log.xa.XALogRecord;
 
 /**
  * @version $Rev$ $Date$
@@ -68,11 +66,12 @@
     private final ServerInfo serverInfo;
     private String logFileDir;
 
-    private final Logger logger;
+    private final XidFactory xidFactory;
+
+    private final XALogger logger;
     private final Configuration configuration = new Configuration();
     private boolean started = false;
-
-    private final SortedSet marks = new TreeSet();
+    private HashMap recovered;
 
     public HOWLLog(String bufferClassName,
                    int bufferSize,
@@ -86,6 +85,7 @@
                    int maxLogFiles,
                    int minBuffers,
                    int threadsWaitingForceThreshold,
+                   XidFactory xidFactory,
                    ServerInfo serverInfo) throws IOException, LogConfigurationException {
         this.serverInfo = serverInfo;
         setBufferClassName(bufferClassName);
@@ -101,7 +101,8 @@
         setMaxLogFiles(maxLogFiles);
         setMinBuffers(minBuffers);
         setThreadsWaitingForceThreshold(threadsWaitingForceThreshold);
-        this.logger = new Logger(configuration);
+        this.xidFactory = xidFactory;
+        this.logger = new XALogger(configuration);
     }
 
     public String getLogFileDir() {
@@ -210,13 +211,21 @@
     public void doStart() throws WaitingException, Exception {
         started = true;
         setLogFileDir(logFileDir);
+        log.info("Initiating transaction manager recovery");
+        recovered = new HashMap();
+
+        logger.open(null);
 
-        logger.open();
+        ReplayListener replayListener = new GeronimoReplayListener(xidFactory, recovered);
+        logger.replayActiveTx(replayListener);
+
+        log.info("In doubt transactions recovered from log");
     }
 
     public void doStop() throws WaitingException, Exception {
         started = false;
         logger.close();
+        recovered = null;
     }
 
     public void doFail() {
@@ -225,7 +234,7 @@
     public void begin(Xid xid) throws LogException {
     }
 
-    public long prepare(Xid xid, List branches) throws LogException {
+    public Object prepare(Xid xid, List branches) throws LogException {
         int branchCount = branches.size();
         byte[][] data = new byte[4 + 2 * branchCount][];
         data[0] = new byte[]{PREPARE};
@@ -239,9 +248,8 @@
             data[i++] = transactionBranchInfo.getResourceName().getBytes();
         }
         try {
-            long logMark = logger.put(data, true);
-            addMark(logMark);
-            return logMark;
+            XACommittingTx committingTx = logger.putCommit(data);
+            return committingTx;
         } catch (LogClosedException e) {
             throw (IllegalStateException) new IllegalStateException().initCause(e);
         } catch (LogRecordSizeException e) {
@@ -255,24 +263,14 @@
         }
     }
 
-    private void addMark(long logMark) {
-        synchronized (marks) {
-            marks.add(new Long(logMark));
-        }
-    }
-
-    public void commit(Xid xid, long logMark) throws LogException {
+    public void commit(Xid xid, Object logMark) throws LogException {
         byte[][] data = new byte[4][];
         data[0] = new byte[]{COMMIT};
         data[1] = intToBytes(xid.getFormatId());
         data[2] = xid.getGlobalTransactionId();
         data[3] = xid.getBranchQualifier();
         try {
-            logger.put(data, false);
-            boolean doMark = removeMark(logMark);
-            if (doMark) {
-                logger.mark(logMark);
-            }
+            logger.putDone(data, (XACommittingTx) logMark);
         } catch (LogClosedException e) {
             throw (IllegalStateException) new IllegalStateException().initCause(e);
         } catch (LogRecordSizeException e) {
@@ -283,23 +281,17 @@
             throw (IllegalStateException) new IllegalStateException().initCause(e);
         } catch (IOException e) {
             throw new LogException(e);
-        } catch (InvalidLogKeyException e) {
-            throw new LogException(e);
         }
     }
 
-    public void rollback(Xid xid, long logMark) throws LogException {
+    public void rollback(Xid xid, Object logMark) throws LogException {
         byte[][] data = new byte[4][];
         data[0] = new byte[]{ROLLBACK};
         data[1] = intToBytes(xid.getFormatId());
         data[2] = xid.getGlobalTransactionId();
         data[3] = xid.getBranchQualifier();
         try {
-            logger.put(data, false);
-            boolean doMark = removeMark(logMark);
-            if (doMark) {
-                logger.mark(logMark);
-            }
+            logger.putDone(data, (XACommittingTx) logMark);
         } catch (LogClosedException e) {
             throw (IllegalStateException) new IllegalStateException().initCause(e);
         } catch (LogRecordSizeException e) {
@@ -310,33 +302,10 @@
             throw (IllegalStateException) new IllegalStateException().initCause(e);
         } catch (IOException e) {
             throw new LogException(e);
-        } catch (InvalidLogKeyException e) {
-            throw new LogException(e);
         }
     }
 
-    private boolean removeMark(long logMark) {
-        boolean doMark = false;
-        Long mark = new Long(logMark);
-        synchronized (marks) {
-            if (!marks.isEmpty()) {
-                doMark = (mark.equals(marks.first()));
-                marks.remove(mark);
-            }
-        }
-        return doMark;
-    }
-
     public Collection recover(XidFactory xidFactory) throws LogException {
-        log.info("Initiating transaction manager recovery");
-        Map recovered = new HashMap();
-        ReplayListener replayListener = new GeronimoReplayListener(xidFactory, recovered);
-        try {
-            logger.replay(replayListener);
-        } catch (LogConfigurationException e) {
-            throw new LogException(e);
-        }
-        log.info("In doubt transactions recovered from log");
         return recovered.values();
     }
 
@@ -361,6 +330,10 @@
         return buffer;
     }
 
+    private int bytesToInt(byte[] buffer) {
+        return ((int) buffer[0]) << 24 + ((int) buffer[1]) << 16 + ((int) buffer[2])
<< 8 + ((int) buffer[3]) << 0;
+    }
+
     private class GeronimoReplayListener implements ReplayListener {
 
         private final XidFactory xidFactory;
@@ -371,60 +344,36 @@
             this.recoveredTx = recoveredTx;
         }
 
-        public void onRecord(LogRecord lr) {
+        public void onRecord(LogRecord plainlr) {
+            XALogRecord lr = (XALogRecord) plainlr;
             short recordType = lr.type;
-            long logMark = lr.key;
-            if (recordType == LogRecordType.USER) {
-                ByteBuffer raw = lr.dataBuffer;
-                if (raw.remaining() == 0) {
-                    log.warn("Received empty log record of user type!");
-                    return;
-                }
-                //type (PREPARE etc)
-                short size = raw.getShort();
-                assert size == 1;
-                byte type = raw.get();
-                //format id integer
-                size = raw.getShort();
-                assert size == 4;
-                int formatId = raw.getInt();
-                //global id
-                int globalIdLength = raw.getShort();
-                byte[] globalId = new byte[globalIdLength];
-                raw.get(globalId);
-                //branch qualifier for master xid
-                int branchIdLength = raw.getShort();
-                byte[] branchId = new byte[branchIdLength];
-                raw.get(branchId);
+            XACommittingTx tx = lr.getTx();
+            if (recordType == LogRecordType.XACOMMIT) {
+
+                byte[][] data = tx.getRecord();
+
+                //first byte is our type, which always should be COMMIT
+                assert data[0].length == 1;
+
+                assert data[1].length == 4;
+                int formatId = bytesToInt(data[1]);
+                byte[] globalId = data[2];
+                byte[] branchId = data[3];
                 Xid masterXid = xidFactory.recover(formatId, globalId, branchId);
-                if (type == PREPARE) {
-                    Recovery.XidBranchesPair xidBranchesPair = new Recovery.XidBranchesPair(masterXid,
logMark);
-                    recoveredTx.put(masterXid, xidBranchesPair);
-                    addMark(logMark);
-//                log.info("recovered prepare record for master xid: " + masterXid);
-                    while (raw.hasRemaining()) {
-                        int branchBranchIdLength = raw.getShort();
-                        byte[] branchBranchId = new byte[branchBranchIdLength];
-                        raw.get(branchBranchId);
-                        Xid branchXid = xidFactory.recover(formatId, globalId, branchBranchId);
-                        int nameLength = raw.getShort();
-                        byte[] nameBytes = new byte[nameLength];
-                        raw.get(nameBytes);
-                        String name = new String(nameBytes);
-                        TransactionBranchInfoImpl branchInfo = new TransactionBranchInfoImpl(branchXid,
name);
-                        xidBranchesPair.addBranch(branchInfo);
-//                    log.info("recovered branch for resource manager, branchId " + name
+ ", " + branchXid);
-                    }
-                } else if (type == COMMIT || type == ROLLBACK) {
-                    recoveredTx.remove(masterXid);
-                    removeMark(logMark);
-//                log.info("Recovered " + TYPE_NAMES[type] + " for xid: " + masterXid + "
and branches: " + o);
-                } else {
-                    log.error("Unknown recovery record received, type byte: " + type + ",
buffer: " + raw);
-                }
-            } else if (recordType == LogRecordType.MARKKEY) {
 
-            } else if (recordType != LogRecordType.END_OF_LOG) {
+                Recovery.XidBranchesPair xidBranchesPair = new Recovery.XidBranchesPair(masterXid,
tx);
+                recoveredTx.put(masterXid, xidBranchesPair);
+                log.info("recovered prepare record for master xid: " + masterXid);
+                for (int i = 4; i < data.length; i += 2) {
+                    byte[] branchBranchId = data[i];
+                    String name = new String(data[i + 1]);
+
+                    Xid branchXid = xidFactory.recover(formatId, globalId, branchBranchId);
+                    TransactionBranchInfoImpl branchInfo = new TransactionBranchInfoImpl(branchXid,
name);
+                    xidBranchesPair.addBranch(branchInfo);
+                    log.info("recovered branch for resource manager, branchId " + name +
", " + branchXid);
+                }
+            } else {
                 log.warn("Received unexpected log record: " + lr);
             }
         }
@@ -457,6 +406,7 @@
         infoFactory.addAttribute("minBuffers", Integer.TYPE, true);
         infoFactory.addAttribute("threadsWaitingForceThreshold", Integer.TYPE, true);
 
+        infoFactory.addReference("XidFactory", XidFactory.class);
         infoFactory.addReference("serverInfo", ServerInfo.class);
 
         infoFactory.addInterface(TransactionLog.class);
@@ -474,6 +424,7 @@
             "maxLogFiles",
             "minBuffers",
             "threadsWaitingForceThreshold",
+            "XidFactory",
             "serverInfo"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
Sun Oct 17 13:06:11 2004
@@ -38,14 +38,14 @@
     public void begin(Xid xid) throws LogException {
     }
 
-    public long prepare(Xid xid, List branches) throws LogException {
-        return 0L;
+    public Object prepare(Xid xid, List branches) throws LogException {
+        return null;
     }
 
-    public void commit(Xid xid, long logMark) throws LogException {
+    public void commit(Xid xid, Object logMark) throws LogException {
     }
 
-    public void rollback(Xid xid, long logMark) throws LogException {
+    public void rollback(Xid xid, Object logMark) throws LogException {
     }
 
     public Collection recover(XidFactory xidFactory) throws LogException {

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
Sun Oct 17 13:06:11 2004
@@ -55,9 +55,9 @@
         //set of TransactionBranchInfo
         private final Set branches = new HashSet();
 
-        private final long mark;
+        private final Object mark;
 
-        public XidBranchesPair(Xid xid, long mark) {
+        public XidBranchesPair(Xid xid, Object mark) {
             this.xid = xid;
             this.mark = mark;
         }
@@ -70,7 +70,7 @@
             return branches;
         }
 
-        public long getMark() {
+        public Object getMark() {
             return mark;
         }
 

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Sun Oct 17 13:06:11 2004
@@ -54,7 +54,7 @@
     private List syncList = new ArrayList(5);
     private LinkedList resourceManagers = new LinkedList();
     private Map xaResources = new HashMap(3);
-    private long logMark;
+    private Object logMark;
 
     TransactionImpl(XidFactory xidFactory, TransactionLog txnLog) throws SystemException
{
         this(xidFactory.createXid(), xidFactory, txnLog);
@@ -404,15 +404,18 @@
         endResources();
         try {
             rollbackResources(rms);
-            try {
-                txnLog.rollback(xid, logMark);
-            } catch (LogException e) {
+            //only write rollback record if we have already written prepare record.
+            if (logMark != null) {
                 try {
-                    rollbackResources(rms);
-                } catch (Exception se) {
-                    log.error("Unable to rollback after failure to log decision", se.getCause());
+                    txnLog.rollback(xid, logMark);
+                } catch (LogException e) {
+                    try {
+                        rollbackResources(rms);
+                    } catch (Exception se) {
+                        log.error("Unable to rollback after failure to log decision", se.getCause());
+                    }
+                    throw (SystemException) new SystemException("Error logging rollback").initCause(e);
                 }
-                throw (SystemException) new SystemException("Error logging rollback").initCause(e);
             }
         } finally {
             afterCompletion();

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionLog.java
Sun Oct 17 13:06:11 2004
@@ -38,11 +38,11 @@
      * @param branches List of TransactionBranchInfo
      * @throws LogException
      */
-    long prepare(Xid xid, List branches) throws LogException;
+    Object prepare(Xid xid, List branches) throws LogException;
 
-    void commit(Xid xid, long logMark) throws LogException;
+    void commit(Xid xid, Object logMark) throws LogException;
 
-    void rollback(Xid xid, long logMark) throws LogException;
+    void rollback(Xid xid, Object logMark) throws LogException;
 
     /**
      * Recovers the log, returning a map of (top level) xid to List of TransactionBranchInfo
for the branches.

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/AbstractLogTest.java
Sun Oct 17 13:06:11 2004
@@ -130,7 +130,7 @@
 
                         for (int i = 0; i < xidCount; i++) {
                             // journalize COMMITTING record
-                            long logMark = logger.prepare(xid, names);
+                            Object logMark = logger.prepare(xid, names);
                             //localXidCount++;
 
                             // journalize FORGET record

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/HOWLLogTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/HOWLLogTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/log/HOWLLogTest.java
Sun Oct 17 13:06:11 2004
@@ -23,6 +23,8 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.geronimo.transaction.manager.TransactionLog;
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
 /**
@@ -46,6 +48,7 @@
 
 
     protected TransactionLog createTransactionLog() throws Exception {
+        XidFactory xidFactory = new XidFactoryImpl();
         HOWLLog howlLog = new HOWLLog(
                 "org.objectweb.howl.log.BlockLogBuffer", //                "bufferClassName",
                 4, //                "bufferSizeKBytes",
@@ -59,7 +62,7 @@
                 2, //                "maxLogFiles",
                 2, //                "minBuffers",
                 10,//                "threadsWaitingForceThreshold"});
-                new ServerInfo(new File(basedir, "target").getAbsolutePath())
+                xidFactory, new ServerInfo(new File(basedir, "target").getAbsolutePath())
         );
         howlLog.doStart();
         return howlLog;

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
Sun Oct 17 13:06:11 2004
@@ -37,7 +37,7 @@
 
     protected TransactionLog txLog;
 
-    private final XidFactory xidFactory = new XidFactoryImpl();
+    protected final XidFactory xidFactory = new XidFactoryImpl();
     private static final String RM1 = "rm1";
     private static final String RM2 = "rm2";
     private static final String RM3 = "rm3";

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/HOWLLogRecoveryTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/HOWLLogRecoveryTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/HOWLLogRecoveryTest.java
Sun Oct 17 13:06:11 2004
@@ -34,6 +34,8 @@
 public class HOWLLogRecoveryTest extends AbstractRecoveryTest {
     private static final File basedir = new File(System.getProperty("basedir", System.getProperty("user.dir")));
     private static final String LOG_FILE_NAME = "howl_test_";
+    private static final String logFileDir = "txlog";
+    private String targetDir;
 
     public void test2Again() throws Exception {
         test2ResOnlineAfterRecoveryStart();
@@ -45,13 +47,17 @@
 
     protected void setUp() throws Exception {
         // Deletes the previous transaction log files.
-        String logFileDir = "txlog";
-        File[] files = new File(logFileDir).listFiles();
+        File[] files = new File(targetDir, logFileDir).listFiles();
         if ( null != files ) {
             for (int i = 0; i < files.length; i++) {
                 files[i].delete();
             }
         }
+        setUpHowlLog();
+    }
+
+    private void setUpHowlLog() throws Exception {
+        targetDir = new File(basedir, "target").getAbsolutePath();
         HOWLLog howlLog = new HOWLLog(
                 "org.objectweb.howl.log.BlockLogBuffer", //                "bufferClassName",
                 4, //                "bufferSizeKBytes",
@@ -65,7 +71,8 @@
                 2, //                "maxLogFiles",
                 2, //                "minBuffers",
                 10,//                "threadsWaitingForceThreshold"});
-                new ServerInfo(new File(basedir, "target").getAbsolutePath())
+                xidFactory,
+                new ServerInfo(targetDir)
         );
         howlLog.doStart();
         txLog = howlLog;
@@ -78,7 +85,7 @@
 
     protected void prepareForReplay() throws Exception {
         tearDown();
-        setUp();
+        setUpHowlLog();
     }
 
     public static Test suite() {

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockLog.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockLog.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/MockLog.java
Sun Oct 17 13:06:11 2004
@@ -40,18 +40,19 @@
     public void begin(Xid xid) throws LogException {
     }
 
-    public long prepare(Xid xid, List branches) throws LogException {
-        Recovery.XidBranchesPair xidBranchesPair = new Recovery.XidBranchesPair(xid, 0L);
+    public Object prepare(Xid xid, List branches) throws LogException {
+        Object mark = new Object();
+        Recovery.XidBranchesPair xidBranchesPair = new Recovery.XidBranchesPair(xid, mark);
         xidBranchesPair.getBranches().addAll(branches);
         prepared.put(xid, xidBranchesPair);
-        return 0L;
+        return mark;
     }
 
-    public void commit(Xid xid, long logMark) throws LogException {
+    public void commit(Xid xid, Object logMark) throws LogException {
         committed.add(xid);
     }
 
-    public void rollback(Xid xid, long logMark) throws LogException {
+    public void rollback(Xid xid, Object logMark) throws LogException {
         rolledBack.add(xid);
     }
 

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XATransactionTester.java
Sun Oct 17 13:06:11 2004
@@ -109,14 +109,14 @@
             XATransactionTester.this.xid = xid;
         }
 
-        public long prepare(Xid xid, List branches) throws LogException {
-            return 0L;
+        public Object prepare(Xid xid, List branches) throws LogException {
+            return new Object();
         }
 
-        public void commit(Xid xid, long logMark) throws LogException {
+        public void commit(Xid xid, Object logMark) throws LogException {
         }
 
-        public void rollback(Xid xid, long logMark) throws LogException {
+        public void rollback(Xid xid, Object logMark) throws LogException {
         }
 
         public Collection recover(XidFactory xidFactory) throws LogException {

Mime
View raw message