[jboss-cvs] JBoss Messaging SVN: r4694 - in trunk: tests/src/org/jboss/messaging/tests/unit/core/journal/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jul 18 13:21:43 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-07-18 13:21:42 -0400 (Fri, 18 Jul 2008)
New Revision: 4694

Modified:
   trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/EasyMockJournalTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
Log:
More Journal work

Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-07-18 15:02:09 UTC (rev 4693)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-07-18 17:21:42 UTC (rev 4694)
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -119,15 +120,17 @@
    
    public static final byte DELETE_RECORD_TX = 16;
    
-   public static final int SIZE_PREPARE_RECORD = BASIC_SIZE + SIZE_LONG + SIZE_INT;
+   public static final int SIZE_COMPLETE_TRANSACTION_RECORD = BASIC_SIZE + SIZE_INT + SIZE_LONG; // + NumerOfElements*SIZE_INT*2
    
+   public static final int SIZE_PREPARE_RECORD = SIZE_COMPLETE_TRANSACTION_RECORD;
+   
    public static final byte PREPARE_RECORD = 17;
    
-   public static final int SIZE_COMMIT_RECORD = BASIC_SIZE + SIZE_LONG + SIZE_INT;
+   public static final int SIZE_COMMIT_RECORD = SIZE_PREPARE_RECORD;
    
    public static final byte COMMIT_RECORD = 18;
    
-   public static final int SIZE_ROLLBACK_RECORD = BASIC_SIZE + SIZE_LONG + SIZE_INT;
+   public static final int SIZE_ROLLBACK_RECORD = BASIC_SIZE + SIZE_LONG;
    
    public static final byte ROLLBACK_RECORD = 19;
    
@@ -567,22 +570,11 @@
          throw new IllegalStateException("Cannot find tx with id " + txID);
       }
       
-      int size = SIZE_PREPARE_RECORD;
+      JournalFile usedFile = writeTransaction(PREPARE_RECORD, txID, tx);
       
-      ByteBuffer bb = fileFactory.newBuffer(size); 
-      
-      bb.put(PREPARE_RECORD);    
-      bb.position(SIZE_BYTE + SIZE_INT); // skip ID part
-      bb.putLong(txID);
-      bb.putInt(tx.getNumberOfElements());
-      bb.putInt(size);           
-      bb.rewind();
-      
-      JournalFile usedFile = appendRecord(bb, syncTransactional, getTransactionCallback(txID));
-      
       tx.prepare(usedFile);
    }
-   
+
    public void appendCommitRecord(final long txID) throws Exception
    {
       if (state != STATE_LOADED)
@@ -597,19 +589,8 @@
          throw new IllegalStateException("Cannot find tx with id " + txID);
       }
       
-      int size = SIZE_COMMIT_RECORD;
+      JournalFile usedFile = writeTransaction(COMMIT_RECORD, txID, tx);
       
-      ByteBuffer bb = fileFactory.newBuffer(size); 
-      
-      bb.put(COMMIT_RECORD);     
-      bb.position(SIZE_BYTE + SIZE_INT); // skip ID part
-      bb.putLong(txID);
-      bb.putInt(tx.getNumberOfElements());
-      bb.putInt(size);           
-      bb.rewind();
-      
-      JournalFile usedFile = appendRecord(bb, syncTransactional, getTransactionCallback(txID));
-      
       transactionCallbacks.remove(txID);
       
       tx.commit(usedFile);
@@ -637,7 +618,6 @@
       bb.put(ROLLBACK_RECORD);      
       bb.position(SIZE_BYTE + SIZE_INT); // skip ID part
       bb.putLong(txID);
-      bb.putInt(tx.getNumberOfElements());
       bb.putInt(size);        
       bb.rewind();
       
@@ -740,7 +720,6 @@
             final int pos = bb.position();
             
             byte recordType = bb.get();
-            
             if (recordType < ADD_RECORD || recordType > ROLLBACK_RECORD)
             {
                if (trace)
@@ -774,7 +753,6 @@
                }
                transactionID = bb.getLong();
                maxTransactionID = Math.max(maxTransactionID, transactionID); 
