use of com.microsoft.azure.storage.blob.CloudBlobDirectory 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 com.microsoft.azure.storage.blob.CloudBlobDirectory in project jackrabbit-oak by apache.
the class AzureArchiveManager method copyFile.
@Override
public void copyFile(String from, String to) throws IOException {
CloudBlobDirectory targetDirectory = getDirectory(to);
getBlobs(from).forEach(cloudBlob -> {
try {
copyBlob(cloudBlob, targetDirectory);
} catch (IOException e) {
log.error("Can't copy segment {}", cloudBlob.getUri().getPath(), e);
}
});
}
use of com.microsoft.azure.storage.blob.CloudBlobDirectory 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 com.microsoft.azure.storage.blob.CloudBlobDirectory in project jackrabbit-oak by apache.
the class AzurePersistence method segmentFilesExist.
@Override
public boolean segmentFilesExist() {
try {
for (ListBlobItem i : segmentstoreDirectory.listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null)) {
if (i instanceof CloudBlobDirectory) {
CloudBlobDirectory dir = (CloudBlobDirectory) i;
String name = Paths.get(dir.getPrefix()).getFileName().toString();
if (name.endsWith(".tar")) {
return true;
}
}
}
return false;
} catch (StorageException | URISyntaxException e) {
log.error("Can't check if the segment archives exists", e);
return false;
}
}
use of com.microsoft.azure.storage.blob.CloudBlobDirectory in project jackrabbit-oak by apache.
the class AzureBlobStoreBackend method addMetadataRecordImpl.
private void addMetadataRecordImpl(final InputStream input, String name, long recordLength) throws DataStoreException {
try {
CloudBlobDirectory metaDir = getAzureContainer().getDirectoryReference(META_DIR_NAME);
CloudBlockBlob blob = metaDir.getBlockBlobReference(name);
blob.upload(input, recordLength);
} catch (StorageException e) {
LOG.info("Error adding metadata record. metadataName={} length={}", name, recordLength, e);
throw new DataStoreException(e);
} catch (URISyntaxException | IOException e) {
throw new DataStoreException(e);
}
}
Aggregations