[jboss-cvs] JBoss Messaging SVN: r7472 - in branches/clebert_temp_expirement: 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
Thu Jun 25 14:39:32 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-06-25 14:39:32 -0400 (Thu, 25 Jun 2009)
New Revision: 7472

Modified:
   branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
Log:
changes

Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2009-06-25 16:51:51 UTC (rev 7471)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2009-06-25 18:39:32 UTC (rev 7472)
@@ -190,9 +190,13 @@
    private final BlockingQueue<JournalFile> openedFiles = new LinkedBlockingQueue<JournalFile>();
 
    // Compacting may replace this structure
-   private volatile ConcurrentMap<Long, RecordFilesRelationship> recordsRelationshipMap = new ConcurrentHashMap<Long, RecordFilesRelationship>();
+   private volatile ConcurrentMap<Long, JournalRecord> records = new ConcurrentHashMap<Long, JournalRecord>();
 
-   private final ConcurrentMap<Long, JournalTransaction> transactionInfos = new ConcurrentHashMap<Long, JournalTransaction>();
+   // Compacting may replace this structure
+   private volatile ConcurrentMap<Long, JournalTransaction> pendingTransactions = new ConcurrentHashMap<Long, JournalTransaction>();
+   
+   // This will be filled only while the Compactor is being done
+   private volatile Compactor compactor;
 
    private ExecutorService filesExecutor = null;
 
@@ -200,8 +204,7 @@
 
    private final ReadWriteLock compactingLock = new ReentrantReadWriteLock();
 
-   /** We don't lock the journal while compacting, however during a short time before we start, and after we finish,
-    *  we need to rearrange the referenceCounting structures*/
+   /** We don't lock the journal while compacting, however we need to lock it while taking and updating snapshots */
    private final Lock readLockCompact = compactingLock.readLock();
 
    private final Lock writeLockCompact = compactingLock.writeLock();
