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 th...@apache.org on 2022/06/16 13:34:02 UTC
[jackrabbit-oak] 06/32: OAK-9757 : increased node name limit for mongo 4.2 version
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch OAK-9780
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit f9b59f8c51cace3b66224ec97acb33a4ec8786ea
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Thu May 5 17:43:28 2022 +0530
OAK-9757 : increased node name limit for mongo 4.2 version
---
.../jackrabbit/oak/jcr/DocumentClusterIT.java | 2 +-
.../document/VersionedDocumentBundlingTest.java | 5 +-
.../document/mongo/MongoDocumentStoreHelper.java | 2 +-
.../commands/ExportRelevantDocumentsCommand.groovy | 2 +-
.../oak/console/commands/LsdDocumentCommand.groovy | 4 +-
.../console/commands/PrintDocumentCommand.groovy | 2 +-
.../oak/index/DocumentStoreIndexerIT.java | 2 +-
.../document/mongo/DocumentTraverserTest.java | 23 ++---
.../jackrabbit/oak/run/RevisionsCommandTest.java | 2 +-
oak-store-document/pom.xml | 4 +
.../jackrabbit/oak/plugins/document/Collision.java | 2 +-
.../jackrabbit/oak/plugins/document/Commit.java | 9 +-
.../oak/plugins/document/CommitBuilder.java | 7 +-
.../oak/plugins/document/DocumentNodeState.java | 2 +-
.../oak/plugins/document/DocumentNodeStore.java | 34 ++++----
.../document/DocumentNodeStoreMBeanImpl.java | 9 +-
.../oak/plugins/document/ExternalChange.java | 8 +-
.../oak/plugins/document/LastRevRecoveryAgent.java | 4 +-
.../oak/plugins/document/MissingLastRevSeeker.java | 2 +-
.../oak/plugins/document/NodeDocument.java | 14 ++--
.../oak/plugins/document/PropertyHistory.java | 2 +-
.../jackrabbit/oak/plugins/document/ResetDiff.java | 17 ++--
.../oak/plugins/document/SplitDocumentCleanUp.java | 2 +-
.../oak/plugins/document/SplitOperations.java | 6 +-
.../oak/plugins/document/Sweep2Helper.java | 2 +-
.../oak/plugins/document/UnmergedBranches.java | 2 +-
.../oak/plugins/document/UnsavedModifications.java | 8 +-
.../plugins/document/VersionGarbageCollector.java | 2 +-
.../document/locks/StripedNodeDocumentLocks.java | 3 +-
.../plugins/document/mongo/MongoDocumentStore.java | 8 +-
.../oak/plugins/document/mongo/MongoUtils.java | 11 +++
.../oak/plugins/document/mongo/MongoVersion.java | 71 ++++++++++++++++
.../document/mongo/MongoVersionGCSupport.java | 2 +-
.../oak/plugins/document/util/Utils.java | 68 +++++++++------
.../oak/plugins/document/AbstractJournalTest.java | 4 +-
.../document/BackgroundSplitFailureTest.java | 4 +-
.../plugins/document/BasicDocumentStoreTest.java | 26 +++---
.../oak/plugins/document/BlobCollectorTest.java | 2 +-
.../document/BlobReferenceIteratorTest.java | 2 +-
.../oak/plugins/document/BranchStateTest.java | 2 +-
.../oak/plugins/document/BranchTest.java | 12 +--
.../plugins/document/CacheConsistencyRDBTest.java | 6 +-
.../oak/plugins/document/CacheConsistencyTest.java | 6 +-
.../oak/plugins/document/CollisionCleanupTest.java | 6 +-
.../oak/plugins/document/CollisionTest.java | 30 +++----
.../plugins/document/CollisionWithSplitTest.java | 2 +-
.../plugins/document/CommitValueResolverTest.java | 4 +-
.../document/ConcurrentQueryAndInvalidateIT.java | 8 +-
.../document/ConcurrentQueryAndUpdate2IT.java | 8 +-
.../document/ConcurrentQueryAndUpdateIT.java | 9 +-
.../oak/plugins/document/DocumentMKResetTest.java | 10 +--
.../DocumentNodeStoreBackgroundUpdateTest.java | 9 +-
.../oak/plugins/document/DocumentNodeStoreIT.java | 10 +--
.../plugins/document/DocumentNodeStoreSweepIT.java | 2 +-
.../document/DocumentNodeStoreSweepTest.java | 2 +-
.../plugins/document/DocumentNodeStoreTest.java | 58 ++++++-------
.../oak/plugins/document/DocumentSplitTest.java | 95 +++++++++------------
.../plugins/document/JournalDiffLoaderTest.java | 2 +-
.../oak/plugins/document/JournalGCTest.java | 2 +-
.../plugins/document/LargeMergeRecoveryTest.java | 2 +-
.../plugins/document/LastRevRecoveryAgentTest.java | 2 +-
.../oak/plugins/document/LastRevRecoveryTest.java | 4 +-
.../LastRevRecoveryWithBundledNodesTest.java | 2 +-
.../oak/plugins/document/LastRevTest.java | 2 +-
.../oak/plugins/document/ManyClusterNodesTest.java | 2 +-
.../oak/plugins/document/MongoDocumentStoreIT.java | 12 +--
.../document/MongoDocumentStoreLimitsTest.java | 2 +-
.../plugins/document/MongoDocumentStoreTest.java | 2 +-
.../plugins/document/MultiDocumentStoreTest.java | 20 ++---
.../document/NodeDocumentIdComparatorTest.java | 10 +--
.../plugins/document/NodeDocumentSweeperTest.java | 6 +-
.../oak/plugins/document/NodeDocumentTest.java | 36 ++++----
.../plugins/document/OptimizedChildFetchTest.java | 2 +-
.../document/OrphanedBranchCleanupTest.java | 2 +-
.../oak/plugins/document/OrphanedBranchTest.java | 6 +-
.../document/ResurrectNodeAfterRevisionGCTest.java | 14 ++--
.../oak/plugins/document/SimpleTest.java | 6 +-
.../oak/plugins/document/SplitOperationsTest.java | 4 +-
.../oak/plugins/document/Sweep2Test.java | 4 +-
.../oak/plugins/document/Sweep2TestHelper.java | 6 +-
.../oak/plugins/document/UnmergedBranchTest.java | 3 +-
.../oak/plugins/document/UpdateLimitTest.java | 2 +-
.../oak/plugins/document/UpdateUtilsTest.java | 5 +-
.../oak/plugins/document/V18BranchCommitTest.java | 2 +-
.../oak/plugins/document/ValueMapTest.java | 26 +++---
.../plugins/document/VersionGCDeletionTest.java | 2 +-
.../oak/plugins/document/VersionGCQueryTest.java | 2 +-
.../plugins/document/VersionGCSplitDocTest.java | 2 +-
.../oak/plugins/document/VersionGCSupportTest.java | 5 +-
.../oak/plugins/document/VersionGCSweepTest.java | 2 +-
.../plugins/document/VersionGCWithSplitTest.java | 2 +-
.../document/VersionGarbageCollectorIT.java | 20 ++---
.../oak/plugins/document/VisibleChangesTest.java | 2 +-
.../document/bundlor/DocumentBundlingTest.java | 4 +-
.../document/cache/CacheChangesTrackerTest.java | 6 +-
.../document/mongo/CacheInvalidationIT.java | 2 +-
.../document/mongo/CollisionMarkerTest.java | 2 +-
.../document/mongo/MongoDBExceptionTest.java | 6 +-
.../mongo/MongoMissingLastRevSeekerTest.java | 4 +-
.../document/mongo/MongoRevisionGCTest.java | 2 +-
.../oak/plugins/document/mongo/MongoUtilsTest.java | 18 ++++
.../plugins/document/mongo/MongoVersionTest.java | 46 ++++++++++
.../oak/plugins/document/mongo/QueryHintTest.java | 4 +-
.../plugins/document/mongo/ReadPreferenceIT.java | 2 +-
.../oak/plugins/document/mongo/RetryReadIT.java | 14 ++--
.../rdb/RDBDocumentStoreSchemaUpgradeTest.java | 16 ++--
.../plugins/document/rdb/RDBDocumentStoreTest.java | 10 +--
.../secondary/SecondaryStoreCacheTest.java | 2 +-
.../oak/plugins/document/util/UtilsTest.java | 97 +++++++++++++++-------
109 files changed, 653 insertions(+), 467 deletions(-)
diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/DocumentClusterIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/DocumentClusterIT.java
index 417039814f..cd80058039 100644
--- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/DocumentClusterIT.java
+++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/DocumentClusterIT.java
@@ -125,7 +125,7 @@ public abstract class DocumentClusterIT {
for (DocumentMK mk : mks) {
mk.getNodeStore().runBackgroundOperations();
}
- String id = Utils.getIdFromPath("/");
+ String id = Utils.getIdFromPath("/", Collections.emptyMap());
// in the second round each MK will pick up changes from the others
for (DocumentMK mk : mks) {
// invalidate root document to make sure background read
diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java
index 56c7e34968..4f8b027377 100644
--- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java
+++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java
@@ -36,11 +36,9 @@ import org.apache.jackrabbit.commons.cnd.CndImporter;
import org.apache.jackrabbit.commons.cnd.ParseException;
import org.apache.jackrabbit.oak.NodeStoreFixtures;
import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.fixture.NodeStoreFixture;
import org.apache.jackrabbit.oak.jcr.Jcr;
import org.apache.jackrabbit.oak.plugins.document.Collection;
-import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
@@ -50,7 +48,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
@@ -150,6 +147,6 @@ public class VersionedDocumentBundlingTest {
}
private NodeDocument getNodeDocument(String path) {
- return ds.find(Collection.NODES, Utils.getIdFromPath(path));
+ return ds.find(Collection.NODES, Utils.getIdFromPath(path, ds.getMetadata()));
}
}
diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreHelper.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreHelper.java
index 981df7534c..151d36b8cb 100644
--- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreHelper.java
+++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreHelper.java
@@ -48,7 +48,7 @@ public class MongoDocumentStoreHelper {
public static void repair(MongoDocumentStore store, String path) {
MongoCollection<BasicDBObject> col = store.getDBCollection(NODES);
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, store.getMetadata());
NodeDocument doc = store.find(NODES, id);
if (doc == null) {
diff --git a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/ExportRelevantDocumentsCommand.groovy b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/ExportRelevantDocumentsCommand.groovy
index dbaae7ce20..fce37273d3 100644
--- a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/ExportRelevantDocumentsCommand.groovy
+++ b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/ExportRelevantDocumentsCommand.groovy
@@ -105,7 +105,7 @@ class ExportRelevantDocumentsCommand extends CommandSupport {
}
private void writeOutDocAndSplits(String currPath, File file) {
- NodeDocument doc = docStore.find(Collection.NODES, Utils.getIdFromPath(currPath))
+ NodeDocument doc = docStore.find(Collection.NODES, Utils.getIdFromPath(currPath, docStore.getMetadata()))
if (doc != null) {
writeOutDoc(doc, file)
diff --git a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsdDocumentCommand.groovy b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsdDocumentCommand.groovy
index 55ec16eb84..06d76ff234 100644
--- a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsdDocumentCommand.groovy
+++ b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsdDocumentCommand.groovy
@@ -42,8 +42,8 @@ class LsdDocumentCommand extends CommandSupport{
assert session.store instanceof DocumentNodeStore
PrintWriter writer = io.out
Path path = Path.fromString(session.getWorkingPath());
- String fromKey = Utils.getKeyLowerLimit(path);
- String toKey = Utils.getKeyUpperLimit(path);
+ String fromKey = Utils.getKeyLowerLimit(path, store.getDocumentStore().getMetadata());
+ String toKey = Utils.getKeyUpperLimit(path, store.getDocumentStore().getMetadata());
int num = 0;
for (NodeDocument doc : store.getDocumentStore().query(
NODES, fromKey, toKey, Integer.MAX_VALUE)) {
diff --git a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/PrintDocumentCommand.groovy b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/PrintDocumentCommand.groovy
index 490108f459..87ffc1a130 100644
--- a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/PrintDocumentCommand.groovy
+++ b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/PrintDocumentCommand.groovy
@@ -42,7 +42,7 @@ class PrintDocumentCommand extends CommandSupport{
@Override
Object execute(List<String> args) {
assert session.store instanceof DocumentNodeStore
- String id = Utils.getIdFromPath(session.getWorkingPath());
+ String id = Utils.getIdFromPath(session.getWorkingPath(), store.getDocumentStore().getMetadata());
NodeDocument doc = store.getDocumentStore().find(NODES, id);
if (doc == null) {
io.out.println("[null]");
diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java
index 1eb71e0483..493550866f 100644
--- a/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java
+++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java
@@ -257,7 +257,7 @@ public class DocumentStoreIndexerIT extends AbstractIndexCommandTest {
}
private NodeDocument getNodeDocument(DocumentStore ds, String path) {
- return ds.find(Collection.NODES, Utils.getIdFromPath(path));
+ return ds.find(Collection.NODES, Utils.getIdFromPath(path, ds.getMetadata()));
}
private static NodeBuilder newNode(String typeName){
diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentTraverserTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentTraverserTest.java
index 64d87951a9..01faee7aa4 100644
--- a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentTraverserTest.java
+++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/DocumentTraverserTest.java
@@ -24,12 +24,7 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.jackrabbit.oak.index.indexer.document.LastModifiedRange;
-import org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest;
-import org.apache.jackrabbit.oak.plugins.document.Collection;
-import org.apache.jackrabbit.oak.plugins.document.DocumentStoreFixture;
-import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
-import org.apache.jackrabbit.oak.plugins.document.Path;
-import org.apache.jackrabbit.oak.plugins.document.UpdateOp;
+import org.apache.jackrabbit.oak.plugins.document.*;
import org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.junit.Test;
@@ -52,9 +47,9 @@ public class DocumentTraverserTest extends AbstractDocumentStoreTest {
public void getAllDocuments() throws Exception{
assumeTrue(ds instanceof MongoDocumentStore);
ds.create(Collection.NODES, asList(
- newDocument("/a/b", 1),
- newDocument("/a/c", 1),
- newDocument("/d", 1)
+ newDocument("/a/b", 1, ds),
+ newDocument("/a/c", 1, ds),
+ newDocument("/d", 1, ds)
));
ds.invalidateCache();
@@ -73,15 +68,15 @@ public class DocumentTraverserTest extends AbstractDocumentStoreTest {
assertThat(paths, containsInAnyOrder("/a/b", "/a/c"));
- assertNotNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/a/b")));
- assertNotNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/a/c")));
+ assertNotNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/a/b", ds.getMetadata())));
+ assertNotNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/a/c", ds.getMetadata())));
// Excluded id should not be cached
- assertNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/d")));
+ assertNull(ds.getIfCached(Collection.NODES, Utils.getIdFromPath("/d", ds.getMetadata())));
}
- private static UpdateOp newDocument(String path, long modified) {
- String id = Utils.getIdFromPath(path);
+ private static UpdateOp newDocument(String path, long modified, DocumentStore ds) {
+ String id = Utils.getIdFromPath(path, ds.getMetadata());
UpdateOp op = new UpdateOp(id, true);
op.set(NodeDocument.MODIFIED_IN_SECS, modified);
return op;
diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandTest.java
index 8c2da319a5..21efecbced 100644
--- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandTest.java
+++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandTest.java
@@ -127,7 +127,7 @@ public class RevisionsCommandTest {
DocumentNodeStoreBuilder<?> builder = builderProvider.newBuilder()
.setMongoDB(c.getMongoClient(), c.getDBName());
DocumentStore store = builder.getDocumentStore();
- UpdateOp op = new UpdateOp(getIdFromPath("/"), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/", store.getMetadata()), false);
op.removeMapEntry("_sweepRev", new Revision(0, 0, clusterId));
assertNotNull(store.findAndUpdate(Collection.NODES, op));
diff --git a/oak-store-document/pom.xml b/oak-store-document/pom.xml
index e1003ca954..84ea9f8329 100644
--- a/oak-store-document/pom.xml
+++ b/oak-store-document/pom.xml
@@ -152,6 +152,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
index 78d79ee8ad..d15ea3e5f7 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
@@ -176,7 +176,7 @@ class Collision {
}
}
// at this point we have a commitRootPath
- UpdateOp op = new UpdateOp(Utils.getIdFromPath(commitRootPath), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath(commitRootPath, store.getMetadata()), false);
NodeDocument commitRoot = store.find(Collection.NODES, op.getId());
// check commit status of revision
if (isCommitted(context.getCommitValue(revision, commitRoot))) {
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
index d74fe9f4d9..da0ddd396f 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
@@ -119,7 +119,7 @@ public class Commit {
UpdateOp getUpdateOperationForNode(Path path) {
UpdateOp op = operations.get(path);
if (op == null) {
- op = createUpdateOp(path, revision, isBranchCommit());
+ op = createUpdateOp(path, revision, isBranchCommit(), nodeStore.getDocumentStore().getMetadata());
operations.put(path, op);
}
return op;
@@ -127,8 +127,9 @@ public class Commit {
static UpdateOp createUpdateOp(Path path,
Revision revision,
- boolean isBranch) {
- String id = Utils.getIdFromPath(path);
+ boolean isBranch,
+ Map<String, String> metadata) {
+ String id = Utils.getIdFromPath(path, metadata);
UpdateOp op = new UpdateOp(id, false);
NodeDocument.setModified(op, revision);
if (isBranch) {
@@ -333,7 +334,7 @@ public class Commit {
commitRootPath = bundledNodes.getOrDefault(commitRootPath, commitRootPath);
rollback = new Rollback(revision, opLog,
- Utils.getIdFromPath(commitRootPath),
+ Utils.getIdFromPath(commitRootPath, store.getMetadata()),
nodeStore.getCreateOrUpdateBatchSize());
for (Path p : bundledNodes.keySet()){
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java
index bd4f20b0ab..487de2ab2e 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitBuilder.java
@@ -285,7 +285,7 @@ class CommitBuilder {
private UpdateOp getUpdateOperationForNode(Path path) {
UpdateOp op = operations.get(path);
if (op == null) {
- op = createUpdateOp(path, revision, isBranchCommit());
+ op = createUpdateOp(path, revision, isBranchCommit(), nodeStore.getDocumentStore().getMetadata());
operations.put(path, op);
}
return op;
@@ -293,8 +293,9 @@ class CommitBuilder {
private static UpdateOp createUpdateOp(Path path,
Revision revision,
- boolean isBranch) {
- String id = Utils.getIdFromPath(path);
+ boolean isBranch,
+ Map<String, String> metadata) {
+ String id = Utils.getIdFromPath(path, metadata);
UpdateOp op = new UpdateOp(id, false);
NodeDocument.setModified(op, revision);
if (isBranch) {
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
index 0af023ade3..a1a017197c 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
@@ -414,7 +414,7 @@ public class DocumentNodeState extends AbstractDocumentNodeState implements Cach
* @param revision the revision this node is created.
*/
UpdateOp asOperation(@NotNull Revision revision) {
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, store.getDocumentStore().getMetadata());
UpdateOp op = new UpdateOp(id, true);
if (Utils.isIdFromLongPath(id)) {
op.set(NodeDocument.PATH, path.toString());
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
index 74b4ff28af..f82ff72639 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
@@ -646,7 +646,7 @@ public final class DocumentNodeStore
diffCache = builder.getDiffCache(this.clusterId);
// check if root node exists
- NodeDocument rootDoc = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument rootDoc = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
if (rootDoc == null) {
if (readOnlyMode) {
throw new DocumentStoreException("Unable to initialize a " +
@@ -670,7 +670,7 @@ public final class DocumentNodeStore
setRoot(head);
// make sure _lastRev is written back to store
backgroundWrite();
- rootDoc = store.find(NODES, Utils.getIdFromPath(ROOT));
+ rootDoc = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
// at this point the root document must exist
if (rootDoc == null) {
throw new IllegalStateException("Root document does not exist");
@@ -1416,12 +1416,12 @@ public final class DocumentNodeStore
private Iterable<NodeDocument> readChildDocs(@NotNull final Path path,
@NotNull String name,
final int limit) {
- final String to = Utils.getKeyUpperLimit(checkNotNull(path));
+ final String to = Utils.getKeyUpperLimit(checkNotNull(path), store.getMetadata());
final String from;
if (name.isEmpty()) {
- from = Utils.getKeyLowerLimit(path);
+ from = Utils.getKeyLowerLimit(path, store.getMetadata());
} else {
- from = Utils.getIdFromPath(new Path(path, name));
+ from = Utils.getIdFromPath(new Path(path, name), store.getMetadata());
}
return store.query(Collection.NODES, from, to, limit);
}
@@ -1458,7 +1458,7 @@ public final class DocumentNodeStore
// declares the child to exist, while its node state is
// null. Let's put some extra effort to do some logging
// and invalidate the affected cache entries.
- String id = Utils.getIdFromPath(p);
+ String id = Utils.getIdFromPath(p, store.getMetadata());
String cachedDocStr = docAsString(id, true);
String uncachedDocStr = docAsString(id, false);
nodeCache.invalidate(new PathRev(p, readRevision));
@@ -1497,7 +1497,7 @@ public final class DocumentNodeStore
@Nullable
private DocumentNodeState readNode(Path path, RevisionVector readRevision) {
final long start = PERFLOG.start();
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, store.getMetadata());
Revision lastRevision = getPendingModifications().get(path);
NodeDocument doc = store.find(Collection.NODES, id);
if (doc == null) {
@@ -1536,7 +1536,7 @@ public final class DocumentNodeStore
// determine the revision for the nodeChildrenCache entry when
// the node is new. Fallback to after revision in case document
// is not in the cache. (OAK-4715)
- NodeDocument doc = store.getIfCached(NODES, getIdFromPath(path));
+ NodeDocument doc = store.getIfCached(NODES, getIdFromPath(path, store.getMetadata()));
RevisionVector afterLastRev = after;
if (doc != null) {
afterLastRev = new RevisionVector(doc.getLastRev().values());
@@ -1577,7 +1577,7 @@ public final class DocumentNodeStore
// Invalidate the relevant cache entries. (OAK-6294)
LOG.warn("Before state is missing {}. Invalidating " +
"affected cache entries.", key);
- store.invalidateCache(NODES, Utils.getIdFromPath(p));
+ store.invalidateCache(NODES, Utils.getIdFromPath(p, store.getMetadata()));
nodeCache.invalidate(key);
nodeChildrenCache.invalidate(childNodeCacheKey(path, lastRev, ""));
beforeState = null;
@@ -1810,7 +1810,7 @@ public final class DocumentNodeStore
revs.add(ancestorRev);
}
revs.addAll(b.getCommits().tailSet(ancestorRev));
- UpdateOp rootOp = new UpdateOp(Utils.getIdFromPath(ROOT), false);
+ UpdateOp rootOp = new UpdateOp(Utils.getIdFromPath(ROOT, store.getMetadata()), false);
// reset each branch commit in reverse order
Map<Path, UpdateOp> operations = Maps.newHashMap();
AtomicReference<Revision> currentRev = new AtomicReference<>();
@@ -1832,7 +1832,7 @@ public final class DocumentNodeStore
LOG.debug("reset: comparing branch {} with base {}",
branchState.getRootRevision(), baseState.getRootRevision());
branchState.compareAgainstBaseState(baseState,
- new ResetDiff(previous.asTrunkRevision(), operations));
+ new ResetDiff(previous.asTrunkRevision(), operations, store.getMetadata()));
LOG.debug("reset: applying {} operations", operations.size());
// apply reset operations
for (List<UpdateOp> ops : partition(operations.values(), getCreateOrUpdateBatchSize())) {
@@ -1864,7 +1864,7 @@ public final class DocumentNodeStore
MergeCommit commit = newMergeCommit(base, numBranchCommits);
try {
// make branch commits visible
- UpdateOp op = new UpdateOp(Utils.getIdFromPath(ROOT), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath(ROOT, store.getMetadata()), false);
NodeDocument.setModified(op, commit.getRevision());
if (b != null) {
// check the branch age and fail the commit
@@ -2369,7 +2369,7 @@ public final class DocumentNodeStore
return new ExternalChange(this) {
@Override
void invalidateCache(@NotNull Iterable<String> paths) {
- stats.cacheStats = store.invalidateCache(pathToId(paths));
+ stats.cacheStats = store.invalidateCache(pathToId(paths, store.getMetadata()));
}
@Override
@@ -2448,7 +2448,7 @@ public final class DocumentNodeStore
while ((b = branches.pollOrphanedBranch()) != null) {
LOG.debug("Cleaning up orphaned branch with base revision: {}, " +
"commits: {}", b.getBase(), b.getCommits());
- UpdateOp op = new UpdateOp(Utils.getIdFromPath(ROOT), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath(ROOT, store.getMetadata()), false);
for (Revision r : b.getCommits()) {
r = r.asTrunkRevision();
NodeDocument.removeRevision(op, r);
@@ -2459,7 +2459,7 @@ public final class DocumentNodeStore
}
private void cleanRootCollisions() {
- String id = Utils.getIdFromPath(ROOT);
+ String id = Utils.getIdFromPath(ROOT, store.getMetadata());
NodeDocument root = store.find(NODES, id);
if (root != null) {
cleanCollisions(root, Integer.MAX_VALUE);
@@ -3338,8 +3338,8 @@ public final class DocumentNodeStore
}
}
long minValue = NodeDocument.getModifiedInSecs(minTimestamp);
- String fromKey = Utils.getKeyLowerLimit(path);
- String toKey = Utils.getKeyUpperLimit(path);
+ String fromKey = Utils.getKeyLowerLimit(path, store.getMetadata());
+ String toKey = Utils.getKeyUpperLimit(path, store.getMetadata());
Set<Path> paths = Sets.newHashSet();
LOG.debug("diffManyChildren: path: {}, fromRev: {}, toRev: {}", path, fromRev, toRev);
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreMBeanImpl.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreMBeanImpl.java
index 8ffdd5f0cb..16bb847009 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreMBeanImpl.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreMBeanImpl.java
@@ -218,7 +218,7 @@ final class DocumentNodeStoreMBeanImpl extends AnnotatedStandardMBean implements
}
String p = path;
- NodeDocument nodeDocument = docStore.find(Collection.NODES, Utils.getIdFromPath(p));
+ NodeDocument nodeDocument = docStore.find(Collection.NODES, Utils.getIdFromPath(p, docStore.getMetadata()));
if(nodeDocument == null) {
throw new DocumentStoreException("Document node with given path = " + p + " does not exist");
}
@@ -239,9 +239,10 @@ final class DocumentNodeStoreMBeanImpl extends AnnotatedStandardMBean implements
private List<NodeDocument> getChildDocs(String path) {
Path pathRef = Path.fromString(path);
- final String to = Utils.getKeyUpperLimit(pathRef);
- final String from = Utils.getKeyLowerLimit(pathRef);
- return nodeStore.getDocumentStore().query(Collection.NODES, from, to, 10000);
+ DocumentStore store = nodeStore.getDocumentStore();
+ final String to = Utils.getKeyUpperLimit(pathRef, store.getMetadata());
+ final String from = Utils.getKeyLowerLimit(pathRef, store.getMetadata());
+ return store.query(Collection.NODES, from, to, 10000);
}
@Override
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
index 4ea1569d1b..1b58832f49 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ExternalChange.java
@@ -22,7 +22,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
-import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.sort.StringSort;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder;
@@ -97,8 +96,9 @@ abstract class ExternalChange {
Clock clock = store.getClock();
int clusterId = store.getClusterId();
long time = clock.getTime();
- String id = Utils.getIdFromPath(Path.ROOT);
- NodeDocument doc = store.getDocumentStore().find(NODES, id, store.getAsyncDelay());
+ DocumentStore docStore = store.getDocumentStore();
+ String id = Utils.getIdFromPath(Path.ROOT, docStore.getMetadata());
+ NodeDocument doc = docStore.find(NODES, id, store.getAsyncDelay());
if (doc == null) {
return stats;
}
@@ -146,7 +146,7 @@ abstract class ExternalChange {
try {
fillExternalChanges(externalSort, invalidate,
Path.ROOT, last, r,
- store.getDocumentStore(), journalEntryConsumer,
+ docStore, journalEntryConsumer,
changeSetBuilder, journalPropertyHandler);
} catch (Exception e1) {
LOG.error("backgroundRead: Exception while reading external changes from journal: " + e1, e1);
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
index eb1af745dd..ceb94506f1 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgent.java
@@ -448,7 +448,7 @@ public class LastRevRecoveryAgent {
// there are missing document and the returned document
// does not have bundled nodes
for (Path p : missingDocuments) {
- log.warn("Unable to find document: {}", Utils.getIdFromPath(p));
+ log.warn("Unable to find document: {}", Utils.getIdFromPath(p, store.getMetadata()));
}
}
}
@@ -584,7 +584,7 @@ public class LastRevRecoveryAgent {
@NotNull List<Path> missingDocuments) {
NodeDocument ancestor;
for (;;) {
- ancestor = store.find(NODES, Utils.getIdFromPath(path));
+ ancestor = store.find(NODES, Utils.getIdFromPath(path, store.getMetadata()));
if (ancestor != null) {
break;
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
index b97f54f24d..8a9839248b 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
@@ -125,7 +125,7 @@ public class MissingLastRevSeeker {
}
public NodeDocument getRoot() {
- return store.find(Collection.NODES, Utils.getIdFromPath(Path.ROOT));
+ return store.find(Collection.NODES, Utils.getIdFromPath(Path.ROOT, store.getMetadata()));
}
/**
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
index 40fe4300f3..6994f9f7aa 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
@@ -1275,7 +1275,7 @@ public final class NodeDocument extends Document {
if (entry != null) {
Revision r = entry.getKey();
int h = entry.getValue().height;
- String prevId = Utils.getPreviousIdFor(mainPath, r, h);
+ String prevId = Utils.getPreviousIdFor(mainPath, r, h, store.getMetadata());
NodeDocument prev = getPreviousDocument(prevId);
if (prev != null) {
if (prev.getValueMap(property).containsKey(revision)) {
@@ -1394,7 +1394,7 @@ public final class NodeDocument extends Document {
@Nullable
private NodeDocument getPreviousDoc(Revision rev, Range range){
int h = range.height;
- String prevId = Utils.getPreviousIdFor(getMainPath(), rev, h);
+ String prevId = Utils.getPreviousIdFor(getMainPath(), rev, h, store.getMetadata());
NodeDocument prev = getPreviousDocument(prevId);
if (prev != null) {
return prev;
@@ -1421,11 +1421,11 @@ public final class NodeDocument extends Document {
return this;
} else if (range.includes(revision)) {
String prevId = Utils.getPreviousIdFor(
- getMainPath(), range.high, range.height);
+ getMainPath(), range.high, range.height, store.getMetadata());
NodeDocument prev = store.find(NODES, prevId);
if (prev == null) {
LOG.warn("Split document {} does not exist anymore. Main document is {}",
- prevId, Utils.getIdFromPath(getMainPath()));
+ prevId, Utils.getIdFromPath(getMainPath(), store.getMetadata()));
continue;
}
// recurse into the split hierarchy
@@ -1891,7 +1891,7 @@ public final class NodeDocument extends Document {
// older than one minute. We don't want to invalidate a document
// too frequently if the document structure is really broken.
Path path = getMainPath();
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, store.getMetadata());
NodeDocument doc = store.getIfCached(NODES, id);
long now = Revision.getCurrentTimestamp();
while (doc != null
@@ -1907,7 +1907,7 @@ public final class NodeDocument extends Document {
doc = null;
for (Range range : ranges) {
if (range.includes(rev)) {
- id = Utils.getPreviousIdFor(path, range.high, range.height);
+ id = Utils.getPreviousIdFor(path, range.high, range.height, store.getMetadata());
doc = store.getIfCached(NODES, id);
break;
}
@@ -2022,7 +2022,7 @@ public final class NodeDocument extends Document {
}
}
// get root of commit
- return store.find(Collection.NODES, Utils.getIdFromPath(commitRootPath));
+ return store.find(Collection.NODES, Utils.getIdFromPath(commitRootPath, store.getMetadata()));
}
/**
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
index 9c15192ffe..07e5181baa 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
@@ -65,7 +65,7 @@ class PropertyHistory implements Iterable<NodeDocument> {
public Map.Entry<Revision, NodeDocument> apply(Map.Entry<Revision, Range> input) {
Revision r = input.getKey();
int h = input.getValue().height;
- String prevId = Utils.getPreviousIdFor(mainPath, r, h);
+ String prevId = Utils.getPreviousIdFor(mainPath, r, h, doc.store.getMetadata());
NodeDocument prev = doc.getPreviousDocument(prevId);
if (prev == null) {
LOG.debug("Document with previous revisions not found: " + prevId);
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ResetDiff.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ResetDiff.java
index 0714a62103..160e1b782b 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ResetDiff.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ResetDiff.java
@@ -39,21 +39,24 @@ class ResetDiff implements NodeStateDiff {
private final Revision revision;
private final Path path;
private final Map<Path, UpdateOp> operations;
+ private final Map<String, String> metadata;
private UpdateOp update;
ResetDiff(@NotNull Revision revision,
- @NotNull Map<Path, UpdateOp> operations) {
- this(null, revision, Path.ROOT, operations);
+ @NotNull Map<Path, UpdateOp> operations, @NotNull Map<String, String> metadata) {
+ this(null, revision, Path.ROOT, operations, metadata);
}
private ResetDiff(@Nullable ResetDiff parent,
@NotNull Revision revision,
@NotNull Path path,
- @NotNull Map<Path, UpdateOp> operations) {
+ @NotNull Map<Path, UpdateOp> operations,
+ @NotNull Map<String, String> metadata) {
this.parent = parent;
this.revision = checkNotNull(revision);
this.path = checkNotNull(path);
this.operations = checkNotNull(operations);
+ this.metadata = metadata;
}
@Override
@@ -78,7 +81,7 @@ class ResetDiff implements NodeStateDiff {
public boolean childNodeAdded(String name, NodeState after) {
NodeDocument.removeCommitRoot(getUpdateOp(), revision);
Path p = new Path(path, name);
- ResetDiff diff = new ResetDiff(this, revision, p, operations);
+ ResetDiff diff = new ResetDiff(this, revision, p, operations, metadata);
UpdateOp op = diff.getUpdateOp();
NodeDocument.removeDeleted(op, revision);
NodeDocument.setDeletedOnce(op);
@@ -95,13 +98,13 @@ class ResetDiff implements NodeStateDiff {
NodeState after) {
Path p = new Path(path, name);
return after.compareAgainstBaseState(before,
- new ResetDiff(this, revision, p, operations));
+ new ResetDiff(this, revision, p, operations, metadata));
}
@Override
public boolean childNodeDeleted(String name, NodeState before) {
Path p = new Path(path, name);
- ResetDiff diff = new ResetDiff(this, revision, p, operations);
+ ResetDiff diff = new ResetDiff(this, revision, p, operations, metadata);
NodeDocument.removeDeleted(diff.getUpdateOp(), revision);
return MISSING_NODE.compareAgainstBaseState(before, diff);
}
@@ -114,7 +117,7 @@ class ResetDiff implements NodeStateDiff {
if (update == null) {
update = operations.get(path);
if (update == null) {
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, metadata);
update = new UpdateOp(id, false);
operations.put(path, update);
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
index ac38225556..e2cf4eb515 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
@@ -109,7 +109,7 @@ public class SplitDocumentCleanUp implements Closeable {
private void disconnect(NodeDocument splitDoc) {
String splitId = splitDoc.getId();
- String mainId = Utils.getIdFromPath(splitDoc.getMainPath());
+ String mainId = Utils.getIdFromPath(splitDoc.getMainPath(), store.getMetadata());
NodeDocument doc = store.find(NODES, mainId);
if (doc == null) {
LOG.warn("Main document {} already removed. Split document is {}",
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java
index 4bca73bb25..79b612c3f8 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java
@@ -315,7 +315,7 @@ class SplitOperations {
throw new IllegalStateException();
}
Path prevPath = Utils.getPreviousPathFor(path, h, entry.getKey() + 1);
- String prevId = Utils.getIdFromPath(prevPath);
+ String prevId = Utils.getIdFromPath(prevPath, doc.store.getMetadata());
UpdateOp intermediate = new UpdateOp(prevId, true);
if (Utils.isIdFromLongPath(prevId)) {
intermediate.set(NodeDocument.PATH, prevPath.toString());
@@ -352,7 +352,7 @@ class SplitOperations {
main = new UpdateOp(id, false);
setPrevious(main, new Range(high, low, 0));
Path oldPath = Utils.getPreviousPathFor(path, high, 0);
- String oldId = Utils.getIdFromPath(oldPath);
+ String oldId = Utils.getIdFromPath(oldPath, doc.store.getMetadata());
UpdateOp old = new UpdateOp(oldId, true);
if (Utils.isIdFromLongPath(oldId)) {
old.set(NodeDocument.PATH, oldPath.toString());
@@ -501,7 +501,7 @@ class SplitOperations {
NodeDocument intermediate = doc.findPrevReferencingDoc(r, height);
if (intermediate == null) {
LOG.warn("Split document {} not referenced anymore. Main document is {}",
- getPreviousIdFor(doc.getPath(), r, height), id);
+ getPreviousIdFor(doc.getPath(), r, height, doc.store.getMetadata()), id);
} else {
UpdateOp op = new UpdateOp(intermediate.getId(), false);
NodeDocument.removePrevious(op, r);
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Helper.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Helper.java
index ad6f226afa..aba10dc969 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Helper.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Helper.java
@@ -31,7 +31,7 @@ public class Sweep2Helper {
private static final Logger LOG = LoggerFactory.getLogger(Sweep2Helper.class);
static boolean isSweep2Necessary(DocumentStore store) {
- NodeDocument rootNodeDoc = store.find(Collection.NODES, Utils.getIdFromPath("/"));
+ NodeDocument rootNodeDoc = store.find(Collection.NODES, Utils.getIdFromPath("/", store.getMetadata()));
if (rootNodeDoc == null) {
// that'd be very weird
LOG.warn("isSweep2Necessary : cannot get root node - assuming no sweep2 needed");
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java
index b42923b044..7896014896 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranches.java
@@ -71,7 +71,7 @@ class UnmergedBranches {
if (!initialized.compareAndSet(false, true)) {
throw new IllegalStateException("already initialized");
}
- NodeDocument doc = store.find(Collection.NODES, Utils.getIdFromPath(Path.ROOT));
+ NodeDocument doc = store.find(Collection.NODES, Utils.getIdFromPath(Path.ROOT, store.getMetadata()));
if (doc == null) {
return;
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
index 8db403d8a5..92b1ec857a 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
@@ -182,7 +182,7 @@ class UnsavedModifications {
// update root individually at the end
continue;
}
- updates.add(newUpdateOp(p, r));
+ updates.add(newUpdateOp(p, r, store.getMetadata()));
pathToRevision.put(entry.getKey(), r);
}
if (!updates.isEmpty()) {
@@ -200,7 +200,7 @@ class UnsavedModifications {
// finally update remaining root document
Revision rootRev = pending.get(Path.ROOT);
if (rootRev != null) {
- UpdateOp rootUpdate = newUpdateOp(Path.ROOT, rootRev);
+ UpdateOp rootUpdate = newUpdateOp(Path.ROOT, rootRev, store.getMetadata());
// also update to most recent sweep revision
if (sweepRev != null) {
NodeDocument.setSweepRevision(rootUpdate, sweepRev);
@@ -234,8 +234,8 @@ class UnsavedModifications {
return map.toString();
}
- private static UpdateOp newUpdateOp(Path path, Revision r) {
- UpdateOp updateOp = createUpdateOp(path, r, false);
+ private static UpdateOp newUpdateOp(Path path, Revision r, Map<String, String> metadata) {
+ UpdateOp updateOp = createUpdateOp(path, r, false, metadata);
NodeDocument.setLastRev(updateOp, r);
return updateOp;
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
index ccbbd6e6fd..fef9a27e98 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
@@ -772,7 +772,7 @@ public class VersionGarbageCollector {
@Override
public String apply(Map.Entry<Revision, Range> input) {
int h = input.getValue().getHeight();
- return Utils.getPreviousIdFor(path, input.getKey(), h);
+ return Utils.getPreviousIdFor(path, input.getKey(), h, doc.store.getMetadata());
}
});
} else {
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/locks/StripedNodeDocumentLocks.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/locks/StripedNodeDocumentLocks.java
index 6453179099..2502744f0a 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/locks/StripedNodeDocumentLocks.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/locks/StripedNodeDocumentLocks.java
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document.locks;
+import java.util.Collections;
import java.util.concurrent.locks.Lock;
import org.apache.jackrabbit.oak.plugins.document.Path;
@@ -25,7 +26,7 @@ import com.google.common.util.concurrent.Striped;
public class StripedNodeDocumentLocks implements NodeDocumentLocks {
- private static final String ROOT = Utils.getIdFromPath(Path.ROOT);
+ private static final String ROOT = Utils.getIdFromPath(Path.ROOT, Collections.emptyMap());
/**
* Locks to ensure cache consistency on reads, writes and invalidation.
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
index 507c7a815e..9edd8f91e0 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
@@ -114,10 +114,7 @@ import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_I
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_MAX_REV_TIME_IN_SECS;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_TYPE;
import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Condition.newEqualsCondition;
-import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoUtils.createIndex;
-import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoUtils.createPartialIndex;
-import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoUtils.getDocumentStoreExceptionTypeFor;
-import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoUtils.hasIndex;
+import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoUtils.*;
/**
* A document store that uses MongoDB as the backend.
@@ -261,6 +258,7 @@ public class MongoDocumentStore implements DocumentStore {
metadata = ImmutableMap.<String,String>builder()
.put("type", "mongo")
.put("version", status.getVersion())
+ .put("sizeLimit", String.valueOf(getSizeLimit(status.getVersion())))
.build();
this.connection = new MongoDBConnection(connection, db, status, builder.getMongoClock());
@@ -696,7 +694,7 @@ public class MongoDocumentStore implements DocumentStore {
}
}
Bson query = Filters.and(clauses);
- String parentId = Utils.getParentIdFromLowerLimit(fromKey);
+ String parentId = Utils.getParentIdFromLowerLimit(fromKey, metadata);
long lockTime = -1;
final Stopwatch watch = startWatch();
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtils.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtils.java
index 42a3ebe904..a01058e167 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtils.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtils.java
@@ -190,4 +190,15 @@ class MongoUtils {
}
return type;
}
+
+ /**
+ * Util method to get node size limit for current mongo version
+ *
+ * @param version version of current mongo db
+ * @return size limit based on mongo db version
+ */
+ static int getSizeLimit(String version) {
+ final MongoVersion mv = MongoVersion.of(version);
+ return mv.compareTo(MongoVersion.MONGO_4_0_0) > 0 ? Integer.MAX_VALUE : 150;
+ }
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersion.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersion.java
new file mode 100644
index 0000000000..daae3f9488
--- /dev/null
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersion.java
@@ -0,0 +1,71 @@
+package org.apache.jackrabbit.oak.plugins.document.mongo;
+
+
+import org.apache.commons.lang3.tuple.ImmutableTriple;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+
+/**
+ * Util Class to represent mongo version
+ */
+public final class MongoVersion implements Comparable<MongoVersion>{
+ final int majorVersion;
+ final int minorVersion;
+ final int patchVersion;
+
+
+ private MongoVersion(@NotNull final String version) {
+
+ final ImmutableTriple<Integer, Integer, Integer> versions = extractVersions(version);
+
+ this.majorVersion = versions.left;
+ this.minorVersion = versions.middle;
+ this.patchVersion = versions.right;
+ }
+
+ private ImmutableTriple<Integer, Integer, Integer> extractVersions(String version) {
+
+ final String[] verArr = version.split("\\.");
+ if (verArr.length >= 3)
+ return ImmutableTriple.of(Integer.valueOf(verArr[0]), Integer.valueOf(verArr[1]), Integer.valueOf(verArr[2]));
+ else
+ return ImmutableTriple.of(Integer.valueOf(verArr[0]), Integer.valueOf(verArr[1]), 0);
+
+ }
+
+ static final MongoVersion MONGO_4_0_0 = new MongoVersion("4.0.0");
+
+ /**
+ * static factory to create mongo version
+ * @param version curent version of mongo db
+ * @return if version is null/malformed then MONGO_4_0 (default) else version as per given param
+ */
+ public static MongoVersion of(String version) {
+ return isVersionMalformed(version) ? MONGO_4_0_0 : new MongoVersion(version);
+ }
+
+ private static boolean isVersionMalformed(String version) {
+ return version == null || !version.contains(".");
+ }
+
+ @Override
+ public int compareTo(@NotNull MongoVersion o) {
+ final int x = Integer.compare(this.majorVersion, o.majorVersion);
+ final int y = Integer.compare(this.minorVersion, o.minorVersion);
+ return x == 0 ? y == 0 ? Integer.compare(this.patchVersion, o.patchVersion) : y : x;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ MongoVersion version = (MongoVersion) o;
+ return majorVersion == version.majorVersion && minorVersion == version.minorVersion && patchVersion == version.patchVersion;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(majorVersion, minorVersion, patchVersion);
+ }
+}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
index 910cf8d4cd..b729d05afd 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
@@ -216,7 +216,7 @@ public class MongoVersionGCSupport extends VersionGCSupport {
// only remove those older than sweep rev
List<Bson> orClauses = Lists.newArrayList();
for (Revision r : sweepRevs) {
- String idSuffix = Utils.getPreviousIdFor(Path.ROOT, r, 0);
+ String idSuffix = Utils.getPreviousIdFor(Path.ROOT, r, 0, store.getMetadata());
idSuffix = idSuffix.substring(idSuffix.lastIndexOf('-'));
// id/path constraint for previous documents
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
index 0f6dc63a5c..5f2db930b9 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
@@ -101,6 +101,8 @@ public class Utils {
private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray();
+ private static final String SIMPLE_INTEGER_REG_EX = "\\d+";
+
/**
* A predicate for property and _deleted names.
*/
@@ -276,9 +278,9 @@ public class Utils {
return !key.startsWith("_") || key.startsWith("__") || key.startsWith("_$");
}
- public static String getIdFromPath(@NotNull String path) {
+ public static String getIdFromPath(@NotNull String path, @NotNull Map<String, String> metadata) {
int depth = Utils.pathDepth(path);
- if (isLongPath(path)) {
+ if (isLongPath(path, metadata)) {
String parent = PathUtils.getParentPath(path);
byte[] hash = createSHA256Digest(parent);
return createHashedId(depth, hash, PathUtils.getName(path));
@@ -286,11 +288,11 @@ public class Utils {
return depth + ":" + path;
}
- public static String getIdFromPath(@NotNull Path path) {
+ public static String getIdFromPath(@NotNull Path path, @NotNull Map<String, String> metadata) {
checkNotNull(path);
int depth = getIdDepth(path);
Path parent = path.getParent();
- if (parent != null && isLongPath(path)) {
+ if (parent != null && isLongPath(path, metadata)) {
byte[] hash = createSHA256Digest(parent.toString());
return createHashedId(depth, hash, path.getName());
}
@@ -338,11 +340,13 @@ public class Utils {
* <li>If id is for root path</li>
* <li>If id is for an invalid path</li>
* </ul>
- * @param id id for which parent id needs to be determined
+ *
+ * @param id id for which parent id needs to be determined
+ * @param metadata
* @return parent id. null if parent id cannot be determined
*/
@Nullable
- public static String getParentId(String id){
+ public static String getParentId(String id, Map<String, String> metadata){
if(Utils.isIdFromLongPath(id)){
return null;
}
@@ -354,10 +358,10 @@ public class Utils {
return null;
}
String parentPath = PathUtils.getParentPath(path);
- return Utils.getIdFromPath(parentPath);
+ return Utils.getIdFromPath(parentPath, metadata);
}
- private static boolean isLongPath(String path) {
+ private static boolean isLongPath(String path, Map<String, String> metadata) {
// the most common case: a short path
// avoid calculating the parent path
if (path.length() < PATH_SHORT) {
@@ -369,13 +373,16 @@ public class Utils {
return false;
}
String name = PathUtils.getName(path);
- if (name.getBytes(UTF_8).length > NODE_NAME_LIMIT) {
+ // default value to ensure backward compatibility
+ final String sizeLimit = metadata.getOrDefault("sizeLimit", String.valueOf(NODE_NAME_LIMIT));
+ if (name.getBytes(UTF_8).length >
+ (sizeLimit.matches(SIMPLE_INTEGER_REG_EX) ? Integer.parseInt(sizeLimit) : NODE_NAME_LIMIT)) {
throw new IllegalArgumentException("Node name is too long: " + path);
}
return true;
}
- public static boolean isLongPath(Path path) {
+ public static boolean isLongPath(Path path, Map<String, String> metadata) {
// the most common case: a short path
// avoid calculating the parent path
if (path.length() < PATH_SHORT) {
@@ -389,7 +396,11 @@ public class Utils {
if (parent.toString().getBytes(UTF_8).length < PATH_LONG) {
return false;
}
- if (path.getName().getBytes(UTF_8).length > NODE_NAME_LIMIT) {
+ // default value to ensure backward compatibility
+ final String sizeLimit = metadata.getOrDefault("sizeLimit", String.valueOf(NODE_NAME_LIMIT));
+
+ if (path.getName().getBytes(UTF_8).length >
+ (sizeLimit.matches(SIMPLE_INTEGER_REG_EX) ? Integer.parseInt(sizeLimit) : NODE_NAME_LIMIT)) {
throw new IllegalArgumentException("Node name is too long: " + path);
}
return true;
@@ -433,8 +444,8 @@ public class Utils {
return new Path(prev, String.valueOf(height));
}
- public static String getPreviousIdFor(Path path, Revision r, int height) {
- return getIdFromPath(getPreviousPathFor(path, r, height));
+ public static String getPreviousIdFor(Path path, Revision r, int height, Map<String, String> metadata) {
+ return getIdFromPath(getPreviousPathFor(path, r, height), metadata);
}
/**
@@ -492,11 +503,12 @@ public class Utils {
* Returns the lower key limit to retrieve the children of the given
* <code>path</code>.
*
- * @param path a path.
+ * @param path a path.
+ * @param metadata
* @return the lower key limit.
*/
- public static String getKeyLowerLimit(Path path) {
- String from = getIdFromPath(new Path(path, "a"));
+ public static String getKeyLowerLimit(Path path, Map<String, String> metadata) {
+ String from = getIdFromPath(new Path(path, "a"), metadata);
from = from.substring(0, from.length() - 1);
return from;
}
@@ -505,11 +517,12 @@ public class Utils {
* Returns the upper key limit to retrieve the children of the given
* <code>path</code>.
*
- * @param path a path.
+ * @param path a path.
+ * @param metadata
* @return the upper key limit.
*/
- public static String getKeyUpperLimit(Path path) {
- String to = getIdFromPath(new Path(path, "z"));
+ public static String getKeyUpperLimit(Path path, Map<String, String> metadata) {
+ String to = getIdFromPath(new Path(path, "z"), metadata);
to = to.substring(0, to.length() - 2) + "0";
return to;
}
@@ -518,17 +531,18 @@ public class Utils {
* Returns parentId extracted from the fromKey. fromKey is usually constructed
* using Utils#getKeyLowerLimit
*
- * @param fromKey key used as start key in queries
+ * @param fromKey key used as start key in queries
+ * @param metadata
* @return parentId if possible.
*/
@Nullable
- public static String getParentIdFromLowerLimit(String fromKey){
+ public static String getParentIdFromLowerLimit(String fromKey, Map<String, String> metadata){
//If key just ends with slash 2:/foo/ then append a fake
//name to create a proper id
if(fromKey.endsWith("/")){
fromKey = fromKey + "a";
}
- return getParentId(fromKey);
+ return getParentId(fromKey, metadata);
}
/**
@@ -685,7 +699,7 @@ public class Utils {
*/
@NotNull
public static NodeDocument getRootDocument(@NotNull DocumentStore store) {
- String rootId = Utils.getIdFromPath(Path.ROOT);
+ String rootId = Utils.getIdFromPath(Path.ROOT, store.getMetadata());
NodeDocument root = store.find(Collection.NODES, rootId);
if (root == null) {
throw new IllegalStateException("missing root document");
@@ -791,13 +805,13 @@ public class Utils {
}
/**
- * Transforms the given paths into ids using {@link #getIdFromPath(String)}.
+ * Transforms the given paths into ids using {@link #getIdFromPath(String, Map)}.
*/
- public static Iterable<String> pathToId(@NotNull Iterable<String> paths) {
+ public static Iterable<String> pathToId(@NotNull Iterable<String> paths, @NotNull final Map<String, String> metadata) {
return transform(paths, new Function<String, String>() {
@Override
public String apply(String input) {
- return getIdFromPath(input);
+ return getIdFromPath(input, metadata);
}
});
}
@@ -1053,7 +1067,7 @@ public class Utils {
ClusterNodeInfo info,
Clock clock)
throws DocumentStoreException {
- NodeDocument root = store.find(Collection.NODES, getIdFromPath(Path.ROOT));
+ NodeDocument root = store.find(Collection.NODES, getIdFromPath(Path.ROOT, store.getMetadata()));
if (root == null) {
return;
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractJournalTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractJournalTest.java
index 403ad708d4..3e73024958 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractJournalTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractJournalTest.java
@@ -90,7 +90,7 @@ public abstract class AbstractJournalTest {
}
protected void assertDocCache(DocumentNodeStore ns, boolean expected, String path) {
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, ns.getDocumentStore().getMetadata());
boolean exists = ns.getDocumentStore().getIfCached(Collection.NODES, id)!=null;
if (exists!=expected) {
if (expected) {
@@ -170,7 +170,7 @@ public abstract class AbstractJournalTest {
}
protected NodeDocument getDocument(DocumentNodeStore nodeStore, String path) {
- return nodeStore.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
+ return nodeStore.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path, nodeStore.getDocumentStore().getMetadata()));
}
protected TestBuilder newDocumentMKBuilder() {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BackgroundSplitFailureTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BackgroundSplitFailureTest.java
index 16c4c658d3..b3421d64ca 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BackgroundSplitFailureTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BackgroundSplitFailureTest.java
@@ -65,7 +65,7 @@ public class BackgroundSplitFailureTest {
.setDocumentStore(failingStore).setAsyncDelay(0).clock(clock).build();
int clusterId = ns.getClusterId();
Path fooPath = new Path(Path.ROOT, "foo");
- String fooId = Utils.getIdFromPath(fooPath);
+ String fooId = Utils.getIdFromPath(fooPath, store.getMetadata());
NodeBuilder builder = ns.getRoot().builder();
builder.child(fooPath.getName()).setProperty("p", -1);
@@ -105,7 +105,7 @@ public class BackgroundSplitFailureTest {
};
ns = builderProvider.newBuilder().setClusterId(clusterId)
.setDocumentStore(testStore).setAsyncDelay(0).clock(clock).build();
- ns.addSplitCandidate(Utils.getIdFromPath(new Path(Path.ROOT, "foo")));
+ ns.addSplitCandidate(Utils.getIdFromPath(new Path(Path.ROOT, "foo"), store.getMetadata()));
falseOnJournalEntryCreate.set(true);
try {
ns.runBackgroundOperations();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
index d7cf4b9828..3702f6c5b1 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
@@ -675,7 +675,7 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
for (String t : tests) {
int pos = t.indexOf(":");
String test = t.substring(pos + 1);
- String id = Utils.getIdFromPath("/" + this.getClass().getName() + ".testInterestingValidIds-" + test);
+ String id = Utils.getIdFromPath("/" + this.getClass().getName() + ".testInterestingValidIds-" + test, ds.getMetadata());
super.ds.remove(Collection.NODES, id);
UpdateOp up = new UpdateOp(id, true);
boolean success = super.ds.create(Collection.NODES, Collections.singletonList(up));
@@ -698,7 +698,7 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
for (String t : tests) {
int pos = t.indexOf(":");
String test = t.substring(pos + 1);
- String id = Utils.getIdFromPath("/" + this.getClass().getName() + ".testInterestingInvalidIds-" + test);
+ String id = Utils.getIdFromPath("/" + this.getClass().getName() + ".testInterestingInvalidIds-" + test, ds.getMetadata());
try {
super.ds.remove(Collection.NODES, id);
@@ -1111,11 +1111,11 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
List<UpdateOp> docs = Lists.newArrayList();
docs.add(newDocument("/foo", 100));
- removeMe.add(Utils.getIdFromPath("/foo"));
+ removeMe.add(Utils.getIdFromPath("/foo", ds.getMetadata()));
docs.add(newDocument("/bar", 200));
- removeMe.add(Utils.getIdFromPath("/bar"));
+ removeMe.add(Utils.getIdFromPath("/bar", ds.getMetadata()));
docs.add(newDocument("/baz", 300));
- removeMe.add(Utils.getIdFromPath("/baz"));
+ removeMe.add(Utils.getIdFromPath("/baz", ds.getMetadata()));
ds.create(Collection.NODES, docs);
for (UpdateOp op : docs) {
@@ -1123,15 +1123,15 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
}
Map<String, Long> toRemove = Maps.newHashMap();
- toRemove.put(Utils.getIdFromPath("/foo"), 100L); // matches
- toRemove.put(Utils.getIdFromPath("/bar"), 300L); // modified differs
- toRemove.put(Utils.getIdFromPath("/qux"), 100L); // does not exist
- toRemove.put(Utils.getIdFromPath("/baz"), 300L); // matches
+ toRemove.put(Utils.getIdFromPath("/foo", ds.getMetadata()), 100L); // matches
+ toRemove.put(Utils.getIdFromPath("/bar", ds.getMetadata()), 300L); // modified differs
+ toRemove.put(Utils.getIdFromPath("/qux", ds.getMetadata()), 100L); // does not exist
+ toRemove.put(Utils.getIdFromPath("/baz", ds.getMetadata()), 300L); // matches
int removed = ds.remove(Collection.NODES, toRemove);
assertEquals(2, removed);
- assertNotNull(ds.find(Collection.NODES, Utils.getIdFromPath("/bar")));
+ assertNotNull(ds.find(Collection.NODES, Utils.getIdFromPath("/bar", ds.getMetadata())));
Path bar = Path.fromString("/bar");
for (NodeDocument doc : Utils.getAllDocuments(ds)) {
if (!doc.getPath().equals(bar) && !existingDocs.contains(doc.getPath())) {
@@ -1143,7 +1143,7 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
@Test
public void removeInvalidatesCache() throws Exception {
String path = "/foo";
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, ds.getMetadata());
long modified = 1;
removeMe.add(id);
ds.create(Collection.NODES, Collections.singletonList(newDocument(path, modified)));
@@ -1155,13 +1155,13 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
// OAK-3932
@Test
public void getIfCachedNonExistingDocument() throws Exception {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", ds.getMetadata());
assertNull(ds.find(Collection.NODES, id));
assertNull(ds.getIfCached(Collection.NODES, id));
}
private UpdateOp newDocument(String path, long modified) {
- String id = Utils.getIdFromPath(path);
+ String id = Utils.getIdFromPath(path, ds.getMetadata());
UpdateOp op = new UpdateOp(id, true);
op.set(NodeDocument.MODIFIED_IN_SECS, modified);
return op;
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobCollectorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobCollectorTest.java
index a1c4f5cdf3..5412e5d377 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobCollectorTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobCollectorTest.java
@@ -86,7 +86,7 @@ public class BlobCollectorTest {
}
NodeDocument doc =
- store.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath("/x/y"));
+ store.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath("/x/y", store.getDocumentStore().getMetadata()));
List<ReferencedBlob> collectedBlobs = Lists.newArrayList();
blobCollector.collect(doc, collectedBlobs);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
index 81ddd27bd8..89d2d0f036 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
@@ -142,7 +142,7 @@ public class BlobReferenceIteratorTest {
public void recreateNodeAfterRevisionGC() throws Exception {
assumeTrue(fixture.hasSinglePersistence());
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getDocumentStore().getMetadata());
NodeBuilder builder = store.getRoot().builder();
Blob b = builder.createBlob(new RandomStream(100, 42));
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchStateTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchStateTest.java
index 3dfde17062..d9e105f67b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchStateTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchStateTest.java
@@ -44,7 +44,7 @@ public class BranchStateTest {
public void before() {
ns = builderProvider.newBuilder().getNodeStore();
store = ns.getDocumentStore();
- testId = Utils.getIdFromPath("/test");
+ testId = Utils.getIdFromPath("/test", store.getMetadata());
}
// OAK-4536
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
index 5015564ac4..796a64d79b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
@@ -202,12 +202,12 @@ public class BranchTest {
merge(ns, builder);
// step 3 : verify that "_bc" are set correctly : on all except /a/b (where nothing was changed)
- assertNotNull(store.find(NODES, Utils.getIdFromPath("/")).get("_bc"));
- assertNotNull(store.find(NODES, Utils.getIdFromPath("/a")).get("_bc"));
- assertNull(store.find(NODES, Utils.getIdFromPath("/a/b")).get("_bc"));
- assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c")).get("_bc"));
- assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c/d")).get("_bc"));
- assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c/d/e")).get("_bc"));
+ assertNotNull(store.find(NODES, Utils.getIdFromPath("/", store.getMetadata())).get("_bc"));
+ assertNotNull(store.find(NODES, Utils.getIdFromPath("/a", store.getMetadata())).get("_bc"));
+ assertNull(store.find(NODES, Utils.getIdFromPath("/a/b", store.getMetadata())).get("_bc"));
+ assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c", store.getMetadata())).get("_bc"));
+ assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c/d", store.getMetadata())).get("_bc"));
+ assertNotNull(store.find(NODES, Utils.getIdFromPath("/a/b/c/d/e", store.getMetadata())).get("_bc"));
// step 4 : verify the "_bc" are set correctly by backgroundSweep()/forceBackgroundSweep()
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyRDBTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyRDBTest.java
index 244420184b..7a3d5405d7 100755
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyRDBTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyRDBTest.java
@@ -60,12 +60,12 @@ public class CacheConsistencyRDBTest extends AbstractRDBConnectionTest {
// of _lastRev on /node
mk.commit("/node", "+\"child\":{}", null, null);
// make sure the document is not cached
- store.invalidateNodeDocument(Utils.getIdFromPath("/node"));
+ store.invalidateNodeDocument(Utils.getIdFromPath("/node", store.getMetadata()));
Thread t = new Thread(new Runnable() {
@Override
public void run() {
- store.query(NODES, Utils.getKeyLowerLimit(Path.ROOT), Utils.getKeyUpperLimit(Path.ROOT), 10);
+ store.query(NODES, Utils.getKeyLowerLimit(Path.ROOT, store.getMetadata()), Utils.getKeyUpperLimit(Path.ROOT, store.getMetadata()), 10);
}
}, "query");
// block thread when it tries to convert db objects
@@ -88,7 +88,7 @@ public class CacheConsistencyRDBTest extends AbstractRDBConnectionTest {
// wait at most one second for background thread
done.tryAcquire(1, TimeUnit.SECONDS);
- store.invalidateNodeDocument(Utils.getIdFromPath("/node"));
+ store.invalidateNodeDocument(Utils.getIdFromPath("/node", store.getMetadata()));
// release thread
store.semaphores.get(t).release();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTest.java
index 85be44bc31..acf17d434c 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTest.java
@@ -65,14 +65,14 @@ public class CacheConsistencyTest extends AbstractMongoConnectionTest {
mk.commit("/node", "+\"child\":{}", null, null);
// make sure the document is not cached
- store.invalidateCache(NODES, Utils.getIdFromPath("/node"));
+ store.invalidateCache(NODES, Utils.getIdFromPath("/node", store.getMetadata()));
Thread t = new Thread(new Runnable() {
@Override
public void run() {
store.query(NODES,
- Utils.getKeyLowerLimit(Path.ROOT),
- Utils.getKeyUpperLimit(Path.ROOT), 10);
+ Utils.getKeyLowerLimit(Path.ROOT, store.getMetadata()),
+ Utils.getKeyUpperLimit(Path.ROOT, store.getMetadata()), 10);
}
});
// block thread when it tries to convert db objects
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionCleanupTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionCleanupTest.java
index a8a5a2949b..0811ec3950 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionCleanupTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionCleanupTest.java
@@ -84,7 +84,7 @@ public class CollisionCleanupTest {
tasks.add(new Updater(ns2));
executor.invokeAll(tasks);
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
ns1.addSplitCandidate(id);
ns1.runBackgroundOperations();
ns2.addSplitCandidate(id);
@@ -103,7 +103,7 @@ public class CollisionCleanupTest {
b1.child("test");
merge(ns1, b1);
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
Revision other = new Revision(r.getTimestamp(), r.getCounter(), r.getClusterId() + 1);
// add lots of old collisions
UpdateOp op = new UpdateOp(id, false);
@@ -143,7 +143,7 @@ public class CollisionCleanupTest {
assertThat(doc.getLocalMap(COLLISIONS).keySet(), hasSize(1));
// must not clean up marker
- ns1.addSplitCandidate(Utils.getIdFromPath("/"));
+ ns1.addSplitCandidate(Utils.getIdFromPath("/", store.getMetadata()));
ns1.runBackgroundOperations();
doc = Utils.getRootDocument(ns1.getDocumentStore());
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionTest.java
index 9efd6681cb..48cef062d7 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionTest.java
@@ -91,7 +91,7 @@ public class CollisionTest {
createCollision(mk1);
createCollision(mk2);
- String id = getIdFromPath("/");
+ String id = getIdFromPath("/", store.getMetadata());
assertEquals(2, getDocument(store, id).getLocalMap(COLLISIONS).size());
// restart node store
@@ -120,7 +120,7 @@ public class CollisionTest {
DocumentNodeStore ns = newBuilder()
.setAsyncDelay(0).getNodeStore();
DocumentStore store = ns.getDocumentStore();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
NodeBuilder b = ns.getRoot().builder();
b.child("test").setProperty("p", "a");
@@ -211,7 +211,7 @@ public class CollisionTest {
retainBranches(ns);
ns.dispose();
- NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
assertThat(root.getLocalBranchCommits(), not(empty()));
@@ -225,7 +225,7 @@ public class CollisionTest {
.setUpdateLimit(10).build();
ns.updateClusterState();
- root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
// on init the DocumentNodeStore removes orphaned
// branch commit entries on the root document
@@ -233,7 +233,7 @@ public class CollisionTest {
// but some changes are still there
Path p = Path.fromString("/n-0");
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p, store.getMetadata()));
assertNotNull(doc);
assertThat(doc.getLocalBranchCommits(), not(empty()));
@@ -265,13 +265,13 @@ public class CollisionTest {
ns1.dispose();
ns2.updateClusterState();
- NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
assertThat(root.getLocalBranchCommits(), not(empty()));
// but some changes are still there
Path p = Path.fromString("/n-0");
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p, store.getMetadata()));
assertNotNull(doc);
assertThat(doc.getLocalBranchCommits(), not(empty()));
@@ -281,7 +281,7 @@ public class CollisionTest {
// must create a collision marker for a branch commit because
// it is not known when ns1 was stopped
- root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
assertThat(root.getLocalMap(COLLISIONS).keySet(), not(empty()));
}
@@ -304,7 +304,7 @@ public class CollisionTest {
retainBranches(ns1);
ns1.dispose();
- NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
assertThat(root.getLocalBranchCommits(), not(empty()));
@@ -317,7 +317,7 @@ public class CollisionTest {
.setDocumentStore(store).setAsyncDelay(0)
.setUpdateLimit(10).setClusterId(1).build();
- root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
// on init the DocumentNodeStore removes orphaned
// branch commit entries on the root document
@@ -325,7 +325,7 @@ public class CollisionTest {
// but some changes are still there
Path p = Path.fromString("/n-0");
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p, store.getMetadata()));
assertNotNull(doc);
assertThat(doc.getLocalBranchCommits(), not(empty()));
@@ -359,7 +359,7 @@ public class CollisionTest {
retainBranches(ns1);
ns1.dispose();
- NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
assertThat(root.getLocalBranchCommits(), not(empty()));
@@ -372,7 +372,7 @@ public class CollisionTest {
.setDocumentStore(store).setAsyncDelay(0)
.setUpdateLimit(updateLimit).setClusterId(1).build();
- root = store.find(NODES, Utils.getIdFromPath(ROOT));
+ root = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(root);
// on init the DocumentNodeStore removes orphaned
// branch commit entries on the root document
@@ -380,7 +380,7 @@ public class CollisionTest {
// but some changes are still there
Path p = Path.fromString("/n-0");
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p, store.getMetadata()));
assertNotNull(doc);
assertThat(doc.getLocalBranchCommits(), not(empty()));
@@ -400,7 +400,7 @@ public class CollisionTest {
}
private static void assertNoCollisions(DocumentStore store, Path p) {
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(p, store.getMetadata()));
assertNotNull(doc);
assertThat(doc.getLocalMap(COLLISIONS).keySet(), empty());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionWithSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionWithSplitTest.java
index 431da8f4d1..cdd9157e79 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionWithSplitTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CollisionWithSplitTest.java
@@ -103,7 +103,7 @@ public class CollisionWithSplitTest extends AbstractMongoConnectionTest {
}
// attempt to set a property on a removed node
- String id = Utils.getIdFromPath("/node-0");
+ String id = Utils.getIdFromPath("/node-0", store.getMetadata());
UpdateOp op = new UpdateOp(id, false);
Revision ourRev = ns2.newRevision();
op.setMapEntry("p", ourRev, "v");
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitValueResolverTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitValueResolverTest.java
index 77a26568e2..703ef3b5ac 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitValueResolverTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitValueResolverTest.java
@@ -215,7 +215,7 @@ public class CommitValueResolverTest {
TestUtils.merge(ns, builder);
Revision commitRev = ns.getHeadRevision().getRevision(ns.getClusterId());
assertNotNull(commitRev);
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", store.getMetadata()), false);
NodeDocument.removeRevision(op, commitRev);
assertNotNull(store.findAndUpdate(NODES, op));
@@ -281,7 +281,7 @@ public class CommitValueResolverTest {
}
private NodeDocument getDocument(String path) {
- return ns.getDocumentStore().find(NODES, getIdFromPath(path));
+ return ns.getDocumentStore().find(NODES, getIdFromPath(path, store.getMetadata()));
}
private void someChange(String path) throws Exception {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
index 8a3e20f61b..12b70772ab 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
@@ -77,7 +77,7 @@ public class ConcurrentQueryAndInvalidateIT extends AbstractMultiDocumentStoreTe
List<UpdateOp> ops = Lists.newArrayList();
List<String> ids = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- String id = Utils.getIdFromPath("/node-" + i);
+ String id = Utils.getIdFromPath("/node-" + i, ds1.getMetadata());
ids.add(id);
UpdateOp op = new UpdateOp(id, true);
NodeDocument.setLastRev(op, r);
@@ -109,7 +109,7 @@ public class ConcurrentQueryAndInvalidateIT extends AbstractMultiDocumentStoreTe
q.join();
u.join();
for (int j = 0; j < NUM_NODES; j++) {
- NodeDocument doc = ds1.find(NODES, Utils.getIdFromPath("/node-" + j));
+ NodeDocument doc = ds1.find(NODES, Utils.getIdFromPath("/node-" + j, ds1.getMetadata()));
assertNotNull(doc);
assertEquals("Unexpected revision timestamp for " + doc.getId(),
counter, doc.getLastRev().get(1).getTimestamp());
@@ -122,7 +122,7 @@ public class ConcurrentQueryAndInvalidateIT extends AbstractMultiDocumentStoreTe
}
private void queryDocuments() {
- ds1.query(NODES, getKeyLowerLimit(Path.ROOT), getKeyUpperLimit(Path.ROOT), 100);
+ ds1.query(NODES, getKeyLowerLimit(Path.ROOT, ds1.getMetadata()), getKeyUpperLimit(Path.ROOT, ds1.getMetadata()), 100);
}
private Iterable<String> updateDocuments() {
@@ -131,7 +131,7 @@ public class ConcurrentQueryAndInvalidateIT extends AbstractMultiDocumentStoreTe
List<UpdateOp> ops = Lists.newArrayList();
List<String> ids = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- String id = getIdFromPath("/node-" + i);
+ String id = getIdFromPath("/node-" + i, ds2.getMetadata());
ids.add(id);
ops.add(op.shallowCopy(id));
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdate2IT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdate2IT.java
index d892568193..4d94e589cc 100755
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdate2IT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdate2IT.java
@@ -60,7 +60,7 @@ public class ConcurrentQueryAndUpdate2IT extends AbstractDocumentStoreTest {
List<UpdateOp> ops = Lists.newArrayList();
List<String> ids = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- String id = Utils.getIdFromPath("/node-" + i);
+ String id = Utils.getIdFromPath("/node-" + i, ds.getMetadata());
ids.add(id);
UpdateOp op = new UpdateOp(id, true);
NodeDocument.setLastRev(op, r);
@@ -87,7 +87,7 @@ public class ConcurrentQueryAndUpdate2IT extends AbstractDocumentStoreTest {
q.join();
u.join();
for (int j = 0; j < NUM_NODES; j++) {
- NodeDocument doc = ds.getIfCached(NODES, Utils.getIdFromPath("/node-" + j));
+ NodeDocument doc = ds.getIfCached(NODES, Utils.getIdFromPath("/node-" + j, ds.getMetadata()));
if (doc != null) {
assertEquals("Unexpected revision timestamp for " + doc.getId(),
counter.get(), doc.getLastRev().get(1).getTimestamp());
@@ -105,7 +105,7 @@ public class ConcurrentQueryAndUpdate2IT extends AbstractDocumentStoreTest {
Thread.sleep(0, ThreadLocalRandom.current().nextInt(1000, 10000));
} catch (InterruptedException ignore) {
}
- ds.query(NODES, getKeyLowerLimit(Path.ROOT), getKeyUpperLimit(Path.ROOT), 100);
+ ds.query(NODES, getKeyLowerLimit(Path.ROOT, ds.getMetadata()), getKeyUpperLimit(Path.ROOT, ds.getMetadata()), 100);
}
private void updateDocuments() {
@@ -114,7 +114,7 @@ public class ConcurrentQueryAndUpdate2IT extends AbstractDocumentStoreTest {
NodeDocument.setLastRev(op, r);
List<UpdateOp> ops = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- ops.add(op.shallowCopy(getIdFromPath("/node-" + i)));
+ ops.add(op.shallowCopy(getIdFromPath("/node-" + i, ds.getMetadata())));
}
ds.createOrUpdate(NODES, ops);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdateIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdateIT.java
index 951c698607..a7e555b5df 100755
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdateIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndUpdateIT.java
@@ -23,6 +23,7 @@ import static org.apache.jackrabbit.oak.plugins.document.util.Utils.getKeyUpperL
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.Collections;
import java.util.List;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
@@ -46,7 +47,7 @@ public class ConcurrentQueryAndUpdateIT extends AbstractDocumentStoreTest {
List<UpdateOp> ops = Lists.newArrayList();
List<String> ids = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- String id = Utils.getIdFromPath("/node-" + i);
+ String id = Utils.getIdFromPath("/node-" + i, ds.getMetadata());
ids.add(id);
UpdateOp op = new UpdateOp(id, true);
NodeDocument.setLastRev(op, r);
@@ -74,7 +75,7 @@ public class ConcurrentQueryAndUpdateIT extends AbstractDocumentStoreTest {
q.join();
u.join();
for (int j = 0; j < NUM_NODES; j++) {
- NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/node-" + j));
+ NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/node-" + j, ds.getMetadata()));
assertNotNull(doc);
assertEquals("Unexpected revision timestamp for " + doc.getId(),
counter, doc.getLastRev().get(1).getTimestamp());
@@ -87,7 +88,7 @@ public class ConcurrentQueryAndUpdateIT extends AbstractDocumentStoreTest {
}
private void queryDocuments() {
- ds.query(NODES, getKeyLowerLimit(Path.ROOT), getKeyUpperLimit(Path.ROOT), 100);
+ ds.query(NODES, getKeyLowerLimit(Path.ROOT, ds.getMetadata()), getKeyUpperLimit(Path.ROOT, ds.getMetadata()), 100);
}
private void updateDocuments() {
@@ -95,7 +96,7 @@ public class ConcurrentQueryAndUpdateIT extends AbstractDocumentStoreTest {
NodeDocument.setLastRev(op, newRevision());
List<UpdateOp> ops = Lists.newArrayList();
for (int i = 0; i < NUM_NODES; i++) {
- ops.add(op.shallowCopy(getIdFromPath("/node-" + i)));
+ ops.add(op.shallowCopy(getIdFromPath("/node-" + i, ds.getMetadata())));
}
ds.createOrUpdate(NODES, ops);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentMKResetTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentMKResetTest.java
index 34d092856b..de7a1b11e7 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentMKResetTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentMKResetTest.java
@@ -180,7 +180,7 @@ public class DocumentMKResetTest extends BaseDocumentMKTest {
String b0 = mk.branch(null);
String b1 = addNodes(b0, "/foo/bar");
- NodeDocument foo = store.find(NODES, getIdFromPath("/foo"));
+ NodeDocument foo = store.find(NODES, getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
assertTrue(foo.getLocalCommitRoot().containsKey(
Revision.fromString(b1).asTrunkRevision()));
@@ -190,7 +190,7 @@ public class DocumentMKResetTest extends BaseDocumentMKTest {
mk.reset(b1, b0);
// reset must also remove _commitRoot entry on parent document
- foo = store.find(NODES, getIdFromPath("/foo"));
+ foo = store.find(NODES, getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
assertFalse(foo.getLocalCommitRoot().containsKey(
Revision.fromString(b1).asTrunkRevision()));
@@ -204,7 +204,7 @@ public class DocumentMKResetTest extends BaseDocumentMKTest {
String b0 = mk.branch(null);
String b1 = addNodes(b0, "/foo/bar");
- NodeDocument foo = store.find(NODES, getIdFromPath("/foo"));
+ NodeDocument foo = store.find(NODES, getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
assertTrue(foo.getLocalCommitRoot().containsKey(
Revision.fromString(b1).asTrunkRevision()));
@@ -233,7 +233,7 @@ public class DocumentMKResetTest extends BaseDocumentMKTest {
mk.commit("", "^\"/foo/p2\":1^\"/foo/p3\":1", null, null);
// check collision markers
- NodeDocument rootDoc = store.find(NODES, getIdFromPath("/"));
+ NodeDocument rootDoc = store.find(NODES, getIdFromPath("/", store.getMetadata()));
assertNotNull(rootDoc);
Map<Revision, String> collisions = rootDoc.getValueMap(COLLISIONS);
assertEquals(2, collisions.size());
@@ -249,7 +249,7 @@ public class DocumentMKResetTest extends BaseDocumentMKTest {
String b4 = mk.reset(b3, b1);
String b5 = mk.commit("", "^\"/foo/p4\":1", b4, null);
- rootDoc = store.find(NODES, getIdFromPath("/"));
+ rootDoc = store.find(NODES, getIdFromPath("/", store.getMetadata()));
assertNotNull(rootDoc);
collisions = rootDoc.getValueMap(COLLISIONS);
assertEquals(0, collisions.size());
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBackgroundUpdateTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBackgroundUpdateTest.java
index 0e48c0eb4d..01413b6161 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBackgroundUpdateTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBackgroundUpdateTest.java
@@ -16,10 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
-import java.util.ArrayList;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -72,7 +69,7 @@ public class DocumentNodeStoreBackgroundUpdateTest {
@Override
public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update) {
- if (!update.getId().equals(Utils.getIdFromPath(Path.ROOT))) {
+ if (!update.getId().equals(Utils.getIdFromPath(Path.ROOT, Collections.emptyMap()))) {
return super.findAndUpdate(collection, update);
}
Lock lock = locks.getOrDefault(Thread.currentThread(), defaultLock);
@@ -141,7 +138,7 @@ public class DocumentNodeStoreBackgroundUpdateTest {
t.join();
- NodeDocument root = failingStore.find(NODES, Utils.getIdFromPath(Path.ROOT));
+ NodeDocument root = failingStore.find(NODES, Utils.getIdFromPath(Path.ROOT, store.getMetadata()));
assertNotNull(root);
ClusterNodeInfoDocument infoDoc = ClusterNodeInfoDocument.all(failingStore).get(0);
Revision lastRev = root.getLastRev().get(clusterId);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreIT.java
index 6e2f1e7df3..dc08d34cc9 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreIT.java
@@ -88,10 +88,10 @@ public class DocumentNodeStoreIT extends AbstractDocumentStoreTest {
removeMeClusterNodes.add("1");
NodeBuilder builder1 = ns1.getRoot().builder();
builder1.child("node");
- removeMe.add(getIdFromPath("/node"));
+ removeMe.add(getIdFromPath("/node", docStore.getMetadata()));
for (int i = 0; i < DocumentMK.MANY_CHILDREN_THRESHOLD; i++) {
builder1.child("node-" + i);
- removeMe.add(getIdFromPath("/node/node-" + i));
+ removeMe.add(getIdFromPath("/node/node-" + i, docStore.getMetadata()));
}
ns1.merge(builder1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// make sure commit is visible to other node store instance
@@ -104,7 +104,7 @@ public class DocumentNodeStoreIT extends AbstractDocumentStoreTest {
NodeBuilder builder2 = ns2.getRoot().builder();
builder2.child("node").child("child-a");
- removeMe.add(getIdFromPath("/node/child-a"));
+ removeMe.add(getIdFromPath("/node/child-a", docStore.getMetadata()));
ns2.merge(builder2, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// wait at least _modified resolution. in reality the wait may
@@ -115,14 +115,14 @@ public class DocumentNodeStoreIT extends AbstractDocumentStoreTest {
builder1 = ns1.getRoot().builder();
builder1.child("node").child("child-b");
- removeMe.add(getIdFromPath("/node/child-b"));
+ removeMe.add(getIdFromPath("/node/child-b", docStore.getMetadata()));
ns1.merge(builder1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// remember root for diff
DocumentNodeState root1 = ns1.getRoot();
builder1 = root1.builder();
builder1.child("node").child("child-c");
- removeMe.add(getIdFromPath("/node/child-c"));
+ removeMe.add(getIdFromPath("/node/child-c", docStore.getMetadata()));
ns1.merge(builder1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// remember root for diff
DocumentNodeState root2 = ns1.getRoot();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepIT.java
index f15e39d3c2..3cfaf9815c 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepIT.java
@@ -108,7 +108,7 @@ public class DocumentNodeStoreSweepIT extends AbstractTwoNodeTest {
static boolean isClean(DocumentNodeStore ns, String path) {
// use find that also reads from the cache
- NodeDocument doc = ns.getDocumentStore().find(NODES, Utils.getIdFromPath(path));
+ NodeDocument doc = ns.getDocumentStore().find(NODES, Utils.getIdFromPath(path, ns.getDocumentStore().getMetadata()));
for (Revision c : doc.getAllChanges()) {
String commitValue = ns.getCommitValue(c, doc);
if (!Utils.isCommitted(commitValue)) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java
index b2609c3167..cfe2520c80 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java
@@ -216,7 +216,7 @@ public class DocumentNodeStoreSweepTest {
crashDocumentNodeStore();
// and remove the sweep revision for clusterId
// this will look like an upgraded and crashed pre 1.8 node store
- UpdateOp op = new UpdateOp(getIdFromPath(Path.ROOT), false);
+ UpdateOp op = new UpdateOp(getIdFromPath(Path.ROOT, store.getMetadata()), false);
op.removeMapEntry("_sweepRev", new Revision(0, 0, clusterId));
assertNotNull(store.findAndUpdate(Collection.NODES, op));
NodeDocument rootDoc = getRootDocument(store);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
index 86147854c2..71f52fb6eb 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
@@ -332,23 +332,23 @@ public class DocumentNodeStoreTest {
writer.join();
assertEquals("expected exception", 1, exceptions.size());
- String id = Utils.getIdFromPath("/newConflictingNode");
+ String id = Utils.getIdFromPath("/newConflictingNode", docStore.getMetadata());
NodeDocument doc = docStore.find(NODES, id);
assertNotNull("document with id " + id + " does not exist", doc);
assertTrue("document with id " + id + " should get _deletedOnce marked due to rollback",
doc.wasDeletedOnce());
- id = Utils.getIdFromPath("/newNonConflictingNode");
+ id = Utils.getIdFromPath("/newNonConflictingNode", docStore.getMetadata());
doc = docStore.find(NODES, id);
assertNull("document with id " + id + " must not have _deletedOnce",
doc.get(NodeDocument.DELETED_ONCE));
- id = Utils.getIdFromPath("/deletedNode");
+ id = Utils.getIdFromPath("/deletedNode", docStore.getMetadata());
doc = docStore.find(NODES, id);
assertTrue("document with id " + id + " should get _deletedOnce marked due to rollback",
doc.wasDeletedOnce());
- id = Utils.getIdFromPath("/updateNode");
+ id = Utils.getIdFromPath("/updateNode", docStore.getMetadata());
doc = docStore.find(NODES, id);
assertNull("document with id " + id + " must not have _deletedOnce despite rollback",
doc.get(NodeDocument.DELETED_ONCE));
@@ -402,7 +402,7 @@ public class DocumentNodeStoreTest {
}
ns1.runBackgroundOperations();
- NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/"));
+ NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/", docStore.getMetadata()));
assertNotNull(doc);
Revision newest = doc.getNewestRevision(ns2, ns2.getHeadRevision(),
Revision.newRevision(ns2.getClusterId()),
@@ -501,13 +501,13 @@ public class DocumentNodeStoreTest {
ns1.runBackgroundOperations();
// get current _modified timestamp on /node
- NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/node"));
+ NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/node", docStore.getMetadata()));
Long mod1 = (Long) doc.get(MODIFIED_IN_SECS);
assertNotNull(mod1);
ns2.runBackgroundOperations();
- doc = docStore.find(NODES, Utils.getIdFromPath("/node"));
+ doc = docStore.find(NODES, Utils.getIdFromPath("/node", docStore.getMetadata()));
Long mod2 = (Long) doc.get(MODIFIED_IN_SECS);
assertTrue("" + mod2 + " < " + mod1, mod2 >= mod1);
}
@@ -571,7 +571,7 @@ public class DocumentNodeStoreTest {
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
RevisionVector rev = ns.getHeadRevision();
- NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/test", docStore.getMetadata()));
assertNotNull(doc);
DocumentNodeState state = doc.getNodeAtRevision(ns, rev, null);
assertNotNull(state);
@@ -586,7 +586,7 @@ public class DocumentNodeStoreTest {
ns.runBackgroundOperations();
// must still return the same value as before the split
- doc = docStore.find(NODES, Utils.getIdFromPath("/test"));
+ doc = docStore.find(NODES, Utils.getIdFromPath("/test", docStore.getMetadata()));
assertNotNull(doc);
state = doc.getNodeAtRevision(ns, rev, null);
assertNotNull(state);
@@ -735,7 +735,7 @@ public class DocumentNodeStoreTest {
merge(ns1, builder);
ns1.dispose();
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/foo"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/foo", docStore.getMetadata()), false);
op.removeMapEntry("_lastRev", new Revision(0, 0, cId1));
assertNotNull(docStore.findAndUpdate(Collection.NODES, op));
@@ -770,7 +770,7 @@ public class DocumentNodeStoreTest {
.getNodeStore();
dns1.dispose();
- NodeDocument beforeRootDoc = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument beforeRootDoc = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(beforeRootDoc);
Revision beforeLastRev = beforeRootDoc.getLastRev().get(clusterId);
@@ -788,7 +788,7 @@ public class DocumentNodeStoreTest {
.setAsyncDelay(0).setClusterId(clusterId)
.getNodeStore();
- NodeDocument afterRootDoc = store.find(NODES, Utils.getIdFromPath(ROOT));
+ NodeDocument afterRootDoc = store.find(NODES, Utils.getIdFromPath(ROOT, store.getMetadata()));
assertNotNull(afterRootDoc);
Revision afterLastRev = afterRootDoc.getLastRev().get(clusterId);
@@ -812,7 +812,7 @@ public class DocumentNodeStoreTest {
builder1 = store.getRoot().builder();
NodeBuilder node = builder1.getChildNode("test").child("node");
- String id = Utils.getIdFromPath("/test/node");
+ String id = Utils.getIdFromPath("/test/node", docStore.getMetadata());
int i = 0;
// force creation of a branch
while (docStore.find(NODES, id) == null) {
@@ -853,7 +853,7 @@ public class DocumentNodeStoreTest {
builder = store1.getRoot().builder();
NodeBuilder node = builder.getChildNode("test").child("node");
- String id = Utils.getIdFromPath("/test/node");
+ String id = Utils.getIdFromPath("/test/node", docStore.getMetadata());
int i = 0;
// force creation of a branch
while (docStore.find(NODES, id) == null) {
@@ -927,7 +927,7 @@ public class DocumentNodeStoreTest {
DocumentNodeStore ns = builderProvider.newBuilder()
.setDocumentStore(store).setAsyncDelay(0).getNodeStore();
NodeBuilder builder = ns.getRoot().builder();
- String testId = Utils.getIdFromPath("/test");
+ String testId = Utils.getIdFromPath("/test", store.getMetadata());
NodeBuilder test = builder.child("test");
test.setProperty("p", "value");
test.setProperty("q", 0);
@@ -946,7 +946,7 @@ public class DocumentNodeStoreTest {
// trigger split
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
assertNotNull(doc);
readSet.clear();
@@ -1056,7 +1056,7 @@ public class DocumentNodeStoreTest {
RevisionVector removedAt = store.getHeadRevision();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", docStore.getMetadata());
int count = 0;
// update node until we have at least two levels of split documents
while (docStore.find(NODES, id).getPreviousRanges().size() <= PREV_SPLIT_FACTOR) {
@@ -1342,7 +1342,7 @@ public class DocumentNodeStoreTest {
}
String parentPath = "/:hidden/parent";
- NodeDocument parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath));
+ NodeDocument parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath, docStore.getMetadata()));
assertFalse("parent node of unseen children must not get deleted",
isDocDeleted(parentDoc, store1));
@@ -1360,7 +1360,7 @@ public class DocumentNodeStoreTest {
//this merge should fail -- but our real check is done by asserting that parent remains intact
}
- parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath));
+ parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath, docStore.getMetadata()));
assertFalse("parent node of unseen children must not get deleted",
isDocDeleted(parentDoc, store1));
@@ -1394,7 +1394,7 @@ public class DocumentNodeStoreTest {
}
parentPath = "/:hidden/parent1";
- parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath));
+ parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath, docStore.getMetadata()));
assertFalse("parent node of unseen children must not get deleted",
isDocDeleted(parentDoc, store1));
@@ -1411,7 +1411,7 @@ public class DocumentNodeStoreTest {
//this merge should fail -- but our real check is done by asserting that parent remains intact
}
- parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath));
+ parentDoc = docStore.find(Collection.NODES, Utils.getIdFromPath(parentPath, docStore.getMetadata()));
assertFalse("parent node of unseen children must not get deleted",
isDocDeleted(parentDoc, store1));
}
@@ -2685,7 +2685,7 @@ public class DocumentNodeStoreTest {
DocumentNodeStore ns = builderProvider.newBuilder()
.setDocumentStore(store).setAsyncDelay(0).getNodeStore();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
NodeBuilder b = ns.getRoot().builder();
b.child("test").setProperty("p", "a");
merge(ns, b);
@@ -3016,7 +3016,7 @@ public class DocumentNodeStoreTest {
builder = ns1.getRoot().builder();
builder.child("node-1").child("bar");
merge(ns1, builder);
- assertFalse(finds.contains(Utils.getIdFromPath("/node-1/bar")));
+ assertFalse(finds.contains(Utils.getIdFromPath("/node-1/bar", store.getMetadata())));
}
// OAK-5149
@@ -3202,7 +3202,7 @@ public class DocumentNodeStoreTest {
}
// check updates are consecutive
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/a/b"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/a/b", store.getMetadata()));
assertNotNull(doc);
long previousValue = -1;
List<String> values = Lists.newArrayList(doc.getLocalMap("p").values());
@@ -3249,7 +3249,7 @@ public class DocumentNodeStoreTest {
builder.child("foo").setProperty("p-" + i, "value");
}
// must have created a branch commit
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
}
@@ -3271,7 +3271,7 @@ public class DocumentNodeStoreTest {
FormatVersion.V1_0.writeTo(store);
// initialize store with root node
Revision r = Revision.newRevision(1);
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", store.getMetadata()), true);
NodeDocument.setModified(op, r);
NodeDocument.setDeleted(op, r, false);
NodeDocument.setRevision(op, r, "c");
@@ -3641,7 +3641,7 @@ public class DocumentNodeStoreTest {
builder = ns.getRoot().builder();
NodeBuilder test = builder.child("test");
- String firstChildId = Utils.getIdFromPath("/test/child-0");
+ String firstChildId = Utils.getIdFromPath("/test/child-0", docStore.getMetadata());
for (int i = 0; ; i++) {
NodeBuilder child = test.child("child-" + i);
for (int j = 0; j < 10; j++) {
@@ -3692,7 +3692,7 @@ public class DocumentNodeStoreTest {
NodeBuilder builder = ns.getRoot().builder();
NodeBuilder test = builder.child("test");
- String testId = Utils.getIdFromPath("/test");
+ String testId = Utils.getIdFromPath("/test", docStore.getMetadata());
for (int i = 0; ; i++) {
NodeBuilder child = test.child("child-" + i);
for (int j = 0; j < 10; j++) {
@@ -3737,7 +3737,7 @@ public class DocumentNodeStoreTest {
builder = ns.getRoot().builder();
NodeBuilder test = builder.child("test");
- String firstChildId = Utils.getIdFromPath("/test/child-0");
+ String firstChildId = Utils.getIdFromPath("/test/child-0", docStore.getMetadata());
for (int i = 0; ; i++) {
NodeBuilder child = test.child("child-" + i);
for (int j = 0; j < 10; j++) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
index 581111e3dc..0da026607b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java
@@ -16,19 +16,10 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterators;
+import com.google.common.collect.*;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
@@ -47,10 +38,6 @@ import org.apache.jackrabbit.oak.stats.Clock;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
import static com.google.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
import static org.apache.jackrabbit.oak.plugins.document.MongoBlobGCTest.randomStream;
@@ -86,7 +73,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
DocumentStore store = mk.getDocumentStore();
DocumentNodeStore ns = mk.getNodeStore();
Set<Revision> revisions = Sets.newHashSet();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/", store.getMetadata()));
assertNotNull(doc);
revisions.addAll(doc.getLocalRevisions().keySet());
revisions.add(Revision.fromString(mk.commit("/", "+\"foo\":{}+\"bar\":{}", null, null)));
@@ -97,7 +84,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
mk.runBackgroundOperations();
String head = mk.getHeadRevision();
- doc = store.find(NODES, Utils.getIdFromPath("/"));
+ doc = store.find(NODES, Utils.getIdFromPath("/", store.getMetadata()));
assertNotNull(doc);
Map<Revision, String> revs = doc.getLocalRevisions();
// one remaining in the local revisions map
@@ -123,7 +110,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
DocumentNodeStore ns = mk.getNodeStore();
Set<Revision> revisions = Sets.newHashSet();
mk.commit("/", "+\"foo\":{}", null, null);
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
revisions.addAll(doc.getLocalRevisions().keySet());
boolean create = false;
@@ -137,7 +124,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
mk.runBackgroundOperations();
String head = mk.getHeadRevision();
- doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
Map<Revision, String> deleted = doc.getLocalDeleted();
// one remaining in the local deleted map
@@ -161,7 +148,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
DocumentStore store = mk.getDocumentStore();
DocumentNodeStore ns = mk.getNodeStore();
mk.commit("/", "+\"foo\":{}+\"bar\":{}", null, null);
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
Set<Revision> commitRoots = Sets.newHashSet();
commitRoots.addAll(doc.getLocalCommitRoot().keySet());
@@ -171,7 +158,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
commitRoots.size() + "^\"bar/prop\":" + commitRoots.size(), null, null)));
}
mk.runBackgroundOperations();
- doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
Map<Revision, String> commits = doc.getLocalCommitRoot();
// two remaining in the local commit root map
@@ -188,7 +175,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
DocumentStore store = mk.getDocumentStore();
DocumentNodeStore ns = mk.getNodeStore();
mk.commit("/", "+\"foo\":{}", null, null);
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
Set<Revision> revisions = Sets.newHashSet();
// create nodes
@@ -197,7 +184,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
revisions.size(), null, null)));
}
mk.runBackgroundOperations();
- doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
Map<Revision, String> localRevs = doc.getLocalRevisions();
// one remaining in the local revisions map
@@ -244,7 +231,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
mk2.runBackgroundOperations();
mk3.runBackgroundOperations();
- NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test", ds.getMetadata()));
assertNotNull(doc);
Map<Revision, String> revs = doc.getLocalRevisions();
assertEquals(3, revs.size());
@@ -302,7 +289,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
}
// read current value
- NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test", ds.getMetadata()));
assertNotNull(doc);
RevisionVector head = ns.getHeadRevision();
Revision lastRev = ns.getPendingModifications().get(Path.fromString("/test"));
@@ -330,14 +317,14 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
mk.commit("/", "+\"test\":{\"node\":{}}", null, null);
mk.commit("/test", "+\"foo\":{}+\"bar\":{}", null, null);
mk.commit("/test", "^\"foo/prop\":0^\"bar/prop\":0", null, null);
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo", store.getMetadata()));
assertNotNull(doc);
String rev = null;
for (int i = 0; i < NodeDocument.NUM_REVS_THRESHOLD; i++) {
rev = mk.commit("/test/foo", "^\"prop\":" + i, null, null);
}
ns.runBackgroundOperations();
- doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ doc = store.find(NODES, Utils.getIdFromPath("/test/foo", store.getMetadata()));
assertNotNull(doc);
DocumentNodeState node = doc.getNodeAtRevision(ns,
RevisionVector.fromString(rev), null);
@@ -354,7 +341,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
mk.commit("/test/foo", "^\"prop\":" + i, null, null);
}
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo", store.getMetadata()));
List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.DEFAULT_LEAF, prevDocs.get(0).getSplitDocType());
@@ -377,7 +364,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo", store.getMetadata()));
List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.COMMIT_ROOT_ONLY, prevDocs.get(0).getSplitDocType());
@@ -399,7 +386,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo", store.getMetadata()));
List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
@@ -417,7 +404,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
@Test
public void cascadingSplitLongPath() {
Path p = Path.ROOT;
- while (!Utils.isLongPath(p)) {
+ while (!Utils.isLongPath(p, Collections.emptyMap())) {
p = new Path(p, "long-path-element");
}
cascadingSplit(p.toString());
@@ -439,7 +426,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
List<String> revs = Lists.newArrayList();
for (int i = 0; i < NodeDocument.PREV_SPLIT_FACTOR + 1; i++) {
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(path));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(path, store.getMetadata()));
assertNotNull(doc);
assertEquals(i, doc.getPreviousRanges().size());
for (int j = 0; j < NodeDocument.NUM_REVS_THRESHOLD; j++) {
@@ -449,7 +436,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
ns.runBackgroundOperations();
}
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath(path));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath(path, store.getMetadata()));
assertNotNull(doc);
assertEquals(2, doc.getPreviousRanges().size());
@@ -506,7 +493,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
Path path = Path.fromString(p);
DocumentStore store = mk.getDocumentStore();
NodeDocument doc = new NodeDocument(store);
- String id = Utils.getPreviousIdFor(path, r, 0);
+ String id = Utils.getPreviousIdFor(path, r, 0, store.getMetadata());
doc.put(NodeDocument.ID, id);
assertEquals(path, doc.getMainPath());
}
@@ -515,9 +502,9 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
// OAK-1692
@Test
public void cascadingWithSplitRatio() {
- String id = Utils.getIdFromPath("/test");
mk.commit("/", "+\"test\":{}", null, null);
DocumentStore store = mk.getDocumentStore();
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
int clusterId = mk.getNodeStore().getClusterId();
UpdateOp op = new UpdateOp(id, false);
@@ -551,7 +538,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
assertEquals(2, splitOps.size());
// first update op is for the new intermediate doc
op = splitOps.get(0);
- String newPrevId = Utils.getPreviousIdFor(Path.fromString("/test"), prev.last(), 1);
+ String newPrevId = Utils.getPreviousIdFor(Path.fromString("/test"), prev.last(), 1, store.getMetadata());
assertEquals(newPrevId, op.getId());
// second update op is for the main document
op = splitOps.get(1);
@@ -564,7 +551,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
if (entry.getValue().type == REMOVE_MAP_ENTRY) {
assertTrue(prev.contains(r));
} else if (entry.getValue().type == SET_MAP_ENTRY) {
- assertEquals(newPrevId, Utils.getPreviousIdFor(Path.fromString("/test"), r, 1));
+ assertEquals(newPrevId, Utils.getPreviousIdFor(Path.fromString("/test"), r, 1, store.getMetadata()));
} else {
fail("unexpected update operation " + entry);
}
@@ -578,9 +565,9 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
@Test
public void splitRevisionsManyClusterNodes() {
int numClusterNodes = 5;
- String id = Utils.getIdFromPath("/test");
mk.commit("/", "+\"test\":{}", null, null);
DocumentStore store = mk.getDocumentStore();
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
int clusterId = mk.getNodeStore().getClusterId();
List<Revision> revs = Lists.newArrayList();
@@ -606,7 +593,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
mk.getNodeStore(), mk.getNodeStore().getHeadRevision(),
NO_BINARY));
assertEquals(2, splitOps.size());
- String prevId = Utils.getPreviousIdFor(Path.fromString("/test"), revs.get(revs.size() - 2), 0);
+ String prevId = Utils.getPreviousIdFor(Path.fromString("/test"), revs.get(revs.size() - 2), 0, store.getMetadata());
assertEquals(prevId, splitOps.get(0).getId());
assertEquals(id, splitOps.get(1).getId());
}
@@ -626,7 +613,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
mk.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/", store.getMetadata()));
assertNotNull(doc);
// the local _revisions map must still contain the entry for
// the initial 'bar' property
@@ -660,7 +647,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
mk.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
assertNotNull(doc);
// the local _commitRoot map must still contain the entry for
// the initial 'bar' property
@@ -678,7 +665,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
@Test(expected = IllegalArgumentException.class)
public void splitPreviousDocument() {
NodeDocument doc = new NodeDocument(mk.getDocumentStore());
- doc.put(NodeDocument.ID, Utils.getIdFromPath("/test"));
+ doc.put(NodeDocument.ID, Utils.getIdFromPath("/test", mk.getDocumentStore().getMetadata()));
doc.put(NodeDocument.SD_TYPE, NodeDocument.SplitDocType.DEFAULT.type);
RevisionVector head = mk.getNodeStore().getHeadRevision();
SplitOperations.forDocument(doc, DummyRevisionContext.INSTANCE, head,
@@ -715,7 +702,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
assertNotNull(doc);
readSet.clear();
@@ -747,7 +734,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
assertNotNull(doc);
assertTrue(doc.getLocalCommitRoot().size() < NUM_REVS_THRESHOLD);
}
@@ -810,7 +797,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
merge(ns1, builder1);
}
// create a _commitRoot entry for a revision, which is not committed
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/test"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/test", store.getMetadata()), false);
NodeDocument.setCommitRoot(op, ns1.newRevision(), 0);
store.findAndUpdate(NODES, op);
@@ -921,7 +908,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
}
- NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
// all but most recent value are moved to individual previous docs
@@ -944,7 +931,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
// must not create split document in this case. See OAK-5010
- NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
assertEquals(0, foo.getPreviousRanges().size());
@@ -955,7 +942,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
// now the old binary value must be moved to a previous document
- foo = store.find(NODES, Utils.getIdFromPath("/foo"));
+ foo = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
@@ -978,7 +965,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
ns.runBackgroundOperations();
}
- NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNotNull(foo);
List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
// must not create split documents for small binaries less 4k
@@ -993,7 +980,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
builder.child("foo");
merge(ns, builder);
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", store.getMetadata());
int num = 0;
while (store.find(NODES, id).getMemory() < DOC_SIZE_THRESHOLD) {
builder = ns.getRoot().builder();
@@ -1021,7 +1008,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
branch = mk.commit("/foo", "^\"p\":\"value\"", branch, null);
mk.merge(branch, null);
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
assertThat(doc.getLocalBranchCommits(), is(not(empty())));
@@ -1059,7 +1046,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
merge(ns, builder);
}
ns.runBackgroundOperations();
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
for (UpdateOp op : SplitOperations.forDocument(doc, ns, ns.getHeadRevision(), NO_BINARY, 5)) {
@@ -1081,7 +1068,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
builder.child("foo");
merge(ns, builder);
// sneak in split candidate
- ns.addSplitCandidate(Utils.getIdFromPath("/foo"));
+ ns.addSplitCandidate(Utils.getIdFromPath("/foo", mk.getDocumentStore().getMetadata()));
ns.runBackgroundOperations();
assertThat(ns.getSplitCandidates(), empty());
}
@@ -1093,7 +1080,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
builder.child("foo");
merge(ns, builder);
// sneak in unknown split candidate
- ns.addSplitCandidate(Utils.getIdFromPath("/bar"));
+ ns.addSplitCandidate(Utils.getIdFromPath("/bar", ns.getDocumentStore().getMetadata()));
ns.runBackgroundOperations();
assertThat(ns.getSplitCandidates(), empty());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalDiffLoaderTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalDiffLoaderTest.java
index 6ee8e127b6..46a0315a86 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalDiffLoaderTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalDiffLoaderTest.java
@@ -329,7 +329,7 @@ public class JournalDiffLoaderTest {
.clock(clock).setAsyncDelay(0).disableBranches().getNodeStore();
DocumentStore store = ns.getDocumentStore();
DocumentNodeState before = ns.getRoot();
- String id = Utils.getIdFromPath("/node-0");
+ String id = Utils.getIdFromPath("/node-0", store.getMetadata());
NodeBuilder builder = ns.getRoot().builder();
int i = 0;
while (store.find(Collection.NODES, id) == null) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalGCTest.java
index 6bf223637d..f96cd58b02 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/JournalGCTest.java
@@ -129,7 +129,7 @@ public class JournalGCTest {
NodeBuilder builder = ns.getRoot().builder();
NodeBuilder test = builder.child("test");
- String testId = Utils.getIdFromPath("/test");
+ String testId = Utils.getIdFromPath("/test", docStore.getMetadata());
for (int i = 0; ; i++) {
NodeBuilder child = test.child("child-" + i);
for (int j = 0; j < 10; j++) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LargeMergeRecoveryTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LargeMergeRecoveryTest.java
index f08d025f9f..94b1d3b3f1 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LargeMergeRecoveryTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LargeMergeRecoveryTest.java
@@ -47,7 +47,7 @@ public class LargeMergeRecoveryTest extends AbstractTwoNodeTest {
private static NodeDocument getDocument(DocumentNodeStore nodeStore,
String path) {
- return nodeStore.getDocumentStore().find(NODES, getIdFromPath(path));
+ return nodeStore.getDocumentStore().find(NODES, getIdFromPath(path, nodeStore.getDocumentStore().getMetadata()));
}
@Parameterized.Parameters(name = "{0}")
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
index 20a4f893cb..1c7f4970fd 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
@@ -254,7 +254,7 @@ public class LastRevRecoveryAgentTest extends AbstractTwoNodeTest {
private static NodeDocument getDocument(DocumentNodeStore nodeStore,
String path) {
- return nodeStore.getDocumentStore().find(NODES, getIdFromPath(path));
+ return nodeStore.getDocumentStore().find(NODES, getIdFromPath(path, nodeStore.getDocumentStore().getMetadata()));
}
private static void merge(DocumentNodeStore store, NodeBuilder builder)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryTest.java
index 6f43635d5c..a042ee5ba3 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryTest.java
@@ -315,7 +315,7 @@ public class LastRevRecoveryTest {
sharedStore.create(CLUSTER_NODES, newArrayList(updateOpFromDocument(info1)));
// remove the sweep revision as well
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", sharedStore.getMetadata()), false);
op.removeMapEntry("_sweepRev", new Revision(0, 0, c1Id));
assertNotNull(sharedStore.findAndUpdate(NODES, op));
NodeDocument doc = getRootDocument(sharedStore);
@@ -404,7 +404,7 @@ public class LastRevRecoveryTest {
}
private NodeDocument getDocument(DocumentNodeStore nodeStore, String path) {
- return nodeStore.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
+ return nodeStore.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path, nodeStore.getDocumentStore().getMetadata()));
}
private static void merge(NodeStore store, NodeBuilder builder)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryWithBundledNodesTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryWithBundledNodesTest.java
index 4acb01a569..f18e837fae 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryWithBundledNodesTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryWithBundledNodesTest.java
@@ -103,7 +103,7 @@ public class LastRevRecoveryWithBundledNodesTest {
merge(ns, builder);
ns.runBackgroundOperations();
- String id = Utils.getIdFromPath(Path.fromString("/file/" + JCR_CONTENT));
+ String id = Utils.getIdFromPath(Path.fromString("/file/" + JCR_CONTENT), store.getMetadata());
store.remove(Collection.NODES, id);
log.starting();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevTest.java
index 631ae42050..3e88829cda 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevTest.java
@@ -61,7 +61,7 @@ public class LastRevTest {
private static void assertLastRevSize(DocumentStore store,
String path, int size) {
- NodeDocument doc = store.find(NODES, getIdFromPath(path));
+ NodeDocument doc = store.find(NODES, getIdFromPath(path, store.getMetadata()));
assertNotNull(doc);
assertEquals("_lastRev: " + doc.getLastRev(), size, doc.getLastRev().size());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java
index 7ee4c0d23e..c89d990f75 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java
@@ -63,7 +63,7 @@ public class ManyClusterNodesTest {
@Test
public void manyMultiValuedPropertyChanges() throws Exception {
String value = "some-long-value-that-will-bloat-the-document";
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", ds.getMetadata());
for (int i = 0; i < 1000; i++) {
DocumentNodeStore ns = stores.get(i % NUM_CLUSTER_NODES);
ns.runBackgroundOperations();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreIT.java
index 4eafd4feb5..64e7b5a268 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreIT.java
@@ -47,8 +47,8 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
public void concurrent() throws Exception {
final long time = System.currentTimeMillis();
mk.commit("/", "+\"test\":{}", null, null);
- final String id = Utils.getIdFromPath("/test");
final DocumentStore docStore = mk.getDocumentStore();
+ final String id = Utils.getIdFromPath("/test", docStore.getMetadata());
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < NUM_THREADS; i++) {
final int tId = i;
@@ -131,8 +131,8 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
@Test
public void negativeCache() throws Exception {
- String id = Utils.getIdFromPath("/test");
DocumentStore docStore = mk.getDocumentStore();
+ String id = Utils.getIdFromPath("/test", docStore.getMetadata());
assertNull(docStore.find(NODES, id));
mk.commit("/", "+\"test\":{}", null, null);
assertNotNull(docStore.find(NODES, id));
@@ -146,7 +146,7 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
// make sure _lastRev is persisted and _modCount updated accordingly
mk.runBackgroundOperations();
- NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/test", docStore.getMetadata()));
assertNotNull(doc);
Long mc1 = doc.getModCount();
assertNotNull(mc1);
@@ -156,7 +156,7 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
} catch (DocumentStoreException e) {
// expected
}
- doc = docStore.find(NODES, Utils.getIdFromPath("/test"));
+ doc = docStore.find(NODES, Utils.getIdFromPath("/test", docStore.getMetadata()));
assertNotNull(doc);
Long mc2 = doc.getModCount();
assertNotNull(mc2);
@@ -167,7 +167,7 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
@Test
public void create() throws Exception {
DocumentStore store = mk.getDocumentStore();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
UpdateOp updateOp = new UpdateOp(id, true);
Revision r1 = Revision.newRevision(1);
updateOp.setMapEntry("p", r1, "a");
@@ -188,7 +188,7 @@ public class MongoDocumentStoreIT extends AbstractMongoConnectionTest {
@Test
public void createWithNull() throws Exception {
DocumentStore store = mk.getDocumentStore();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
UpdateOp updateOp = new UpdateOp(id, true);
Revision r1 = Revision.newRevision(1);
updateOp.setMapEntry("p", r1, "a");
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
index 2c6b7719b8..f8e1332634 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
@@ -57,7 +57,7 @@ public class MongoDocumentStoreLimitsTest extends AbstractMongoConnectionTest {
// check that the document was created
// when no exception was thrown
- String id = Utils.getIdFromPath(longPath);
+ String id = Utils.getIdFromPath(longPath, ns.getDocumentStore().getMetadata());
NodeDocument doc = ns.getDocumentStore().find(Collection.NODES, id, 0);
assertNotNull(doc);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreTest.java
index 5d95a805dd..8dbeb8da5c 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreTest.java
@@ -235,7 +235,7 @@ public class MongoDocumentStoreTest {
}
docStore.create(Collection.NODES, inserts);
List<NodeDocument> docs = docStore.query(Collection.NODES,
- Utils.getKeyLowerLimit(Path.ROOT), Utils.getKeyUpperLimit(Path.ROOT),
+ Utils.getKeyLowerLimit(Path.ROOT, docStore.getMetadata()), Utils.getKeyUpperLimit(Path.ROOT, docStore.getMetadata()),
DocumentMK.MANY_CHILDREN_THRESHOLD);
assertEquals(DocumentMK.MANY_CHILDREN_THRESHOLD, docs.size());
store.dispose();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MultiDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MultiDocumentStoreTest.java
index 5cf2ae39ea..5254dffaa1 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MultiDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MultiDocumentStoreTest.java
@@ -114,7 +114,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
final CountDownLatch go = new CountDownLatch(1);
final List<String> ids = Lists.newArrayList();
for (int i = 0; i < 100; i++) {
- ids.add(Utils.getIdFromPath("/node-" + i));
+ ids.add(Utils.getIdFromPath("/node-" + i,ds1.getMetadata() ));
}
removeMe.addAll(ids);
@@ -194,7 +194,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
@Test
public void batchUpdateCachedDocument() throws Exception {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", ds1.getMetadata());
removeMe.add(id);
UpdateOp op = new UpdateOp(id, true);
@@ -217,7 +217,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
for (int i = 0; i < 10; i++) {
// add more ops to make sure a batch
// update call is triggered
- String docId = Utils.getIdFromPath("/node-" + i);
+ String docId = Utils.getIdFromPath("/node-" + i, ds1.getMetadata());
UpdateOp update = new UpdateOp(docId, true);
update.set("_ds2", 1);
removeMe.add(docId);
@@ -236,7 +236,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
@Test
public void testUpdateRemovedNode() {
- String id = Utils.getIdFromPath("testUpdateRemovedNode");
+ String id = Utils.getIdFromPath("testUpdateRemovedNode", ds1.getMetadata());
removeMe.add(id);
UpdateOp op = new UpdateOp(id, true);
@@ -267,7 +267,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
@Test
public void testUpdateOrCreateDeletedDocument() {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", ds1.getMetadata());
removeMe.add(id);
UpdateOp op1 = new UpdateOp(id, true);
@@ -292,7 +292,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
@Test
public void testUpdateNoCreateDeletedDocument() {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", ds1.getMetadata());
removeMe.add(id);
UpdateOp op1 = new UpdateOp(id, true);
@@ -381,7 +381,7 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
List<UpdateOp> ops = new ArrayList<>();
for (int i = 0; i < count; i++) {
- UpdateOp op = new UpdateOp(getIdFromPath("/bulktracelog-" + i), true);
+ UpdateOp op = new UpdateOp(getIdFromPath("/bulktracelog-" + i, ds.getMetadata()), true);
ops.add(op);
removeMe.add(op.getId());
}
@@ -398,17 +398,17 @@ public class MultiDocumentStoreTest extends AbstractMultiDocumentStoreTest {
ops.clear();
// modify first entry through secondary store
- String modifiedRow = getIdFromPath("/bulktracelog-" + 0);
+ String modifiedRow = getIdFromPath("/bulktracelog-" + 0, ds2.getMetadata());
UpdateOp op2 = new UpdateOp(modifiedRow, false);
op2.set("foo", "bar");
ds2.createOrUpdate(NODES, op2);
// delete second entry through secondary store
- String deletedRow = getIdFromPath("/bulktracelog-" + 1);
+ String deletedRow = getIdFromPath("/bulktracelog-" + 1, ds2.getMetadata());
ds2.remove(NODES, deletedRow);
for (int i = 0; i < count; i++) {
- UpdateOp op = new UpdateOp(getIdFromPath("/bulktracelog-" + i), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/bulktracelog-" + i, ds.getMetadata()), false);
op.set("foo", "qux");
ops.add(op);
removeMe.add(op.getId());
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentIdComparatorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentIdComparatorTest.java
index 3e2b59eb7e..69325fe68a 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentIdComparatorTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentIdComparatorTest.java
@@ -37,11 +37,11 @@ public class NodeDocumentIdComparatorTest {
@Test
public void sort() {
List<String> paths = new ArrayList<String>();
- paths.add(Utils.getIdFromPath("/foo"));
- paths.add(Utils.getIdFromPath("/foo/bar"));
- paths.add(Utils.getIdFromPath("/bar/qux"));
- paths.add(Utils.getIdFromPath("/"));
- paths.add(Utils.getIdFromPath("/bar"));
+ paths.add(Utils.getIdFromPath("/foo", Collections.emptyMap()));
+ paths.add(Utils.getIdFromPath("/foo/bar", Collections.emptyMap()));
+ paths.add(Utils.getIdFromPath("/bar/qux", Collections.emptyMap()));
+ paths.add(Utils.getIdFromPath("/", Collections.emptyMap()));
+ paths.add(Utils.getIdFromPath("/bar", Collections.emptyMap()));
Collections.sort(paths, NodeDocumentIdComparator.INSTANCE);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperTest.java
index 0601513bfe..4f39e669af 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentSweeperTest.java
@@ -78,7 +78,7 @@ public class NodeDocumentSweeperTest {
merge(ns, b);
ns.runBackgroundUpdateOperations();
- UpdateOp op = new UpdateOp(getIdFromPath("/test"), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/test", store.getMetadata()), false);
op.setMapEntry("foo", uncommitted, "value");
setCommitRoot(op, uncommitted, 0);
setModified(op, uncommitted);
@@ -108,7 +108,7 @@ public class NodeDocumentSweeperTest {
ns.runBackgroundUpdateOperations();
Revision uncommitted = ns.newRevision();
- UpdateOp op = new UpdateOp(getIdFromPath("/test"), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/test", store.getMetadata()), false);
op.setMapEntry("foo", uncommitted, "value");
setCommitRoot(op, uncommitted, 0);
setModified(op, uncommitted);
@@ -169,7 +169,7 @@ public class NodeDocumentSweeperTest {
ns.runBackgroundUpdateOperations();
// simulate a pre 1.8 branch commit by removing the branch commit entry
- NodeDocument doc = store.find(NODES, getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, getIdFromPath("/foo", store.getMetadata()));
assertNotNull(doc);
assertEquals(1, doc.getLocalBranchCommits().size());
UpdateOp op = new UpdateOp(doc.getId(), false);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java
index 7edb026d3c..993d187081 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java
@@ -332,7 +332,7 @@ public class NodeDocumentTest {
if (Math.random() < 0.2) {
RevisionVector head = ns.getHeadRevision();
NodeDocument doc = ns.getDocumentStore().find(
- NODES, Utils.getIdFromPath("/test"));
+ NODES, Utils.getIdFromPath("/test", store.getMetadata()));
for (UpdateOp op : SplitOperations.forDocument(
doc, ns, head, NO_BINARY, 2)) {
store.createOrUpdate(NODES, op);
@@ -340,7 +340,7 @@ public class NodeDocumentTest {
}
}
NodeDocument doc = ns.getDocumentStore().find(
- NODES, Utils.getIdFromPath("/test"));
+ NODES, Utils.getIdFromPath("/test", store.getMetadata()));
// get most recent previous doc
NodeDocument prev = doc.getAllPreviousDocs().next();
// simulate a change revision within the range of
@@ -371,7 +371,7 @@ public class NodeDocumentTest {
RevisionVector headCreated = ns1.getHeadRevision();
Revision created = headCreated.getRevision(ns1.getClusterId());
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
Set<Revision> collisions = newHashSet();
Revision newest = doc.getNewestRevision(ns1, ns1.getHeadRevision(),
ns1.newRevision(), null, collisions);
@@ -390,21 +390,21 @@ public class NodeDocumentTest {
collisions.clear();
// now ns2 sees /test
- doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
newest = doc.getNewestRevision(ns2, ns2.getHeadRevision(),
ns2.newRevision(), null, collisions);
assertEquals(created, newest);
assertEquals(0, collisions.size());
Revision uncommitted = ns1.newRevision();
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/test"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/test", store.getMetadata()), false);
NodeDocument.setCommitRoot(op, uncommitted, 0);
op.setMapEntry("p", uncommitted, "v");
assertNotNull(store.findAndUpdate(NODES, op));
collisions.clear();
// ns1 must report uncommitted in collisions
- doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
newest = doc.getNewestRevision(ns1, ns1.getHeadRevision(),
ns1.newRevision(), null, collisions);
assertEquals(created, newest);
@@ -428,7 +428,7 @@ public class NodeDocumentTest {
// ns1 must now report committed revision as newest
// uncommitted is not considered a collision anymore
// because it is older than the base revision
- doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
newest = doc.getNewestRevision(ns1, headCreated,
ns1.newRevision(), null, collisions);
assertEquals(committed, newest);
@@ -458,7 +458,7 @@ public class NodeDocumentTest {
merge(ns, builder);
Set<Revision> collisions = newHashSet();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
RevisionVector branchBase = ns.getHeadRevision().asBranchRevision(ns.getClusterId());
try {
doc.getNewestRevision(ns, branchBase, ns.newRevision(), null, collisions);
@@ -504,7 +504,7 @@ public class NodeDocumentTest {
// start fresh
DocumentNodeStore ns = createTestStore(store, 1, 0, 0);
- String id = Utils.getIdFromPath(Path.fromString("/bar/test"));
+ String id = Utils.getIdFromPath(Path.fromString("/bar/test"), store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
@@ -524,7 +524,7 @@ public class NodeDocumentTest {
// start fresh
DocumentNodeStore ns = createTestStore(store, 1, 0, 0);
- String id = Utils.getIdFromPath(Path.fromString("/bar/test"));
+ String id = Utils.getIdFromPath(Path.fromString("/bar/test"), store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
@@ -557,7 +557,7 @@ public class NodeDocumentTest {
merge(ns, builder);
}
ns.runBackgroundOperations();
- String rootId = Utils.getIdFromPath(Path.ROOT);
+ String rootId = Utils.getIdFromPath(Path.ROOT, store.getMetadata());
NodeDocument rootDoc = store.find(NODES, rootId);
assertNotNull(rootDoc);
assertThat(rootDoc.getPreviousRanges().keySet(), not(empty()));
@@ -636,7 +636,7 @@ public class NodeDocumentTest {
assertEquals(200, valueMap.size());
RevisionVector baseRev = new RevisionVector(valueMap.keySet().iterator().next());
Revision commitRev = ns.newRevision();
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), false);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", store.getMetadata()), false);
op.setMapEntry("p", commitRev, "v");
prevDocCalls.clear();
@@ -677,7 +677,7 @@ public class NodeDocumentTest {
b2.child("test").setProperty("ns2", i);
merge(ns2, b2);
}
- String testId = Utils.getIdFromPath("/test");
+ String testId = Utils.getIdFromPath("/test", store.getMetadata());
NodeDocument test = ns2.getDocumentStore().find(NODES, testId);
assertNotNull(test);
List<UpdateOp> ops = SplitOperations.forDocument(test, ns2,
@@ -899,7 +899,7 @@ public class NodeDocumentTest {
if (i % 3 == 0) {
// split the document
RevisionVector head = ns.getHeadRevision();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
for (UpdateOp op : SplitOperations.forDocument(
doc, ns, head, NO_BINARY, 2)) {
store.createOrUpdate(NODES, op);
@@ -908,7 +908,7 @@ public class NodeDocumentTest {
}
ns.runBackgroundOperations();
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test", store.getMetadata()));
assertNotNull(doc);
List<Integer> numCalls = Lists.newArrayList();
// go back in time and check number of find calls
@@ -979,7 +979,7 @@ public class NodeDocumentTest {
setProperty(ns, "/test/q", 1);
setProperty(ns, "/test/q", 2);
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
List<UpdateOp> splitOps = SplitOperations.forDocument(
@@ -1055,7 +1055,7 @@ public class NodeDocumentTest {
createTestData(singletonList(ns), new Random(), 200);
ns.runBackgroundUpdateOperations();
- NodeDocument doc = ds.find(NODES, getIdFromPath("/foo"));
+ NodeDocument doc = ds.find(NODES, getIdFromPath("/foo", ds.getMetadata()));
assertNotNull(doc);
findCalls.clear();
doc.getNodeAtRevision(ns, ns.getHeadRevision(), null);
@@ -1067,7 +1067,7 @@ public class NodeDocumentTest {
ns.runBackgroundSweepOperation();
// now number of find calls must be zero
- doc = ds.find(NODES, getIdFromPath("/foo"));
+ doc = ds.find(NODES, getIdFromPath("/foo", ds.getMetadata()));
assertNotNull(doc);
findCalls.clear();
doc.getNodeAtRevision(ns, ns.getHeadRevision(), null);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OptimizedChildFetchTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OptimizedChildFetchTest.java
index 9e9053b03f..014e60939c 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OptimizedChildFetchTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OptimizedChildFetchTest.java
@@ -96,7 +96,7 @@ public class OptimizedChildFetchTest extends BaseDocumentMKTest {
}
private boolean hasChildren(String path) {
- NodeDocument nd = mk.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
+ NodeDocument nd = mk.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path, ds.getMetadata()));
return nd.hasChildren();
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
index 8371890d45..283c46b4f8 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
@@ -100,7 +100,7 @@ public class OrphanedBranchCleanupTest {
private void createOrphanedBranch(DocumentNodeStore ns) {
DocumentStore store = ns.getDocumentStore();
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
NodeBuilder builder = ns.getRoot().builder();
NodeBuilder test = builder.child("test");
for (int i = 0; store.find(NODES, id) == null; i++) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchTest.java
index 4b08e745ea..8b93f76122 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchTest.java
@@ -115,7 +115,7 @@ public class OrphanedBranchTest {
store.runBackgroundOperations();
// after background ops we must not see more collisions
// than active branches
- String id = Utils.getIdFromPath("/");
+ String id = Utils.getIdFromPath("/", store.getDocumentStore().getMetadata());
NodeDocument doc = store.getDocumentStore().find(NODES, id);
assertNotNull(doc);
Map<Revision, String> collisions = doc.getLocalMap(COLLISIONS);
@@ -125,7 +125,7 @@ public class OrphanedBranchTest {
// limit to check is number of branches considered active
// plus NodeDocument.NUM_REVS_THRESHOLD
int limit = numBranches + NodeDocument.NUM_REVS_THRESHOLD;
- id = Utils.getIdFromPath("/foo");
+ id = Utils.getIdFromPath("/foo", store.getDocumentStore().getMetadata());
doc = store.getDocumentStore().find(NODES, id);
assertNotNull(doc);
Map<Revision, String> map = doc.getLocalMap("prop");
@@ -158,7 +158,7 @@ public class OrphanedBranchTest {
// OAK-2442
@Test
public void removeUncommittedChange() throws Exception {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", store.getDocumentStore().getMetadata());
NodeBuilder builder = store.getRoot().builder();
builder.child("foo");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
index cdfd1008a3..98c38bbb41 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
@@ -52,10 +52,10 @@ public class ResurrectNodeAfterRevisionGCTest
@Before
public void prepare() throws Exception {
- removeMe.add(getIdFromPath("/"));
- removeMe.add(getIdFromPath("/foo"));
- removeMe.add(getIdFromPath("/baz"));
- removeMe.add(getIdFromPath("/foo/bar"));
+ removeMe.add(getIdFromPath("/", ds.getMetadata()));
+ removeMe.add(getIdFromPath("/foo", ds.getMetadata()));
+ removeMe.add(getIdFromPath("/baz", ds.getMetadata()));
+ removeMe.add(getIdFromPath("/foo/bar", ds.getMetadata()));
for (String id : removeMe) {
ds.remove(Collection.NODES, id);
}
@@ -105,7 +105,7 @@ public class ResurrectNodeAfterRevisionGCTest
ns2.runBackgroundOperations();
assertFalse(ns2.getRoot().getChildNode("foo").exists());
- NodeDocument doc = ds2.find(Collection.NODES, getIdFromPath("/foo/bar"));
+ NodeDocument doc = ds2.find(Collection.NODES, getIdFromPath("/foo/bar", ds2.getMetadata()));
assertNotNull(doc);
NodeState state = doc.getNodeAtRevision(ns2, ns2.getHeadRevision(), null);
assertNull(state);
@@ -200,7 +200,7 @@ public class ResurrectNodeAfterRevisionGCTest
private void resurrectInvalidateWithModified(Invalidate inv)
throws Exception {
- UpdateOp op = new UpdateOp(getIdFromPath("/foo"), true);
+ UpdateOp op = new UpdateOp(getIdFromPath("/foo", ds1.getMetadata()), true);
op.set("p", 0);
op.set(NodeDocument.MODIFIED_IN_SECS, 50);
assertTrue(ds1.create(Collection.NODES, Lists.newArrayList(op)));
@@ -223,7 +223,7 @@ public class ResurrectNodeAfterRevisionGCTest
}
private void resurrectInvalidate(Invalidate inv) throws Exception {
- UpdateOp op = new UpdateOp(getIdFromPath("/foo"), true);
+ UpdateOp op = new UpdateOp(getIdFromPath("/foo", ds1.getMetadata()), true);
op.set("p", 0);
assertTrue(ds1.create(Collection.NODES, Lists.newArrayList(op)));
NodeDocument doc = ds2.find(Collection.NODES, op.getId());
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SimpleTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SimpleTest.java
index 40f5281492..4c33eedaa6 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SimpleTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SimpleTest.java
@@ -56,11 +56,11 @@ public class SimpleTest {
@Test
public void pathToId() {
- assertEquals("0:/", Utils.getIdFromPath("/"));
+ assertEquals("0:/", Utils.getIdFromPath("/", Collections.emptyMap()));
assertEquals("/", Utils.getPathFromId("0:/"));
- assertEquals("1:/test", Utils.getIdFromPath("/test"));
+ assertEquals("1:/test", Utils.getIdFromPath("/test", Collections.emptyMap()));
assertEquals("/test", Utils.getPathFromId("1:/test"));
- assertEquals("10:/1/2/3/3/4/6/7/8/9/a", Utils.getIdFromPath("/1/2/3/3/4/6/7/8/9/a"));
+ assertEquals("10:/1/2/3/3/4/6/7/8/9/a", Utils.getIdFromPath("/1/2/3/3/4/6/7/8/9/a", Collections.emptyMap()));
assertEquals("/1/2/3/3/4/6/7/8/9/a", Utils.getPathFromId("10:/1/2/3/3/4/6/7/8/9/a"));
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SplitOperationsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SplitOperationsTest.java
index 7bdd4b9faa..76ad5eafef 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SplitOperationsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SplitOperationsTest.java
@@ -22,6 +22,8 @@ import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.junit.Test;
+import java.util.Collections;
+
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
import static org.apache.jackrabbit.oak.plugins.document.TestUtils.NO_BINARY;
import static org.junit.Assert.assertEquals;
@@ -29,7 +31,7 @@ import static org.junit.Assert.assertNotNull;
public class SplitOperationsTest extends BaseDocumentMKTest {
- private static final String ROOT_ID = Utils.getIdFromPath("/");
+ private static final String ROOT_ID = Utils.getIdFromPath("/", Collections.emptyMap());
@Override
public void initDocumentMK() {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Test.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Test.java
index c762fcb120..4b89d29472 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Test.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Test.java
@@ -383,7 +383,7 @@ public class Sweep2Test {
// aging, and keep instance 2 running thereafter - it holds a fake sweep2 lock
DocumentNodeStore ns2 = Sweep2TestHelper.applyPre18Aging(store, withAsyncDelay(builderProvider, 0), 2);
// add clusterId 1 to the _sweepRev to make sure it gets included in any subsequent sweep2
- UpdateOp addSweepRev1 = new UpdateOp(Utils.getIdFromPath("/"), false);
+ UpdateOp addSweepRev1 = new UpdateOp(Utils.getIdFromPath("/", store.getMetadata()), false);
addSweepRev1.setMapEntry("_sweepRev", new Revision(0, 0, 1), new Revision(0, 0, 1).toString());
assertNotNull(store.findAndUpdate(Collection.NODES, addSweepRev1));
Sweep2TestHelper.removeSweep2Status(store, false);
@@ -669,7 +669,7 @@ public class Sweep2Test {
}
private boolean hasBcProperty(MemoryDocumentStore store, String path) {
- NodeDocument doc = store.find(Collection.NODES, Utils.getIdFromPath(path));
+ NodeDocument doc = store.find(Collection.NODES, Utils.getIdFromPath(path, store.getMetadata()));
if (doc == null) {
fail("could not find " + path);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2TestHelper.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2TestHelper.java
index f8cc03118c..2b24c22fad 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2TestHelper.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/Sweep2TestHelper.java
@@ -36,8 +36,6 @@ import org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.util.LeaseCheckDocumentStoreWrapper;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import junitx.util.PrivateAccessor;
@@ -199,7 +197,7 @@ public class Sweep2TestHelper {
assertNotNull(store.findAndUpdate(Collection.NODES, removeBc));
}
// B : remove "_sweepRev"
- UpdateOp removeSweepRev = new UpdateOp(Utils.getIdFromPath("/"), false);
+ UpdateOp removeSweepRev = new UpdateOp(Utils.getIdFromPath("/", store.getMetadata()), false);
removeSweepRev.remove("_sweepRev");
assertNotNull(store.findAndUpdate(Collection.NODES, removeSweepRev));
// C : remove the "sweep2Status" from the settings
@@ -230,7 +228,7 @@ public class Sweep2TestHelper {
static void removeSweep2Status(DocumentStore store, boolean emptySweepRev) {
store.remove(Collection.SETTINGS, "sweep2Status");
if (emptySweepRev) {
- String rootId = Utils.getIdFromPath("/");
+ String rootId = Utils.getIdFromPath("/", store.getMetadata());
NodeDocument rootDoc = store.find(Collection.NODES, rootId);
SortedMap<Revision, String> sweepRevs = rootDoc.getLocalMap(NodeDocument.SWEEP_REV);
if (!sweepRevs.isEmpty()) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranchTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranchTest.java
index 018040a6c7..055f0c8342 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranchTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UnmergedBranchTest.java
@@ -92,7 +92,8 @@ public class UnmergedBranchTest {
}
private NodeDocument getRootDoc(DocumentMK mk){
- return mk.getNodeStore().getDocumentStore().find(Collection.NODES, Utils.getIdFromPath("/"));
+ return mk.getNodeStore().getDocumentStore().find(Collection.NODES,
+ Utils.getIdFromPath("/", mk.getDocumentStore().getMetadata()));
}
private DocumentMK create(DocumentStore ds, int clusterId){
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateLimitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateLimitTest.java
index e8bd3edb33..dbaf230828 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateLimitTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateLimitTest.java
@@ -37,7 +37,7 @@ public class UpdateLimitTest {
public void before() {
ns = builderProvider.newBuilder().getNodeStore();
store = ns.getDocumentStore();
- testId = Utils.getIdFromPath("/test");
+ testId = Utils.getIdFromPath("/test", store.getMetadata());
}
@Test
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtilsTest.java
index 7ba34be4e7..5e4364749a 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtilsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtilsTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import java.util.Collections;
import java.util.Map;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
@@ -34,7 +35,7 @@ public class UpdateUtilsTest {
@Test
public void applyChanges() {
Revision r = Revision.newRevision(1);
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", Collections.emptyMap());
Document d = new Document();
d.put(Document.ID, id);
@@ -78,7 +79,7 @@ public class UpdateUtilsTest {
@Test
public void checkConditions() {
Revision r = Revision.newRevision(1);
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", Collections.emptyMap());
Document d = new Document();
d.put(Document.ID, id);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/V18BranchCommitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/V18BranchCommitTest.java
index 5f14280ed6..bdb5aa0aac 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/V18BranchCommitTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/V18BranchCommitTest.java
@@ -140,6 +140,6 @@ public class V18BranchCommitTest {
}
private NodeDocument docForPath(String path) {
- return ns.getDocumentStore().find(NODES, Utils.getIdFromPath(path));
+ return ns.getDocumentStore().find(NODES, Utils.getIdFromPath(path, ns.getDocumentStore().getMetadata()));
}
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ValueMapTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ValueMapTest.java
index dc05e3d41d..86ed2c0e0e 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ValueMapTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ValueMapTest.java
@@ -46,17 +46,17 @@ public class ValueMapTest {
@Test
public void previousDocs1() {
- String rootId = Utils.getIdFromPath(ROOT);
- Revision r0 = new Revision(0, 0, 1);
MemoryDocumentStore store = new MemoryDocumentStore();
+ String rootId = Utils.getIdFromPath(ROOT, store.getMetadata());
+ Revision r0 = new Revision(0, 0, 1);
// create previous docs
- UpdateOp op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r0, 0), true);
+ UpdateOp op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r0, 0, store.getMetadata()), true);
op.setMapEntry("prop", r0, "0");
NodeDocument.setRevision(op, r0, "c");
store.createOrUpdate(NODES, op);
Revision r1low = new Revision(1, 0, 1);
Revision r1high = new Revision(1, 10, 1);
- op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r1high, 0), true);
+ op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r1high, 0, store.getMetadata()), true);
for (int i = r1low.getCounter(); i <= r1high.getCounter(); i++) {
Revision r = new Revision(1, i, 1);
op.setMapEntry("foo", r, String.valueOf(i));
@@ -88,7 +88,7 @@ public class ValueMapTest {
@Test
public void previousDocs2() {
MemoryDocumentStore store = new MemoryDocumentStore();
- String rootId = Utils.getIdFromPath(ROOT);
+ String rootId = Utils.getIdFromPath(ROOT, store.getMetadata());
Revision r01 = new Revision(0, 0, 1);
Revision r12 = new Revision(1, 0, 2);
Revision r22 = new Revision(2, 0, 2);
@@ -96,14 +96,14 @@ public class ValueMapTest {
Revision r42 = new Revision(4, 0, 2);
Revision r51 = new Revision(5, 0, 1);
// create previous docs
- UpdateOp op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r31, 0), true);
+ UpdateOp op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r31, 0, store.getMetadata()), true);
op.setMapEntry("p0", r01, "0");
NodeDocument.setRevision(op, r01, "c");
op.setMapEntry("p1", r31, "1");
NodeDocument.setRevision(op, r31, "c");
store.createOrUpdate(NODES, op);
- op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r42, 0), true);
+ op = new UpdateOp(Utils.getPreviousIdFor(ROOT, r42, 0, store.getMetadata()), true);
op.setMapEntry("p1", r12, "0");
NodeDocument.setRevision(op, r12, "c");
op.setMapEntry("p1", r22, "1");
@@ -126,8 +126,8 @@ public class ValueMapTest {
List<NodeDocument> prevDocs = Lists.newArrayList(
doc.getPreviousDocs("p1", null));
assertEquals(2, prevDocs.size());
- assertEquals(Utils.getPreviousIdFor(ROOT, r31, 0), prevDocs.get(0).getId());
- assertEquals(Utils.getPreviousIdFor(ROOT, r42, 0), prevDocs.get(1).getId());
+ assertEquals(Utils.getPreviousIdFor(ROOT, r31, 0, store.getMetadata()), prevDocs.get(0).getId());
+ assertEquals(Utils.getPreviousIdFor(ROOT, r42, 0, store.getMetadata()), prevDocs.get(1).getId());
List<Revision> revs = new ArrayList<Revision>();
for (Revision r : doc.getValueMap("p1").keySet()) {
@@ -141,7 +141,7 @@ public class ValueMapTest {
public void mergeSorted() throws Exception {
DocumentNodeStore store = new DocumentMK.Builder().setAsyncDelay(0).getNodeStore();
DocumentStore docStore = store.getDocumentStore();
- String id = Utils.getIdFromPath("/");
+ String id = Utils.getIdFromPath("/", docStore.getMetadata());
List<NodeBuilder> branches = Lists.newArrayList();
int i = 0;
@@ -188,18 +188,18 @@ public class ValueMapTest {
Range range1 = new Range(r7, r5, 0);
Range range2 = new Range(r4, r1, 0);
- String prevId1 = Utils.getPreviousIdFor(ROOT, range1.high, 0);
+ String prevId1 = Utils.getPreviousIdFor(ROOT, range1.high, 0, store.getMetadata());
UpdateOp prevOp1 = new UpdateOp(prevId1, true);
NodeDocument.setRevision(prevOp1, r5, "c");
NodeDocument.setRevision(prevOp1, r7, "c");
- String prevId2 = Utils.getPreviousIdFor(ROOT, range2.high, 0);
+ String prevId2 = Utils.getPreviousIdFor(ROOT, range2.high, 0, store.getMetadata());
UpdateOp prevOp2 = new UpdateOp(prevId2, true);
NodeDocument.setRevision(prevOp2, r1, "c");
NodeDocument.setRevision(prevOp2, r2, "c");
NodeDocument.setRevision(prevOp2, r4, "c");
- String rootId = Utils.getIdFromPath("/");
+ String rootId = Utils.getIdFromPath("/", store.getMetadata());
UpdateOp op = new UpdateOp(rootId, true);
NodeDocument.setRevision(op, r3, "c");
NodeDocument.setRevision(op, r6, "c");
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCDeletionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCDeletionTest.java
index 11b863e00f..791cfce065 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCDeletionTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCDeletionTest.java
@@ -132,7 +132,7 @@ public class VersionGCDeletionTest {
.setAsyncDelay(0)
.getNodeStore();
- String id = Utils.getIdFromPath("/x");
+ String id = Utils.getIdFromPath("/x", ts.getMetadata());
NodeBuilder b1 = store.getRoot().builder();
b1.child("x");
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCQueryTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCQueryTest.java
index 3f659a180a..1a0a5f1c75 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCQueryTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCQueryTest.java
@@ -122,7 +122,7 @@ public class VersionGCQueryTest {
NodeBuilder builder = ns.getRoot().builder();
builder.child("test");
merge(builder);
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getMetadata());
while (!Iterables.any(store.find(Collection.NODES, id).getPreviousRanges().values(), INTERMEDIATE)) {
InputStream s = new RandomStream(10 * 1024, 42);
PropertyState p = new BinaryPropertyState("p", ns.createBlob(s));
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSplitDocTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSplitDocTest.java
index 0c7649bab9..386c837eba 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSplitDocTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSplitDocTest.java
@@ -133,7 +133,7 @@ public class VersionGCSplitDocTest {
merge(ns, builder);
}
ns.runBackgroundOperations();
- String id = Utils.getIdFromPath("/" + "createNoBranchSplitDocument" + longpath + "/" + parent);
+ String id = Utils.getIdFromPath("/" + "createNoBranchSplitDocument" + longpath + "/" + parent, store.getMetadata());
NodeDocument doc = store.find(NODES, id);
assertNotNull(doc);
for (UpdateOp op : SplitOperations.forDocument(doc, ns, ns.getHeadRevision(), NO_BINARY, 5)) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
index fc6799ed73..b467ec2254 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import java.util.Collections;
import java.util.List;
import com.google.common.collect.Iterables;
@@ -97,7 +98,7 @@ public class VersionGCSupportTest {
long offset = SECONDS.toMillis(42);
for (int i = 0; i < 5; i++) {
Revision r = new Revision(offset + SECONDS.toMillis(i), 0, 1);
- String id = Utils.getIdFromPath("/doc-" + i);
+ String id = Utils.getIdFromPath("/doc-" + i, store.getMetadata());
ids.add(id);
UpdateOp op = new UpdateOp(id, true);
NodeDocument.setModified(op, r);
@@ -132,7 +133,7 @@ public class VersionGCSupportTest {
long secs = 123456;
long offset = SECONDS.toMillis(secs);
Revision r = new Revision(offset, 0, 1);
- String id = Utils.getIdFromPath("/doc-del");
+ String id = Utils.getIdFromPath("/doc-del", store.getMetadata());
ids.add(id);
UpdateOp op = new UpdateOp(id, true);
NodeDocument.setModified(op, r);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSweepTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSweepTest.java
index 56e549f952..4ff8dc4662 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSweepTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSweepTest.java
@@ -104,7 +104,7 @@ public class VersionGCSweepTest extends AbstractTwoNodeTest {
private static int getNumSplitDocuments(DocumentStore store, String path)
throws Exception {
- NodeDocument doc = store.find(NODES, getIdFromPath(path));
+ NodeDocument doc = store.find(NODES, getIdFromPath(path, store.getMetadata()));
assertNotNull(doc);
return Iterators.size(doc.getAllPreviousDocs());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCWithSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCWithSplitTest.java
index fb08250cee..044e3093df 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCWithSplitTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCWithSplitTest.java
@@ -116,7 +116,7 @@ public class VersionGCWithSplitTest {
builder.child("test").setProperty("prop", -1);
merge(store, builder);
- final String id = Utils.getIdFromPath("/test");
+ final String id = Utils.getIdFromPath("/test", store.getDocumentStore().getMetadata());
DocumentStore docStore = store.getDocumentStore();
int count = 0;
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
index bc8a8a11bf..a2b07063a4 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
@@ -317,7 +317,7 @@ public class VersionGarbageCollectorIT {
}
// trigger another split, now that we have 10 previous docs
// this will create an intermediate previous doc
- store.addSplitCandidate(Utils.getIdFromPath("/test"));
+ store.addSplitCandidate(Utils.getIdFromPath("/test", store.getDocumentStore().getMetadata()));
store.runBackgroundOperations();
Map<Revision, Range> prevRanges = getDoc("/test").getPreviousRanges();
@@ -426,7 +426,7 @@ public class VersionGarbageCollectorIT {
builder.child("test").setProperty("prop", -1);
merge(store, builder);
- String id = Utils.getIdFromPath("/test");
+ String id = Utils.getIdFromPath("/test", store.getDocumentStore().getMetadata());
long start = Revision.getCurrentTimestamp();
// simulate continuous writes once a second for one day
// collect garbage older than one hour
@@ -533,7 +533,7 @@ public class VersionGarbageCollectorIT {
}
assertEquals(1, names.size());
- doc = ds.find(NODES, Utils.getIdFromPath("/" + names.get(0)));
+ doc = ds.find(NODES, Utils.getIdFromPath("/" + names.get(0), store.getDocumentStore().getMetadata()));
assertNotNull(doc);
assertEquals(0, Iterators.size(doc.getAllPreviousDocs()));
@@ -588,14 +588,14 @@ public class VersionGarbageCollectorIT {
merge(store, builder);
RevisionVector head = store.getHeadRevision();
for (UpdateOp op : SplitOperations.forDocument(
- ds.find(NODES, Utils.getIdFromPath("/foo")), store, head,
+ ds.find(NODES, Utils.getIdFromPath("/foo", ds.getMetadata())), store, head,
NO_BINARY, 2)) {
ds.createOrUpdate(NODES, op);
}
clock.waitUntil(clock.getTime() + TimeUnit.MINUTES.toMillis(1));
}
store.runBackgroundOperations();
- NodeDocument foo = ds.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument foo = ds.find(NODES, Utils.getIdFromPath("/foo", ds.getMetadata()));
assertNotNull(foo);
Long modCount = foo.getModCount();
assertNotNull(modCount);
@@ -625,12 +625,12 @@ public class VersionGarbageCollectorIT {
ds.invalidateCache(NODES, id);
}
- foo = ds.find(NODES, Utils.getIdFromPath("/foo"));
+ foo = ds.find(NODES, Utils.getIdFromPath("/foo", ds.getMetadata()));
assertNotNull(foo);
Iterators.size(foo.getAllPreviousDocs());
// foo must now reflect state after GC
- foo = ds.find(NODES, Utils.getIdFromPath("/foo"));
+ foo = ds.find(NODES, Utils.getIdFromPath("/foo", ds.getMetadata()));
assertNotEquals(modCount, foo.getModCount());
}
@@ -875,7 +875,7 @@ public class VersionGarbageCollectorIT {
String nodeName = "foo";
Path path = new Path(Path.ROOT, nodeName);
- String docId = Utils.getIdFromPath(path);
+ String docId = Utils.getIdFromPath(path, store.getDocumentStore().getMetadata());
NodeBuilder builder = store.getRoot().builder();
builder.child(nodeName).setProperty("p", -1);
@@ -963,7 +963,7 @@ public class VersionGarbageCollectorIT {
NodeBuilder builder = store.getRoot().builder();
builder.child(name);
merge(store, builder);
- String id = Utils.getIdFromPath("/" + name);
+ String id = Utils.getIdFromPath("/" + name, ds.getMetadata());
int i = 0;
while (ds.find(NODES, id).getPreviousRanges().isEmpty()) {
builder = store.getRoot().builder();
@@ -983,6 +983,6 @@ public class VersionGarbageCollectorIT {
}
private NodeDocument getDoc(Path path) {
- return store.getDocumentStore().find(NODES, Utils.getIdFromPath(path), 0);
+ return store.getDocumentStore().find(NODES, Utils.getIdFromPath(path, store.getDocumentStore().getMetadata()), 0);
}
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
index 2a566f9d9c..c36457befd 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
@@ -109,7 +109,7 @@ public class VisibleChangesTest {
}
private static int getRevisionsSize(DocumentStore store, String path) {
- NodeDocument doc = store.find(Collection.NODES, getIdFromPath(path));
+ NodeDocument doc = store.find(Collection.NODES, getIdFromPath(path, store.getMetadata()));
assertNotNull(doc);
return doc.getLocalRevisions().size();
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
index 79fd6fbae7..f5d86bc6c6 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
@@ -1032,7 +1032,7 @@ public class DocumentBundlingTest {
}
private NodeDocument getNodeDocument(String path) {
- return ds.find(Collection.NODES, Utils.getIdFromPath(path));
+ return ds.find(Collection.NODES, Utils.getIdFromPath(path, ds.getMetadata()));
}
private NodeState merge(NodeBuilder builder) throws CommitFailedException {
@@ -1090,7 +1090,7 @@ public class DocumentBundlingTest {
public <T extends Document> List<T> query(Collection<T> collection, String fromKey, String toKey,
String indexedProperty, long startValue, int limit) {
if (collection == Collection.NODES){
- queryPaths.add(Utils.getPathFromId(Utils.getParentIdFromLowerLimit(fromKey)));
+ queryPaths.add(Utils.getPathFromId(Utils.getParentIdFromLowerLimit(fromKey, getMetadata())));
}
return super.query(collection, fromKey, toKey, indexedProperty, startValue, limit);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTrackerTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTrackerTest.java
index 499d67df5c..872d76f870 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTrackerTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTrackerTest.java
@@ -84,7 +84,7 @@ public class CacheChangesTrackerTest {
public void testRegisterChildrenTracker() {
NodeDocumentCache cache = createCache();
Path parent = Path.fromString("/parent");
- CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent), getKeyUpperLimit(parent));
+ CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent, ds.getMetadata()), getKeyUpperLimit(parent, ds.getMetadata()));
assertFalse(tracker.mightBeenAffected("2:/parent/xyz"));
assertFalse(tracker.mightBeenAffected("2:/parent/abc"));
@@ -108,7 +108,7 @@ public class CacheChangesTrackerTest {
public void testGetLoaderAffectsTracker() throws ExecutionException {
NodeDocumentCache cache = createCache();
Path parent = Path.fromString("/parent");
- CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent), getKeyUpperLimit(parent));
+ CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent, ds.getMetadata()), getKeyUpperLimit(parent, ds.getMetadata()));
assertFalse(tracker.mightBeenAffected("2:/parent/xyz"));
@@ -153,7 +153,7 @@ public class CacheChangesTrackerTest {
public void testOnlyExternalChanges() {
NodeDocumentCache cache = createCache();
Path parent = Path.fromString("/parent");
- CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent), getKeyUpperLimit(parent));
+ CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent, ds.getMetadata()), getKeyUpperLimit(parent, ds.getMetadata()));
cache.putNonConflictingDocs(tracker, ImmutableSet.of(createDoc("2:/parent/local")));
assertFalse(tracker.mightBeenAffected("2:/parent/local"));
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
index 15aa6e25e5..98c1aac30c 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
@@ -149,7 +149,7 @@ public class CacheInvalidationIT extends AbstractMongoConnectionTest {
}
private static void refreshHead(DocumentNodeStore store) {
- ds(store).find(Collection.NODES, Utils.getIdFromPath("/"), 0);
+ ds(store).find(Collection.NODES, Utils.getIdFromPath("/", store.getDocumentStore().getMetadata()), 0);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CollisionMarkerTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CollisionMarkerTest.java
index 0581cad02b..33d9965f28 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CollisionMarkerTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CollisionMarkerTest.java
@@ -87,7 +87,7 @@ public class CollisionMarkerTest extends AbstractMongoConnectionTest {
// expected
}
- String rootId = Utils.getIdFromPath("/");
+ String rootId = Utils.getIdFromPath("/", ns2.getDocumentStore().getMetadata());
NodeDocument root = ns2.getDocumentStore().find(NODES, rootId);
assertFalse("root document must not have a collision marker for a" +
" committed revision", root.getValueMap(COLLISIONS).containsKey(head));
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
index 73a1d9d49d..ecf1ce6989 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
@@ -65,7 +65,7 @@ public class MongoDBExceptionTest {
@Test
public void idInExceptionMessage() {
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", store.getMetadata());
UpdateOp insert = new UpdateOp(id, true);
assertTrue(store.create(Collection.NODES, singletonList(insert)));
@@ -116,8 +116,8 @@ public class MongoDBExceptionTest {
}
Path foo = Path.fromString("/foo");
- String fromKey = Utils.getKeyLowerLimit(foo);
- String toKey = Utils.getKeyUpperLimit(foo);
+ String fromKey = Utils.getKeyLowerLimit(foo, store.getMetadata());
+ String toKey = Utils.getKeyUpperLimit(foo, store.getMetadata());
exceptionMsg = "query failed";
setExceptionMsg();
try {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeekerTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeekerTest.java
index 166781b727..1683eba96a 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeekerTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoMissingLastRevSeekerTest.java
@@ -84,7 +84,7 @@ public class MongoMissingLastRevSeekerTest {
// populate the store
List<UpdateOp> ops = Lists.newArrayList();
for (int i = 0; i < NUM_DOCS; i++) {
- UpdateOp op = new UpdateOp(getIdFromPath("/node-" + i), true);
+ UpdateOp op = new UpdateOp(getIdFromPath("/node-" + i, store.getMetadata()), true);
NodeDocument.setModified(op, new Revision(i * 5000, 0, 1));
ops.add(op);
}
@@ -96,7 +96,7 @@ public class MongoMissingLastRevSeekerTest {
for (NodeDocument doc : seeker.getCandidates(0)) {
if (!updated) {
// as soon as we have the first document, update /node-0
- UpdateOp op = new UpdateOp(getIdFromPath("/node-0"), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/node-0", store.getMetadata()), false);
// and push out the _modified timestamp
NodeDocument.setModified(op, new Revision(NUM_DOCS * 5000, 0, 1));
// even after the update the document matches the query
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoRevisionGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoRevisionGCTest.java
index 05f7f00df8..ac3bfd6a5b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoRevisionGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoRevisionGCTest.java
@@ -134,7 +134,7 @@ public class MongoRevisionGCTest extends AbstractMongoConnectionTest {
b.child("child").remove();
merge(ns, b);
ns.runBackgroundOperations();
- NodeDocument doc = ns.getDocumentStore().find(NODES, Utils.getIdFromPath("/child"));
+ NodeDocument doc = ns.getDocumentStore().find(NODES, Utils.getIdFromPath("/child", ns.getDocumentStore().getMetadata()));
assertNotNull(doc);
for (Iterator<NodeDocument> it = getAllPreviousDocs(doc); it.hasNext(); ) {
prev = it.next();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtilsTest.java
index 6f4e5247d8..5e8fe944d4 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtilsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtilsTest.java
@@ -200,6 +200,24 @@ public class MongoUtilsTest {
}
}
+ @Test
+ public void getSizeLimitForMongo4() {
+ int sizeLimit = MongoUtils.getSizeLimit("4.0.0");
+ assertEquals(150, sizeLimit);
+ }
+
+ @Test
+ public void getSizeLimitForMongo3() {
+ int sizeLimit = MongoUtils.getSizeLimit("3.5.0");
+ assertEquals(150, sizeLimit);
+ }
+
+ @Test
+ public void getSizeLimitForMongo4_2() {
+ int sizeLimit = MongoUtils.getSizeLimit("4.2.0");
+ assertEquals(Integer.MAX_VALUE, sizeLimit);
+ }
+
private static MongoCommandException newMongoCommandException(int code) {
return new MongoCommandException(response(code), new ServerAddress());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionTest.java
new file mode 100644
index 0000000000..5abb1bcc03
--- /dev/null
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionTest.java
@@ -0,0 +1,46 @@
+package org.apache.jackrabbit.oak.plugins.document.mongo;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MongoVersionTest {
+
+
+ @Test
+ public void createMongoVersion() {
+ MongoVersion version = MongoVersion.of("4.0.0");
+ assertEquals(MongoVersion.MONGO_4_0_0, version);
+ }
+
+ @Test
+ public void createDefaultMongoVersionFromNull() {
+ MongoVersion version = MongoVersion.of(null);
+ assertEquals(MongoVersion.MONGO_4_0_0, version);
+ }
+
+ @Test
+ public void createDefaultMongoVersionMalformed() {
+ MongoVersion version = MongoVersion.of("234");
+ assertEquals(MongoVersion.MONGO_4_0_0, version);
+ }
+
+ @Test
+ public void createDefaultMongoVersionMalformed2() {
+ MongoVersion version = MongoVersion.of("4.0");
+ assertEquals(MongoVersion.MONGO_4_0_0, version);
+ }
+
+ @Test
+ public void compareMongoVersion() {
+ MongoVersion version = MongoVersion.of("2.3.4");
+ assertTrue(MongoVersion.MONGO_4_0_0.compareTo(version) > 0);
+ }
+
+ @Test
+ public void compareMongoVersion2() {
+ MongoVersion version = MongoVersion.of("4.0.4");
+ assertTrue(MongoVersion.MONGO_4_0_0.compareTo(version) < 0);
+ }
+
+}
\ No newline at end of file
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/QueryHintTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/QueryHintTest.java
index 33f0f94d31..b878050a0d 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/QueryHintTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/QueryHintTest.java
@@ -76,8 +76,8 @@ public class QueryHintTest extends AbstractMongoConnectionTest {
assertTrue(mongoDS.canUseModifiedTimeIdx(10));
mongoDS.query(Collection.NODES,
- Utils.getKeyLowerLimit(Path.ROOT),
- Utils.getKeyUpperLimit(Path.ROOT),
+ Utils.getKeyLowerLimit(Path.ROOT, mongoDS.getMetadata()),
+ Utils.getKeyUpperLimit(Path.ROOT, mongoDS.getMetadata()),
NodeDocument.MODIFIED_IN_SECS,
50,
10);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
index ae0963ecf5..5841940c3b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
@@ -129,7 +129,7 @@ public class ReadPreferenceIT extends AbstractMongoConnectionTest {
@Test
public void getMongoReadPreference() {
- String id = getIdFromPath("/does/not/exist");
+ String id = getIdFromPath("/does/not/exist", mongoDS.getMetadata());
mongoDS.setReadWriteMode(rwMode(ReadPreference.secondaryPreferred()));
mongoDS.find(NODES, id);
ReadPreference readPref = mongoDS.getMongoReadPreference(NODES, id,
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/RetryReadIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/RetryReadIT.java
index c70376b1d9..8d2f5f378f 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/RetryReadIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/RetryReadIT.java
@@ -62,15 +62,15 @@ public class RetryReadIT extends AbstractMongoConnectionTest {
public void retry() {
// must survive two consecutive failures. -> 2 retries
store.failRead = 2;
- NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNull(doc);
// previous result is cached and will not fail
store.failRead = 3;
- doc = store.find(NODES, Utils.getIdFromPath("/foo"));
+ doc = store.find(NODES, Utils.getIdFromPath("/foo", store.getMetadata()));
assertNull(doc);
// must fail with three consecutive failures on unknown path
try {
- store.find(NODES, Utils.getIdFromPath("/bar"));
+ store.find(NODES, Utils.getIdFromPath("/bar", store.getMetadata()));
fail("must fail with DocumentStoreException");
} catch (DocumentStoreException e) {
// expected
@@ -80,16 +80,16 @@ public class RetryReadIT extends AbstractMongoConnectionTest {
@Test
public void retryQuery() {
Path foo = Path.fromString("/foo");
- String fromKey = Utils.getKeyLowerLimit(foo);
- String toKey = Utils.getKeyUpperLimit(foo);
+ String fromKey = Utils.getKeyLowerLimit(foo, store.getMetadata());
+ String toKey = Utils.getKeyUpperLimit(foo, store.getMetadata());
// must survive two consecutive failures. -> 2 retries
store.failRead = 2;
List<NodeDocument> docs = store.query(NODES, fromKey, toKey, 100);
assertThat(docs, is(empty()));
Path bar = Path.fromString("/bar");
- fromKey = Utils.getKeyLowerLimit(bar);
- toKey = Utils.getKeyUpperLimit(bar);
+ fromKey = Utils.getKeyLowerLimit(bar, store.getMetadata());
+ toKey = Utils.getKeyUpperLimit(bar, store.getMetadata());
// must fail with three consecutive failures
store.failRead = 3;
try {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreSchemaUpgradeTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreSchemaUpgradeTest.java
index abd2eac742..aa02705124 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreSchemaUpgradeTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreSchemaUpgradeTest.java
@@ -55,7 +55,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
@Parameterized.Parameters(name = "{0}")
public static java.util.Collection<Object[]> fixtures() {
java.util.Collection<Object[]> result = new ArrayList<Object[]>();
- DocumentStoreFixture candidates[] = new DocumentStoreFixture[] { DocumentStoreFixture.RDB_H2,
+ DocumentStoreFixture[] candidates = new DocumentStoreFixture[] { DocumentStoreFixture.RDB_H2,
DocumentStoreFixture.RDB_DERBY, DocumentStoreFixture.RDB_PG, DocumentStoreFixture.RDB_DB2,
DocumentStoreFixture.RDB_MYSQL, DocumentStoreFixture.RDB_ORACLE, DocumentStoreFixture.RDB_MSSQL };
@@ -141,7 +141,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
rdb1 = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), new RDBOptions().tablePrefix("T0T1").initialSchema(0).upgradeToSchema(1));
RDBTableMetaData meta1 = rdb1.getTable(Collection.NODES);
assertTrue(meta1.hasVersion());
- UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo"), true);
+ UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo", rdb1.getMetadata()), true);
assertTrue(rdb1.create(Collection.NODES, Collections.singletonList(testInsert)));
} finally {
if (rdb1 != null) {
@@ -165,11 +165,11 @@ public class RDBDocumentStoreSchemaUpgradeTest {
rdb1 = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), new RDBOptions().tablePrefix("T0T2").initialSchema(0).upgradeToSchema(2));
RDBTableMetaData meta1 = rdb1.getTable(Collection.NODES);
assertTrue(meta1.hasVersion());
- UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo"), true);
+ UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo", rdb1.getMetadata()), true);
testInsert.set(NodeDocument.SD_TYPE, 123L);
assertTrue(rdb1.create(Collection.NODES, Collections.singletonList(testInsert)));
// check that old instance can read a new entry
- NodeDocument check = rdb0.find(Collection.NODES, Utils.getIdFromPath("/foo"));
+ NodeDocument check = rdb0.find(Collection.NODES, Utils.getIdFromPath("/foo", rdb1.getMetadata()));
assertNotNull(check);
assertEquals(123L, check.get(NodeDocument.SD_TYPE));
} finally {
@@ -225,7 +225,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
assertFalse(meta.hasVersion());
assertEquals("unexpected # of log entries: " + logCustomizer.getLogs(), RDBDocumentStore.getTableNames().size(),
logCustomizer.getLogs().size());
- UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo"), true);
+ UpdateOp testInsert = new UpdateOp(Utils.getIdFromPath("/foo", rdb.getMetadata()), true);
assertTrue(rdb.create(Collection.NODES, Collections.singletonList(testInsert)));
} finally {
wds.setFailAlterTableAddColumnStatements(false);
@@ -300,7 +300,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
assertTrue(meta.hasVersion());
assertEquals("unexpected # of log entries: " + logCustomizer.getLogs(), RDBDocumentStore.getTableNames().size() * 4,
logCustomizer.getLogs().size());
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", rdb.getMetadata());
UpdateOp testInsert = new UpdateOp(id, true);
assertTrue(rdb.create(Collection.NODES, Collections.singletonList(testInsert)));
UpdateOp testUpdate = new UpdateOp(id, false);
@@ -329,7 +329,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
RDBTableMetaData meta = rdb.getTable(Collection.NODES);
assertEquals(op.getTablePrefix() + "_NODES", meta.getName());
assertTrue(meta.hasVersion());
- String id = Utils.getIdFromPath("/foo");
+ String id = Utils.getIdFromPath("/foo", rdb.getMetadata());
UpdateOp testInsert = new UpdateOp(id, true);
assertTrue(rdb.create(Collection.NODES, Collections.singletonList(testInsert)));
UpdateOp testUpdate = new UpdateOp(id, false);
@@ -402,7 +402,7 @@ public class RDBDocumentStoreSchemaUpgradeTest {
op01.set(NodeDocument.SD_TYPE, SplitDocType.DEFAULT_LEAF.typeCode());
op01.set(NodeDocument.SD_MAX_REV_TIME_IN_SECS, sdmaxrev);
- UpdateOp op02 = new UpdateOp(Utils.getIdFromPath("/regular"), true);
+ UpdateOp op02 = new UpdateOp(Utils.getIdFromPath("/regular", rdb0.getMetadata()), true);
ops.add(op01);
ops.add(op02);
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreTest.java
index 304592f2be..a3850d91e0 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreTest.java
@@ -162,8 +162,8 @@ public class RDBDocumentStoreTest extends AbstractDocumentStoreTest {
logCustomizerQuery.starting();
try {
- String id1 = Utils.getIdFromPath("/testRDBJDBCPerfLog");
- String id2 = Utils.getIdFromPath("/testRDBJDBCPerfLog/foo");
+ String id1 = Utils.getIdFromPath("/testRDBJDBCPerfLog", ds.getMetadata());
+ String id2 = Utils.getIdFromPath("/testRDBJDBCPerfLog/foo", ds.getMetadata());
UpdateOp up1 = new UpdateOp(id1, true);
up1.set(NodeDocument.MODIFIED_IN_SECS, 12345L);
super.removeMe.add(id1);
@@ -185,7 +185,7 @@ public class RDBDocumentStoreTest extends AbstractDocumentStoreTest {
// query
Path p = Path.fromString("/testRDBJDBCPerfLog");
- List<NodeDocument> results = super.ds.query(Collection.NODES, Utils.getKeyLowerLimit(p), Utils.getKeyUpperLimit(p), 10);
+ List<NodeDocument> results = super.ds.query(Collection.NODES, Utils.getKeyLowerLimit(p, ds.getMetadata()), Utils.getKeyUpperLimit(p, ds.getMetadata()), 10);
assertEquals(1, results.size());
assertEquals(2, logCustomizerQuery.getLogs().size());
} finally {
@@ -203,7 +203,7 @@ public class RDBDocumentStoreTest extends AbstractDocumentStoreTest {
// populate the store
List<UpdateOp> ops = Lists.newArrayList();
for (int i = 0; i < NUM_DOCS; i++) {
- UpdateOp op = new UpdateOp(getIdFromPath("/lastRevnode-" + i), true);
+ UpdateOp op = new UpdateOp(getIdFromPath("/lastRevnode-" + i, ds.getMetadata()), true);
NodeDocument.setModified(op, new Revision(i * 5000, 0, 1));
ops.add(op);
removeMe.add(op.getId());
@@ -217,7 +217,7 @@ public class RDBDocumentStoreTest extends AbstractDocumentStoreTest {
if (!updated) {
// as soon as we have the first document, update
// /lastRevnode-0
- UpdateOp op = new UpdateOp(getIdFromPath("/lastRevnode-0"), false);
+ UpdateOp op = new UpdateOp(getIdFromPath("/lastRevnode-0", ds.getMetadata()), false);
// and push out the _modified timestamp
NodeDocument.setModified(op, new Revision(NUM_DOCS * 5000, 0, 1));
// even after the update the document matches the query
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java
index 0822f93afd..25d7baf6ed 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java
@@ -275,7 +275,7 @@ public class SecondaryStoreCacheTest {
}
private NodeDocument getNodeDocument(String path) {
- return primary.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
+ return primary.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path, primary.getDocumentStore().getMetadata()));
}
private SecondaryStoreBuilder createBuilder(PathFilter pathFilter) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
index ccc537557d..0a6d1b27f4 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
@@ -16,14 +16,12 @@
*/
package org.apache.jackrabbit.oak.plugins.document.util;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
+import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import org.apache.commons.codec.binary.Hex;
@@ -75,24 +73,26 @@ import static org.mockito.Mockito.when;
public class UtilsTest {
private static final long TIME_DIFF_WARN_THRESHOLD_MILLIS = 2000L;
+ private static final String LONG_PATH = "/tmp/commerce/qwerty/asdfgh/BU~PCSDB2C_CM~2020 IdeaPad IdeaCentre Holiday Campaign _CV~All The Right Answers IdeaCentre AIO AMD Caro usel_CT~FB_CS~1x1_LG~EN_PR~IdeaCentre AIO 5_FS~AMD_OT~_CR~The Woo_5_jpg/BU~PCSDB2C_CM~2020 IdeaPad IdeaCentre Holiday Campaign _CV~All The Right Answers IdeaCentre AIO AMD Carousel_CT~FB_CS~1x1_LG~EN_PR ~IdeaCentre AIO 5_FS~AMD_OT~_CR~The Woo_5_jpg1/BU~PCSDB2C_CM~2020 IdeaPad IdeaCentre Holiday Campaign [...]
+ public static final String SIZE_LIMIT = "sizeLimit";
@Test
public void getPreviousIdFor() {
Revision r = new Revision(System.currentTimeMillis(), 0, 0);
assertEquals("2:p/" + r.toString() + "/0",
- Utils.getPreviousIdFor(Path.ROOT, r, 0));
+ Utils.getPreviousIdFor(Path.ROOT, r, 0, Collections.emptyMap()));
assertEquals("3:p/test/" + r.toString() + "/1",
- Utils.getPreviousIdFor(Path.fromString("/test"), r, 1));
+ Utils.getPreviousIdFor(Path.fromString("/test"), r, 1, Collections.emptyMap()));
assertEquals("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/" + r.toString() + "/3",
- Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3));
+ Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3, Collections.emptyMap()));
}
@Test
public void previousDoc() throws Exception{
Revision r = new Revision(System.currentTimeMillis(), 0, 0);
- assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor(Path.ROOT, r, 0)));
- assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3)));
- assertFalse(Utils.isPreviousDocId(Utils.getIdFromPath("/a/b")));
+ assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor(Path.ROOT, r, 0, Collections.emptyMap())));
+ assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3, Collections.emptyMap())));
+ assertFalse(Utils.isPreviousDocId(Utils.getIdFromPath("/a/b", Collections.emptyMap())));
assertFalse(Utils.isPreviousDocId("foo"));
assertFalse(Utils.isPreviousDocId("0:"));
}
@@ -100,10 +100,10 @@ public class UtilsTest {
@Test
public void leafPreviousDoc() throws Exception {
Revision r = new Revision(System.currentTimeMillis(), 0, 0);
- assertTrue(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.ROOT, r, 0)));
- assertTrue(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 0)));
- assertFalse(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3)));
- assertFalse(Utils.isLeafPreviousDocId(Utils.getIdFromPath("/a/b")));
+ assertTrue(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.ROOT, r, 0, Collections.emptyMap())));
+ assertTrue(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 0, Collections.emptyMap())));
+ assertFalse(Utils.isLeafPreviousDocId(Utils.getPreviousIdFor(Path.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"), r, 3, Collections.emptyMap())));
+ assertFalse(Utils.isLeafPreviousDocId(Utils.getIdFromPath("/a/b", Collections.emptyMap())));
assertFalse(Utils.isLeafPreviousDocId("foo"));
assertFalse(Utils.isLeafPreviousDocId("0:"));
assertFalse(Utils.isLeafPreviousDocId(":/0"));
@@ -111,19 +111,56 @@ public class UtilsTest {
@Test
public void getParentIdFromLowerLimit() throws Exception{
- assertEquals("1:/foo",Utils.getParentIdFromLowerLimit(Utils.getKeyLowerLimit(Path.fromString("/foo"))));
- assertEquals("1:/foo",Utils.getParentIdFromLowerLimit("2:/foo/bar"));
+ assertEquals("1:/foo",Utils.getParentIdFromLowerLimit(Utils.getKeyLowerLimit(Path.fromString("/foo"), Collections.emptyMap()), Collections.emptyMap()));
+ assertEquals("1:/foo",Utils.getParentIdFromLowerLimit("2:/foo/bar", Collections.emptyMap()));
}
@Test
public void getParentId() throws Exception{
Path longPath = Path.fromString(PathUtils.concat("/"+Strings.repeat("p", Utils.PATH_LONG + 1), "foo"));
- assertTrue(Utils.isLongPath(longPath));
+ assertTrue(Utils.isLongPath(longPath, Collections.emptyMap()));
- assertNull(Utils.getParentId(Utils.getIdFromPath(longPath)));
+ assertNull(Utils.getParentId(Utils.getIdFromPath(longPath, Collections.emptyMap()), Collections.emptyMap()));
+
+ assertNull(Utils.getParentId(Utils.getIdFromPath(Path.ROOT, Collections.emptyMap()), Collections.emptyMap()));
+ assertEquals("1:/foo", Utils.getParentId("2:/foo/bar", Collections.emptyMap()));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getParentIdForLongPathWithNodeNameLimit() {
+ Path longPath = Path.fromString(LONG_PATH);
+ assertTrue(Utils.isLongPath(longPath, Collections.emptyMap()));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getParentIdForLongPathWithInvalidNodeNameLimit() {
+ Path longPath = Path.fromString(LONG_PATH);
+ assertTrue(Utils.isLongPath(longPath, ImmutableMap.of(SIZE_LIMIT, "103we")));
+ }
+
+ @Test
+ public void getParentIdForLongPathWithoutNodeNameLimit() {
+ Path longPath = Path.fromString(LONG_PATH);
+ final Map<String, String> metadata = ImmutableMap.of(SIZE_LIMIT, String.valueOf(Integer.MAX_VALUE));
+ assertTrue(Utils.isLongPath(longPath, metadata));
+ assertNull(Utils.getParentId(Utils.getIdFromPath(longPath, metadata), metadata));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getIdFromLongPathWithNodeNameLimit() {
+ assertNull(Utils.getParentId(Utils.getIdFromPath(LONG_PATH, Collections.emptyMap()), Collections.emptyMap()));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getIdFromLongPathWithInvalidNodeNameLimit() {
+ assertNull(Utils.getParentId(Utils.getIdFromPath(LONG_PATH, ImmutableMap.of(SIZE_LIMIT, "103we")), ImmutableMap.of(SIZE_LIMIT, "103we")));
+ }
+
+ @Test
+ public void getParentIdForLongStringPathWithoutNodeNameLimit() {
+ final Map<String, String> metadata = ImmutableMap.of(SIZE_LIMIT, String.valueOf(Integer.MAX_VALUE));
+ assertNull(Utils.getParentId(Utils.getIdFromPath(LONG_PATH, metadata), metadata));
- assertNull(Utils.getParentId(Utils.getIdFromPath(Path.ROOT)));
- assertEquals("1:/foo", Utils.getParentId("2:/foo/bar"));
}
@Test
@@ -140,11 +177,11 @@ public class UtilsTest {
Path path = Path.fromString("/some/test/path/foo");
// warm up
for (int i = 0; i < 1 * 1000 * 1000; i++) {
- Utils.getPreviousIdFor(path, r, 0);
+ Utils.getPreviousIdFor(path, r, 0, Collections.emptyMap());
}
long time = System.currentTimeMillis();
for (int i = 0; i < 10 * 1000 * 1000; i++) {
- Utils.getPreviousIdFor(path, r, 0);
+ Utils.getPreviousIdFor(path, r, 0, Collections.emptyMap());
}
time = System.currentTimeMillis() - time;
System.out.println(time);
@@ -293,7 +330,7 @@ public class UtilsTest {
// create a root document
NodeDocument doc = new NodeDocument(new MemoryDocumentStore(), c.getTime());
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), true);
NodeDocument.setLastRev(op, lastRev1);
NodeDocument.setLastRev(op, lastRev2);
UpdateUtils.applyChanges(doc, op);
@@ -318,7 +355,7 @@ public class UtilsTest {
// create a root document
NodeDocument doc = new NodeDocument(new MemoryDocumentStore(), c.getTime());
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), true);
NodeDocument.setLastRev(op, lastRev1);
NodeDocument.setLastRev(op, lastRev2);
UpdateUtils.applyChanges(doc, op);
@@ -348,7 +385,7 @@ public class UtilsTest {
// create a root document
NodeDocument doc = new NodeDocument(new MemoryDocumentStore(), c.getTime());
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), true);
NodeDocument.setLastRev(op, lastRev1);
NodeDocument.setLastRev(op, lastRev2);
UpdateUtils.applyChanges(doc, op);
@@ -375,7 +412,7 @@ public class UtilsTest {
// create a root document
NodeDocument doc = new NodeDocument(new MemoryDocumentStore(), c.getTime());
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), true);
NodeDocument.setLastRev(op, lastRev1);
UpdateUtils.applyChanges(doc, op);
@@ -393,10 +430,10 @@ public class UtilsTest {
@Test
public void isIdFromLongPath() {
Path path = Path.fromString("/test");
- while (!Utils.isLongPath(path)) {
+ while (!Utils.isLongPath(path, Collections.emptyMap())) {
path = new Path(path, path.getName());
}
- String idFromLongPath = Utils.getIdFromPath(path);
+ String idFromLongPath = Utils.getIdFromPath(path, Collections.emptyMap());
assertTrue(Utils.isIdFromLongPath(idFromLongPath));
assertFalse(Utils.isIdFromLongPath("foo"));
assertFalse(Utils.isIdFromLongPath(NodeDocument.MIN_ID_VALUE));
@@ -468,7 +505,7 @@ public class UtilsTest {
// store is empty -> fine
Utils.checkRevisionAge(store, info, clock);
- UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
+ UpdateOp op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), true);
NodeDocument.setLastRev(op, new Revision(clock.getTime(), 0, 1));
assertTrue(store.create(Collection.NODES, Collections.singletonList(op)));
@@ -476,7 +513,7 @@ public class UtilsTest {
Utils.checkRevisionAge(store, info, clock);
long lastRevTime = clock.getTime();
- op = new UpdateOp(Utils.getIdFromPath("/"), false);
+ op = new UpdateOp(Utils.getIdFromPath("/", Collections.emptyMap()), false);
NodeDocument.setLastRev(op, new Revision(lastRevTime, 0, 2));
assertNotNull(store.findAndUpdate(Collection.NODES, op));