use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class ExternalIndexObserverTest method assertIndexing.
private void assertIndexing(Observer observer) {
Multimap<String, String> indexedPaths = HashMultimap.create();
indexedPaths.put("/a", "/oak:index/foo");
commitContext.set(LuceneDocumentHolder.NAME, new IndexedPaths(indexedPaths));
CommitInfo ci = newCommitInfo();
when(queue.add(any(LuceneDoc.class))).thenReturn(true);
when(tracker.getIndexDefinition("/oak:index/foo")).thenReturn(createNRTIndex("nt:base"));
NodeBuilder nb = INITIAL_CONTENT.builder();
nb.child("a").setProperty("foo", "bar");
observer.contentChanged(nb.getNodeState(), ci);
ArgumentCaptor<LuceneDoc> doc = ArgumentCaptor.forClass(LuceneDoc.class);
verify(queue).add(doc.capture());
assertEquals("/oak:index/foo", doc.getValue().getIndexPath());
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class CopyOnWriteDirectoryTest method writeTree.
private void writeTree(NodeBuilder builder) {
NodeBuilder test = builder.child("test");
for (int i = 0; i < 100; i++) {
NodeBuilder b = test.child("child-" + i);
for (int j = 0; j < 10; j++) {
NodeBuilder child = b.child("child-" + j);
child.setProperty("p", "value");
}
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method blobsWithSizeMismatch.
@Test
public void blobsWithSizeMismatch() throws Exception {
FailingBlob failingBlob = new FailingBlob("foo", true);
idx.child(":index").setProperty("foo", failingBlob);
NodeBuilder builder = EMPTY_NODE.builder();
builder.setChildNode("a", idx.getNodeState());
IndexConsistencyChecker checker = new IndexConsistencyChecker(builder.getNodeState(), "/a", temporaryFolder.getRoot());
Result result = checker.check(Level.BLOBS_ONLY);
assertFalse(result.clean);
assertFalse(result.missingBlobs);
assertTrue(result.blobSizeMismatch);
assertEquals(1, result.invalidBlobIds.size());
dumpResult(result);
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class LockBasedScheduler method removeCheckpoint.
@Override
public boolean removeCheckpoint(String name) {
checkNotNull(name);
// try 5 times
for (int i = 0; i < 5; i++) {
if (commitSemaphore.tryAcquire()) {
try {
refreshHead(true);
SegmentNodeState state = head.get();
SegmentNodeBuilder builder = state.builder();
NodeBuilder cp = builder.child("checkpoints").child(name);
if (cp.exists()) {
cp.remove();
SegmentNodeState newState = builder.getNodeState();
if (revisions.setHead(state.getRecordId(), newState.getRecordId())) {
refreshHead(false);
return true;
}
}
} finally {
commitSemaphore.release();
}
}
}
return false;
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class SameNameSiblingTest method createNodeStore.
@Override
protected NodeStore createNodeStore(NodeStoreFixture fixture) throws RepositoryException {
try {
NodeStore nodeStore = super.createNodeStore(fixture);
NodeBuilder root = nodeStore.getRoot().builder();
NodeBuilder sns = root.setChildNode("sns");
sns.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
for (String sibling : asList(SIBLING, SIBLINGS)) {
if (!sibling.endsWith("[1]")) {
sns.setChildNode(sibling).setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
}
}
nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
return nodeStore;
} catch (CommitFailedException e) {
throw new RepositoryException(e);
}
}
Aggregations