@@ -299,7 +302,7 @@
          {
             JournalFile usedFile = appendRecord(bb, false, sync, null, callback);
 
-            recordsRelationshipMap.put(id, new RecordFilesRelationship(usedFile));
+            records.put(id, new JournalRecord(usedFile));
          }
          finally
          {
@@ -336,7 +339,7 @@
       try
       {
 
-         RecordFilesRelationship posFiles = recordsRelationshipMap.get(id);
+         JournalRecord posFiles = records.get(id);
 
          if (posFiles == null)
          {
@@ -394,9 +397,9 @@
       try
       {
 
-         RecordFilesRelationship posFiles = recordsRelationshipMap.remove(id);
+         JournalRecord record = records.remove(id);
 
-         if (posFiles == null)
+         if (record == null)
          {
             throw new IllegalStateException("Cannot find add info " + id);
          }
@@ -417,7 +420,7 @@
          {
             JournalFile usedFile = appendRecord(bb, false, sync, null, callback);
 
-            posFiles.addDelete(usedFile);
+            record.delete(usedFile);
          }
          finally
          {
@@ -462,11 +465,11 @@
 
          writeAddRecordTX(-1, txID, id, recordType, record, size, bb);
 
+         JournalTransaction tx = getTransactionInfo(txID);
+
          lock.acquire();
          try
          {
-            JournalTransaction tx = getTransactionInfo(txID);
-
             JournalFile usedFile = appendRecord(bb, false, false, tx, null);
 
             tx.addPositive(usedFile, id);
@@ -518,11 +521,11 @@
          record.encode(bb);
          bb.writeInt(size);
 
+         JournalTransaction tx = getTransactionInfo(txID);
+
          lock.acquire();
          try
          {
-            JournalTransaction tx = getTransactionInfo(txID);
-
             JournalFile usedFile = appendRecord(bb, false, false, tx, null);
 
             tx.addPositive(usedFile, id);
@@ -569,11 +572,11 @@
          }
          bb.writeInt(size);
 
+         JournalTransaction tx = getTransactionInfo(txID);
+
          lock.acquire();
          try
          {
-            JournalTransaction tx = getTransactionInfo(txID);
-
             JournalFile usedFile = appendRecord(bb, false, false, tx, null);
 
             tx.addNegative(usedFile, id);
@@ -611,11 +614,11 @@
          bb.writeInt(0);
          bb.writeInt(size);
 
+         JournalTransaction tx = getTransactionInfo(txID);
+
          lock.acquire();
          try
          {
-            JournalTransaction tx = getTransactionInfo(txID);
-
             JournalFile usedFile = appendRecord(bb, false, false, tx, null);
 
             tx.addNegative(usedFile, id);
@@ -667,7 +670,7 @@
          int size = SIZE_COMPLETE_TRANSACTION_RECORD + transactionData.getEncodeSize() + SIZE_INT;
          ChannelBuffer bb = newBuffer(size);
 
-         writeTransaction(PREPARE_RECORD, txID, tx, transactionData, size, bb);
+         writeTransaction(-1, PREPARE_RECORD, txID, tx, transactionData, size, -1, bb);
 
          lock.acquire();
          try
@@ -693,16 +696,16 @@
 
    /**
     * <p>A transaction record (Commit or Prepare), will hold the number of elements the transaction has on each file.</p>
-    * <p>For example, a transaction was spread along 3 journal files with 10 records on each file. 
-    *    (What could happen if there are too many records, or if an user event delayed records to come in time to a single file).</p>
+    * <p>For example, a transaction was spread along 3 journal files with 10 pendingTransactions on each file. 
+    *    (What could happen if there are too many pendingTransactions, or if an user event delayed pendingTransactions to come in time to a single file).</p>
     * <p>The element-summary will then have</p>
     * <p>FileID1, 10</p>
     * <p>FileID2, 10</p>
     * <p>FileID3, 10</p>
     * 
     * <br>
-    * <p> During the load, the transaction needs to have 30 records spread across the files as originally written.</p>
-    * <p> If for any reason there are missing records, that means the transaction was not completed and we should ignore the whole transaction </p>
+    * <p> During the load, the transaction needs to have 30 pendingTransactions spread across the files as originally written.</p>
+    * <p> If for any reason there are missing pendingTransactions, that means the transaction was not completed and we should ignore the whole transaction </p>
     * <p> We can't just use a global counter as reclaiming could delete files after the transaction was successfully committed. 
     *     That also means not having a whole file on journal-reload doesn't mean we have to invalidate the transaction </p>
     *
@@ -715,7 +718,7 @@
          throw new IllegalStateException("Journal must be loaded first");
       }
 
-      JournalTransaction tx = transactionInfos.remove(txID);
+      JournalTransaction tx = pendingTransactions.remove(txID);
 
       readLockCompact.lock();
 
@@ -729,7 +732,7 @@
 
          ChannelBuffer bb = newBuffer(SIZE_COMPLETE_TRANSACTION_RECORD);
 
-         writeTransaction(COMMIT_RECORD, txID, tx, null, SIZE_COMPLETE_TRANSACTION_RECORD, bb);
+         writeTransaction(-1, COMMIT_RECORD, txID, tx, null, SIZE_COMPLETE_TRANSACTION_RECORD, -1, bb);
 
          lock.acquire();
          try
@@ -769,7 +772,7 @@
 
       try
       {
-         tx = transactionInfos.remove(txID);
+         tx = pendingTransactions.remove(txID);
 
          if (tx == null)
          {
@@ -857,26 +860,34 @@
 
    public void compact() throws Exception
    {
-      ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshotList = null;
+      if (compactor != null)
+      {
+         throw new IllegalStateException("There is pending compacting operation");
+      }
 
+      ConcurrentMap<Long, JournalRecord> recordsSnapshot = null;
+
       ArrayList<JournalFile> dataFilesToProcess = new ArrayList<JournalFile>(dataFiles.size());
+      
+      Map<Long, JournalTransaction> pendingTransactions;
 
       boolean previousReclaimValue = autoReclaim;
 
       try
       {
 
-         // First, we replace the recordsRelationshipMap by a new one.
+         // First, we replace the records by a new one.
          // We need to guarantee that the journal is frozen for this short time
-         // We don't freeze the journal as we compact, only for the short time where we replace recordsRelationshipMap
+         // We don't freeze the journal as we compact, only for the short time where we replace records
          writeLockCompact.lock();
          try
          {
             autoReclaim = false;
 
-            recordsSnapshotList = recordsRelationshipMap;
+            recordsSnapshot = records;
+            pendingTransactions = this.pendingTransactions;
 
-            recordsRelationshipMap = new ConcurrentHashMap<Long, RecordFilesRelationship>();
+            records = new ConcurrentHashMap<Long, JournalRecord>();
 
             for (JournalFile file : dataFiles)
             {
@@ -891,7 +902,12 @@
                   break;
                }
             }
+            
+            
 
+            this.compactor = new Compactor(recordsSnapshot, pendingTransactions, dataFilesToProcess.get(0).getFileID());
+
+
          }
          finally
          {
@@ -904,10 +920,6 @@
          autoReclaim = previousReclaimValue;
       }
 
-      final ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshot = recordsSnapshotList;
-
-      Compactor compactor = new Compactor(recordsSnapshot, dataFilesToProcess.get(0).getFileID());
-
       for (final JournalFile file : dataFilesToProcess)
       {
          readJournalFile(file, compactor);
@@ -943,12 +955,19 @@
 
       int nextOrderingID;
 
-      ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshot;
+      final Map<Long, JournalRecord> recordsSnapshot;
+      final Map<Long, JournalTransaction> pendingTransactions;
+      
+      final Map<Long, JournalRecord> newRecords = new HashMap<Long, JournalRecord>();
+      final Map<Long, JournalTransaction> newTransactions = new HashMap<Long, JournalTransaction>();
+      
+      
 
-      public Compactor(ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshot, int firstFileID)
+      public Compactor(Map<Long, JournalRecord> recordsSnapshot, Map<Long, JournalTransaction> pendingTransactions, int firstFileID)
       {
          this.recordsSnapshot = recordsSnapshot;
          this.nextOrderingID = firstFileID;
+         this.pendingTransactions = pendingTransactions;
       }
 
       private void checkSize(int size) throws Exception
@@ -1013,43 +1032,80 @@
                            new ByteArrayEncoding(info.data),
                            size,
                            channelWrapper);
+            
+            newRecords.put(info.id, new JournalRecord(currentFile));
          }
       }
 
       public void addRecordTX(long transactionID, RecordInfo info) throws Exception
       {
-         if (recordsSnapshot.get(info.id) != null)
+         JournalTransaction pending = pendingTransactions.get(transactionID);
+         
+         if (pending != null)
          {
-            System.out.println("RecordTX " + info.id + " to be out on compacted file");
+            JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
             
+            int size = SIZE_ADD_RECORD_TX + info.data.length;
+            
+            checkSize(size);
+            
+            newTransaction.addPositive(currentFile, info.id);
+            
             writeAddRecordTX(fileID,
                              transactionID,
                              info.id,
                              info.getUserRecordType(),
                              new ByteArrayEncoding(info.data),
-                             SIZE_ADD_RECORD_TX + info.data.length,
+                             size,
                              channelWrapper);
          }
+         else
+         if (recordsSnapshot.get(info.id) != null)
+         {
+            System.out.println("AddRecordTX for a committed record, just converting it as a regular record");
+            // AddRecordTX for a committed record, just converting it as a regular record
+            // The record is already confirmed. There is no need to keep the transaction information during compacting
+            addRecord(info);
+         }
       }
 
       public void commitRecord(long transactionID, int numberOfRecords) throws Exception
       {
+         // Even though this shouldn't happen, I'm processing the commit as it was legal (instead of throwing it away)
+         JournalTransaction pendingTx = pendingTransactions.get(transactionID);
+         
+         if (pendingTx != null)
+         {
+            log.warn("A commit record for a pending transaction is being read on compactor. This shouldn't happen");
+            
+            JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
+            checkSize(SIZE_COMMIT_RECORD);
+            writeTransaction(fileID, COMMIT_RECORD, transactionID, newTransaction, null, SIZE_COMMIT_RECORD, pendingTx.getCounter(currentFile), channelWrapper);
+            newTransaction.commit(currentFile);
+         }
       }
 
       public void deleteRecord(long recordID) throws Exception
       {
+         // nothing to be done here
       }
 
       public void deleteRecordTX(long transactionID, RecordInfo recordInfo) throws Exception
       {
+         // nothing to be done here
       }
 
       public void markAsDataFile(JournalFile file)
       {
+         // nothing to be done here
       }
 
       public void prepareRecord(long transactionID, byte[] extraData, int numberOfRecords) throws Exception
       {
+         if (pendingTransactions.get(transactionID) != null)
+         {
+            
+         }
       }
 
       public void rollbackRecord(long transactionID) throws Exception
@@ -1071,7 +1127,24 @@
             System.out.println("UpdateTX " + info.id + " to be out on compacted file");
          }
       }
+      
 
+      /**
+       * @param transactionID
+       * @return
+       */
+      private JournalTransaction getNewJournalTransaction(long transactionID)
+      {
+         JournalTransaction newTransaction = newTransactions.get(transactionID);
+         if (newTransaction == null)
+         {
+            newTransaction = new JournalTransaction();
+            newTransactions.put(transactionID, newTransaction);
+         }
+         return newTransaction;
+      }
+      
+
    }
 
    private boolean isInvalidSize(int bufferPos, int size)
@@ -1157,7 +1230,7 @@
 
                loadManager.addRecord(info);
 
-               recordsRelationshipMap.put(info.id, new RecordFilesRelationship(file));
+               records.put(info.id, new JournalRecord(file));
             }
 
             public void updateRecord(RecordInfo info) throws Exception
@@ -1170,7 +1243,7 @@
 
                loadManager.updateRecord(info);
 
-               RecordFilesRelationship posFiles = recordsRelationshipMap.get(info.id);
+               JournalRecord posFiles = records.get(info.id);
 
                if (posFiles != null)
                {
@@ -1192,11 +1265,11 @@
 
                loadManager.deleteRecord(recordID);
 
-               RecordFilesRelationship posFiles = recordsRelationshipMap.remove(recordID);
+               JournalRecord posFiles = records.remove(recordID);
 
                if (posFiles != null)
                {
-                  posFiles.addDelete(file);
+                  posFiles.delete(file);
                }
             }
 
@@ -1226,13 +1299,13 @@
 
                tx.recordInfos.add(info);
 
-               JournalTransaction tnp = transactionInfos.get(transactionID);
+               JournalTransaction tnp = pendingTransactions.get(transactionID);
 
                if (tnp == null)
                {
                   tnp = new JournalTransaction();
 
-                  transactionInfos.put(transactionID, tnp);
+                  pendingTransactions.put(transactionID, tnp);
                }
 
                tnp.addPositive(file, info.id);
@@ -1258,13 +1331,13 @@
 
                tx.recordsToDelete.add(info);
 
-               JournalTransaction tnp = transactionInfos.get(transactionID);
+               JournalTransaction tnp = pendingTransactions.get(transactionID);
 
                if (tnp == null)
                {
                   tnp = new JournalTransaction();
 
-                  transactionInfos.put(transactionID, tnp);
+                  pendingTransactions.put(transactionID, tnp);
                }
 
                tnp.addNegative(file, info.id);
@@ -1294,13 +1367,13 @@
 
                tx.extraData = extraData;
 
-               JournalTransaction journalTransaction = transactionInfos.get(transactionID);
+               JournalTransaction journalTransaction = pendingTransactions.get(transactionID);
 
                if (journalTransaction == null)
                {
                   journalTransaction = new JournalTransaction();
 
-                  transactionInfos.put(transactionID, journalTransaction);
+                  pendingTransactions.put(transactionID, journalTransaction);
                }
 
                boolean healthy = checkTransactionHealth(file, journalTransaction, orderedFiles, numberOfRecords);
@@ -1334,7 +1407,7 @@
                // ignore this
                if (tx != null)
                {
-                  JournalTransaction journalTransaction = transactionInfos.remove(transactionID);
+                  JournalTransaction journalTransaction = pendingTransactions.remove(transactionID);
 
                   if (journalTransaction == null)
                   {
@@ -1392,7 +1465,7 @@
                // point
                if (tx != null)
                {
-                  JournalTransaction tnp = transactionInfos.remove(transactionID);
+                  JournalTransaction tnp = pendingTransactions.remove(transactionID);
 
                   if (tnp == null)
                   {
@@ -1482,7 +1555,7 @@
          {
             log.warn("Uncommitted transaction with id " + transaction.transactionID + " found and discarded");
 
-            JournalTransaction transactionInfo = transactionInfos.get(transaction.transactionID);
+            JournalTransaction transactionInfo = pendingTransactions.get(transaction.transactionID);
 
             if (transactionInfo == null)
             {
@@ -1493,7 +1566,7 @@
             transactionInfo.forget();
 
             // Remove the transactionInfo
-            transactionInfos.remove(transaction.transactionID);
+            pendingTransactions.remove(transaction.transactionID);
          }
          else
          {
@@ -1583,7 +1656,7 @@
    {
       fileFactory.testFlush();
 
-      for (JournalTransaction tx : transactionInfos.values())
+      for (JournalTransaction tx : pendingTransactions.values())
       {
          tx.waitCallbacks();
       }
@@ -1660,7 +1733,7 @@
 
    public int getIDMapSize()
    {
-      return recordsRelationshipMap.size();
+      return records.size();
    }
 
    public int getFileSize()
@@ -1946,7 +2019,7 @@
             wholeFileBuffer.get(record);
          }
 
-         // Case this is a transaction, this will contain the number of records on a transaction, at the currentFile
+         // Case this is a transaction, this will contain the number of pendingTransactions on a transaction, at the currentFile
          int transactionCheckNumberOfRecords = 0;
 
          if (recordType == PREPARE_RECORD || recordType == COMMIT_RECORD)
@@ -1969,7 +2042,7 @@
          if (isInvalidSize(pos, recordSize + variableSize + preparedTransactionExtraDataSize))
          {
             // Avoid a buffer overflow caused by damaged data... continue
-            // scanning for more records...
+            // scanning for more pendingTransactions...
             trace("Record at position " + pos +
                   " recordType = " +
                   recordType +
@@ -1982,7 +2055,7 @@
                   " preparedTransactionExtraDataSize: " +
                   preparedTransactionExtraDataSize +
                   " is corrupted and it is being ignored (II)");
-            // If a file has damaged records, we make it a dataFile, and the
+            // If a file has damaged pendingTransactions, we make it a dataFile, and the
             // next reclaiming will fix it
             reader.markAsDataFile(file);
             wholeFileBuffer.position(pos + 1);
@@ -2009,7 +2082,7 @@
                   file.getFile().getFileName() +
                   " is corrupted and it is being ignored (III)");
 
-            // If a file has damaged records, we make it a dataFile, and the
+            // If a file has damaged pendingTransactions, we make it a dataFile, and the
             // next reclaiming will fix it
             reader.markAsDataFile(file);
 
@@ -2022,7 +2095,7 @@
          // reused and we need to ignore this record
          if (readFileId != file.getFileID())
          {
-            // If a file has damaged records, we make it a dataFile, and the
+            // If a file has damaged pendingTransactions, we make it a dataFile, and the
             // next reclaiming will fix it
             reader.markAsDataFile(file);
 
@@ -2129,8 +2202,8 @@
    /**
     * <p> Check for holes on the transaction (a commit written but with an incomplete transaction) </p>
     * <p>This method will validate if the transaction (PREPARE/COMMIT) is complete as stated on the COMMIT-RECORD.</p>
-    * <p> We record a summary about the records on the journal file on COMMIT and PREPARE. 
-    *     When we load the records we build a new summary and we check the original summary to the current summary.
+    * <p> We record a summary about the pendingTransactions on the journal file on COMMIT and PREPARE. 
+    *     When we load the pendingTransactions we build a new summary and we check the original summary to the current summary.
     *     This method is basically verifying if the entire transaction is being loaded </p> 
     *     
     * <p>Look at the javadoc on {@link JournalImpl#appendCommitRecord(long)} about how the transaction-summary is recorded</p> 
@@ -2152,16 +2225,16 @@
 
    /**
     * <p>A transaction record (Commit or Prepare), will hold the number of elements the transaction has on each file.</p>
-    * <p>For example, a transaction was spread along 3 journal files with 10 records on each file. 
-    *    (What could happen if there are too many records, or if an user event delayed records to come in time to a single file).</p>
+    * <p>For example, a transaction was spread along 3 journal files with 10 pendingTransactions on each file. 
+    *    (What could happen if there are too many pendingTransactions, or if an user event delayed pendingTransactions to come in time to a single file).</p>
     * <p>The element-summary will then have</p>
     * <p>FileID1, 10</p>
     * <p>FileID2, 10</p>
     * <p>FileID3, 10</p>
     * 
     * <br>
-    * <p> During the load, the transaction needs to have 30 records spread across the files as originally written.</p>
-    * <p> If for any reason there are missing records, that means the transaction was not completed and we should ignore the whole transaction </p>
+    * <p> During the load, the transaction needs to have 30 pendingTransactions spread across the files as originally written.</p>
+    * <p> If for any reason there are missing pendingTransactions, that means the transaction was not completed and we should ignore the whole transaction </p>
     * <p> We can't just use a global counter as reclaiming could delete files after the transaction was successfully committed. 
     *     That also means not having a whole file on journal-reload doesn't mean we have to invalidate the transaction </p>
     * 
@@ -2172,17 +2245,19 @@
     * @return
     * @throws Exception
     */
-   private void writeTransaction(final byte recordType,
+   private void writeTransaction(final int fileID,
+                                 final byte recordType,
                                  final long txID,
                                  final JournalTransaction tx,
                                  final EncodingSupport transactionData,
                                  final int size,
+                                 final int numberOfRecords,
                                  final ChannelBuffer bb) throws Exception
    {
       bb.writeByte(recordType);
-      bb.writeInt(-1); // skip ID part
+      bb.writeInt(fileID); // skip ID part
       bb.writeLong(txID);
-      bb.writeInt(-1); // skip number of records part
+      bb.writeInt(numberOfRecords); // skip number of pendingTransactions part
 
       if (transactionData != null)
       {
@@ -2375,7 +2450,7 @@
    /** 
     * Note: You should aways guarantee locking the semaphore lock.
     * 
-    * @param transactional If the appendRecord is for a prepare or commit, where we should update the number of records on the current file
+    * @param completeTransaction If the appendRecord is for a prepare or commit, where we should update the number of pendingTransactions on the current file
     * */
    private JournalFile appendRecord(final MessagingBuffer bb,
                                     final boolean completeTransaction,
@@ -2441,16 +2516,16 @@
                tx.syncPreviousFiles();
             }
 
+            // We need to add the number of records on currentFile if prepare or commit
             if (completeTransaction)
             {
-               // Filling the number of records at the current file
+               // Filling the number of pendingTransactions at the current file
                tx.fillNumberOfRecords(currentFile, bb);
             }
          }
 
          // Adding fileID
          bb.writerIndex(SIZE_BYTE);
-
          bb.writeInt(currentFile.getFileID());
 
          if (callback != null)
@@ -2671,13 +2746,13 @@
 
    private JournalTransaction getTransactionInfo(final long txID)
    {
-      JournalTransaction tx = transactionInfos.get(txID);
+      JournalTransaction tx = pendingTransactions.get(txID);
 
       if (tx == null)
       {
          tx = new JournalTransaction();
 
-         JournalTransaction trans = transactionInfos.putIfAbsent(txID, tx);
+         JournalTransaction trans = pendingTransactions.putIfAbsent(txID, tx);
 
          if (trans != null)
          {
@@ -2761,13 +2836,13 @@
     * Note: This class used to be called PosFiles
     * 
     * Used on the ref-count for reclaiming */
-   private static class RecordFilesRelationship
+   private static class JournalRecord
    {
       private final JournalFile addFile;
 
       private List<JournalFile> updateFiles;
 
-      RecordFilesRelationship(final JournalFile addFile)
+      JournalRecord(final JournalFile addFile)
       {
          this.addFile = addFile;
 
@@ -2786,7 +2861,7 @@
          updateFile.incPosCount();
       }
 
-      void addDelete(final JournalFile file)
+      void delete(final JournalFile file)
       {
          file.incNegCount(addFile);
 
@@ -2802,7 +2877,7 @@
       public String toString()
       {
          StringBuffer buffer = new StringBuffer();
-         buffer.append("RecordFilesRelationship(add=" + addFile.getFile().getFileName());
+         buffer.append("JournalRecord(add=" + addFile.getFile().getFileName());
 
          if (updateFiles != null)
          {
@@ -2971,13 +3046,13 @@
          {
             for (Pair<JournalFile, Long> p : pos)
             {
-               RecordFilesRelationship posFiles = recordsRelationshipMap.get(p.b);
+               JournalRecord posFiles = records.get(p.b);
 
                if (posFiles == null)
                {
-                  posFiles = new RecordFilesRelationship(p.a);
+                  posFiles = new JournalRecord(p.a);
 
-                  recordsRelationshipMap.put(p.b, posFiles);
+                  records.put(p.b, posFiles);
                }
                else
                {
@@ -2990,11 +3065,11 @@
          {
             for (Pair<JournalFile, Long> n : neg)
             {
-               RecordFilesRelationship posFiles = recordsRelationshipMap.remove(n.b);
+               JournalRecord posFiles = records.remove(n.b);
 
                if (posFiles != null)
                {
-                  posFiles.addDelete(n.a);
+                  posFiles.delete(n.a);
                }
             }
          }

Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java	2009-06-25 16:51:51 UTC (rev 7471)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java	2009-06-25 18:39:32 UTC (rev 7472)
@@ -3078,20 +3078,42 @@
 
       assertEquals(0, journal.getDataFilesCount());
    }
+   
+   
+   public void testCompactwithPendingPrepare() throws Exception
+   {
+   }
 
+   public void testCompactwithConcurrentDeletes() throws Exception
+   {
+   }
+
+   public void testCompactwithConcurrentAppend() throws Exception
+   {
+   }
+      
+   public void testCompactWithPendingTransactionAndDelete() throws Exception
+   {
+   }
+   
    public void testCompactingWithPendingTransaction() throws Exception
    {
+      
+   }
+
+   public void testSimpleCompacting() throws Exception
+   {
       setup(2, 60 * 1024, true);
 
       createJournal();
       startJournal();
       load();
       
-      int NUMBER_OF_RECRODS = 100;
+      int NUMBER_OF_RECORDS = 100;
 
       long transactionID = 0;
 
-      for (int i = 0; i < NUMBER_OF_RECRODS/2; i++)
+      for (int i = 0; i < NUMBER_OF_RECORDS/2; i++)
       {
          add(i);
          if (i % 10 == 0 && i > 0)
@@ -3101,7 +3123,7 @@
          update(i);
       }
 
-      for (int i = NUMBER_OF_RECRODS/2; i < NUMBER_OF_RECRODS; i++)
+      for (int i = NUMBER_OF_RECORDS/2; i < NUMBER_OF_RECORDS; i++)
       {
 
          addTx(transactionID, i);
@@ -3116,7 +3138,7 @@
 
       System.out.println("Number of Files: " + journal.getDataFilesCount());
 
-      for (int i = 0; i < NUMBER_OF_RECRODS; i++)
+      for (int i = 0; i < NUMBER_OF_RECORDS; i++)
       {
          if (!(i % 10 == 0))
          {




More information about the jboss-cvs-commits mailing list