activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1306780 - in /activemq/trunk/kahadb/src: main/java/org/apache/kahadb/index/ListNode.java test/java/org/apache/kahadb/index/ListIndexTest.java
Date Thu, 29 Mar 2012 10:33:11 GMT
Author: tabish
Date: Thu Mar 29 10:33:11 2012
New Revision: 1306780

URL: http://svn.apache.org/viewvc?rev=1306780&view=rev
Log:
additional fix for: https://issues.apache.org/jira/browse/AMQ-3775 

The ListIndex was not properly configured after a split occurred during put operations, the
page Ids weren't set correctly on split and the tail page Id was never set. 

Modified:
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/ListNode.java
    activemq/trunk/kahadb/src/test/java/org/apache/kahadb/index/ListIndexTest.java

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/ListNode.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/ListNode.java?rev=1306780&r1=1306779&r2=1306780&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/ListNode.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/ListNode.java Thu Mar 29 10:33:11
2012
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.NoSuchElementException;
+
 import org.apache.kahadb.page.Page;
 import org.apache.kahadb.page.Transaction;
 import org.apache.kahadb.util.LinkedNode;
@@ -325,6 +326,11 @@ public final class ListNode<Key,Value> {
             } else {
                 getContainingList().storeNode(tx, this, false);
             }
+
+            if (this.next == -1) {
+                getContainingList().setTailPageId(getPageId());
+            }
+
         } catch ( Transaction.PageOverflowIOException e ) {
             // If we get an overflow
             split(tx, addFirst);
@@ -343,15 +349,16 @@ public final class ListNode<Key,Value> {
         ListNode<Key, Value> extension = getContainingList().createNode(tx);
         if (isAddFirst) {
             // head keeps the first entry, insert extension with the rest
+            extension.setEntries(entries.getHead().splitAfter());
             extension.setNext(this.getNext());
+            extension.store(tx, isAddFirst);
             this.setNext(extension.getPageId());
-            extension.setEntries(entries.getHead().splitAfter());
         }  else {
-            this.setNext(extension.getPageId());
             extension.setEntries(entries.getTail().getPrevious().splitAfter());
+            extension.store(tx, isAddFirst);
             getContainingList().setTailPageId(extension.getPageId());
+            this.setNext(extension.getPageId());
         }
-        extension.store(tx, isAddFirst);
         store(tx, true);
     }
 

Modified: activemq/trunk/kahadb/src/test/java/org/apache/kahadb/index/ListIndexTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/test/java/org/apache/kahadb/index/ListIndexTest.java?rev=1306780&r1=1306779&r2=1306780&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/test/java/org/apache/kahadb/index/ListIndexTest.java (original)
+++ activemq/trunk/kahadb/src/test/java/org/apache/kahadb/index/ListIndexTest.java Thu Mar
29 10:33:11 2012
@@ -452,11 +452,8 @@ public class ListIndexTest extends Index
         LOG.info("Loading up the ListIndex with "+NUM_ITERATIONS+" entires and sparsely populating
the sequences.");
 
         for (int i = 0; i < NUM_ITERATIONS; ++i) {
-            tx =  pf.tx();
             test.add(tx, String.valueOf(expectedListEntries++), new SequenceSet());
-            tx.commit();
 
-            tx =  pf.tx();
             for (int j = 0; j < expectedListEntries; j++) {
 
                 SequenceSet sequenceSet = test.get(tx, String.valueOf(j));
@@ -474,16 +471,13 @@ public class ListIndexTest extends Index
                     test.put(tx, String.valueOf(j), sequenceSet);
                 }
             }
-            tx.commit();
         }
 
         LOG.info("Checking if Index has the expected number of entries.");
 
         for (int i = 0; i < NUM_ITERATIONS; ++i) {
-            tx =  pf.tx();
             assertTrue("List should contain Key["+i+"]",test.containsKey(tx, String.valueOf(i)));
             assertNotNull("List contents of Key["+i+"] should not be null", test.get(tx,
String.valueOf(i)));
-            tx.commit();
         }
 
         LOG.info("Index has the expected number of entries.");
@@ -491,13 +485,11 @@ public class ListIndexTest extends Index
         assertEquals(expectedListEntries, test.size());
 
         for (int i = 0; i < NUM_ITERATIONS; ++i) {
-            LOG.info("Size of ListIndex before removal of entry ["+i+"] is: " + test.size());
-            tx =  pf.tx();
+            LOG.debug("Size of ListIndex before removal of entry ["+i+"] is: " + test.size());
 
-//            assertTrue("List should contain Key["+i+"]",test.containsKey(tx, String.valueOf(i)));
+            assertTrue("List should contain Key["+i+"]",test.containsKey(tx, String.valueOf(i)));
             assertNotNull("List contents of Key["+i+"] should not be null", test.remove(tx,
String.valueOf(i)));
-            tx.commit();
-            LOG.info("Size of ListIndex after removal of entry ["+i+"] is: " + test.size());
+            LOG.debug("Size of ListIndex after removal of entry ["+i+"] is: " + test.size());
 
             assertEquals(expectedListEntries - (i + 1), test.size());
         }



Mime
View raw message