-               
             }
             
             long recordID = 0;
@@ -786,10 +764,8 @@
                }
                recordID = bb.getLong();
                maxMessageID = Math.max(maxMessageID, recordID);
-               
             }
             
-            
             // The variable record portion used on Updates and Appends
             int variableSize = 0;
             byte userRecordType = 0;
@@ -815,6 +791,11 @@
                bb.get(record);
             }
             
+            if (recordType == PREPARE_RECORD || recordType == COMMIT_RECORD)
+            {
+               variableSize = bb.getInt() * SIZE_INT * 2;
+            }
+            
             int recordSize = getRecordSize(recordType);
             
             if (pos + recordSize + variableSize > fileSize)
@@ -938,55 +919,67 @@
                }  
                case PREPARE_RECORD:
                {
-                  int numberOfElements = bb.getInt();
-                  
                   TransactionHolder tx = transactions.get(transactionID);
                   
-                  if (tx == null)
-                  {
-                     throw new IllegalStateException("Cannot find tx with id " + transactionID);
-                  }
-                  
-                  tx.prepared = true;
-                  
-                  JournalTransaction journalTransaction = transactionInfos.get(transactionID);
-                  
-                  if (journalTransaction == null)
-                  {
-                     throw new IllegalStateException("Cannot find tx " + transactionID);
-                  }
+                  // We need to read it even if transaction was not found, or the reading checks would fail
+                  // Pair <OrderId, NumberOfElements>
+                  Pair<Integer, Integer>[] values = readReferencesOnTransaction(variableSize, bb);
 
-                  if (numberOfElements == journalTransaction.getNumberOfElements())
+                  if (tx != null)
                   {
-                     journalTransaction.prepare(file);
+                     
+                     tx.prepared = true;
+                     
+                     JournalTransaction journalTransaction = transactionInfos.get(transactionID);
+                     
+                     if (journalTransaction == null)
+                     {
+                        throw new IllegalStateException("Cannot find tx " + transactionID);
+                     }
+                     
+                     
+                     boolean healthy = checkTransactionHealth(
+                           journalTransaction, orderedFiles, values);
+                     
+                     if (healthy)
+                     {
+                        journalTransaction.prepare(file);
+                     }
+                     else
+                     {
+                        log.warn("Prepared transaction " + healthy + " wasn't considered completed, it will be ignored");
+                        journalTransaction.setInvalid(true);
+                        tx.invalid = true;
+                     }
+                     
+                     hasData = true;
                   }
-                  else
-                  {
-                     journalTransaction.setInvalid(true);
-                     tx.invalid = true;
-                  }
                   
-                  hasData = true;         
-                  
                   break;
                }
                case COMMIT_RECORD:
                {
-                  int numberOfElements = bb.getInt();
-                  
                   TransactionHolder tx = transactions.remove(transactionID);
                   
+                  // We need to read it even if transaction was not found, or the reading checks would fail
+                  // Pair <OrderId, NumberOfElements>
+                  Pair<Integer, Integer>[] values = readReferencesOnTransaction(variableSize, bb);
+
                   if (tx != null)
                   {
                      
-                     JournalTransaction tnp = transactionInfos.remove(transactionID);
+                     JournalTransaction journalTransaction = transactionInfos.remove(transactionID);
                      
-                     if (tnp == null)
+                     if (journalTransaction == null)
                      {
                         throw new IllegalStateException("Cannot find tx " + transactionID);
                      }
+
+                     boolean healthy = checkTransactionHealth(
+                           journalTransaction, orderedFiles, values);
                      
-                     if (numberOfElements == tnp.getNumberOfElements())
+                     
+                     if (healthy)
                      {
                         for (RecordInfo txRecord: tx.recordInfos)
                         {
@@ -1004,12 +997,12 @@
                         {
                            loadManager.deleteRecord(deleteValue);
                         }
-                        tnp.commit(file);       
+                        journalTransaction.commit(file);       
                      }
                      else
                      {
-                        log.warn("Transaction " + transactionID + " is missing " + (numberOfElements - tnp.getNumberOfElements()) + " so the transaction is being ignored");
-                        tnp.rollback(file);
+                        log.warn("Transaction " + transactionID + " is missing elements so the transaction is being ignored");
+                        journalTransaction.rollback(file);
                      }
                      
                      hasData = true;         
@@ -1019,8 +1012,6 @@
                }
                case ROLLBACK_RECORD:
                {
-                  /* int numberOfElements = */ bb.getInt(); // Not being currently used
-                  
                   TransactionHolder tx = transactions.remove(transactionID);
                   
                   if (tx != null)
@@ -1465,6 +1456,83 @@
    // Public -----------------------------------------------------------------------------
    
    // Private -----------------------------------------------------------------------------
+
+   @SuppressWarnings("unchecked")
+   private Pair<Integer, Integer>[] readReferencesOnTransaction(int variableSize, ByteBuffer bb)
+   {
+      int numberOfFiles = variableSize / (SIZE_INT * 2);
+      Pair<Integer, Integer> values[] = (Pair<Integer, Integer> [])new Pair[numberOfFiles];
+      for (int i = 0; i < numberOfFiles; i++)
+      {
+         values[i] = new Pair(bb.getInt(), bb.getInt());
+      }
+      return values;
+   }
+
+   private boolean checkTransactionHealth(
+         JournalTransaction journalTransaction, List<JournalFile> orderedFiles,
+         Pair<Integer, Integer>[] readReferences)
+   {
+      boolean healthy = true;
+      Map<Integer, AtomicInteger> refMap = journalTransaction.getElementsSummary();
+      
+      for (Pair<Integer, Integer> ref: readReferences)
+      {
+         AtomicInteger counter = refMap.get(ref.a);
+         if (counter == null)
+         {
+            // Couldn't find the counter, but if part of the transaction was reclaimed it is ok!
+            boolean found = false;
+            for (JournalFile lookupFile: orderedFiles)
+            {
+               if (lookupFile.getOrderingID() == ref.a)
+               {
+                  found = true;
+               }
+            }
+            if (found)
+            {
+               healthy = false;
+               break;
+            }
+         }
+         else
+         {
+            if (counter.get() != ref.b)
+            {
+               healthy = false;
+               break;
+            }
+         }
+      }
+      return healthy;
+   }
+
+   /** a method that shares the logic of writing a complete transaction between COMMIT and PREPARE */
+   private JournalFile writeTransaction(final byte recordType, final long txID, final JournalTransaction tx) throws Exception
+   {
+      int size = SIZE_COMPLETE_TRANSACTION_RECORD + tx.getElementsSummary().size() * SIZE_INT * 2;
+      
+      ByteBuffer bb = fileFactory.newBuffer(size); 
+      
+      bb.put(recordType);    
+      bb.position(SIZE_BYTE + SIZE_INT); // skip ID part
+      bb.putLong(txID);
+      
+      bb.putInt(tx.getElementsSummary().size());
+      
+      for (Map.Entry<Integer, AtomicInteger> entry: tx.getElementsSummary().entrySet())
+      {
+         bb.putInt(entry.getKey());
+         bb.putInt(entry.getValue().get());
+      }
+      
+      bb.putInt(size);           
+      bb.rewind();
+      
+      JournalFile usedFile = appendRecord(bb, syncTransactional, getTransactionCallback(txID));
+      return usedFile;
+   }
    
    private boolean isTransaction(final byte recordType)
    {
@@ -1930,15 +1998,10 @@
       
       // Number of elements participating on the transaction
       // Used to verify completion on reload
-      private final AtomicInteger numberOfElements = new AtomicInteger(0);
+      private final Map<Integer, AtomicInteger> numberOfElements = new HashMap<Integer, AtomicInteger>();
       
       private boolean invalid = false;
       
-      public int getNumberOfElements()
-      {
-         return numberOfElements.get();
-      }
-      
       public void setInvalid(boolean b)
       {
          this.invalid = b;
@@ -1949,9 +2012,15 @@
          return this.invalid;
       }
 
+      
+      public Map<Integer, AtomicInteger> getElementsSummary()
+      {
+         return numberOfElements;
+      }
+
       public void addPositive(final JournalFile file, final long id)
       {
-         numberOfElements.incrementAndGet();
+         getCounter(file).incrementAndGet();
 
          addTXPosCount(file);          
          
@@ -1964,8 +2033,8 @@
       }
       
       public void addNegative(final JournalFile file, final long id)
-      {        
-         numberOfElements.incrementAndGet();
+      {
+         getCounter(file).incrementAndGet();
 
          addTXPosCount(file);    
          
@@ -2069,6 +2138,19 @@
          }  
       }
       
+      private AtomicInteger getCounter(JournalFile file)
+      {
+         AtomicInteger value = numberOfElements.get(file.getOrderingID());
+         
+         if (value == null)
+         {
+            value = new AtomicInteger();
+            numberOfElements.put(file.getOrderingID(), value);
+            
+         }
+         
+         return value;
+      }
       
    }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java	2008-07-18 15:02:09 UTC (rev 4693)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AlignedJournalImplTest.java	2008-07-18 17:21:42 UTC (rev 4694)
@@ -26,8 +26,6 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.jboss.messaging.core.journal.EncodingSupport;
 import org.jboss.messaging.core.journal.PreparedTransactionInfo;
 import org.jboss.messaging.core.journal.RecordInfo;
@@ -38,7 +36,6 @@
 import org.jboss.messaging.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
 import org.jboss.messaging.tests.unit.core.journal.impl.fakes.SimpleEncoding;
 import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.MessagingBuffer;
 
 /**
  * 
@@ -52,8 +49,6 @@
    
    // Attributes ----------------------------------------------------
    
-   private int alignment = 0;
-   
    private SequentialFileFactory factory;
 
    JournalImpl journalImpl = null;
@@ -134,6 +129,32 @@
       }
    }
    
+   public void testSimpleAdd() throws Exception
+   {
+      final int JOURNAL_SIZE = 1060;
+      
+      setupJournal(JOURNAL_SIZE, 10);
+      
+      journalImpl.appendAddRecord(13, (byte)14, new SimpleEncoding(1, (byte)15));
+      
+      journalImpl.forceMoveNextFile();
+      
+      journalImpl.checkAndReclaimFiles();
+      
+      setupJournal(JOURNAL_SIZE, 10);
+      
+      assertEquals(1, records.size());
+      
+      assertEquals(13, records.get(0).id);
+      
+      assertEquals(14, records.get(0).userRecordType);
+      
+      assertEquals(1, records.get(0).data.length);
+      
+      assertEquals(15, records.get(0).data[0]);
+      
+   }
+   
    public void testAppendAndUpdateRecords() throws Exception
    {
       
@@ -434,7 +455,7 @@
       
       for (int i = 0; i < 10; i++)
       {
-         journalImpl.appendAddRecordTransactional(1, 1, (byte) 1, new SimpleEncoding(1,(byte) 1));
+         journalImpl.appendAddRecordTransactional(1, i, (byte) 1, new SimpleEncoding(1,(byte) 1));
          journalImpl.forceMoveNextFile();
       }
       
@@ -482,6 +503,51 @@
    
    
    
+   public void testDeleteme() throws Exception
+   {
+      final int JOURNAL_SIZE = 2000;
+      
+      setupJournal(JOURNAL_SIZE, 100);
+      
+      for (int i = 0; i < 10; i++)
+      {
+         journalImpl.appendAddRecordTransactional(1, i, (byte) 1, new SimpleEncoding(1,(byte) 1));
+         journalImpl.forceMoveNextFile();
+      }
+      
+      journalImpl.appendCommitRecord(1l);
+
+      journalImpl.debugWait();
+
+      setupJournal(JOURNAL_SIZE, 100);
+
+      assertEquals(10, records.size());
+      assertEquals(0, transactions.size());
+      
+      journalImpl.checkAndReclaimFiles();
+      
+      for (int i = 0; i < 2; i++)
+      {
+         journalImpl.appendDeleteRecordTransactional(2l, (long)i);
+         //journalImpl.appendAddRecordTransactional(2l, i*10, (byte) 1, new SimpleEncoding(1,(byte) 1));
+         journalImpl.forceMoveNextFile();
+      }
+      
+      journalImpl.appendCommitRecord(2l);
+      
+      journalImpl.appendAddRecord(100, (byte)1, new SimpleEncoding(5, (byte)1));
+      
+      journalImpl.forceMoveNextFile();
+      
+      journalImpl.appendAddRecord(101, (byte)1, new SimpleEncoding(5, (byte)1));
+      
+      journalImpl.checkAndReclaimFiles();
+      
+      setupJournal(JOURNAL_SIZE, 100);
+   }
+   
+   
+   
    public void testTotalSize() throws Exception
    {
       final int JOURNAL_SIZE = 2000;
@@ -529,9 +595,81 @@
       // We should miss one record (hole) on the transaction
    }
    
+   public void testPrepareAloneOnSeparatedFile() throws Exception
+   {
+      final int JOURNAL_SIZE = 20000;
+      
+      setupJournal(JOURNAL_SIZE, 100, 5);
+      
+      assertEquals(0, records.size());
+      assertEquals(0, transactions.size());
+      
+      for (int i=0;i<10;i++)
+      {
+         journalImpl.appendAddRecordTransactional(1l, (long)i, (byte)0, new SimpleEncoding(1, (byte)15));
+      }
+      
+      journalImpl.forceMoveNextFile();
+      
+      journalImpl.appendPrepareRecord(1l);
+      journalImpl.appendCommitRecord(1l);
+      
+      for (int i=0;i<10;i++)
+      {
+         journalImpl.appendDeleteRecordTransactional(2l, (long)i);
+      }
+      
+      journalImpl.appendCommitRecord(2l);
+      journalImpl.appendAddRecord(100l, (byte)0, new SimpleEncoding(1, (byte)10)); // Add anything to keep holding the file
+      journalImpl.forceMoveNextFile();
+      journalImpl.checkAndReclaimFiles();
+
+      setupJournal(JOURNAL_SIZE, 100, 5);
+      
+      assertEquals(1, records.size());
+   }
    
+   public void testCommitWithMultipleFiles() throws Exception
+   {
+      final int JOURNAL_SIZE = 20000;
+      
+      setupJournal(JOURNAL_SIZE, 100, 5);
+      
+      assertEquals(0, records.size());
+      assertEquals(0, transactions.size());
+      
+      for (int i=0;i<50;i++)
+      {
+         if (i==10)
+         {
+            journalImpl.forceMoveNextFile();
+         }
+         journalImpl.appendAddRecordTransactional(1l, (long)i, (byte)0, new SimpleEncoding(1, (byte)15));
+      }
+      
+      journalImpl.appendCommitRecord(1l);
+      
+      for (int i=0;i<10;i++)
+      {
+         if (i==5)
+         {
+            journalImpl.forceMoveNextFile();
+         }
+         journalImpl.appendDeleteRecordTransactional(2l, (long)i);
+      }
+      
+      journalImpl.appendCommitRecord(2l);
+      journalImpl.forceMoveNextFile();
+      journalImpl.checkAndReclaimFiles();
+
+      setupJournal(JOURNAL_SIZE, 100, 5);
+      
+      assertEquals(40, records.size());
+      
+   }
    
    
+   
    public void testReloadWithPreparedTransaction() throws Exception
    {
       final int JOURNAL_SIZE = 3 * 1024;
@@ -644,10 +782,13 @@
 
    private void setupJournal(final int journalSize, final int alignment) throws Exception
    {
+      setupJournal(journalSize, alignment, 2);
+   }
+
+   private void setupJournal(final int journalSize, final int alignment, final int numberOfMinimalFiles) throws Exception
+   {
       if (factory == null)
       {
-         this.alignment = alignment;
-         
          factory = new FakeSequentialFileFactory(alignment,
                true, false);
       }
@@ -657,7 +798,7 @@
          journalImpl.stop();
       }
       
-      journalImpl = new JournalImpl(journalSize, 2,
+      journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles,
             true, true,
             factory, 
             "tt", "tt", 1000, 10000);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/EasyMockJournalTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/EasyMockJournalTest.java	2008-07-18 15:02:09 UTC (rev 4693)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/EasyMockJournalTest.java	2008-07-18 17:21:42 UTC (rev 4694)
@@ -129,7 +129,6 @@
             /* body */(byte)10, 
             JournalImpl.SIZE_ADD_RECORD + 1)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_ADD_RECORD + 1);
 
-
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.DELETE_RECORD_TX, 
             /*FileID*/1, 
             /* Transaction ID*/ 100l,
@@ -140,13 +139,17 @@
             /*FileID*/1, 
             /* Transaction ID*/ 100l,
             /* Number of Elements */ 1,
-            JournalImpl.SIZE_PREPARE_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_PREPARE_RECORD);
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 1,
+            JournalImpl.SIZE_PREPARE_RECORD + 8)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_PREPARE_RECORD);
       
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.COMMIT_RECORD, 
             /*FileID*/1, 
             /* Transaction ID*/ 100l,
             /* Number of Elements */ 1,
