@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; } }
@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; } }
/** * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. * * @param prefix * A <code>String</code> that represents the blob name prefix. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin * with the specified prefix in this directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(String prefix) throws URISyntaxException, StorageException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); }
/** * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. * * @param prefix * A <code>String</code> that represents the blob name prefix. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin * with the specified prefix in this directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(String prefix) throws URISyntaxException, StorageException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); }
/** * Returns a reference to a {@link CloudAppendBlob} object that represents an append blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudAppendBlob} object that represents a reference to the specified append blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudAppendBlob getAppendBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudAppendBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
/** * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudBlockBlob getBlockBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudBlockBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
/** * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. * * @param prefix * A <code>String</code> that represents the prefix of the blob name. * * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of * {@link ListBlobItem} objects that represent the blob items whose names begin with the specified prefix in * the directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public ResultSegment<ListBlobItem> listBlobsSegmented(String prefix) throws StorageException, URISyntaxException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix)); }
/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudPageBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
/** * Returns a reference to a {@link CloudAppendBlob} object that represents an append blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudAppendBlob} object that represents a reference to the specified append blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudAppendBlob getAppendBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudAppendBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
/** * Returns an enumerable collection of blob items for the directory. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this * container. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() throws StorageException, URISyntaxException { return this.getContainer().listBlobs(this.getPrefix()); }
/** * Returns a result segment of an enumerable collection of blob items in the directory. * * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of * {@link ListBlobItem} objects that represent the blob items in the directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public ResultSegment<ListBlobItem> listBlobsSegmented() throws StorageException, URISyntaxException { return this.getContainer().listBlobsSegmented(this.getPrefix()); }
/** * Returns an enumerable collection of blob items for the directory. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this * container. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() throws StorageException, URISyntaxException { return this.getContainer().listBlobs(this.getPrefix()); }
/** * Returns a result segment of an enumerable collection of blob items in the directory. * * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of * {@link ListBlobItem} objects that represent the blob items in the directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public ResultSegment<ListBlobItem> listBlobsSegmented() throws StorageException, URISyntaxException { return this.getContainer().listBlobsSegmented(this.getPrefix()); }
public Builder withSource(CloudBlobDirectory dir) throws URISyntaxException, StorageException { this.source = new AzurePersistence(dir); this.sourceName = storeDescription(SegmentStoreType.AZURE, dir.getContainer().getName() + "/" + dir.getPrefix()); return this; }
public Builder withTarget(CloudBlobDirectory dir) throws URISyntaxException, StorageException { this.target = new AzurePersistence(dir); this.targetName = storeDescription(SegmentStoreType.AZURE, dir.getContainer().getName() + "/" + dir.getPrefix()); return this; }
private void testHierarchicalTraversal(String delimiter, CloudBlobContainer container) throws StorageException, URISyntaxException { // Traverse hierarchically starting with length 1 CloudBlobDirectory directory1 = container.getDirectoryReference("Dir1" + delimiter); CloudBlobDirectory subdir1 = directory1.getDirectoryReference("Dir2"); CloudBlobDirectory parent1 = subdir1.getParent(); assertEquals(parent1.getPrefix(), directory1.getPrefix()); CloudBlobDirectory subdir2 = subdir1.getDirectoryReference("Dir3"); CloudBlobDirectory parent2 = subdir2.getParent(); assertEquals(parent2.getPrefix(), subdir1.getPrefix()); CloudBlobDirectory subdir3 = subdir2.getDirectoryReference("Dir4"); CloudBlobDirectory parent3 = subdir3.getParent(); assertEquals(parent3.getPrefix(), subdir2.getPrefix()); CloudBlobDirectory subdir4 = subdir3.getDirectoryReference("Dir5"); CloudBlobDirectory parent4 = subdir4.getParent(); assertEquals(parent4.getPrefix(), subdir3.getPrefix()); }
private void testParentValidate(String delimiter, CloudBlobContainer container) throws StorageException, URISyntaxException { CloudBlockBlob blob = container.getBlockBlobReference("TopDir1" + delimiter + "MidDir1" + delimiter + "EndDir1" + delimiter + "EndBlob1"); CloudBlobDirectory directory = blob.getParent(); assertEquals("TopDir1" + delimiter + "MidDir1" + delimiter + "EndDir1" + delimiter, directory.getPrefix()); assertEquals(new URI(container.getUri().getScheme(), container.getUri().getAuthority(), container.getUri() .getPath() + "/TopDir1" + delimiter + "MidDir1" + delimiter + "EndDir1" + delimiter, null, null), directory.getUri()); }
private void testGetSubdirectoryAndTraverseBackToParent(String delimiter, CloudBlobContainer container) throws URISyntaxException, StorageException { CloudBlobDirectory directory = container.getDirectoryReference("TopDir1" + delimiter); CloudBlobDirectory subDirectory = directory.getDirectoryReference("MidDir1" + delimiter); CloudBlobDirectory parent = subDirectory.getParent(); assertEquals(parent.getPrefix(), directory.getPrefix()); assertEquals(parent.getUri(), directory.getUri()); }
@NotNull public BlobDirectory createBlobDirectory(@NotNull StorageAccount storageAccount, @NotNull BlobDirectory parentBlobDirectory, @NotNull BlobDirectory blobDirectory) throws AzureCmdException { try { CloudBlobClient client = getCloudBlobClient(storageAccount); String containerName = parentBlobDirectory.getContainerName(); CloudBlobContainer container = client.getContainerReference(containerName); CloudBlobDirectory parentDirectory = container.getDirectoryReference(parentBlobDirectory.getPath()); CloudBlobDirectory directory = parentDirectory.getDirectoryReference(blobDirectory.getName()); String uri = directory.getUri() != null ? directory.getUri().toString() : ""; String path = Strings.nullToEmpty(directory.getPrefix()); blobDirectory.setUri(uri); blobDirectory.setContainerName(containerName); blobDirectory.setPath(path); return blobDirectory; } catch (Throwable t) { throw new AzureCmdException("Error creating the Blob Directory", t); } }
private void testGetParent(String delimiter, CloudBlobContainer container) throws URISyntaxException, StorageException { CloudPageBlob blob = container.getPageBlobReference("Dir1" + delimiter + "Blob1"); blob.create(0); try { assertTrue(blob.exists()); assertEquals(blob.getName(), "Dir1" + delimiter + "Blob1"); CloudBlobDirectory parent = blob.getParent(); assertEquals("Dir1" + delimiter, parent.getPrefix()); } finally { blob.deleteIfExists(); } }