Search in sources :

Example 51 with BlobStore

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

the class BinaryAccessUnsupportedIT method createRepository.

@Override
protected Repository createRepository(NodeStore nodeStore) {
    Whiteboard wb = new DefaultWhiteboard();
    BlobStore blobStore = getNodeStoreComponent(BlobStore.class);
    if (blobStore != null && blobStore instanceof BlobAccessProvider) {
        wb.register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.emptyMap());
    }
    return initJcr(new Jcr(nodeStore).with(wb)).createRepository();
}
Also used : BlobAccessProvider(org.apache.jackrabbit.oak.api.blob.BlobAccessProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Example 52 with BlobStore

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

the class SegmentMemoryNodeStoreFixture method createNodeStore.

@Override
public NodeStore createNodeStore() {
    try {
        log.info("Creating NodeStore using " + toString());
        File fileStoreRoot = FixtureUtils.createTempFolder();
        FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(fileStoreRoot).withNodeDeduplicationCacheSize(16384).withMaxFileSize(256).withMemoryMapping(false);
        File dataStoreFolder = null;
        BlobStore blobStore = null;
        DataStore dataStore = null;
        if (dataStoreFixture != null) {
            dataStore = dataStoreFixture.createDataStore();
            // init with a new folder inside a temporary one
            dataStoreFolder = FixtureUtils.createTempFolder();
            dataStore.init(dataStoreFolder.getAbsolutePath());
            blobStore = new DataStoreBlobStore(dataStore);
            fileStoreBuilder.withBlobStore(blobStore);
        }
        FileStore fileStore = fileStoreBuilder.build();
        NodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        // track all main components
        if (dataStore != null) {
            components.put(nodeStore, DataStore.class.getName(), dataStore);
            components.put(nodeStore, DataStore.class.getName() + ":folder", dataStoreFolder);
        }
        if (blobStore != null) {
            components.put(nodeStore, BlobStore.class.getName(), blobStore);
        }
        components.put(nodeStore, FileStore.class.getName(), fileStore);
        components.put(nodeStore, FileStore.class.getName() + ":root", fileStoreRoot);
        return nodeStore;
    } catch (IOException | InvalidFileStoreVersionException | RepositoryException e) {
        throw new AssertionError("Cannot create test repo fixture " + toString(), e);
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) DataStore(org.apache.jackrabbit.core.data.DataStore) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) File(java.io.File) 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 53 with BlobStore

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

the class BlobStoreFixture method getDataStore.

public static BlobStoreFixture getDataStore(final File basedir, final int fdsCacheInMB, final StatisticsProvider statisticsProvider) {
    return new BlobStoreFixture("DS") {

        private DataStore dataStore;

        private BlobStore blobStore;

        private File storeDir;

        private Map<String, ?> config;

        @Override
        public BlobStore setUp() {
            String className = System.getProperty("dataStore");
            checkNotNull(className, "No system property named 'dataStore' defined");
            try {
                dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance();
                config = getConfig();
                configure(dataStore, config);
                dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider);
                storeDir = new File(basedir, unique);
                dataStore.init(storeDir.getAbsolutePath());
                blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB);
                configure(blobStore);
                return blobStore;
            } catch (Exception e) {
                throw new IllegalStateException("Cannot instantiate DataStore " + className, e);
            }
        }

        @Override
        public void tearDown() {
            if (blobStore instanceof DataStoreBlobStore) {
                try {
                    ((DataStoreBlobStore) blobStore).close();
                    cleanup(storeDir, config, unique.toLowerCase());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        @Override
        public long size() {
            throw new UnsupportedOperationException("Implementation pending");
        }
    };
}
Also used : DataStoreUtils.configureIfCloudDataStore(org.apache.jackrabbit.oak.fixture.DataStoreUtils.configureIfCloudDataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) File(java.io.File) Map(java.util.Map) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) FileBlobStore(org.apache.jackrabbit.oak.spi.blob.FileBlobStore) IOException(java.io.IOException) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 54 with BlobStore

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

the class SegmentTarFixture method setUpCluster.

@Override
public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Exception {
    init(n);
    Oak[] cluster = new Oak[n];
    for (int i = 0; i < cluster.length; i++) {
        BlobStore blobStore = null;
        if (useBlobStore) {
            blobStoreFixtures[i] = BlobStoreFixture.create(parentPath, true, dsCacheSize, statsProvider);
            blobStore = blobStoreFixtures[i].setUp();
        }
        FileStoreBuilder builder = fileStoreBuilder(new File(parentPath, "primary-" + i));
        if (awsBucketName != null) {
            Configuration config = getAwsConfig(awsBucketName + "-" + i, awsRootPath, awsJournalTableName + "-" + i, awsLockTableName + "-" + i);
            AwsContext awsContext = AwsContext.create(config);
            builder.withCustomPersistence(new AwsPersistence(awsContext));
        }
        if (azureConnectionString != null) {
            CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
            CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
            container.createIfNotExists();
            containers[i] = container;
            CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath + "/primary-" + i);
            builder.withCustomPersistence(new AzurePersistence(directory));
        }
        if (blobStore != null) {
            builder.withBlobStore(blobStore);
        }
        stores[i] = builder.withMaxFileSize(maxFileSize).withStatisticsProvider(statsProvider).withSegmentCacheSize(segmentCacheSize).withMemoryMapping(memoryMapping).withStrictVersionCheck(true).build();
        if (withColdStandby) {
            attachStandby(i, n, statsProvider, blobStore);
        }
        cluster[i] = newOak(SegmentNodeStoreBuilders.builder(stores[i]).build());
        if (blobStore != null) {
            cluster[i].getWhiteboard().register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
        }
    }
    return cluster;
}
Also used : Configuration(org.apache.jackrabbit.oak.segment.aws.Configuration) AzurePersistence(org.apache.jackrabbit.oak.segment.azure.AzurePersistence) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) AwsPersistence(org.apache.jackrabbit.oak.segment.aws.AwsPersistence) Oak(org.apache.jackrabbit.oak.Oak) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) File(java.io.File) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) AwsContext(org.apache.jackrabbit.oak.segment.aws.AwsContext)

