Search in sources :

Example 51 with FileStore

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

Example 52 with FileStore

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

the class FailoverSslTestIT method synchronizeAndCompareHead.

private boolean synchronizeAndCompareHead(StandbyServerSync serverSync, StandbyClientSync clientSync) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    serverSync.start();
    addTestContent(store, "server");
    // this speeds up the test a little bit...
    storeS.flush();
    clientSync.run();
    return storeS.getHead().equals(storeC.getHead());
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore)

Example 53 with FileStore

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

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

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

the class NodeStoreFixtureProvider method configureSegment.

private static NodeStore configureSegment(Options options, BlobStore blobStore, StatisticsProvider statisticsProvider, Closer closer, boolean readOnly) throws IOException, InvalidFileStoreVersionException {
    String path = options.getOptionBean(CommonOptions.class).getStoreArg();
    FileStoreBuilder builder = fileStoreBuilder(new File(path)).withMaxFileSize(256);
    if (blobStore != null) {
        builder.withBlobStore(blobStore);
    }
    NodeStore nodeStore;
    if (readOnly) {
        ReadOnlyFileStore fileStore = builder.withStatisticsProvider(statisticsProvider).buildReadOnly();
        closer.register(fileStore);
        nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    } else {
        FileStore fileStore = builder.withStatisticsProvider(statisticsProvider).build();
        closer.register(fileStore);
        nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    }
    return nodeStore;
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) File(java.io.File)

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