You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2014/12/08 15:44:47 UTC

svn commit: r1643828 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugi...

Author: mreutegg
Date: Mon Dec  8 14:44:47 2014
New Revision: 1643828

URL: http://svn.apache.org/r1643828
Log:
OAK-2324: Remove dependency to MapDB

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java
      - copied, changed from r1643789, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactoryTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Branch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapFactory.java

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Mon Dec  8 14:44:47 2014
@@ -39,8 +39,6 @@
         <configuration>
           <instructions>
             <Embed-Dependency>
-              <!-- OAK-1768 TODO: embedded as short term workaround -->
-              mapdb,
               <!-- OAK-1708 TODO: temporary workaround for embedding code for DocumentNodeStoreService-->
               commons-dbcp,commons-pool,h2,json-simple,
               <!-- OAK-1708 TODO: note these below will only embedded when build with the respective profiles from oak-parent -->
@@ -269,13 +267,6 @@
       <optional>true</optional>
     </dependency>
 
-    <!-- OAK-1768 added as short term workaround -->
-    <dependency>
-      <groupId>org.mapdb</groupId>
-      <artifactId>mapdb</artifactId>
-      <version>1.0.6</version>
-    </dependency>
-
     <!-- JCR and Jackrabbit dependencies -->
     <dependency>
       <groupId>javax.jcr</groupId>

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Branch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Branch.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Branch.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Branch.java Mon Dec  8 14:44:47 2014
@@ -20,19 +20,18 @@ import static com.google.common.base.Pre
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.collect.Iterables.transform;
 
-import java.util.Map;
 import java.util.NavigableMap;
+import java.util.Set;
 import java.util.SortedSet;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
-import org.apache.jackrabbit.oak.plugins.document.util.MapFactory;
-
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 /**
  * Contains commit information about a branch and its base revision.
@@ -49,8 +48,6 @@ class Branch {
      */
     private final Revision base;
 
-    private MapFactory mapFactory;
-
     /**
      * Create a new branch instance with an initial set of commits and a given
      * base revision.
@@ -228,25 +225,9 @@ class Branch {
     }
 
     /**
-     * Releases resources held by this branch.
-     */
-    public void dispose() {
-        if (mapFactory != null) {
-            mapFactory.dispose();
-        }
-    }
-
-    private MapFactory getMapFactory() {
-        if (mapFactory == null) {
-            mapFactory = MapFactory.createFactory();
-        }
-        return mapFactory;
-    }
-
-    /**
      * Information about a commit within a branch.
      */
