Search in sources :

Example 61 with NodeBuilder

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());
}
Also used : CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 62 with NodeBuilder

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");
        }
    }
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 63 with NodeBuilder

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);
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Result(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result) Test(org.junit.Test)

Example 64 with NodeBuilder

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;
}
Also used : SegmentNodeBuilder(org.apache.jackrabbit.oak.segment.SegmentNodeBuilder) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) SegmentNodeBuilder(org.apache.jackrabbit.oak.segment.SegmentNodeBuilder) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 65 with NodeBuilder

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);
    }
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) RepositoryException(javax.jcr.RepositoryException) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26