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());
}
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);
}
}
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;
}
Aggregations