Author: mreutegg Date: Mon Apr 28 14:03:19 2014 New Revision: 1590643 URL: http://svn.apache.org/r1590643 Log: OAK-1773: Optimize upgrade to DocumentNodeStore
Modified: jackrabbit/oak/branches/1.0/ (props changed) jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Propchange: jackrabbit/oak/branches/1.0/ ------------------------------------------------------------------------------ Merged /jackrabbit/oak/trunk:r1590628 Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1590643&r1=1590642&r2=1590643&view=diff ============================================================================== --- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java (original) +++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java Mon Apr 28 14:03:19 2014 @@ -167,7 +167,7 @@ public class Commit { Revision baseRev = getBaseRevision(); boolean isBranch = baseRev != null && baseRev.isBranch(); Revision rev = getRevision(); - if (isBranch) { + if (isBranch && !nodeStore.isDisableBranches()) { rev = rev.asBranchRevision(); // remember branch commit Branch b = nodeStore.getBranches().getBranch(baseRev); @@ -192,6 +192,9 @@ public class Commit { } else { applyInternal(); } + if (isBranch) { + rev = rev.asBranchRevision(); + } return rev; } Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1590643&r1=1590642&r2=1590643&view=diff ============================================================================== --- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java (original) +++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java Mon Apr 28 14:03:19 2014 @@ -463,6 +463,7 @@ public class DocumentMK implements Micro private boolean useSimpleRevision; private long splitDocumentAgeMillis = 5 * 60 * 1000; private long offHeapCacheSize = -1; + private boolean disableBranches; private Clock clock = Clock.SIMPLE; private Executor executor; @@ -730,6 +731,15 @@ public class DocumentMK implements Micro return clock; } + public Builder disableBranches() { + disableBranches = true; + return this; + } + + public boolean isDisableBranches() { + return disableBranches; + } + /** * Open the DocumentMK instance using the configured options. * Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1590643&r1=1590642&r2=1590643&view=diff ============================================================================== --- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (original) +++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java Mon Apr 28 14:03:19 2014 @@ -209,7 +209,15 @@ class DocumentNodeState extends Abstract // check if this node state is head of a branch Branch b = store.getBranches().getBranch(rev); if (b == null) { - throw new IllegalStateException("No branch for revision: " + rev); + if (store.isDisableBranches()) { + if (DocumentNodeStoreBranch.getCurrentBranch() != null) { + return new DocumentRootBuilder(this, store); + } else { + return new MemoryNodeBuilder(this); + } + } else { + throw new IllegalStateException("No branch for revision: " + rev); + } } if (b.isHead(rev) && DocumentNodeStoreBranch.getCurrentBranch() != null) { Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1590643&r1=1590642&r2=1590643&view=diff ============================================================================== --- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original) +++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Mon Apr 28 14:03:19 2014 @@ -310,6 +310,8 @@ public final class DocumentNodeStore private final LastRevRecoveryAgent lastRevRecoveryAgent; + private final boolean disableBranches; + public DocumentNodeStore(DocumentMK.Builder builder) { this.blobStore = builder.getBlobStore(); if (builder.isUseSimpleRevision()) { @@ -342,6 +344,7 @@ public final class DocumentNodeStore this.asyncDelay = builder.getAsyncDelay(); this.versionGarbageCollector = new VersionGarbageCollector(this); this.lastRevRecoveryAgent = new LastRevRecoveryAgent(this); + this.disableBranches = builder.isDisableBranches(); this.missing = new DocumentNodeState(this, "MISSING", new Revision(0, 0, 0)) { @Override public int getMemory() { @@ -590,6 +593,10 @@ public final class DocumentNodeStore return unsavedLastRevisions.getPaths().size(); } + public boolean isDisableBranches() { + return disableBranches; + } + /** * Checks that revision x is newer than another revision. * @@ -879,13 +886,19 @@ public final class DocumentNodeStore List<String> removed, List<String> changed, DiffCache.Entry cacheEntry) { UnsavedModifications unsaved = unsavedLastRevisions; - if (isBranchCommit) { - Revision branchRev = rev.asBranchRevision(); - unsaved = branches.getBranch(branchRev).getModifications(branchRev); - } - if (isBranchCommit || pendingLastRev) { - // write back _lastRev with background thread - unsaved.put(path, rev); + if (disableBranches) { + if (pendingLastRev) { + unsaved.put(path, rev); + } + } else { + if (isBranchCommit) { + Revision branchRev = rev.asBranchRevision(); + unsaved = branches.getBranch(branchRev).getModifications(branchRev); + } + if (isBranchCommit || pendingLastRev) { + // write back _lastRev with background thread + unsaved.put(path, rev); + } } if (isNew) { CacheValue key = childNodeCacheKey(path, rev, null); @@ -1029,6 +1042,9 @@ public final class DocumentNodeStore Revision rebase(@Nonnull Revision branchHead, @Nonnull Revision base) { checkNotNull(branchHead); checkNotNull(base); + if (disableBranches) { + return branchHead; + } // TODO conflict handling Branch b = getBranches().getBranch(branchHead); if (b == null) {