geronimo-scm mailing list archives

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

Modified:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/HOWLLogRecoveryTest.java
Log:
further simplification of howl logger usage

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:26:44 2004
@@ -18,7 +18,6 @@
 package org.apache.geronimo.transaction.log;
 
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -48,16 +47,17 @@
 import org.objectweb.howl.log.LogRecordType;
 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;
+import org.objectweb.howl.log.xa.XALogger;
 
 /**
  * @version $Rev$ $Date$
  */
 public class HOWLLog implements TransactionLog, GBeanLifecycle {
-    static final byte PREPARE = 1;
-    static final byte COMMIT = 2;
-    static final byte ROLLBACK = 3;
+//    static final byte PREPARE = 1;
+    //these are used as debugging aids only
+    private static final byte COMMIT = 2;
+    private static final byte ROLLBACK = 3;
 
     static final String[] TYPE_NAMES = {null, "PREPARE", "COMMIT", "ROLLBACK"};
 
@@ -236,12 +236,11 @@
 
     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};
-        data[1] = intToBytes(xid.getFormatId());
-        data[2] = xid.getGlobalTransactionId();
-        data[3] = xid.getBranchQualifier();
-        int i = 4;
+        byte[][] data = new byte[3 + 2 * branchCount][];
+        data[0] = intToBytes(xid.getFormatId());
+        data[1] = xid.getGlobalTransactionId();
+        data[2] = xid.getBranchQualifier();
+        int i = 3;
         for (Iterator iterator = branches.iterator(); iterator.hasNext();) {
             TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) iterator.next();
             data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier();
@@ -264,6 +263,7 @@
     }
 
     public void commit(Xid xid, Object logMark) throws LogException {
+        //the data is theoretically unnecessary but is included to help with debugging and
because HOWL currently requires it.
         byte[][] data = new byte[4][];
         data[0] = new byte[]{COMMIT};
         data[1] = intToBytes(xid.getFormatId());
@@ -285,6 +285,7 @@
     }
 
     public void rollback(Xid xid, Object logMark) throws LogException {
+        //the data is theoretically unnecessary but is included to help with debugging and
because HOWL currently requires it.
         byte[][] data = new byte[4][];
         data[0] = new byte[]{ROLLBACK};
         data[1] = intToBytes(xid.getFormatId());
@@ -352,19 +353,16 @@
 
                 byte[][] data = tx.getRecord();
 
-                //first byte is our type, which always should be COMMIT
-                assert data[0].length == 1;
-
-                assert data[1].length == 4;
+                assert data[0].length == 4;
                 int formatId = bytesToInt(data[1]);
-                byte[] globalId = data[2];
-                byte[] branchId = data[3];
+                byte[] globalId = data[1];
+                byte[] branchId = data[2];
                 Xid masterXid = xidFactory.recover(formatId, globalId, branchId);
 
                 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) {
+                for (int i = 3; i < data.length; i += 2) {
                     byte[] branchBranchId = data[i];
                     String name = new String(data[i + 1]);
 

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:26:44 2004
@@ -35,7 +35,8 @@
     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;
+    private static final String targetDir = new File(basedir, "target").getAbsolutePath();
+    private static final File txlogDir = new File(basedir, "target/" + logFileDir);
 
     public void test2Again() throws Exception {
         test2ResOnlineAfterRecoveryStart();
@@ -47,7 +48,7 @@
 
     protected void setUp() throws Exception {
         // Deletes the previous transaction log files.
-        File[] files = new File(targetDir, logFileDir).listFiles();
+        File[] files = txlogDir.listFiles();
         if ( null != files ) {
             for (int i = 0; i < files.length; i++) {
                 files[i].delete();
@@ -57,7 +58,6 @@
     }
 
     private void setUpHowlLog() throws Exception {
-        targetDir = new File(basedir, "target").getAbsolutePath();
         HOWLLog howlLog = new HOWLLog(
                 "org.objectweb.howl.log.BlockLogBuffer", //                "bufferClassName",
                 4, //                "bufferSizeKBytes",
@@ -91,11 +91,11 @@
     public static Test suite() {
         return new TestSetup(new TestSuite(HOWLLogRecoveryTest.class)) {
             protected void setUp() throws Exception {
-                File logFile = new File(basedir, "target/" + LOG_FILE_NAME + "_1.log");
+                File logFile = new File(txlogDir, LOG_FILE_NAME + "_1.log");
                 if (logFile.exists()) {
                     logFile.delete();
                 }
-                logFile = new File(basedir, "target/" + LOG_FILE_NAME + "_2.log");
+                logFile = new File(txlogDir, LOG_FILE_NAME + "_2.log");
                 if (logFile.exists()) {
                     logFile.delete();
                 }

Mime
View raw message