Search in sources :

Example 11 with DataStoreBlobStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore in project jackrabbit-oak by apache.

the class ReadOnlyBlobStoreWrapperTest method readOnly.

@Test
public void readOnly() throws Exception {
    FileDataStore fds = new FileDataStore();
    fds.setPath(temporaryFolder.getRoot().getAbsolutePath());
    fds.init(null);
    DataStoreBlobStore writableBS = new DataStoreBlobStore(fds);
    BlobStore readOnly = ReadOnlyBlobStoreWrapper.wrap(writableBS);
    try {
        readOnly.writeBlob(new ByteArrayInputStream("foo".getBytes()));
        fail();
    } catch (Exception ignore) {
    }
    String blobId = writableBS.writeBlob(new ByteArrayInputStream("foo".getBytes()));
    try (InputStream is = readOnly.getInputStream(blobId)) {
        assertNotNull(is);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) 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) Test(org.junit.Test)

Example 12 with DataStoreBlobStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore in project jackrabbit-oak by apache.

the class LuceneIndexProviderServiceTest method blobStoreRegistered.

@Test
public void blobStoreRegistered() throws Exception {
    MockOsgi.activate(service, context.bundleContext(), getDefaultConfig());
    LuceneIndexEditorProvider editorProvider = (LuceneIndexEditorProvider) context.getService(IndexEditorProvider.class);
    assertNull(editorProvider.getBlobStore());
    /* Register a blob store */
    CachingFileDataStore ds = DataStoreUtils.createCachingFDS(folder.newFolder().getAbsolutePath(), folder.newFolder().getAbsolutePath());
    service.bindBlobStore(new DataStoreBlobStore(ds));
    assertNotNull(editorProvider.getBlobStore());
}
Also used : CachingFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Test(org.junit.Test)

Example 13 with DataStoreBlobStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore in project jackrabbit-oak by apache.

the class LuceneBlobCacheTest method setUp.

@Before
public void setUp() throws Exception {
    fileDataStore = new ReadAccessCountingDataStore();
    fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
    FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
    store = fileStoreBuilder.build();
    NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    root = nodeStore.getRoot();
    builder = root.builder();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Before(org.junit.Before)

Example 14 with DataStoreBlobStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore in project jackrabbit-oak by apache.

the class FileDataStoreFactory method create.

@Override
public BlobStore create(Closer closer) {
    OakFileDataStore delegate = new OakFileDataStore();
    delegate.setPath(directory);
    delegate.init(null);
    closer.register(asCloseable(delegate));
    if (ignoreMissingBlobs) {
        return new SafeDataStoreBlobStore(delegate);
    } else {
        return new DataStoreBlobStore(delegate);
    }
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 15 with DataStoreBlobStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore in project jackrabbit-oak by apache.

the class S3DataStoreFactory method create.

@Override
public BlobStore create(Closer closer) throws IOException {
    S3DataStore delegate = new S3DataStore();
    delegate.setProperties(props);
    delegate.setPath(directory);
    try {
        delegate.init(tempHomeDir.getPath());
    } catch (RepositoryException e) {
        throw new IOException(e);
    }
    closer.register(asCloseable(delegate, tempHomeDir));
    if (ignoreMissingBlobs) {
        return new SafeDataStoreBlobStore(delegate);
    } else {
        return new DataStoreBlobStore(delegate);
    }
}
Also used : S3DataStore(org.apache.jackrabbit.aws.ext.ds.S3DataStore) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Aggregations

DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)33 File (java.io.File)12 Properties (java.util.Properties)12 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)11 Test (org.junit.Test)10 DataStore (org.apache.jackrabbit.core.data.DataStore)5 OakFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore)5 Before (org.junit.Before)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Random (java.util.Random)4 CachingFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore)4 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)4 Blob (org.apache.jackrabbit.oak.api.Blob)3 AbstractBlob (org.apache.jackrabbit.oak.plugins.memory.AbstractBlob)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Closer (com.google.common.io.Closer)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Date (java.util.Date)2