Search in sources :

Example 26 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class MigrationFactory method createUpgrade.

public RepositoryUpgrade createUpgrade() throws IOException, RepositoryException, CliArgumentException {
    RepositoryContext src = stores.getSrcStore().create(closer);
    BlobStore srcBlobStore = new DataStoreBlobStore(src.getDataStore());
    NodeStore dstStore = createTarget(closer, srcBlobStore);
    return createUpgrade(src, dstStore);
}
Also used : RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 27 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class MigrationFactory method createTarget.

protected NodeStore createTarget(Closer closer, BlobStore srcBlobStore) throws IOException {
    BlobStore dstBlobStore = datastores.getDstBlobStore(srcBlobStore).create(closer);
    NodeStore dstStore = stores.getDstStore().create(dstBlobStore, closer);
    return dstStore;
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 28 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class StandbyDiff method readBlob.

private void readBlob(String blobId, String pName) throws InterruptedException {
    byte[] data = client.getBlob(blobId);
    if (data == null) {
        throw new IllegalStateException("Unable to load remote blob " + blobId + " at " + path + "#" + pName);
    }
    try {
        BlobStore blobStore = store.getBlobStore();
        assert blobStore != null : "Blob store must not be null";
        blobStore.writeBlob(new ByteArrayInputStream(data));
    } catch (IOException f) {
        throw new IllegalStateException("Unable to persist blob " + blobId + " at " + path + "#" + pName, f);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Example 29 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class BlobStoreFixtureProviderTest method readOnlyFileDataStore.

@Test
public void readOnlyFileDataStore() throws Exception {
    String[] args = { "--fds-path", temporaryFolder.getRoot().getAbsolutePath() };
    try (BlobStoreFixture fixture = BlobStoreFixtureProvider.create(createFDSOptions(args))) {
        try {
            BlobStore blobStore = fixture.getBlobStore();
            assertThat(blobStore, instanceOf(GarbageCollectableBlobStore.class));
            assertThat(blobStore, instanceOf(TypedDataStore.class));
            assertThat(blobStore, instanceOf(BlobTrackingStore.class));
            fixture.getBlobStore().writeBlob(new ByteArrayInputStream("foo".getBytes()));
            fail();
        } catch (Exception ignore) {
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GarbageCollectableBlobStore(org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore) BlobTrackingStore(org.apache.jackrabbit.oak.plugins.blob.BlobTrackingStore) TypedDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.TypedDataStore) GarbageCollectableBlobStore(org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) IOException(java.io.IOException) Test(org.junit.Test)

Example 30 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class NodeStoreFixtureProvider method create.

public static NodeStoreFixture create(Options options, boolean readOnly) throws Exception {
    CommonOptions commonOpts = options.getOptionBean(CommonOptions.class);
    Whiteboard wb = options.getWhiteboard();
    Closer closer = Closer.create();
    BlobStoreFixture blobFixture = BlobStoreFixtureProvider.create(options);
    BlobStore blobStore = null;
    if (blobFixture != null) {
        blobStore = blobFixture.getBlobStore();
        closer.register(blobFixture);
    }
    StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer);
    wb.register(StatisticsProvider.class, statisticsProvider, Collections.emptyMap());
    NodeStore store;
    if (commonOpts.isMongo() || commonOpts.isRDB()) {
        store = configureDocumentMk(options, blobStore, statisticsProvider, closer, wb, readOnly);
    } else {
        store = configureSegment(options, blobStore, statisticsProvider, closer, readOnly);
    }
    return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Also used : Closer(com.google.common.io.Closer) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Aggregations

BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)31 Test (org.junit.Test)14 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)9 GarbageCollectableBlobStore (org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore)9 File (java.io.File)8 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)8 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataStoreUtils.getBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreUtils.getBlobStore)6 IOException (java.io.IOException)5 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)4 DataStore (org.apache.jackrabbit.core.data.DataStore)3 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)3 Closer (com.google.common.io.Closer)2 Hashtable (java.util.Hashtable)2 Oak (org.apache.jackrabbit.oak.Oak)2 BlobTrackingStore (org.apache.jackrabbit.oak.plugins.blob.BlobTrackingStore)2 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)2 FileBlobStore (org.apache.jackrabbit.oak.spi.blob.FileBlobStore)2 DefaultSplitBlobStore (org.apache.jackrabbit.oak.spi.blob.split.DefaultSplitBlobStore)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2