Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BPage.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BPage.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BPage.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BPage.java Sun Oct 9 17:03:52 2011 @@ -67,7 +67,7 @@ import org.apache.directory.server.i18n. /** * Page of a Btree. *

- * The page contains a number of key-value pairs. Keys are ordered to allow + * The page contains a number of key-value pairs. Keys are ordered to allow * dichotomic search. *

* If the page is a leaf page, the keys and values are user-defined and @@ -221,10 +221,14 @@ public class BPage implements Seri newPage.recordId = this.recordId; if ( this.children != null ) + { this.copyChildren( this, 0, newPage, 0, btree.pageSize ); // this copies keys as well + } - if (this.values != null ) + if (this.values != null ) + { this.copyEntries( this, 0, newPage, 0, btree.pageSize ); // this copies keys as well + } return newPage; } @@ -401,7 +405,7 @@ public class BPage implements Seri if ( replace ) { - pageNewCopy.values[index] = value; + pageNewCopy.values[index] = btree.copyValue( value ); btree.recordManager.update( recordId, pageNewCopy, this ); } @@ -956,10 +960,10 @@ public class BPage implements Seri /** * Set the entry at the given index. */ - private void setEntry( BPage page, int index, K key, V value ) + private void setEntry( BPage page, int index, K key, V value ) throws IOException { page.keys[index] = key; - page.values[index] = value; + page.values[index] = btree.copyValue( value ); } @@ -1075,11 +1079,11 @@ public class BPage implements Seri */ private void dump( int height ) { - String prefix = ""; + StringBuffer prefix = new StringBuffer(); for ( int i = 0; i < height; i++ ) { - prefix += " "; + prefix.append( " " ); } System.out.println( prefix + "-------------------------------------- BPage recordId=" + recordId ); @@ -1494,7 +1498,9 @@ public class BPage implements Seri finally { if ( context != null ) + { btree.unsetAsCurrentAction( context ); + } } return true; @@ -1502,7 +1508,8 @@ public class BPage implements Seri public boolean getPrevious( Tuple tuple ) throws IOException { - btree.setAsCurrentAction( context ); + btree.setAsCurrentAction( context ); + try { if ( index == page.first ) @@ -1514,7 +1521,7 @@ public class BPage implements Seri } else { - // reached beginning of the tree + // reached beginning of the tree return false; } } @@ -1533,8 +1540,10 @@ public class BPage implements Seri finally { if ( context != null ) + { btree.unsetAsCurrentAction( context ); - } + } + } return true; } @@ -1552,6 +1561,7 @@ public class BPage implements Seri } int browserCount = outstandingBrowsers.decrementAndGet(); + if ( browserCount > 0 ) { //System.out.println( "JDBM btree browsers are outstanding after close: " + browserCount ); Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BTree.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BTree.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BTree.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/btree/BTree.java Sun Oct 9 17:03:52 2011 @@ -949,6 +949,12 @@ public class BTree implements Exte byte[] array; V valueCopy = null; + + if ( value == null ) + { + return null; + } + if ( this.valueSerializer != null ) { array = this.valueSerializer.serialize( value ); @@ -969,7 +975,7 @@ public class BTree implements Exte out.flush(); byte[] arr = bout.toByteArray(); bin = new ByteArrayInputStream( arr ); - in =new ObjectInputStream( bin ); + in = new ObjectInputStream( bin ); valueCopy = ( V )in.readObject(); } catch ( ClassNotFoundException e ) Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionContext.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionContext.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionContext.java Sun Oct 9 17:03:52 2011 @@ -45,7 +45,7 @@ public class ActionContext public void endAction() { - assert( version != null ); + assert( version != null ) : "Unexpected action state during endAction: " + this; version = null; } @@ -78,4 +78,17 @@ public class ActionContext { return whoStarted; } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "ActionContext: " ); + sb.append( "(readOnly: " ).append( readOnly ); + sb.append( ", version: " ).append( version ); + sb.append( ", whoStarted: " ).append( whoStarted ); + sb.append( ")\n" ); + + return sb.toString(); + } } Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionVersioning.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionVersioning.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionVersioning.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ActionVersioning.java Sun Oct 9 17:03:52 2011 @@ -153,7 +153,7 @@ public class ActionVersioning { long numActions = version.getNumActions().decrementAndGet(); - assert( numActions >= 0 ); + assert( numActions >= 0 ) : "NumActions zero when read action is ended : " + version; if ( ( numActions > 0 ) || ( version == readReference.get() ) ) { @@ -216,5 +216,17 @@ public class ActionVersioning { return version; } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "Version: "); + sb.append( "(vesion: " ).append( version ); + sb.append( ", numActions: " ).append( numActions ); + sb.append( ")\n" ); + + return sb.toString(); + } } } \ No newline at end of file Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ExplicitList.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ExplicitList.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ExplicitList.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/ExplicitList.java Sun Oct 9 17:03:52 2011 @@ -31,8 +31,10 @@ package jdbm.helper; public class ExplicitList { - Link head = new Link( null ); + private Link head = new Link( null ); + private int listSize = 0; + public static class Link { private V element; @@ -73,7 +75,7 @@ public class ExplicitList public void remove() { - assert ( isLinked() ); + assert( isLinked() ) : "Trying to remove from list an unlinked link"; this.getPrev().setNext( this.getNext() ); this.getNext().setPrev( this.getPrev() ); this.reset(); @@ -82,6 +84,7 @@ public class ExplicitList public void addAfter( Link after ) { + assert( this.isUnLinked() ) : "Trying to add to list already linked link: " + this; after.getNext().setPrev( this ); this.setNext( after.getNext() ); after.setNext( this ); @@ -91,6 +94,7 @@ public class ExplicitList public void addBefore( Link before ) { + assert( this.isUnLinked() ) : "Trying to add to list already linked link: " + this; before.getPrev().setNext( this ); this.setPrev( before.getPrev() ); before.setPrev( this ); @@ -98,6 +102,11 @@ public class ExplicitList } + /** + * Splices the given list by making this link as the new head. + * + * @param listHead head of the existing list + */ public void splice( Link listHead ) { Link prevLink = listHead.getPrev(); @@ -110,7 +119,7 @@ public class ExplicitList public boolean isUnLinked() { - return ( prev == this && next == this ); + return ( ( prev == this ) && ( next == this ) ); } @@ -129,7 +138,7 @@ public class ExplicitList public void uninit() { - assert ( this.isUnLinked() ); + assert ( this.isUnLinked() ) : " Unitializing a still linked entry" + this; element = null; } @@ -138,23 +147,39 @@ public class ExplicitList { return this.element; } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "Link: " ).append( this ).append( " " ); + sb.append( "(next: " ).append( next ); + sb.append( ",prev: " ).append( prev ).append(")"); + sb.append( "\n" ); + + return sb.toString(); + } } public void remove( Link link ) { + assert( listSize > 0 ) : "Trying to remove link " + link + " from a list with no elements"; + listSize--; link.remove(); } public void addFirst( Link link ) { + listSize++; link.addAfter( head ); } public void addLast( Link link ) { + listSize++; link.addBefore( head ); } @@ -169,5 +194,21 @@ public class ExplicitList { return head; } + + public int size() + { + return listSize; + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "List: " ); + sb.append( "(size: " ).append( listSize ).append( ")" ); + sb.append( "\n" ); + + return sb.toString(); + } } \ No newline at end of file Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/LRUCache.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/LRUCache.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/LRUCache.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/helper/LRUCache.java Sun Oct 9 17:03:52 2011 @@ -1,4 +1,4 @@ -/* + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -65,7 +65,7 @@ public class LRUCache private final int numBuckets; /** Log of number of hash buckets each latch protects */ - private final static int LOG_BUCKET_PER_LATCH = 3; + private final static int LOG_BUCKET_PER_LATCH = 0; /** Number of lrus */ private final static int NUM_LRUS = 16; @@ -74,7 +74,7 @@ public class LRUCache private final static int MIN_ENTRIES = 1 << 10; /** Max sleep time(in ms) for writes in case of cache eviction failure */ - private final static long MAX_WRITE_SLEEP_TIME = 10000; + private final static long MAX_WRITE_SLEEP_TIME = 600000; /** lru list */ LRU lrus[]; @@ -94,8 +94,18 @@ public class LRUCache /** minimum version cache has to satisfy during reads */ private long minReadVersion; - - + /** Stats to keep track of cache gets */ + private long cacheGets; + + /** Stats to keep track of cache hits for cache gets */ + private long cacheMisses; + + /** Stats to keep track of cache puts */ + private long cachePuts; + + /** Stats to keep track of # of times writes sleep for free cache entry */ + private long cachePutSleeps; + @SuppressWarnings("unchecked") public LRUCache( EntryIO entryIO, int cacheSize ) { @@ -196,6 +206,8 @@ public class LRUCache * While reading or waiting, latch is released. */ + this.cachePuts++; + while ( true ) { latches[latchIndex].lock(); @@ -226,7 +238,19 @@ public class LRUCache if ( !entry.isCurrentVersion() ) { - CacheEntry newEntry = this.findNewEntry( key, latchIndex ); + assert( entry.isNeverReplace() == false ) : " Non current entry should not have neverReplace set " + entry; + + entry.setNeverReplace(); + CacheEntry newEntry = null; + + try + { + newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH ); + } + finally + { + entry.clearNeverReplace(); + } /* * Remove existing entry, chain as a snapshot @@ -269,7 +293,7 @@ public class LRUCache // FALLTHROUGH default: - assert ( false ); + assert ( false ): "Unknown cache entry state: " + entry ; } } else @@ -287,6 +311,7 @@ public class LRUCache if ( sleepForFreeEntry == false ) { + System.out.println(" NO cache entry for write " + totalSleepTime ); throw e; } } @@ -314,6 +339,11 @@ public class LRUCache break; } } + + if ( totalSleepTime != 0 ) + { + this.cachePutSleeps++; + } } @@ -346,6 +376,9 @@ public class LRUCache * * While reading or waiting, latch is released. */ + + this.cacheGets++; + latches[latchIndex].lock(); boolean chainExists = false; @@ -374,10 +407,26 @@ public class LRUCache { value = this.searchChainForVersion( entry, version ); - if (value != null) + if ( value != null ) + { break; - - CacheEntry newEntry = this.findNewEntry( key, latchIndex ); + } + + this.cacheMisses++; + + assert( entry.isNeverReplace() == false ) : "Non Current Entry has neverReplace set to true:" + entry; + + entry.setNeverReplace(); + CacheEntry newEntry = null; + + try + { + newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH ); + } + finally + { + entry.clearNeverReplace(); + } /* * Remove existing entry, chain as a snapshot @@ -411,16 +460,18 @@ public class LRUCache case ENTRY_INITIAL: LOG.warn( "Entry with key {} is at intial while trying to read from it", entry.getKey() ); + this.cacheMisses++; this.doRead( entry, latches[latchIndex], serializer ); value = this.searchChainForVersion( entry, version ); break; default: - assert ( false ); + assert ( false ) : "Unknown cache entry state: " + entry; } } else { + this.cacheMisses++; entry = this.findNewEntry( key, latchIndex ); buckets[hashIndex].add( entry ); this.doRead( entry, latches[latchIndex], serializer ); @@ -444,6 +495,21 @@ public class LRUCache return value; } + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "LRUCache: " ); + sb.append( "(numEntries:" ).append( this.numEntries ); + sb.append( ",maxEntries:" ).append( this.maxEntries ); + sb.append( ",cacheGets:" ).append( this.cacheGets ); + sb.append( ",cacheMisses:" ).append( this.cacheMisses ); + sb.append( ",cachePuts:" ).append( this.cachePuts ); + sb.append( ",cachePutSleeps:" ).append( this.cachePutSleeps ); + sb.append( ")\n" ); + + return sb.toString(); + } /** * Creates a new version of the given entry with the given new version. @@ -461,12 +527,33 @@ public class LRUCache private void putNewVersion( CacheEntry entry, K key, V value, long newVersion, int hashIndex, Lock latch, Serializer serializer, boolean neverReplace ) throws IOException, CacheEvictionException { + if ( entry.getStartVersion() != newVersion ) { - CacheEntry newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH ); - - // Initialize and set to new version - newEntry.initialize( key ); + + boolean resetNeverReplace = true; + + if ( entry.isNeverReplace() ) + { + resetNeverReplace = false; + } + + entry.setNeverReplace(); + CacheEntry newEntry = null; + + try + { + newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH ); + } + finally + { + if ( resetNeverReplace ) + { + entry.clearNeverReplace(); + } + } + + // Set to new version newEntry.setAsCurrentVersion( value, newVersion ); /* @@ -482,7 +569,7 @@ public class LRUCache } else { - assert( entry.isCurrentVersion() ); + assert( entry.isCurrentVersion() ) : "Entry not at expected version: " + entry ; // Entry already at current version. Just update the value entry.setAsCurrentVersion( value, newVersion ); @@ -506,7 +593,11 @@ public class LRUCache * Not much we can do here, just leave the entry in an * inconsistent state. */ + latch.lock(); + + entry.setState( EntryState.ENTRY_INITIAL ); + entry.clearNeverReplace(); if ( entry.anyWaiters() ) { @@ -559,14 +650,15 @@ public class LRUCache if ( curEntry.getState() != EntryState.ENTRY_READY ) { - assert( curEntry == head ); + assert( curEntry == head ) : "Unexpected state for entry: " + curEntry; curLink = curLink.getNext(); continue; } if ( curStartVersion != 0 && ( curEntry.getEndVersion() > curStartVersion ) ) { - assert( false ); + assert( false ) : "Unexpected version number for entry. curStartVersion: " + + curStartVersion + " entry: " + curEntry; } curStartVersion = curEntry.getStartVersion(); @@ -594,7 +686,7 @@ public class LRUCache if ( value == null && mustFind == true ) { - assert( false ); + assert( false ) : "Traversed all versions and could not find cache entry"; } return value; @@ -711,18 +803,17 @@ public class LRUCache numEntries.incrementAndGet(); CacheEntry newEntry = new CacheEntry( index ); lru = lrus[index]; + newEntry.initialize( key ); lru.getLock().lock(); lru.addToLRU( newEntry ); lru.getLock().unlock(); - newEntry.initialize( key ); return newEntry; } /* * We start with a lru determined by the lru randomizer and try to lock the lru without waiting. - * If this doesnt work, we wait on the first lru lock. Once we get the lru, we walk over each lru - * (this time waiting on the lock when we switch to a new lru) and try to find a victim. + * If this doesnt work, we wait on the first lru lock. */ CacheEntry victimEntry = null; lru = null; @@ -747,37 +838,23 @@ public class LRUCache lru.getLock().lock(); } - int startingIndex = curIndex; + victimEntry = lru.findVictim( latchIndex ); - do - { - victimEntry = lru.findVictim( latchIndex ); - lru.getLock().unlock(); - - if ( victimEntry != null ) - { - break; - } - - curIndex = (curIndex + 1) % NUM_LRUS; - if ( curIndex == startingIndex ) - break; - - lru = lrus[curIndex]; - lru.getLock().lock(); - } - while ( true ); if ( victimEntry != null ) { victimEntry.initialize( key ); + lru.getLock().unlock(); } else { + lru.getLock().unlock(); + LOG.warn( "Cache eviction failure: " + this.minReadVersion ); throw new CacheEvictionException( null ); } + return victimEntry; } @@ -856,17 +933,18 @@ public class LRUCache { this.key = key; value = null; - startVersion = endVersion = 0; + startVersion = 0; + endVersion = Long.MAX_VALUE; stateCondition = null; - assert ( numWaiters == 0 ); + assert ( numWaiters == 0 ) : "Numwaiters is not zero when entry is newly initialized: " + this; state = EntryState.ENTRY_INITIAL; assert ( versionsLink.isUnLinked() == true ); hashIndex = hash( key ) & ( numBuckets - 1 ); - assert( neverReplace == false ); + assert( neverReplace == false ) : "Neverreplace is true when entry is newly intialized:" + this; } public void setNeverReplace() @@ -874,6 +952,16 @@ public class LRUCache neverReplace = true; } + public void clearNeverReplace() + { + neverReplace = false; + } + + public boolean isNeverReplace() + { + return neverReplace; + } + public K getKey() { @@ -918,7 +1006,7 @@ public class LRUCache public void decrementWaiters() { - assert ( numWaiters > 0 ); + assert ( numWaiters > 0 ) : "Unexpected num waiters for entry:" + this; numWaiters--; } @@ -1000,10 +1088,10 @@ public class LRUCache public void setAsSnapshotVersion( long newEndVersion ) { - this.endVersion = newEndVersion; - neverReplace = false; + this.clearNeverReplace(); LRU lru = this.getLru(); lru.getLock().lock(); + this.endVersion = newEndVersion; lru.addToSnapshots( this ); lru.getLock().unlock(); } @@ -1014,6 +1102,23 @@ public class LRUCache return ( this.state != EntryState.ENTRY_READING && this.numWaiters == 0 && this.state != EntryState.ENTRY_WRITING && !neverReplace); } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "Entry: " ); + sb.append("(state: ").append( this.state ); + sb.append(",numWaiters:").append( this.numWaiters ); + sb.append(",startVersion:").append( this.startVersion ); + sb.append(",endVersion:").append( this.endVersion ); + sb.append(",key:").append( this.key ); + sb.append(",value:").append( this.value ).append( ")" ); + sb.append( "\n" ); + + return sb.toString(); + + } } @@ -1023,11 +1128,14 @@ public class LRUCache private ExplicitList mostRecentVersions = new ExplicitList(); /** List of snapshot entries */ - private LinkedList snapshotVersions = new LinkedList(); + private ExplicitList snapshotVersions = new ExplicitList(); /** Lock protecting the list */ private Lock lock = new ReentrantLock(); + /** Number of snaphot versions created */ + private int numSnapshotsCreated; + public Lock getLock() { return lock; @@ -1054,7 +1162,9 @@ public class LRUCache public void addToSnapshots( CacheEntry entry ) { mostRecentVersions.remove( entry.getLruLink() ); - snapshotVersions.addLast( entry ); + snapshotVersions.addLast( entry.getLruLink() ); + + numSnapshotsCreated++; } @@ -1074,7 +1184,7 @@ public class LRUCache /** * Increases the hotness of the given entry * - * @param entry cahce entry for which we will increase hotness + * @param entry cache entry for which we will increase hotness */ public void touch( CacheEntry entry ) { @@ -1093,7 +1203,6 @@ public class LRUCache public CacheEntry findVictim( int latchIndex ) { CacheEntry victimEntry = null; - boolean victimFound = false; int victimBucketIndex; int victimLatchIndex; @@ -1102,28 +1211,40 @@ public class LRUCache * gotten from the tail of the lru. */ - Iterator it = snapshotVersions.listIterator(); + ExplicitList.Link curLink; + + curLink = snapshotVersions.begin(); - while ( it.hasNext() ) + while ( curLink != snapshotVersions.end() ) { - victimEntry = it.next(); + victimEntry = curLink.getElement(); if ( victimEntry.getEndVersion() > minReadVersion ) { break; } + + assert( victimEntry.getKey() != null ) : + "Snapshot victimEntry doesnt have key set:" + victimEntry ; - assert ( victimEntry.isEntryFreeable() == true ); - + if ( victimEntry.isNeverReplace() ) + { + curLink = curLink.getNext(); + continue; + } victimBucketIndex = victimEntry.getHashIndex(); victimLatchIndex = (victimBucketIndex >> LOG_BUCKET_PER_LATCH ); if ( ( latchIndex != victimLatchIndex ) && ( latches[victimLatchIndex].tryLock() == false ) ) { + curLink = curLink.getNext(); continue; } + assert( victimEntry.isEntryFreeable() == true ) : + "Snapshot victimEntry is not freeable:" + victimEntry ; + int hashChainIndex = buckets[victimEntry.getHashIndex()].indexOf( victimEntry ); if ( hashChainIndex != -1 ) @@ -1149,13 +1270,13 @@ public class LRUCache latches[victimLatchIndex].unlock(); } - it.remove(); - this.mostRecentVersions.addLast( victimEntry.lruLink ); + this.snapshotVersions.remove( victimEntry.getLruLink() ); + this.mostRecentVersions.addLast( victimEntry.getLruLink() ); return victimEntry; } - ExplicitList.Link curLink = mostRecentVersions.begin(); + curLink = mostRecentVersions.begin(); while ( curLink != mostRecentVersions.end() ) { Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java Sun Oct 9 17:03:52 2011 @@ -61,6 +61,8 @@ import jdbm.helper.DefaultSerializer; import jdbm.helper.Serializer; import org.apache.directory.server.i18n.I18n; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class manages records, which are uninterpreted blobs of data. The @@ -86,6 +88,9 @@ import org.apache.directory.server.i18n. */ public final class BaseRecordManager implements RecordManager { + /** A logger for this class */ + private static final Logger LOG = LoggerFactory.getLogger( BaseRecordManager.class.getSimpleName() ); + /** Underlying record recordFile. */ private RecordFile recordFile; @@ -230,6 +235,7 @@ public final class BaseRecordManager imp public TransactionManager getTransactionManager() throws IOException { checkIfClosed(); + return recordFile.getTxnMgr(); } @@ -300,10 +306,7 @@ public final class BaseRecordManager imp physRowId = physMgr.insert( data, 0, data.length ); recid = logMgr.insert( physRowId ).toLong(); - if ( DEBUG ) - { - System.out.println( "BaseRecordManager.insert() recid " + recid + " length " + data.length ) ; - } + LOG.debug( "BaseRecordManager.insert() recid {} length {}", recid, data.length ) ; return recid; } @@ -325,13 +328,10 @@ public final class BaseRecordManager imp throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } - if ( DEBUG ) - { - System.out.println( "BaseRecordManager.delete() recid " + recid ) ; - } + LOG.debug( "BaseRecordManager.delete() recid {}", recid ) ; - element = this.beginIO(recid, IOType.WRITE_IO); + element = beginIO( recid, IOType.WRITE_IO ); try { @@ -342,7 +342,7 @@ public final class BaseRecordManager imp } finally { - this.endIO(recid, element, IOType.WRITE_IO); + this.endIO( recid, element, IOType.WRITE_IO ); } } @@ -379,7 +379,7 @@ public final class BaseRecordManager imp throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) ); } - element = this.beginIO(recid, IOType.WRITE_IO); + element = this.beginIO( recid, IOType.WRITE_IO ); try { @@ -388,10 +388,7 @@ public final class BaseRecordManager imp byte[] data = serializer.serialize( obj ); - if ( DEBUG ) - { - System.out.println( "BaseRecordManager.update() recid " + recid + " length " + data.length ) ; - } + LOG.debug( "BaseRecordManager.update() recid {} length {}", recid, data.length ) ; Location newRecid = physMgr.update( physRecid, data, 0, data.length ); @@ -402,7 +399,7 @@ public final class BaseRecordManager imp } finally { - this.endIO(recid, element, IOType.WRITE_IO); + endIO( recid, element, IOType.WRITE_IO ); } } @@ -446,21 +443,18 @@ public final class BaseRecordManager imp { byte[] data; - data = physMgr.fetch( logMgr.fetch( new Location( recid ) ) ); + Location location = logMgr.fetch( new Location( recid ) ) ; + data = physMgr.fetch( location ); - if ( DEBUG ) - { - System.out.println( "BaseRecordManager.fetch() recid " + recid + " length " + data.length ) ; - } + LOG.debug( "BaseRecordManager.fetch() recid {} length {}", recid, data.length ) ; result = serializer.deserialize( data ); } finally { - this.endIO(recid, element, IOType.READ_IO); + endIO(recid, element, IOType.READ_IO); } - return result; } Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/CacheRecordManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/CacheRecordManager.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/CacheRecordManager.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/CacheRecordManager.java Sun Oct 9 17:03:52 2011 @@ -423,7 +423,7 @@ public class CacheRecordManager implemen /** * A class to store a cached entry. */ - private class CacheEntry + private static class CacheEntry { long recid; Object obj; Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/PhysicalRowIdManager.java Sun Oct 9 17:03:52 2011 @@ -55,28 +55,37 @@ import java.io.IOException; */ final class PhysicalRowIdManager { - // The file we're talking to and the associated page manager. + /** The file we're talking to and the associated page manager. */ private RecordFile file; + + /** The page manager */ private PageManager pageManager; - private FreePhysicalRowIdPageManager freeman; + + /** The FreePage manager */ + private FreePhysicalRowIdPageManager freePageManager; /** * Creates a new rowid manager using the indicated record file. * and page manager. + * @throws IOException If we had an issue while creating the file */ PhysicalRowIdManager( PageManager pageManager ) throws IOException { this.pageManager = pageManager; - this.file = pageManager.getRecordFile(); - this.freeman = new FreePhysicalRowIdPageManager( pageManager ); + file = pageManager.getRecordFile(); + freePageManager = new FreePhysicalRowIdPageManager( pageManager ); } + /** * Inserts a new record. Returns the new physical rowid. */ Location insert( byte[] data, int start, int length ) throws IOException { + // Find the location for the added data Location retval = alloc( length ); + + // And write it write( retval, data, start, length ); return retval; @@ -181,7 +190,7 @@ final class PhysicalRowIdManager */ private Location alloc( int size ) throws IOException { - Location retval = freeman.get( size ); + Location retval = freePageManager.get( size ); if ( retval == null ) { @@ -323,7 +332,7 @@ final class PhysicalRowIdManager file.release( id.getBlock(), true ); // write the rowid to the free list - freeman.put( id, hdr.getAvailableSize() ); + freePageManager.put( id, hdr.getAvailableSize() ); } @@ -342,6 +351,7 @@ final class PhysicalRowIdManager if ( length == 0 ) { file.release( curs.getBlockId(), true ); + return; } @@ -355,11 +365,12 @@ final class PhysicalRowIdManager // copy current page's data to return buffer int toCopy = RecordFile.BLOCK_SIZE - dataOffset; - if ( leftToWrite < toCopy ) { + if ( leftToWrite < toCopy ) + { toCopy = leftToWrite; } - System.arraycopy( data, offsetInBuffer, block.getData(), - dataOffset, toCopy ); + + System.arraycopy( data, offsetInBuffer, block.getData(), dataOffset, toCopy ); // Go to the next block leftToWrite -= toCopy; Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java Sun Oct 9 17:03:52 2011 @@ -47,16 +47,16 @@ public class SnapshotRecordManager imple /** Wrapped RecordManager */ protected RecordManager recordManager; - /** Per thread action context */ private static final ThreadLocal < ActionContext > actionContextVar = - new ThreadLocal < ActionContext > () { + new ThreadLocal < ActionContext > () + { @Override protected ActionContext initialValue() { return null; } - }; + }; /** Used for keeping track of actions versions */ ActionVersioning versioning = new ActionVersioning(); @@ -107,7 +107,7 @@ public class SnapshotRecordManager imple } actionContext.beginAction( readOnly, version, whoStarted ); - this.setCurrentActionContext( actionContext ); + setCurrentActionContext( actionContext ); return actionContext; } @@ -158,7 +158,7 @@ public class SnapshotRecordManager imple assert( false ); } - this.unsetCurrentActionContext( actionContext ); + unsetCurrentActionContext( actionContext ); if ( minVersion != null ) { @@ -199,7 +199,7 @@ public class SnapshotRecordManager imple assert( false ); } - this.unsetCurrentActionContext( actionContext ); + unsetCurrentActionContext( actionContext ); if ( minVersion != null ) { @@ -250,7 +250,7 @@ public class SnapshotRecordManager imple if ( actionContext == null ) { - actionContext = this.beginAction( false, "insert missing action" ); + actionContext = beginAction( false, "insert missing action" ); startedAction = true; } @@ -260,14 +260,14 @@ public class SnapshotRecordManager imple { recid = recordManager.insert( obj, serializer ); - versionedCache.put( new Long( recid ), obj, actionContext.getVersion().getVersion(), + versionedCache.put( Long.valueOf( recid ), obj, actionContext.getVersion().getVersion(), serializer, false ); } catch ( IOException e ) { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -277,7 +277,7 @@ public class SnapshotRecordManager imple { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -287,7 +287,7 @@ public class SnapshotRecordManager imple { if ( startedAction && !abortedAction ) { - this.endAction ( actionContext ); + endAction( actionContext ); } } @@ -311,21 +311,21 @@ public class SnapshotRecordManager imple if ( actionContext == null ) { - actionContext = this.beginAction( false, "delete missing action" ); + actionContext = beginAction( false, "delete missing action" ); startedAction = true; } // Update the cache try { - versionedCache.put( new Long( recid ), null, actionContext.getVersion().getVersion(), + versionedCache.put( Long.valueOf( recid ), null, actionContext.getVersion().getVersion(), null, false ); } catch ( IOException e ) { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -335,17 +335,17 @@ public class SnapshotRecordManager imple { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } throw new IOException( except.getLocalizedMessage() ); - } + } finally { if ( startedAction && !abortedAction ) { - this.endAction ( actionContext ); + endAction( actionContext ); } } } @@ -381,20 +381,20 @@ public class SnapshotRecordManager imple if ( actionContext == null ) { - actionContext = this.beginAction( false, "update missing action" ); + actionContext = beginAction( false, "update missing action" ); startedAction = true; } try { - versionedCache.put( new Long( recid ), obj, actionContext.getVersion().getVersion(), + versionedCache.put( Long.valueOf( recid ), obj, actionContext.getVersion().getVersion(), serializer, recid < 0 ); } catch ( IOException e ) { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -404,7 +404,7 @@ public class SnapshotRecordManager imple { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -414,7 +414,7 @@ public class SnapshotRecordManager imple { if ( startedAction && !abortedAction ) { - this.endAction ( actionContext ); + endAction ( actionContext ); } } } @@ -452,20 +452,20 @@ public class SnapshotRecordManager imple if ( actionContext == null ) { - actionContext = this.beginAction( false, "fetch missing action" ); + actionContext = beginAction( false, "fetch missing action" ); startedAction = true; } try { - obj = versionedCache.get( new Long( recid ), actionContext.getVersion().getVersion(), + obj = versionedCache.get( Long.valueOf( recid ), actionContext.getVersion().getVersion(), serializer ); } catch ( IOException e ) { if ( startedAction ) { - this.abortAction( actionContext ); + abortAction( actionContext ); abortedAction = true; } @@ -475,7 +475,7 @@ public class SnapshotRecordManager imple { if ( startedAction && !abortedAction ) { - this.endAction ( actionContext ); + endAction( actionContext ); } } @@ -625,6 +625,17 @@ public class SnapshotRecordManager imple bigLock.unlock(); } } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append( "SnapshotRecordManager: " ); + sb.append( "(lruCache:" ).append( versionedCache ); + sb.append( ")\n" ); + + return sb.toString(); + } /** Modified: directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java (original) +++ directory/apacheds/branches/one-sub-level-index-removal/jdbm/src/test/java/jdbm/btree/TestSnapshotBTree.java Sun Oct 9 17:03:52 2011 @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTru import java.io.IOException; import java.io.Serializable; +import java.util.Random; import java.util.concurrent.Semaphore; import jdbm.RecordManager; @@ -36,10 +37,6 @@ import jdbm.recman.SnapshotRecordManager import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; - -import com.mycila.junit.concurrent.Concurrency; -import com.mycila.junit.concurrent.ConcurrentJunitRunner; /** * @@ -47,8 +44,6 @@ import com.mycila.junit.concurrent.Concu * * @author Apache Directory Project */ -@RunWith(ConcurrentJunitRunner.class) -@Concurrency() public class TestSnapshotBTree { @Rule @@ -77,8 +72,8 @@ public class TestSnapshotBTree int idx; int numReadThreads = 1; - TestThread readThreads[] = new TestThread[numReadThreads]; - TestThread updateThread; + BasicTestThread readThreads[] = new BasicTestThread[numReadThreads]; + BasicTestThread updateThread; Semaphore browseSem = new Semaphore( 0 ); Semaphore updateSem = new Semaphore( 0 ); @@ -95,17 +90,17 @@ public class TestSnapshotBTree for ( idx = 0; idx < numReadThreads; idx++ ) { - readThreads[idx] = new TestThread( true, tree, browseSem, updateSem, numReadThreads ); + readThreads[idx] = new BasicTestThread( true, tree, browseSem, updateSem, numReadThreads ); } - updateThread = new TestThread( false, tree, browseSem, updateSem, numReadThreads ); + updateThread = new BasicTestThread( false, tree, browseSem, updateSem, numReadThreads ); updateThread.start(); + for ( idx = 0; idx < numReadThreads; idx++ ) { readThreads[idx].start(); } - for ( idx = 0; idx < numReadThreads; idx++ ) { readThreads[idx].join(); @@ -115,8 +110,10 @@ public class TestSnapshotBTree snapshotRecman.close(); } + + - class TestThread extends Thread + class BasicTestThread extends Thread { boolean readOnly; BTree btree; @@ -124,8 +121,8 @@ public class TestSnapshotBTree Semaphore updateSem; int numReadThreads; - TestThread( boolean readOnly, BTree btree, Semaphore firstBrowse, - Semaphore updateDone, int numReadThreads) + BasicTestThread( boolean readOnly, BTree btree, Semaphore firstBrowse, + Semaphore updateDone, int numReadThreads ) { this.readOnly = readOnly; this.btree = btree; @@ -158,7 +155,9 @@ public class TestSnapshotBTree // Sleep a little randomly. if ( (count & 7) == 0 ) + { Thread.sleep( 1 ); + } assertTrue( tuple.getValue().value != -1 ); } @@ -172,6 +171,7 @@ public class TestSnapshotBTree browser = btree.browse( new Integer( 10 ) ); browseSem.release(); + for ( idx = 20; idx < 1024; idx++ ) { assertTrue( browser.getNext( tuple ) ); @@ -179,6 +179,7 @@ public class TestSnapshotBTree //System.out.println( "key:"+ tuple.getKey().intValue() + " idx:" + idx ); assertTrue( tuple.getKey().intValue() == idx ); } + browser.close(); } @@ -187,7 +188,9 @@ public class TestSnapshotBTree int idx; for ( idx = 0; idx < numReadThreads; idx++ ) + { browseSem.acquireUninterruptibly(); + } Integer key = new Integer( 1023 ); @@ -211,6 +214,7 @@ public class TestSnapshotBTree btree.insert( key, value , true ); btree.insert( new Integer(1024), new IntWrapper( -1 ), true ); + for ( idx = 10; idx < 20; idx++ ) { btree.remove( new Integer( idx ) ); @@ -219,15 +223,186 @@ public class TestSnapshotBTree updateSem.release(); for ( idx = 0; idx < numReadThreads; idx++ ) + { browseSem.acquireUninterruptibly(); + } for ( idx = 0; idx < 10; idx++ ) + { btree.remove( new Integer( idx ) ); + } for ( idx = 20; idx < 1024; idx++ ) + { btree.remove( new Integer( idx ) ); + } + } + public void run() + { + try + { + if ( readOnly ) + { + this.readOnlyActions(); + } + else + { + this.readWriteActions(); + } + } + catch( IOException e ) + { + e.printStackTrace(); + assertTrue( false ); + } + catch( InterruptedException e ) + { + e.printStackTrace(); + assertTrue( false ); + } + + } + } // end of class BasicTestThread + + + @Test + public void testLongBrowsing() throws IOException, InterruptedException + { + RecordManager recman; + BTree tree; + int numElements = 10000; + + int idx; + int numReadThreads = 4; + LongBrowsingTestThread readThreads[] = new LongBrowsingTestThread[numReadThreads]; + LongBrowsingTestThread updateThread; + + recman = RecordManagerFactory.createRecordManager( getTemporaryFile( "testLongBrowsing" ) ); + SnapshotRecordManager snapshotRecman = new SnapshotRecordManager( recman, 1 << 10 ); + + tree = new BTree( snapshotRecman, new IntegerComparator() ); + + for ( idx = 0; idx < numElements; idx++ ) + { + tree.insert( new Integer( idx ), new IntWrapper( 0 ), true ); + } + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + readThreads[idx] = new LongBrowsingTestThread( true, tree, numElements); + } + updateThread = new LongBrowsingTestThread( false, tree, numElements ); + + + readThreads[0].start(); + + Thread.sleep( 10 ); + + updateThread.start(); + + for ( idx = 1; idx < numReadThreads; idx++ ) + { + Thread.sleep( 1000 ); + readThreads[idx].start(); + } + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + readThreads[idx].join(); + } + + updateThread.join(); + + snapshotRecman.close(); + } + + class LongBrowsingTestThread extends Thread + { + boolean readOnly; + BTree btree; + int numElements; + + + LongBrowsingTestThread( boolean readOnly, BTree btree, int numElements) + { + this.readOnly = readOnly; + this.btree = btree; + this.numElements = numElements; + } + + + + private void readOnlyActions() throws IOException, InterruptedException + { + int count = 0; + TupleBrowser browser = btree.browse(); + Tuple tuple = new Tuple(); + + assertTrue( browser.getNext( tuple ) ); + int max = tuple.getValue().value; + count++; + System.out.println( " TestLongBrowsing read thread min key is" + tuple.getKey() + "max value is" + max ); + + while( browser.getNext( tuple ) ) + { + count++; + + // Sleep for a while to keep browsing long + Thread.sleep( 10 ); + + + if ( tuple.getValue().value > max ) + { + System.out.println(" tupe value:" + tuple.getValue().value + " Expected max:" + max + " count:" + count); + + } + + assertTrue( tuple.getValue().value <= max ); + + } + + + System.out.println( "TestLongBrowsing read thread count is " + count ); + assertEquals( count, numElements ); + browser.close(); + } + + private void readWriteActions() + { + int idx; + Random updateRandomizer = new Random(); + + try + { + for ( idx = 1; idx < 100; idx++ ) + { + Integer key = new Integer( 0 ); + IntWrapper value = btree.find( key ); + value.value = idx; + btree.insert( key, value, true ); + + for ( int updates = 0; updates < 2048; updates++ ) + { + key = new Integer( updateRandomizer.nextInt( numElements ) ); + value = btree.find( key ); + + assertTrue( value.value <= idx ); + + value.value = idx; + btree.insert( key, value, true ); + } + } + + System.out.println( "TestLongBrowsing updates ended" ); + + } + catch( IOException e ) + { + e.printStackTrace(); + assertTrue( false ); + } } @@ -236,18 +411,197 @@ public class TestSnapshotBTree try { if ( readOnly ) + { this.readOnlyActions(); + } else + { this.readWriteActions(); + } } catch( IOException e ) { + e.printStackTrace(); + assertTrue( false ); } catch( InterruptedException e ) { + e.printStackTrace(); + assertTrue( false ); + } + + } + } // end of class LongBrowsingTestThread + + + + @Test + public void testRemoveInsert() throws IOException, InterruptedException + { + RecordManager recman; + BTree tree; + int numElements = 10000; + + int idx; + int numReadThreads = 4; + RemoveInsertTestThread readThreads[] = new RemoveInsertTestThread[numReadThreads]; + RemoveInsertTestThread updateThread; + + Semaphore browseSem = new Semaphore( 0 ); + + recman = RecordManagerFactory.createRecordManager( getTemporaryFile( "testRemoveInsert" ) ); + SnapshotRecordManager snapshotRecman = new SnapshotRecordManager( recman, 1 << 12 ); + + tree = new BTree( snapshotRecman, new IntegerComparator() ); + + for ( idx = 0; idx < numElements; idx++ ) + { + tree.insert( new Integer( idx ), new IntWrapper( 0 ), true ); + } + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + readThreads[idx] = new RemoveInsertTestThread( true, tree, numElements, browseSem, numReadThreads ); + } + updateThread = new RemoveInsertTestThread( false, tree, numElements, browseSem, numReadThreads ); + + + updateThread.start(); + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + Thread.sleep( 1000 ); + readThreads[idx].start(); + } + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + readThreads[idx].join(); + } + updateThread.join(); + + snapshotRecman.close(); + } + + + + class RemoveInsertTestThread extends Thread + { + boolean readOnly; + BTree btree; + int numElements; + Semaphore browseSem; + int numReadThreads; + + RemoveInsertTestThread( boolean readOnly, BTree btree, int numElements, Semaphore browseSem, int numReadThreads ) + { + this.readOnly = readOnly; + this.btree = btree; + this.numElements = numElements; + this.browseSem = browseSem; + this.numReadThreads = numReadThreads; + } + + private void readOnlyActions() throws IOException, InterruptedException + { + int count = 0; + TupleBrowser browser = btree.browse(); + Tuple tuple = new Tuple(); + + browseSem.release(); + + while( browser.getNext( tuple ) ) + { + count++; + + // Sleep for a while to keep browsing long + Thread.sleep( 10 ); + + + if ( tuple.getValue().value == -1 ) + { + System.out.println(" tupe key:" + tuple.getKey() + " value:" + tuple.getValue().value); + + } + + assertTrue( tuple.getValue().value != -1 ); + } + + + System.out.println( "TestRemoveInsert read thread count is " + count ); + assertEquals( count, numElements ); + browser.close(); + } + + private void readWriteActions() throws IOException, InterruptedException + { + int idx; + Random updateRandomizer = new Random(); + + for ( idx = 0; idx < numReadThreads; idx++ ) + { + browseSem.acquireUninterruptibly(); + } + + + Integer key; + IntWrapper value = new IntWrapper( -1 ); + + for ( idx = 0; idx < 10; idx++ ) + { + Thread.sleep( 10000 ); + + int startingIndex = updateRandomizer.nextInt( numElements ); + for ( int updates = 0; updates < 32; updates++ ) + { + key = new Integer( startingIndex + updates ); + + if ( key.intValue() >= numElements ) + { + break; + } + + btree.remove( key ); + } + + for ( int updates = 0; updates < 32; updates++ ) + { + key = new Integer( startingIndex + updates ); + btree.insert( key, value, true ); + } + } + + System.out.println( "TestRemoveInsert updates ended" ); + + } + + + public void run() + { + try + { + if ( readOnly ) + { + this.readOnlyActions(); + } + else + { + this.readWriteActions(); + } } + catch( IOException e ) + { + e.printStackTrace(); + assertTrue( false ); + } + catch( InterruptedException e ) + { + e.printStackTrace(); + assertTrue( false ); + } + } - } // end of class TestThread + } // end of class RemoveInsertTestThread } \ No newline at end of file Modified: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/pom.xml?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/pom.xml (original) +++ directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/pom.xml Sun Oct 9 17:03:52 2011 @@ -22,7 +22,7 @@ org.apache.directory.server apacheds-parent - 2.0.0-M3-SNAPSHOT + 2.0.0-M4-SNAPSHOT apacheds-kerberos-codec Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/server/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/server:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -2,5 +2,5 @@ /directory/apacheds/branches/apacheds-config/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1023442-1029077 /directory/apacheds/branches/apacheds-dnfactory-experiment/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:980138-980936 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/types/PaDataType.java:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -2,5 +2,5 @@ /directory/apacheds/branches/apacheds-config/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/types/SamType.java:1023442-1029077 /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/types/SamType.java:980138-980936 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/Checksum.java:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionKey.java:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PaData.java:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/ChecksumType.java:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -6,5 +6,5 @@ /directory/apacheds/branches/apacheds-subtree/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbError.java:965203-965686 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java:1072812-1075328 /directory/apacheds/branches/xdbm-refactoring/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KrbError.java:945827-946347 -/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-codec/src/test/java/org/apache/directory/server/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/test/java/org/apache/directory/server:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/server:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-codec/src/test/java/org/apache/directory/server:1072812-1075328 -/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-codec/src/test/java/org/apache/directory/server:1067786-1067997 Propchange: directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -3,5 +3,5 @@ /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-test:980138-980936 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test:1040956-1043765 /directory/apacheds/branches/milestones/kerberos-test:1072812-1075328 -/directory/apacheds/trunk/kerberos-test:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/kerberos-test:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/kerberos-test:1067786-1067997 Modified: directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/pom.xml?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/pom.xml (original) +++ directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/pom.xml Sun Oct 9 17:03:52 2011 @@ -22,7 +22,7 @@ org.apache.directory.server apacheds-parent - 2.0.0-M3-SNAPSHOT + 2.0.0-M4-SNAPSHOT apacheds-kerberos-test Modified: directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/src/test/resources/org/apache/directory/server/kerberos/kdc/KerberosIT.ldif URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/src/test/resources/org/apache/directory/server/kerberos/kdc/KerberosIT.ldif?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/src/test/resources/org/apache/directory/server/kerberos/kdc/KerberosIT.ldif (original) +++ directory/apacheds/branches/one-sub-level-index-removal/kerberos-test/src/test/resources/org/apache/directory/server/kerberos/kdc/KerberosIT.ldif Sun Oct 9 17:03:52 2011 @@ -1,3 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# EXAMPLE.COM is reserved for testing according to this RFC: +# +# http://www.rfc-editor.org/rfc/rfc2606.txt +# + dn: dc=example,dc=com objectClass: top objectClass: domain Propchange: directory/apacheds/branches/one-sub-level-index-removal/ldap-client-test/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -7,5 +7,5 @@ /directory/apacheds/branches/apacheds-subtree/ldap-client-test:965203-965686 /directory/apacheds/branches/milestones/ldap-client-test:1072812-1075328 /directory/apacheds/branches/xdbm-refactoring/ldap-client-test:945827-946347 -/directory/apacheds/trunk/ldap-client-test:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/ldap-client-test:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/ldap-client-test:1067786-1067997 Modified: directory/apacheds/branches/one-sub-level-index-removal/ldap-client-test/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/ldap-client-test/pom.xml?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/ldap-client-test/pom.xml (original) +++ directory/apacheds/branches/one-sub-level-index-removal/ldap-client-test/pom.xml Sun Oct 9 17:03:52 2011 @@ -24,7 +24,7 @@ org.apache.directory.server apacheds-parent - 2.0.0-M3-SNAPSHOT + 2.0.0-M4-SNAPSHOT ldap-client-test Propchange: directory/apacheds/branches/one-sub-level-index-removal/ldif-partition/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 9 17:03:52 2011 @@ -4,5 +4,5 @@ /directory/apacheds/branches/apacheds-jdbm/ldif-partition:1160768-1164092 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/ldif-partition:1040956-1043765 /directory/apacheds/branches/milestones/ldif-partition:1072812-1075328 -/directory/apacheds/trunk/ldif-partition:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1164660 +/directory/apacheds/trunk/ldif-partition:1066126-1067785,1068026-1072718,1072800-1075329,1158399-1180637 /directory/studio/trunk/ldif-partition:1067786-1067997 Modified: directory/apacheds/branches/one-sub-level-index-removal/ldif-partition/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/branches/one-sub-level-index-removal/ldif-partition/pom.xml?rev=1180652&r1=1180651&r2=1180652&view=diff ============================================================================== --- directory/apacheds/branches/one-sub-level-index-removal/ldif-partition/pom.xml (original) +++ directory/apacheds/branches/one-sub-level-index-removal/ldif-partition/pom.xml Sun Oct 9 17:03:52 2011 @@ -22,7 +22,7 @@ org.apache.directory.server apacheds-parent - 2.0.0-M3-SNAPSHOT + 2.0.0-M4-SNAPSHOT apacheds-ldif-partition