Example 55 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);
    Closer closer = Closer.create();
    Whiteboard wb = new ClosingWhiteboard(options.getWhiteboard(), closer);
    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, emptyMap());
    NodeStore store;
    if (commonOpts.isMemory()) {
        store = new MemoryNodeStore();
    } else if (commonOpts.isMongo() || commonOpts.isRDB()) {
        DocumentNodeStore dns = DocumentFixtureProvider.configureDocumentMk(options, blobStore, wb, closer, readOnly);
        store = dns;
        if (blobStore == null) {
            blobStore = dns.getBlobStore();
        }
    } else if (commonOpts.isOldSegment()) {
        store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
    } else {
        try {
            store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly);
        } catch (InvalidFileStoreVersionException e) {
            if (oldSegmentStore(options)) {
                store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
            } else {
                throw e;
            }
        }
    }
    return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Also used : Closer(com.google.common.io.Closer) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) 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)64 Test (org.junit.Test)32 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)19 File (java.io.File)17 GarbageCollectableBlobStore (org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore)16 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)12 IOException (java.io.IOException)11 DataStoreUtils.getBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreUtils.getBlobStore)11 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataStore (org.apache.jackrabbit.core.data.DataStore)5 InputStream (java.io.InputStream)4 Parameters (junitparams.Parameters)4 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)4 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Before (org.junit.Before)4 Closer (com.google.common.io.Closer)3 ArrayList (java.util.ArrayList)3 RepositoryException (javax.jcr.RepositoryException)3 BlobAccessProvider (org.apache.jackrabbit.oak.api.blob.BlobAccessProvider)3