-    abstract class BranchCommit implements LastRevTracker {
+    abstract static class BranchCommit implements LastRevTracker {
 
         protected final Revision base;
         protected final Revision commit;
@@ -270,50 +251,40 @@ class Branch {
     /**
      * Implements a regular branch commit.
      */
-    private class BranchCommitImpl extends BranchCommit {
+    private static class BranchCommitImpl extends BranchCommit {
 
-        private Map<String, Revision> modifications;
+        private final Set<String> modifications = Sets.newHashSet();
 
         BranchCommitImpl(Revision base, Revision commit) {
             super(base, commit);
-            if (mapFactory == null) {
-                modifications = Maps.newConcurrentMap();
-            } else {
-                modifications = mapFactory.create();
-            }
         }
 
         @Override
         void applyTo(UnsavedModifications trunk, Revision commit) {
-            for (String p : modifications.keySet()) {
+            for (String p : modifications) {
                 trunk.put(p, commit);
             }
         }
 
         @Override
         boolean isModified(String path) { // TODO: rather pass NodeDocument?
-            return modifications.containsKey(path);
+            return modifications.contains(path);
         }
 
         @Override
         Iterable<String> getModifiedPaths() {
-            return modifications.keySet();
+            return modifications;
         }
 
         //------------------< LastRevTracker >----------------------------------
 
         @Override
         public void track(String path) {
-            if (mapFactory == null && modifications.size() >= 1000) {
-                Map<String, Revision> tmp = getMapFactory().create();
-                tmp.putAll(modifications);
-                modifications = tmp;
-            }
-            modifications.put(path, commit);
+            modifications.add(path);
         }
     }
 
-    class RebaseCommit extends BranchCommit {
+    static class RebaseCommit extends BranchCommit {
 
         private final NavigableMap<Revision, BranchCommit> previous;
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Mon Dec  8 14:44:47 2014
@@ -466,8 +466,6 @@ public final class DocumentNodeStore
                 clusterNodeInfo.dispose();
             }
             store.dispose();
-            unsavedLastRevisions.close();
-
             LOG.info("Disposed DocumentNodeStore with clusterNodeId: {}", clusterId);
 
             if (blobStore instanceof Closeable) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java Mon Dec  8 14:44:47 2014
@@ -23,20 +23,20 @@ import static com.google.common.collect.
 import static com.google.common.collect.Iterables.filter;
 import static com.google.common.collect.Iterables.mergeSorted;
 
-import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.locks.ReentrantLock;
 
 import javax.annotation.CheckForNull;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Lists;
-import com.google.common.io.Closer;
 
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoMissingLastRevSeeker;
+import org.apache.jackrabbit.oak.plugins.document.util.MapFactory;
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -132,93 +132,81 @@ public class LastRevRecoveryAgent {
      */
     public int recover(Iterator<NodeDocument> suspects,
                        int clusterId, boolean dryRun) {
-        Closer closer = Closer.create();
-        try {
-            UnsavedModifications unsaved = new UnsavedModifications();
-            closer.register(unsaved);
-            UnsavedModifications unsavedParents = new UnsavedModifications();
-            closer.register(unsavedParents);
-
-            //Map of known last rev of checked paths
-            UnsavedModifications knownLastRevs = new UnsavedModifications();
-            closer.register(knownLastRevs);
-
-            long count = 0;
-            while (suspects.hasNext()) {
-                NodeDocument doc = suspects.next();
-                count++;
-                if (count % 100000 == 0) {
-                    log.info("Scanned {} suspects so far...", count);
-                }
-
-                Revision currentLastRev = doc.getLastRev().get(clusterId);
-                if (currentLastRev != null) {
-                    knownLastRevs.put(doc.getPath(), currentLastRev);
-                }
-                // 1. determine last committed modification on document
-                Revision lastModifiedRev = determineLastModification(doc, clusterId);
+        UnsavedModifications unsaved = new UnsavedModifications();
+        UnsavedModifications unsavedParents = new UnsavedModifications();
 
-                Revision lastRevForParents = Utils.max(lastModifiedRev, currentLastRev);
+        //Map of known last rev of checked paths
+        Map<String, Revision> knownLastRevs = MapFactory.getInstance().create();
 
-                //If both currentLastRev and lostLastRev are null it means
-                //that no change is done by suspect cluster on this document
-                //so nothing needs to be updated. Probably it was only changed by
-                //other cluster nodes. If this node is parent of any child node which
-                //has been modified by cluster then that node roll up would
-                //add this node path to unsaved
-
-                //2. Update lastRev for parent paths aka rollup
-                if (lastRevForParents != null) {
-                    String path = doc.getPath();
-                    while (true) {
-                        if (PathUtils.denotesRoot(path)) {
-                            break;
-                        }
-                        path = PathUtils.getParentPath(path);
-                        unsavedParents.put(path, lastRevForParents);
-                    }
-                }
+        long count = 0;
+        while (suspects.hasNext()) {
+            NodeDocument doc = suspects.next();
+            count++;
+            if (count % 100000 == 0) {
+                log.info("Scanned {} suspects so far...", count);
             }
 
-            for (String parentPath : unsavedParents.getPaths()) {
-                Revision calcLastRev = unsavedParents.get(parentPath);
-                Revision knownLastRev = knownLastRevs.get(parentPath);
-
-                //Copy the calcLastRev of parent only if they have changed
-                //In many case it might happen that parent have consistent lastRev
-                //This check ensures that unnecessary updates are not made
-                if (knownLastRev == null
-                        || calcLastRev.compareRevisionTime(knownLastRev) > 0) {
-                    unsaved.put(parentPath, calcLastRev);
-                }
+            Revision currentLastRev = doc.getLastRev().get(clusterId);
+            if (currentLastRev != null) {
+                knownLastRevs.put(doc.getPath(), currentLastRev);
             }
+            // 1. determine last committed modification on document
+            Revision lastModifiedRev = determineLastModification(doc, clusterId);
 
-            //Note the size before persist as persist operation
-            //would empty the internal state
-            int size = unsaved.getPaths().size();
-            String updates = unsaved.toString();
-
-            if (dryRun) {
-                log.info("Dry run of lastRev recovery identified [{}] documents for " +
-                        "cluster node [{}]: {}", size, clusterId, updates);
-            } else {
-                //UnsavedModifications is designed to be used in concurrent
-                //access mode. For recovery case there is no concurrent access
-                //involve so just pass a new lock instance
-                unsaved.persist(nodeStore, new ReentrantLock());
+            Revision lastRevForParents = Utils.max(lastModifiedRev, currentLastRev);
 
-                log.info("Updated lastRev of [{}] documents while performing lastRev recovery for " +
-                        "cluster node [{}]: {}", size, clusterId, updates);
+            //If both currentLastRev and lostLastRev are null it means
+            //that no change is done by suspect cluster on this document
+            //so nothing needs to be updated. Probably it was only changed by
+            //other cluster nodes. If this node is parent of any child node which
+            //has been modified by cluster then that node roll up would
+            //add this node path to unsaved
+
+            //2. Update lastRev for parent paths aka rollup
+            if (lastRevForParents != null) {
+                String path = doc.getPath();
+                while (true) {
+                    if (PathUtils.denotesRoot(path)) {
+                        break;
+                    }
+                    path = PathUtils.getParentPath(path);
+                    unsavedParents.put(path, lastRevForParents);
+                }
             }
+        }
 
-            return size;
-        } finally {
-            try {
-                closer.close();
-            } catch (IOException e) {
-                log.warn("Error closing UnsavedModifications", e);
+        for (String parentPath : unsavedParents.getPaths()) {
+            Revision calcLastRev = unsavedParents.get(parentPath);
+            Revision knownLastRev = knownLastRevs.get(parentPath);
+
+            //Copy the calcLastRev of parent only if they have changed
+            //In many case it might happen that parent have consistent lastRev
+            //This check ensures that unnecessary updates are not made
+            if (knownLastRev == null
+                    || calcLastRev.compareRevisionTime(knownLastRev) > 0) {
+                unsaved.put(parentPath, calcLastRev);
             }
         }
+
+        //Note the size before persist as persist operation
+        //would empty the internal state
+        int size = unsaved.getPaths().size();
+        String updates = unsaved.toString();
+
+        if (dryRun) {
+            log.info("Dry run of lastRev recovery identified [{}] documents for " +
+                    "cluster node [{}]: {}", size, clusterId, updates);
+        } else {
+            //UnsavedModifications is designed to be used in concurrent
+            //access mode. For recovery case there is no concurrent access
+            //involve so just pass a new lock instance
+            unsaved.persist(nodeStore, new ReentrantLock());
+
+            log.info("Updated lastRev of [{}] documents while performing lastRev recovery for " +
+                    "cluster node [{}]: {}", size, clusterId, updates);
+        }
+
+        return size;
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java Mon Dec  8 14:44:47 2014
@@ -144,6 +144,5 @@ class UnmergedBranches {
      */
     void remove(Branch b) {
         branches.remove(b);
-        b.dispose();
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java Mon Dec  8 14:44:47 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.document;
 
-import java.io.Closeable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -45,25 +44,14 @@ import static org.apache.jackrabbit.oak.
  * Keeps track of when nodes where last modified. To be persisted later by
  * a background thread.
  */
-class UnsavedModifications implements Closeable {
-
-    /**
-     * Keep at most this number of entries in memory when modifications are
-     * persisted, otherwise use the MapFactory potentially backed by MapDB.
-     */
-    static final int IN_MEMORY_SIZE_LIMIT = 100000;
+class UnsavedModifications {
 
     /**
      * The maximum number of document to update at once in a multi update.
      */
     static final int BACKGROUND_MULTI_UPDATE_LIMIT = 10000;
 
-    /**
-     * The map factory for this instance.
-     */
-    private final MapFactory mapFactory = MapFactory.createFactory();
-
-    private final ConcurrentMap<String, Revision> map = mapFactory.create();
+    private final ConcurrentMap<String, Revision> map = MapFactory.getInstance().create();
 
     /**
      * Puts a revision for the given path. The revision for the given path is
@@ -154,80 +142,63 @@ class UnsavedModifications implements Cl
 
         // get a copy of the map while holding the lock
         lock.lock();
-        MapFactory tmpFactory = null;
         Map<String, Revision> pending;
         try {
-            if (map.size() > IN_MEMORY_SIZE_LIMIT) {
-                tmpFactory = MapFactory.createFactory();
-                pending = tmpFactory.create(PathComparator.INSTANCE);
-            } else {
-                pending = Maps.newTreeMap(PathComparator.INSTANCE);
-            }
+            pending = Maps.newTreeMap(PathComparator.INSTANCE);
             pending.putAll(map);
         } finally {
             lock.unlock();
         }
-        try {
-            UpdateOp updateOp = null;
-            Revision lastRev = null;
-            PeekingIterator<String> paths = Iterators.peekingIterator(
-                    pending.keySet().iterator());
-            int i = 0;
-            ArrayList<String> pathList = new ArrayList<String>();
-            while (paths.hasNext()) {
-                String p = paths.peek();
-                Revision r = pending.get(p);
-
-                int size = pathList.size();
-                if (updateOp == null) {
-                    // create UpdateOp
-                    Commit commit = new Commit(store, null, r);
-                    updateOp = commit.getUpdateOperationForNode(p);
-                    NodeDocument.setLastRev(updateOp, r);
-                    lastRev = r;
-                    pathList.add(p);
-                    paths.next();
-                    i++;
-                } else if (r.equals(lastRev)) {
-                    // use multi update when possible
-                    pathList.add(p);
-                    paths.next();
-                    i++;
-                }
-                // call update if any of the following is true:
-                // - this is the second-to-last or last path (update last path, the
-                //   root document, individually)
-                // - revision is not equal to last revision (size of ids didn't change)
-                // - the update limit is reached
-                if (i + 2 > pending.size()
-                        || size == pathList.size()
-                        || pathList.size() >= BACKGROUND_MULTI_UPDATE_LIMIT) {
-                    List<String> ids = new ArrayList<String>();
-                    for (String path : pathList) {
-                        ids.add(Utils.getIdFromPath(path));
-                    }
-                    store.getDocumentStore().update(NODES, ids, updateOp);
-                    for (String path : pathList) {
-                        map.remove(path, lastRev);
-                    }
-                    pathList.clear();
-                    updateOp = null;
-                    lastRev = null;
-                }
+        UpdateOp updateOp = null;
+        Revision lastRev = null;
+        PeekingIterator<String> paths = Iterators.peekingIterator(
+                pending.keySet().iterator());
+        int i = 0;
+        ArrayList<String> pathList = new ArrayList<String>();
+        while (paths.hasNext()) {
+            String p = paths.peek();
+            Revision r = pending.get(p);
+
+            int size = pathList.size();
+            if (updateOp == null) {
+                // create UpdateOp
+                Commit commit = new Commit(store, null, r);
+                updateOp = commit.getUpdateOperationForNode(p);
+                NodeDocument.setLastRev(updateOp, r);
+                lastRev = r;
+                pathList.add(p);
+                paths.next();
+                i++;
+            } else if (r.equals(lastRev)) {
+                // use multi update when possible
+                pathList.add(p);
+                paths.next();
+                i++;
             }
-        } finally {
-            if (tmpFactory != null) {
-                tmpFactory.dispose();
+            // call update if any of the following is true:
+            // - this is the second-to-last or last path (update last path, the
+            //   root document, individually)
+            // - revision is not equal to last revision (size of ids didn't change)
+            // - the update limit is reached
+            if (i + 2 > pending.size()
+                    || size == pathList.size()
+                    || pathList.size() >= BACKGROUND_MULTI_UPDATE_LIMIT) {
+                List<String> ids = new ArrayList<String>();
+                for (String path : pathList) {
+                    ids.add(Utils.getIdFromPath(path));
+                }
+                store.getDocumentStore().update(NODES, ids, updateOp);
+                for (String path : pathList) {
+                    map.remove(path, lastRev);
+                }
+                pathList.clear();
+                updateOp = null;
+                lastRev = null;
             }
         }
     }
 
     @Override
-    public void close() {
-        mapFactory.dispose();
-    }
-
-    @Override
     public String toString() {
         return map.toString();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapFactory.java?rev=1643828&r1=1643827&r2=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapFactory.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapFactory.java Mon Dec  8 14:44:47 2014
@@ -19,45 +19,25 @@
 
 package org.apache.jackrabbit.oak.plugins.document.util;
 
-import java.util.Comparator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentSkipListMap;
 
 import org.apache.jackrabbit.oak.plugins.document.Revision;
 
 /**
- * Experimental extension point for OAK-1772 to try out alternative approaches
- * for persisting in memory state. Not part of API.
+ * Experimental extension point for OAK-1772 to try out alternative approaches for persisting in memory state
+ * Not part of API
  */
 public abstract class MapFactory {
-
-    private static final boolean USE_MEMORY_MAP_FACTORY
-            = Boolean.getBoolean("oak.useMemoryMapFactory");
-
     private static MapFactory DEFAULT = new MapFactory() {
         @Override
         public ConcurrentMap<String, Revision> create() {
             return new ConcurrentHashMap<String, Revision>();
         }
-
-        @Override
-        public ConcurrentMap<String, Revision> create(Comparator<String> comparator) {
-            return new ConcurrentSkipListMap<String, Revision>(comparator);
-        }
-
-        @Override
-        public void dispose() {
-            // nothing to do
-        }
     };
 
     public abstract ConcurrentMap<String, Revision> create();
 
-    public abstract ConcurrentMap<String, Revision> create(Comparator<String> comparator);
-
-    public abstract void dispose();
-
     private static MapFactory instance = DEFAULT;
 
     public static MapFactory getInstance(){
@@ -67,12 +47,4 @@ public abstract class MapFactory {
     public static void setInstance(MapFactory instance) {
         MapFactory.instance = instance;
     }
-
-    public static MapFactory createFactory() {
-        if (USE_MEMORY_MAP_FACTORY) {
-            return MapFactory.getInstance();
-        } else {
-            return new MapDBMapFactory();
-        }
-    }
 }

Copied: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java (from r1643789, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java?p2=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java&r1=1643789&r2=1643828&rev=1643828&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MapDBMapFactory.java Mon Dec  8 14:44:47 2014
@@ -41,6 +41,7 @@ public class MapDBMapFactory extends Map
     public MapDBMapFactory() {
         this.db = DBMaker.newTempFileDB()
                 .deleteFilesAfterClose()
+                .closeOnJvmShutdown()
                 .transactionDisable()
                 .asyncWriteEnable()
                 .make();
@@ -54,50 +55,6 @@ public class MapDBMapFactory extends Map
                 .makeStringMap();
     }
 
-    @Override
-    public synchronized BTreeMap<String, Revision> create(
-            Comparator<String> comparator) {
-        return db.createTreeMap(String.valueOf(counter.incrementAndGet()))
-                .valueSerializer(new RevisionSerializer())
-                .keySerializer(new CustomKeySerializer(comparator))
-                .counterEnable()
-                .make();
-    }
-
-    @Override
-    public void dispose() {
-        db.close();
-    }
-
-    private static class CustomKeySerializer extends BTreeKeySerializer<String>
-            implements Serializable {
-
-        private static final long serialVersionUID = -95963379229842881L;
-
-        private final Comparator<String> comparator;
-
-        CustomKeySerializer(Comparator<String> comparator) {
-            this.comparator = comparator;
-        }
-
-        @Override
-        public void serialize(DataOutput out, int start, int end, Object[] keys)
-                throws IOException {
-            BTreeKeySerializer.STRING.serialize(out, start, end, keys);
-        }
-
-        @Override
-        public Object[] deserialize(DataInput in, int start, int end, int size)
-                throws IOException {
-            return BTreeKeySerializer.STRING.deserialize(in, start, end, size);
-        }
-
-        @Override
-        public Comparator<String> getComparator() {
-            return comparator;
-        }
-    }
-
     private static class RevisionSerializer implements Serializer<Revision>,
             Serializable {
         private static final long serialVersionUID = 8648365575103098316L;