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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 30 18:35:42 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-04-30 18:35:42 -0400 (Wed, 30 Apr 2008)
New Revision: 4142

Modified:
   branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
   branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
   branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/Reclaimer.java
   branches/trunk_tmp_aio/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestUnit.java
Log:
Adding debug methods into temporary branch

Modified: branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
===================================================================
--- branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java	2008-04-30 16:52:09 UTC (rev 4141)
+++ branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java	2008-04-30 22:35:42 UTC (rev 4142)
@@ -57,4 +57,5 @@
 	void setOffset(final int offset);
 	
 	SequentialFile getFile();
+
 }

Modified: branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
===================================================================
--- branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java	2008-04-30 16:52:09 UTC (rev 4141)
+++ branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java	2008-04-30 22:35:42 UTC (rev 4142)
@@ -23,6 +23,7 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.jboss.messaging.core.journal.SequentialFile;
 import org.jboss.messaging.core.logging.Logger;
@@ -74,6 +75,8 @@
 
 	public void incNegCount(final JournalFile file)
 	{
+	   log.info("File:" + this + " adding neg dep to " + file);
+	   
 		Integer count = negCounts.get(file);
 		
 		int c = count == null ? 1 : count.intValue() + 1;
@@ -142,6 +145,18 @@
 	      return "Error:" + e.toString();
 	   }
 	}
+
+   public String debug()
+   {
+      StringBuilder builder = new StringBuilder();
+      
+      for (Entry<JournalFile, Integer> entry: negCounts.entrySet())
+      {
+         builder.append(" file = " + entry.getKey() + " value = " + entry.getValue() + "\n");
+      }
+
+      return builder.toString();
+   }
 	
 
 }

Modified: branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-04-30 16:52:09 UTC (rev 4141)
+++ branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-04-30 22:35:42 UTC (rev 4142)
@@ -1307,7 +1307,7 @@
 
 		if (currentFile == null || fileSize - currentFile.getOffset() < size)
 		{
-		   //Thread.sleep(1000);
+		   log.info("Closing file " + currentFile);
 			currentFile.getFile().close();
 			
 			dataFiles.add(currentFile);
@@ -1323,6 +1323,7 @@
 				currentFile = createFile();
 				currentFile.getFile().open();
 			}
+         log.info("Opened file " + currentFile);
 		}		
 	}
 	
