Search in sources :

Example 16 with SegmentNodeStore

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

the class IncludeExcludeSidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (targetNodeStore == null) {
        File directory = getTestDirectory();
        File source = new File(directory, "source");
        source.mkdirs();
        FileStore fileStore = fileStoreBuilder(source).build();
        SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(source, target);
        targetNodeStore = target;
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Example 17 with SegmentNodeStore

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

the class IncludeExcludeSidegradeTest method doUpgradeRepository.

@Override
protected void doUpgradeRepository(File source, NodeStore target) throws RepositoryException, IOException {
    FileStore fileStore;
    try {
        fileStore = fileStoreBuilder(source).build();
    } catch (InvalidFileStoreVersionException e) {
        throw new IllegalStateException(e);
    }
    SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    try {
        final RepositorySidegrade sidegrade = new RepositorySidegrade(segmentNodeStore, target);
        sidegrade.setIncludes("/content/foo/en", "/content/assets/foo", "/content/other");
        sidegrade.setExcludes("/content/assets/foo/2013", "/content/assets/foo/2012", "/content/assets/foo/2011", "/content/assets/foo/2010");
        sidegrade.setExcludeFragments("oak-mount-libs-xyz");
        sidegrade.setFragmentPaths("/content/other/path");
        sidegrade.copy();
    } finally {
        fileStore.close();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore)

Example 18 with SegmentNodeStore

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

the class OakDirectoryTest method largeFile.

@Test
public void largeFile() throws Exception {
    FileStore store = FileStoreBuilder.fileStoreBuilder(tempFolder.getRoot()).withMemoryMapping(false).withBlobStore(new BlackHoleBlobStore()).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    IndexDefinition defn = new IndexDefinition(INITIAL_CONTENT, EmptyNodeState.EMPTY_NODE, "/foo");
    Directory directory = new OakDirectory(nodeStore.getRoot().builder(), defn, false);
    long expectedSize = ONE_GB * 2 + ONE_MB;
    String fileName = "test";
    writeFile(directory, fileName, expectedSize);
    assertEquals(expectedSize, directory.fileLength(fileName));
    IndexInput input = directory.openInput(fileName, IOContext.DEFAULT);
    readInputToEnd(expectedSize, input);
    store.close();
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) IndexInput(org.apache.lucene.store.IndexInput) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) Directory(org.apache.lucene.store.Directory) Test(org.junit.Test)

Example 19 with SegmentNodeStore

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

the class RepeatedRepositorySidegradeTest method doUpgradeRepository.

@Override
protected void doUpgradeRepository(File source, NodeStore target, boolean skipInit) throws RepositoryException, IOException {
    FileStore fileStore;
    try {
        fileStore = fileStoreBuilder(source).build();
    } catch (InvalidFileStoreVersionException e) {
        throw new IllegalStateException(e);
    }
    SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    try {
        final RepositorySidegrade repositoryUpgrade = new RepositorySidegrade(segmentNodeStore, target);
        NodeBuilder builder = target.getRoot().builder();
        builder.child("foo").child("bar");
        target.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        repositoryUpgrade.copy();
    } catch (CommitFailedException e) {
        throw new RepositoryException(e);
    } finally {
        fileStore.close();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) RepositoryException(javax.jcr.RepositoryException) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

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