Search in sources :

Example 6 with FileStore

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

the class FileStoreBackupTest method compare.

private static void compare(FileStore store, File destination) throws Exception {
    FileStore backup = fileStoreBuilder(destination).build();
    assertEquals(store.getHead(), backup.getHead());
    backup.close();
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore)

Example 7 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore 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 FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore 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)

Example 9 with FileStore

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

the class ReadOnlyStoreTest method initStoreAt.

private static void initStoreAt(File path) throws InvalidFileStoreVersionException, IOException {
    FileStore store = fileStoreBuilder(path).build();
    store.close();
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore)

Example 10 with FileStore

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

the class NodeRecordTest method unreferencedNodeRecordShouldBeRoot.

@Test
public void unreferencedNodeRecordShouldBeRoot() throws Exception {
    try (FileStore store = newFileStore()) {
        SegmentWriter writer = SegmentWriterBuilder.segmentWriterBuilder("test").build(store);
        SegmentNodeState state = writer.writeNode(EmptyNodeState.EMPTY_NODE);
        writer.flush();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) Test(org.junit.Test)

Aggregations

FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)106 Test (org.junit.Test)70 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)41 File (java.io.File)25 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)25 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)18 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)18 IOException (java.io.IOException)17 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)13 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)13 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)12 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)11 Blob (org.apache.jackrabbit.oak.api.Blob)10 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)9 Before (org.junit.Before)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)7