-            JournalImpl.SIZE_COMMIT_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD);
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 1,
+            JournalImpl.SIZE_COMMIT_RECORD + 8)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD);
       
       EasyMock.replay(mockFactory, file1, file2);
       
@@ -188,14 +191,18 @@
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.PREPARE_RECORD, 
             /*FileID*/1, 
             /* TXID */ 3l,
-            /* Number Of Elements */ 2,
-            JournalImpl.SIZE_PREPARE_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_PREPARE_RECORD);
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 2,
+            JournalImpl.SIZE_COMMIT_RECORD + 8)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_PREPARE_RECORD + 8);
       
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.COMMIT_RECORD, 
             /*FileID*/1, 
             /* TXID */ 3l,
-            /* Number Of Elements */ 2,
-            JournalImpl.SIZE_COMMIT_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD);
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 2,
+            JournalImpl.SIZE_COMMIT_RECORD + 8)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD + 8);
 
       EasyMock.replay(mockFactory, file1, file2);
       
@@ -226,7 +233,6 @@
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.ROLLBACK_RECORD, 
             /*FileID*/1, 
             /* TXID */ 3l,
-            /* NumberOfElements */ 1,
             JournalImpl.SIZE_ROLLBACK_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_ROLLBACK_RECORD);
 
       EasyMock.replay(mockFactory, file1, file2);
