Search in sources :

Example 6 with SegmentNodeStore

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

the class FileStoreBackupTest method testBackup.

@Test
public void testBackup() throws Exception {
    FileStore source = newFileStore(src);
    SegmentNodeStore store = SegmentNodeStoreBuilders.builder(source).build();
    FileStoreBackup fsb = new FileStoreBackupImpl();
    try {
        init(store);
        source.flush();
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
        addTestContent(store);
        source.flush();
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
        source.compact();
        fsb.cleanup(source);
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
    } finally {
        source.close();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) FileStoreBackupImpl(org.apache.jackrabbit.oak.backup.impl.FileStoreBackupImpl) Test(org.junit.Test)

Example 7 with SegmentNodeStore

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

the class FileStoreBackupTest method testRestore.

@Test
public void testRestore() throws Exception {
    FileStore source = newFileStore(src);
    SegmentNodeStore store = SegmentNodeStoreBuilders.builder(source).build();
    FileStoreBackup fsb = new FileStoreBackupImpl();
    FileStoreRestore fsr = new FileStoreRestoreImpl();
    init(store);
    source.flush();
    fsb.backup(source.getReader(), source.getRevisions(), destination);
    source.close();
    fsr.restore(destination, src);
    source = newFileStore(src);
    compare(source, destination);
    source.close();
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) FileStoreRestoreImpl(org.apache.jackrabbit.oak.backup.impl.FileStoreRestoreImpl) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) FileStoreBackupImpl(org.apache.jackrabbit.oak.backup.impl.FileStoreBackupImpl) Test(org.junit.Test)

Example 8 with SegmentNodeStore

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

the class ReferenceBinaryIT method fixtures.

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> fixtures() throws Exception {
    File file = getTestDir("tar");
    FileStore fileStore = FileStoreBuilder.fileStoreBuilder(file).withBlobStore(createBlobStore()).withMaxFileSize(256).withMemoryMapping(true).build();
    SegmentNodeStore sns = SegmentNodeStoreBuilders.builder(fileStore).build();
    List<Object[]> fixtures = Lists.newArrayList();
    SegmentTarFixture segmentTarFixture = new SegmentTarFixture(sns);
    if (segmentTarFixture.isAvailable()) {
        fixtures.add(new Object[] { segmentTarFixture });
    }
    FileBlobStore fbs = new FileBlobStore(getTestDir("fbs1").getAbsolutePath());
    fbs.setReferenceKeyPlainText("foobar");
    FileStore fileStoreWithFBS = FileStoreBuilder.fileStoreBuilder(getTestDir("tar2")).withBlobStore(fbs).withMaxFileSize(256).withMemoryMapping(true).build();
    SegmentNodeStore snsWithFBS = SegmentNodeStoreBuilders.builder(fileStoreWithFBS).build();
    SegmentTarFixture segmentTarFixtureFBS = new SegmentTarFixture(snsWithFBS);
    if (segmentTarFixtureFBS.isAvailable()) {
        fixtures.add(new Object[] { segmentTarFixtureFBS });
    }
    DocumentMongoFixture documentFixture = new DocumentMongoFixture(MongoUtils.URL, createBlobStore());
    if (documentFixture.isAvailable()) {
        fixtures.add(new Object[] { documentFixture });
    }
    return fixtures;
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) DocumentMongoFixture(org.apache.jackrabbit.oak.fixture.DocumentMongoFixture) FileBlobStore(org.apache.jackrabbit.oak.spi.blob.FileBlobStore) SegmentTarFixture(org.apache.jackrabbit.oak.segment.fixture.SegmentTarFixture) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File)

Example 9 with SegmentNodeStore

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

the class NodeStateTestUtils method createNodeStoreWithContent.

public static NodeStore createNodeStoreWithContent(String... paths) throws CommitFailedException, IOException {
    final SegmentNodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    final NodeBuilder builder = store.getRoot().builder();
    for (String path : paths) {
        create(builder, path);
    }
    commit(store, builder);
    return store;
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 10 with SegmentNodeStore

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

the class OakDirectoryTest method dirNameInException_Writes.

@Test
public void dirNameInException_Writes() throws Exception {
    FailOnDemandBlobStore blobStore = new FailOnDemandBlobStore();
    FileStore store = FileStoreBuilder.fileStoreBuilder(tempFolder.getRoot()).withMemoryMapping(false).withBlobStore(blobStore).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    String indexPath = "/foo/bar";
    int minFileSize = SegmentTestConstants.MEDIUM_LIMIT;
    int blobSize = minFileSize + 1000;
    builder = nodeStore.getRoot().builder();
    builder.setProperty(LuceneIndexConstants.BLOB_SIZE, blobSize);
    Directory dir = createDir(builder, false, indexPath);
    blobStore.startFailing();
    IndexOutput o = dir.createOutput("test1.txt", IOContext.DEFAULT);
    try {
        o.writeBytes(randomBytes(blobSize + 10), blobSize + 10);
        fail();
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString(indexPath));
        assertThat(e.getMessage(), containsString("test1.txt"));
    }
    blobStore.reset();
    IndexOutput o3 = dir.createOutput("test3.txt", IOContext.DEFAULT);
    o3.writeBytes(randomBytes(minFileSize), minFileSize);
    blobStore.startFailing();
    try {
        o3.flush();
        fail();
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString(indexPath));
        assertThat(e.getMessage(), containsString("test3.txt"));
    }
    store.close();
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) IndexOutput(org.apache.lucene.store.IndexOutput) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IOException(java.io.IOException) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) Directory(org.apache.lucene.store.Directory) Test(org.junit.Test)

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