[jboss-cvs] JBoss Messaging SVN: r7436 - branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 23 01:41:59 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-06-23 01:41:59 -0400 (Tue, 23 Jun 2009)
New Revision: 7436

Modified:
   branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.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-23 01:34:15 UTC (rev 7435)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2009-06-23 05:41:59 UTC (rev 7436)
@@ -937,79 +937,107 @@
 
       for (final JournalFile file : dataFilesToProcess)
       {
-         readJournalFile(file, new JournalReader()
+         readJournalFile(file, new CompactorJournalReader(recordsSnapshot));
+
+         writeLockCompact.lock();
+         try
          {
-            public void addRecord(RecordInfo info) throws Exception
-            {
+            // Restore relationshipMap
+            // Deal with updates and deletes that happened during the compacting
 
-               if (recordsSnapshot.get(info.id) != null)
-               {
-                  System.out.println("Record " + info.id + " to be out on compacted file");
-               }
-            }
+         }
+         finally
+         {
+            writeLockCompact.unlock();
+         }
 
-            public void addRecordTX(long transactionID, RecordInfo info) throws Exception
-            {
-               if (recordsSnapshot.get(info.id) != null)
-               {
-                  System.out.println("RecordTX " + info.id + " to be out on compacted file");
-               }
-            }
+      }
 
-            public void commitRecord(long transactionID, Pair<Integer, Integer>[] summary) throws Exception
-            {
-            }
+   }
 
-            public void deleteRecord(long recordID) throws Exception
-            {
-            }
+   class CompactorJournalReader implements JournalReader
+   {
+      JournalFile currentOutputFile;
 
-            public void deleteRecordTX(long transactionID, RecordInfo recordInfo) throws Exception
-            {
-            }
+      ByteBuffer bufferWrite;
 
-            public void markAsDataFile(JournalFile file)
-            {
-            }
+      ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshot;
 
-            public void prepareRecord(long transactionID, byte[] extraData, Pair<Integer, Integer>[] summary) throws Exception
-            {
-            }
+      public CompactorJournalReader(ConcurrentMap<Long, RecordFilesRelationship> recordsSnapshot)
+      {
+         this.recordsSnapshot = recordsSnapshot;
+      }
 
-            public void rollbackRecord(long transactionID) throws Exception
-            {
-            }
+      private void checkSize(int size) throws Exception
+      {
+         if (bufferWrite == null)
+         {
+            bufferWrite = fileFactory.newBuffer(size);
+         }
 
-            public void updateRecord(RecordInfo info) throws Exception
-            {
-               if (recordsSnapshot.get(info.id) != null)
-               {
-                  System.out.println("Update " + info.id + " to be out on compacted file");
-               }
-            }
+         if (currentOutputFile == null)
+         {
+            currentOutputFile = openFile(false);
+         }
+      }
 
-            public void updateRecordTX(long transactionID, RecordInfo info) throws Exception
-            {
-               if (recordsSnapshot.get(info.id) != null)
-               {
-                  System.out.println("UpdateTX " + info.id + " to be out on compacted file");
-               }
-            }
+      public void addRecord(RecordInfo info) throws Exception
+      {
 
-         });
+         if (recordsSnapshot.get(info.id) != null)
+         {
+            System.out.println("Record " + info.id + " to be out on compacted file");
+         }
       }
 
-      writeLockCompact.lock();
-      try
+      public void addRecordTX(long transactionID, RecordInfo info) throws Exception
       {
-         // Restore relationshipMap
-         // Deal with updates and deletes that happened during the compacting
+         if (recordsSnapshot.get(info.id) != null)
+         {
+            System.out.println("RecordTX " + info.id + " to be out on compacted file");
+         }
       }
-      finally
+
+      public void commitRecord(long transactionID, Pair<Integer, Integer>[] summary) throws Exception
       {
-         writeLockCompact.unlock();
       }
 
+      public void deleteRecord(long recordID) throws Exception
+      {
+      }
+
+      public void deleteRecordTX(long transactionID, RecordInfo recordInfo) throws Exception
+      {
+      }
+
+      public void markAsDataFile(JournalFile file)
+      {
+      }
+
+      public void prepareRecord(long transactionID, byte[] extraData, Pair<Integer, Integer>[] summary) throws Exception
+      {
+      }
+
+      public void rollbackRecord(long transactionID) throws Exception
+      {
+      }
+
+      public void updateRecord(RecordInfo info) throws Exception
+      {
+         if (recordsSnapshot.get(info.id) != null)
+         {
+            System.out.println("Update " + info.id + " to be out on compacted file");
+         }
+      }
+
+      public void updateRecordTX(long transactionID, RecordInfo info) throws Exception
+      {
+         if (recordsSnapshot.get(info.id) != null)
+         {
+            System.out.println("UpdateTX " + info.id + " to be out on compacted file");
+         }
+      }
+
    }
 
    private boolean isInvalidSize(int bufferPos, int size)




More information about the jboss-cvs-commits mailing list