@@ -1416,6 +1417,7 @@
 		
 		void addTXPosCount(final JournalFile file)
 		{
+		   log.info ("Adding TX Pos Count");
 			if (transactionPos == null)
 			{
 				transactionPos = new HashSet<JournalFile>();
@@ -1434,6 +1436,7 @@
 		void addPos(final JournalFile file, final long id)
 		{		
 			addTXPosCount(file);				
+         log.info("Adding positive id=" + id + " count into " + file + " positiveCounter = " + file.getPosCount());
 			
 			if (pos == null)
 			{
@@ -1446,6 +1449,7 @@
 		void addNeg(final JournalFile file, final long id)
 		{			
 			addTXPosCount(file);		
+         log.info("Adding negative id=" + id + " count into " + file + " negativeCounter = " + file.getNegCount(file));
 			
 			if (neg == null)
 			{
@@ -1456,13 +1460,16 @@
 		}
 		
 		void commit(final JournalFile file)
-		{			
+		{
+		   log.info("Transaction negPos Commit into file" + file);
 			if (pos != null)
 			{
 				for (Pair<JournalFile, Long> p: pos)
 	   		{
 					PosFiles posFiles = posFilesMap.get(p.b);
 					
+					log.info("Adding a positive dependency between transaction=" + p.b + " and file= "  + p.a );
+					
 					if (posFiles == null)
 					{
 						posFiles = new PosFiles(p.a);
@@ -1480,8 +1487,11 @@
 			{
    			for (Pair<JournalFile, Long> n: neg)
    			{
-   				PosFiles posFiles = posFilesMap.remove(n.b);
+
+   			   log.info("Adding a negative dependency between transaction=" + n.b + " and file= "  + n.a );
    				
+   			   PosFiles posFiles = posFilesMap.remove(n.b);
+   				
    				if (posFiles == null)
    				{
    					throw new IllegalStateException("Cannot find add info " + n.b);
@@ -1501,7 +1511,9 @@
 		
 		void rollback(JournalFile file)
 		{		
-			//Now add negs for the pos we added in each file in which there were transactional operations
+
+		   log.info("Rollback into " + file);
+		   //Now add negs for the pos we added in each file in which there were transactional operations
 			//Note that we do this on rollback as we do on commit, since we need to ensure the file containing
 			//the rollback record doesn't get deleted before the files with the transactional operations are deleted
 			//Otherwise we may run into problems especially with XA where we are just left with a prepare when the tx
@@ -1515,6 +1527,7 @@
 		
 		void prepare(JournalFile file)
 		{
+         log.info("Prepare into " + file);
 			//We don't want the prepare record getting deleted before time
 			
 			addTXPosCount(file);
@@ -1531,4 +1544,26 @@
 		}
 	}
 
+   public String debug()
+   {
+      StringBuilder builder = new StringBuilder();
+      
+      for (JournalFile file: dataFiles)
+      {
+         System.out.println("File:" + file);
+         builder.append("DataFile:" + file + " posCounter = " + file.getPosCount() + "\n");
+         if (file instanceof JournalFileImpl)
+         {
+            builder.append(((JournalFileImpl)file).debug());
+            
+         }
+      }
+      
+      builder.append("CurrentFile:" + currentFile+ " posCounter = " + currentFile.getPosCount() + "\n");
+      builder.append(((JournalFileImpl)currentFile).debug());
+      
+      
+      return builder.toString();
+   }
+
 }

Modified: branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/Reclaimer.java
===================================================================
--- branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/Reclaimer.java	2008-04-30 16:52:09 UTC (rev 4141)
+++ branches/trunk_tmp_aio/src/main/org/jboss/messaging/core/journal/impl/Reclaimer.java	2008-04-30 22:35:42 UTC (rev 4142)
@@ -65,37 +65,44 @@
 				totNeg += files[j].getNegCount(currentFile);
 			}
 			
-			currentFile.setCanReclaim(true);
+			boolean reclaim = true;
 			
 			if (posCount <= totNeg)
 			{   		
 	   		//Now we evaluate criterion 2)
 				
-	   		for (int j = 0; j <= i; j++)
+            log.info("Marking " + currentFile + " as reclaim, posCount = " + posCount + " totNeg = " + totNeg);
+
+            for (int j = 0; j <= i; j++)
 	   		{
 	   			JournalFile file = files[j];
 	   			
 	   			int negCount = currentFile.getNegCount(file);
 	   			
+	   			
 	   			if (negCount != 0)
 	   			{
-	   				if (file.isCanReclaim())
-	   				{
-	   					//Ok
-	   				}
-	   				else
-	   				{
-	   					currentFile.setCanReclaim(false);
-	   					
-	   					break;
-	   				}
+	               log.info("But the count from " + file + " was " + negCount +" so.. no reclaims");
+   				   reclaim = false;
+   					
+   					break;
 	   			}
 	   		}   		
 			}
 			else
 			{
-				currentFile.setCanReclaim(false);
-			}			
-		}			
+			   reclaim = false;
+			}
+			
+			if (reclaim)
+			{
+			}
+			
+			if (!currentFile.isCanReclaim())
+			{
+			   currentFile.setCanReclaim(reclaim);
+			}
+		}
+		
 	}
 }

Modified: branches/trunk_tmp_aio/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestUnit.java
===================================================================
--- branches/trunk_tmp_aio/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestUnit.java	2008-04-30 16:52:09 UTC (rev 4141)
+++ branches/trunk_tmp_aio/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestUnit.java	2008-04-30 22:35:42 UTC (rev 4142)
@@ -2284,27 +2284,81 @@
       loadAndCheck();
    }
 	
-	public void testTransactionOnDifferentFiles() throws Exception
-	{
-	   setup(2, 512 + 2*1024, true);
+   public void testTransactionOnDifferentFiles() throws Exception
+   {
+      setup(2, 512 + 2*1024, true);
 
-	   createJournal();
+      createJournal();
       startJournal();
       load();
 
+      log.info("JournalInfo: " + debugJournal());
+      
       addTx(1, 1, 2, 3, 4, 5, 6);
+
+      log.info("JournalInfo: " + debugJournal());
       updateTx(1, 1, 3, 5);
-      deleteTx(1, 1, 2, 3, 4, 5, 6);
+
+      log.info("JournalInfo: " + debugJournal());
       commit(1);
+      log.info("JournalInfo (right after commit 1): " + debugJournal());
+
+      addTx(3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 50);
+      log.info("JournalInfo: " + debugJournal());
+      deleteTx(2, 1, 2, 3, 4, 5, 6);
+
+      log.info("JournalInfo: " + debugJournal());
+      commit(2);
+
+      log.info("JournalInfo (right after commit 2): " + debugJournal());
       
-      addTx(2, 11, 12);
+      // Just to make sure the commit won't be released. The commit will be on the same file as addTx(3);
+      addTx(3, 11, 12);
+      log.info("JournalInfo: " + debugJournal());
       
       stopJournal();
       createJournal();
       startJournal();
       loadAndCheck();
       
+   }
+   
+   private String debugJournal()
+   {
+      
+      return "\n" + ((JournalImpl)journal).debug();
+   }
+	
+	public void testBreakingReclaiming() throws Exception
+	{
+      setup(2, calculateRecordSize(JournalImpl.SIZE_HEADER, getAlignment()) +  2*recordLength + JournalImpl.SIZE_DELETE_RECORD_TX , true);
+//      setup(2, 10*1024, true);
 	   
+      createJournal();
+      startJournal();
+      load();
+
+      addTx(1, 1);
+      updateTx(1, 1);
+      updateTx(1, 1);
+      updateTx(1, 1);
+      deleteTx(1, 1);
+      commit(1);
+      //addWithSize(100, 2);
+      //delete(2);
+      
+      stopJournal(); 
+      createJournal();
+      startJournal();
+      try
+      {
+      loadAndCheck();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
 	}
 	
 	public void testMultipleInterleavedTransactionsDifferentIDs() throws Exception




More information about the jboss-cvs-commits mailing list