@@ -308,8 +314,10 @@
       EasyMock.expect(file1.write(compareByteBuffer(autoEncode(JournalImpl.COMMIT_RECORD, 
             /*FileID*/1, 
             /* Transaction ID*/ 33l,
-            /* NumberOfElements*/ 2,
-            JournalImpl.SIZE_COMMIT_RECORD)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD);
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 1,
+            /* Number of Elements */ 2,
+            JournalImpl.SIZE_COMMIT_RECORD + 8)), EasyMock.eq(true))).andReturn(JournalImpl.SIZE_COMMIT_RECORD);
       
       EasyMock.replay(mockFactory, file1, file2);
       

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java	2008-07-18 15:02:09 UTC (rev 4693)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java	2008-07-18 17:21:42 UTC (rev 4694)
@@ -882,10 +882,6 @@
 			rollback(1);
 		}
 		
-		// If this change, we need to consider commit or rollback size on the test
-		assertEquals(JournalImpl.SIZE_ROLLBACK_RECORD, JournalImpl.SIZE_COMMIT_RECORD);
-		assertEquals(calculateNumberOfFiles(fileSize , journal.getAlignment(), 200, recordLength, 200, JournalImpl.SIZE_DELETE_RECORD_TX, 1, JournalImpl.SIZE_COMMIT_RECORD), journal.getDataFilesCount());
-		
 		//Add more records to make sure we get to the next file
 		
 		for (int i = 200; i < 210; i++)




More information about the jboss-cvs-commits mailing list