Search in sources :

Example 11 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.

the class BrokenVersionableTest method createSourceContent.

private NodeStore createSourceContent() throws Exception {
    SegmentNodeStore source = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(source)).createRepository();
    Session session = repository.login(CREDENTIALS);
    List<String> versionHistoryPaths = new ArrayList<String>();
    try {
        CndImporter.registerNodeTypes(new StringReader("<test = 'http://jackrabbit.apache.org/ns/test'>\n" + "[test:Versionable] > nt:unstructured, mix:versionable"), session);
        Node root = session.getRootNode();
        Node versionable1 = root.addNode("versionable1", NT_UNSTRUCTURED);
        versionable1.addMixin(MIX_VERSIONABLE);
        versionable1.addNode("child", NT_UNSTRUCTURED);
        Node versionable2 = root.addNode("versionable2", "test:Versionable");
        versionable2.addNode("child", NT_UNSTRUCTURED);
        session.save();
        VersionManager vMgr = session.getWorkspace().getVersionManager();
        vMgr.checkin("/versionable1");
        vMgr.checkin("/versionable2");
        versionHistoryPaths.add(vMgr.getVersionHistory("/versionable1").getPath());
        versionHistoryPaths.add(vMgr.getVersionHistory("/versionable2").getPath());
    } finally {
        session.logout();
        repository.shutdown();
    }
    // remove version history to corrupt the JCR repository structure
    NodeBuilder rootBuilder = source.getRoot().builder();
    for (String versionHistoryPath : versionHistoryPaths) {
        NodeStateTestUtils.createOrGetBuilder(rootBuilder, versionHistoryPath).remove();
    }
    source.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    return source;
}
Also used : Node(javax.jcr.Node) ArrayList(java.util.ArrayList) VersionManager(javax.jcr.version.VersionManager) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) StringReader(java.io.StringReader) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 12 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.

the class SegmentReferenceLimitTestIT method corruption.

@Test
public void corruption() throws Exception {
    FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withNodeDeduplicationCacheSize(1).withStringDeduplicationCacheSize(0).withTemplateDeduplicationCacheSize(0).withMemoryMapping(true).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    NodeBuilder root = nodeStore.getRoot().builder();
    root.setChildNode("test");
    nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    List<FutureTask<Void>> l = new ArrayList<FutureTask<Void>>();
    for (int i = 0; i < 10; i++) {
        l.add(run(new Worker(nodeStore, "w" + i)));
    }
    try {
        for (FutureTask<Void> w : l) {
            w.get();
        }
    } finally {
        fileStore.close();
    }
}
Also used : FutureTask(java.util.concurrent.FutureTask) ArrayList(java.util.ArrayList) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 13 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.

the class FileStoreStatsTest method testJournalWriteStats.

@Test
public void testJournalWriteStats() throws Exception {
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
    FileStore fileStore = fileStoreBuilder(segmentFolder.newFolder()).withStatisticsProvider(statsProvider).build();
    FileStoreStats stats = new FileStoreStats(statsProvider, fileStore, 0);
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    for (int i = 0; i < 10; i++) {
        NodeBuilder root = nodeStore.getRoot().builder();
        root.setProperty("count", i);
        nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        fileStore.flush();
    }
    assertEquals(10, stats.getJournalWriteStatsAsCount());
}
Also used : DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Test(org.junit.Test)

Example 14 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.

the class CheckRepositoryTestBase method addValidRevision.

protected void addValidRevision() throws InvalidFileStoreVersionException, IOException, CommitFailedException {
    FileStore fileStore = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMaxFileSize(256).withSegmentCacheSize(64).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    NodeBuilder builder = nodeStore.getRoot().builder();
    addChildWithBlobProperties(nodeStore, builder, "a", 1);
    addChildWithBlobProperties(nodeStore, builder, "b", 2);
    addChildWithBlobProperties(nodeStore, builder, "c", 3);
    addChildWithProperties(nodeStore, builder, "d", 4);
    addChildWithProperties(nodeStore, builder, "e", 5);
    addChildWithProperties(nodeStore, builder, "f", 6);
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    fileStore.close();
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 15 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.

the class CheckRepositoryTestBase method addInvalidRevision.

protected void addInvalidRevision() throws InvalidFileStoreVersionException, IOException, CommitFailedException {
    FileStore fileStore = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMaxFileSize(256).withSegmentCacheSize(64).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    NodeBuilder builder = nodeStore.getRoot().builder();
    // add a new child "z"
    addChildWithBlobProperties(nodeStore, builder, "z", 5);
    // add a new property value to existing child "a"
    addChildWithBlobProperties(nodeStore, builder, "a", 1);
    NodeState after = nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // get record number to corrupt (NODE record for "z")
    SegmentNodeState child = (SegmentNodeState) after.getChildNode("z");
    int zRecordNumber = child.getRecordId().getRecordNumber();
    // get record number to corrupt (NODE record for "a")
    child = (SegmentNodeState) after.getChildNode("a");
    int aRecordNumber = child.getRecordId().getRecordNumber();
    fileStore.close();
    corruptRecord(zRecordNumber);
    corruptRecord(aRecordNumber);
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState)

Aggregations

SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)19 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)11 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 Test (org.junit.Test)10 File (java.io.File)4 Session (javax.jcr.Session)3 Oak (org.apache.jackrabbit.oak.Oak)3 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)3 RepositoryImpl (org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl)3 MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)3 ArrayList (java.util.ArrayList)2 FileStoreBackupImpl (org.apache.jackrabbit.oak.backup.impl.FileStoreBackupImpl)2 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 Directory (org.apache.lucene.store.Directory)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1