use of com.microsoft.azure.storage.blob.CloudBlobDirectory 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;
}
use of com.microsoft.azure.storage.blob.CloudBlobDirectory in project crate by crate.
the class AzureStorageService method children.
public Set<String> children(String account, String container, BlobPath path) throws URISyntaxException, StorageException {
final var blobsBuilder = new HashSet<String>();
final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client();
final CloudBlobContainer blobContainer = client.v1().getContainerReference(container);
final String keyPath = path.buildAsString();
final EnumSet<BlobListingDetails> enumBlobListingDetails = EnumSet.of(BlobListingDetails.METADATA);
for (ListBlobItem blobItem : blobContainer.listBlobs(keyPath, false, enumBlobListingDetails, null, client.v2().get())) {
if (blobItem instanceof CloudBlobDirectory) {
final URI uri = blobItem.getUri();
LOGGER.trace(() -> new ParameterizedMessage("blob url [{}]", uri));
// uri.getPath is of the form /container/keyPath.* and we want to strip off the /container/
// this requires 1 + container.length() + 1, with each 1 corresponding to one of the /.
// Lastly, we add the length of keyPath to the offset to strip this container's path.
final String uriPath = uri.getPath();
blobsBuilder.add(uriPath.substring(1 + container.length() + 1 + keyPath.length(), uriPath.length() - 1));
}
}
return Set.copyOf(blobsBuilder);
}
Aggregations