Search in sources :

Example 1 with AzurePersistence

use of org.apache.jackrabbit.oak.segment.azure.AzurePersistence in project jackrabbit-oak by apache.

the class SegmentTarFixture method getOak.

@Override
public Oak getOak(int clusterId) throws Exception {
    FileStoreBuilder fileStoreBuilder = fileStoreBuilder(parentPath).withMaxFileSize(maxFileSize).withSegmentCacheSize(segmentCacheSize).withMemoryMapping(memoryMapping);
    if (azureConnectionString != null) {
        CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
        CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
        container.createIfNotExists();
        CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath);
        fileStoreBuilder.withCustomPersistence(new AzurePersistence(directory));
    }
    if (useBlobStore) {
        FileDataStore fds = new FileDataStore();
        fds.setMinRecordLength(4092);
        fds.init(parentPath.getAbsolutePath());
        BlobStore blobStore = new DataStoreBlobStore(fds);
        fileStoreBuilder.withBlobStore(blobStore);
    }
    FileStore fs = fileStoreBuilder.build();
    return newOak(SegmentNodeStoreBuilders.builder(fs).build());
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) AzurePersistence(org.apache.jackrabbit.oak.segment.azure.AzurePersistence) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 2 with AzurePersistence

use of org.apache.jackrabbit.oak.segment.azure.AzurePersistence in project jackrabbit-oak by apache.

the class SegmentAzureFixture method createNodeStore.

@Override
public NodeStore createNodeStore() {
    AzurePersistence persistence;
    CloudBlobContainer container;
    try {
        CloudStorageAccount cloud = CloudStorageAccount.parse(AZURE_CONNECTION_STRING);
        int i = 1;
        while (true) {
            String containerName;
            if (i == 1) {
                containerName = AZURE_CONTAINER;
            } else {
                containerName = AZURE_CONTAINER + "_" + i;
            }
            container = cloud.createCloudBlobClient().getContainerReference(containerName);
            if (!container.exists()) {
                container.create();
                break;
            }
            i++;
        }
        CloudBlobDirectory directory = container.getDirectoryReference(AZURE_ROOT_PATH);
        persistence = new AzurePersistence(directory);
    } catch (StorageException | URISyntaxException | InvalidKeyException e) {
        throw new RuntimeException(e);
    }
    try {
        FileStore fileStore = FileStoreBuilder.fileStoreBuilder(Files.createTempDir()).withCustomPersistence(persistence).build();
        NodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        fileStoreMap.put(nodeStore, fileStore);
        containerMap.put(nodeStore, container);
        return nodeStore;
    } catch (IOException | InvalidFileStoreVersionException e) {
        throw new RuntimeException(e);
    }
}
Also used : AzurePersistence(org.apache.jackrabbit.oak.segment.azure.AzurePersistence) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) StorageException(com.microsoft.azure.storage.StorageException)

Example 3 with AzurePersistence

use of org.apache.jackrabbit.oak.segment.azure.AzurePersistence 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 (azureConnectionString != null) {
            CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
            CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
            container.createIfNotExists();
            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());
    }
    return cluster;
}
Also used : FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) AzurePersistence(org.apache.jackrabbit.oak.segment.azure.AzurePersistence) Oak(org.apache.jackrabbit.oak.Oak) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) 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)

Aggregations

CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)3 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)3 CloudBlobDirectory (com.microsoft.azure.storage.blob.CloudBlobDirectory)3 AzurePersistence (org.apache.jackrabbit.oak.segment.azure.AzurePersistence)3 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)2 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)2 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)2 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)2 StorageException (com.microsoft.azure.storage.StorageException)1 File (java.io.File)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)1 Oak (org.apache.jackrabbit.oak.Oak)1 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)1 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)1