Search in sources :

Example 91 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method customTikaConfig.

@Test
public void customTikaConfig() throws Exception {
    NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING));
    IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertFalse(defn.hasCustomTikaConfig());
    defnb.child(LuceneIndexConstants.TIKA).child(LuceneIndexConstants.TIKA_CONFIG).child(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_DATA, "hello".getBytes());
    defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertTrue(defn.hasCustomTikaConfig());
}
Also used : LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 92 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method maxExtractLength.

@Test
public void maxExtractLength() throws Exception {
    NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING));
    IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertEquals(-IndexDefinition.DEFAULT_MAX_EXTRACT_LENGTH * IndexDefinition.DEFAULT_MAX_FIELD_LENGTH, defn.getMaxExtractLength());
    defnb.child(TIKA).setProperty(LuceneIndexConstants.TIKA_MAX_EXTRACT_LENGTH, 1000);
    defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertEquals(1000, defn.getMaxExtractLength());
}
Also used : LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 93 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class CompactionEstimatorTest method testGainEstimator.

@Test
public void testGainEstimator() throws Exception {
    final int MB = 1024 * 1024;
    final int blobSize = 2 * MB;
    FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(2).withMemoryMapping(false).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    // 1. Create some blob properties
    NodeBuilder builder = nodeStore.getRoot().builder();
    NodeBuilder c1 = builder.child("c1");
    c1.setProperty("a", createBlob(nodeStore, blobSize));
    c1.setProperty("b", "foo");
    NodeBuilder c2 = builder.child("c2");
    c2.setProperty("a", createBlob(nodeStore, blobSize));
    c2.setProperty("b", "foo");
    NodeBuilder c3 = builder.child("c3");
    c3.setProperty("a", createBlob(nodeStore, blobSize));
    c3.setProperty("b", "foo");
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // 2. Now remove the property
    builder = nodeStore.getRoot().builder();
    builder.child("c1").remove();
    builder.child("c2").remove();
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    fileStore.flush();
    try {
        GCEstimation est = fileStore.estimateCompactionGain();
        assertTrue(est.gcNeeded());
    } finally {
        fileStore.close();
    }
}
Also used : SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 94 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class LargeNumberOfPropertiesTestIT method corruption.

@Test
public void corruption() throws Exception {
    FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(5).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withMemoryMapping(true).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    NodeBuilder root = nodeStore.getRoot().builder();
    try {
        NodeBuilder c = root.child("c" + System.currentTimeMillis());
        // have (262144)
        for (int i = 0; i < 25; i++) {
            LOG.debug("run {}/24", i);
            for (int j = 0; j < 10000; j++) {
                c.setProperty("int-" + i + "-" + j, i);
            }
        }
        nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    } finally {
        fileStore.close();
    }
}
Also used : SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 95 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class RepeatedRepositoryUpgradeTest method doUpgradeRepository.

protected void doUpgradeRepository(File source, NodeStore target, boolean skipInit) throws RepositoryException, IOException {
    final RepositoryConfig config = RepositoryConfig.create(source);
    final RepositoryContext context = RepositoryContext.create(config);
    try {
        final RepositoryUpgrade repositoryUpgrade = new RepositoryUpgrade(context, target);
        repositoryUpgrade.setSkipInitialization(skipInit);
        repositoryUpgrade.copy(new RepositoryInitializer() {

            @Override
            public void initialize(@Nonnull NodeBuilder builder) {
                builder.child("foo").child("bar");
            }
        });
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

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