com.microsoft.azure.storage.blob.BlobListingDetails Java Examples

The following examples show how to use com.microsoft.azure.storage.blob.BlobListingDetails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AzureBackuper.java    From cassandra-backup with Apache License 2.0 6 votes vote down vote up
private void deleteStaleBlobs() throws Exception {
    final Date expiryDate = Date.from(ZonedDateTime.now().minusWeeks(1).toInstant());

    final CloudBlobDirectory directoryReference = blobContainer.getDirectoryReference(request.storageLocation.clusterId + "/" + request.storageLocation.datacenterId);

    for (final ListBlobItem blob : directoryReference.listBlobs(null, true, EnumSet.noneOf(BlobListingDetails.class), null, null)) {
        if (!(blob instanceof CloudBlob)) {
            continue;
        }

        final BlobProperties properties = ((CloudBlob) blob).getProperties();
        if (properties == null || properties.getLastModified() == null) {
            continue;
        }

        if (properties.getLastModified().before(expiryDate)) {
            ((CloudBlob) blob).delete();
        }
    }
}
 
Example #2
Source File: AzureStorageService.java    From crate with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: AzureRestorer.java    From cassandra-backup with Apache License 2.0 5 votes vote down vote up
private Iterable<ListBlobItem> list(final Path prefix) {
    final String blobPrefix = Paths.get(request.storageLocation.clusterId)
        .resolve(request.storageLocation.datacenterId)
        .resolve(request.storageLocation.nodeId)
        .resolve(prefix).toString();

    return blobContainer.listBlobs(blobPrefix, true, EnumSet.noneOf(BlobListingDetails.class), null, null);
}
 
Example #4
Source File: AzureStorageService.java    From crate with Apache License 2.0 5 votes vote down vote up
public Map<String, BlobMetaData> listBlobsByPrefix(String container, String keyPath, String prefix)
    throws URISyntaxException, StorageException {
    // NOTE: this should be here: if (prefix == null) prefix = "";
    // however, this is really inefficient since deleteBlobsByPrefix enumerates everything and
    // then does a prefix match on the result; it should just call listBlobsByPrefix with the prefix!
    final var blobsBuilder = new HashMap<String, BlobMetaData>();
    final EnumSet<BlobListingDetails> enumBlobListingDetails = EnumSet.of(BlobListingDetails.METADATA);
    final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client();
    final CloudBlobContainer blobContainer = client.v1().getContainerReference(container);
    LOGGER.trace(() -> new ParameterizedMessage("listing container [{}], keyPath [{}], prefix [{}]", container, keyPath, prefix));
    for (final ListBlobItem blobItem : blobContainer.listBlobs(keyPath + (prefix == null ? "" : prefix), false,
        enumBlobListingDetails, null, client.v2().get())) {
        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 /
        final String blobPath = uri.getPath().substring(1 + container.length() + 1);
        if (blobItem instanceof CloudBlob) {
            final BlobProperties properties = ((CloudBlob) blobItem).getProperties();
            final String name = blobPath.substring(keyPath.length());
            LOGGER.trace(() -> new ParameterizedMessage("blob url [{}], name [{}], size [{}]", uri, name, properties.getLength()));
            blobsBuilder.put(name, new PlainBlobMetaData(name, properties.getLength()));
        }
    }

    return Map.copyOf(blobsBuilder);
}
 
Example #5
Source File: AzureStorageService.java    From crate with Apache License 2.0 5 votes vote down vote up
public void deleteFiles(String container, String path) throws URISyntaxException, StorageException {
    final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client();
    // container name must be lower case.
    LOGGER.trace(() -> new ParameterizedMessage("delete files container [{}], path [{}]", container, path));
    // list the blobs using a flat blob listing mode
    final CloudBlobContainer blobContainer = client.v1().getContainerReference(container);
    for (final ListBlobItem blobItem : blobContainer.listBlobs(path, true, EnumSet.noneOf(BlobListingDetails.class), null,
        client.v2().get())) {
        final String blobName = blobNameFromUri(blobItem.getUri());
        LOGGER.trace(() -> new ParameterizedMessage("removing blob [{}] full URI was [{}]", blobName, blobItem.getUri()));
        // don't call {@code #deleteBlob}, use the same client
        final CloudBlockBlob azureBlob = blobContainer.getBlockBlobReference(blobName);
        azureBlob.delete(DeleteSnapshotsOption.NONE, null, null, client.v2().get());
    }
}
 
Example #6
Source File: LogBlobIterable.java    From azure-storage-android with Apache License 2.0 5 votes vote down vote up
protected LogBlobIterable(final CloudBlobDirectory logDirectory, final Date startTime, final Date endTime,
        final EnumSet<LoggingOperations> operations, final EnumSet<BlobListingDetails> details,
        final BlobRequestOptions options, final OperationContext opContext) {
    this.logDirectory = logDirectory;
    this.startTime = startTime;
    this.endTime = endTime;
    this.operations = operations;
    this.details = details;
    this.options = options;
    this.opContext = opContext;
}
 
Example #7
Source File: LogBlobIterator.java    From azure-storage-android with Apache License 2.0 5 votes vote down vote up
public LogBlobIterator(final CloudBlobDirectory logDirectory, final Date startDate, final Date endDate,
        final EnumSet<LoggingOperations> operations, final EnumSet<BlobListingDetails> details,
        final BlobRequestOptions options, final OperationContext opContext) {
    TimeZone gmtTime = TimeZone.getTimeZone("GMT");
    HOUR_FORMAT.setTimeZone(gmtTime);
    DAY_FORMAT.setTimeZone(gmtTime);
    MONTH_FORMAT.setTimeZone(gmtTime);
    YEAR_FORMAT.setTimeZone(gmtTime);

    this.logDirectory = logDirectory;
    this.operations = operations;
    this.details = details;
    this.opContext = opContext;

    if (options == null) {
        this.options = new BlobRequestOptions();
    }
    else {
        this.options = options;
    }

    if (startDate != null) {
        this.startDate = new GregorianCalendar();
        this.startDate.setTime(startDate);
        this.startDate.add(GregorianCalendar.MINUTE, (-this.startDate.get(GregorianCalendar.MINUTE)));
        this.startDate.setTimeZone(gmtTime);
    }
    if (endDate != null) {
        this.endDate = new GregorianCalendar();
        this.endDate.setTime(endDate);
        this.endDate.setTimeZone(gmtTime);
        this.endPrefix = this.logDirectory.getPrefix() + HOUR_FORMAT.format(this.endDate.getTime());
    }
}
 
Example #8
Source File: CloudAnalyticsClient.java    From azure-storage-android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an enumerable collection of log blobs, retrieved lazily.
 * 
 * @param service
 *            A {@link StorageService} enumeration value that indicates which storage service to use.
 * @param startTime
 *            A <code>java.util.Date</code> object representing the start of the time range for which logs should
 *            be retrieved.
 * @param endTime
 *            A <code>java.util.Date</code> object representing the end of the time range for which logs should
 *            be retrieved.
 * @param operations
 *            A {@link LoggingOperations} enumeration set that indicates which log types to return.
 * @param details
 *            A {@link BlobListingDetails} enumeration set that indicates whether or not blob metadata should
 *            be returned. None or METADATA are the only valid values.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies additional options for the request.
 * @param operationContext
 *            An {@link OperationContext} object that represents the context for the current operation.
 * @return
 *         An enumerable collection of objects that implement {@link ListBlobItem} and are retrieved lazily.
 * @throws StorageException
 * @throws URISyntaxException
 */
public Iterable<ListBlobItem> listLogBlobs(StorageService service, Date startTime, Date endTime,
        EnumSet<LoggingOperations> operations, BlobListingDetails details, BlobRequestOptions options,
        OperationContext operationContext) throws StorageException, URISyntaxException {
    Utility.assertNotNull("service", service);
    if (operations == null) {
        operations = EnumSet.allOf(LoggingOperations.class);
    }

    if (!(details == null || details.equals(BlobListingDetails.METADATA))) {
        throw new IllegalArgumentException(SR.INVALID_LISTING_DETAILS);
    }

    if (operations.equals(EnumSet.noneOf(LoggingOperations.class))) {
        throw new IllegalArgumentException(SR.INVALID_LOGGING_LEVEL);
    }

    EnumSet<BlobListingDetails> metadataDetails;
    if (details != null
            && (details.equals(BlobListingDetails.METADATA) || !operations.equals(EnumSet
                    .allOf(LoggingOperations.class)))) {
        metadataDetails = EnumSet.of(BlobListingDetails.METADATA);
    }
    else {
        metadataDetails = EnumSet.noneOf(BlobListingDetails.class);
    }

    return new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails,
            options, operationContext);
}
 
Example #9
Source File: AzureStorageBlobService.java    From components with Apache License 2.0 5 votes vote down vote up
public Iterable<ListBlobItem> listBlobs(final String containerName, final String prefix, final boolean useFlatBlobListing)
        throws URISyntaxException, StorageException, InvalidKeyException {
    CloudBlobClient cloudBlobClient = connection.getCloudStorageAccount().createCloudBlobClient();
    CloudBlobContainer cloudBlobContainer = cloudBlobClient.getContainerReference(containerName);
    return cloudBlobContainer.listBlobs(prefix, useFlatBlobListing, EnumSet.noneOf(BlobListingDetails.class), null,
            AzureStorageUtils.getTalendOperationContext());
}
 
Example #10
Source File: StorageInterfaceImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  return WrappingIterator.wrap(directory.listBlobs(prefix,
      useFlatBlobListing, listingDetails, options, opContext));
}
 
Example #11
Source File: StorageInterfaceImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  return WrappingIterator.wrap(directory.listBlobs(prefix,
      useFlatBlobListing, listingDetails, options, opContext));
}
 
Example #12
Source File: MockStorageInterface.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  ArrayList<ListBlobItem> ret = new ArrayList<ListBlobItem>();
  URI searchUri = null;
  if (prefix == null) {
    searchUri = uri;
  } else {
    try {
      searchUri = UriBuilder.fromUri(uri).path(prefix).build();
    } catch (UriBuilderException e) {
      throw new AssertionError("Failed to encode path: " + prefix);
    }
  }

  String fullPrefix = convertUriToDecodedString(searchUri);
  boolean includeMetadata = listingDetails.contains(BlobListingDetails.METADATA);
  HashSet<String> addedDirectories = new HashSet<String>();
  for (InMemoryBlockBlobStore.ListBlobEntry current : backingStore.listBlobs(
      fullPrefix, includeMetadata)) {
    int indexOfSlash = current.getKey().indexOf('/', fullPrefix.length());
    if (useFlatBlobListing || indexOfSlash < 0) {
      if (current.isPageBlob()) {
        ret.add(new MockCloudPageBlobWrapper(
            convertKeyToEncodedUri(current.getKey()),
            current.getMetadata(),
            current.getContentLength()));
      } else {
      ret.add(new MockCloudBlockBlobWrapper(
          convertKeyToEncodedUri(current.getKey()),
          current.getMetadata(),
          current.getContentLength()));
      }
    } else {
      String directoryName = current.getKey().substring(0, indexOfSlash);
      if (!addedDirectories.contains(directoryName)) {
        addedDirectories.add(current.getKey());
        ret.add(new MockCloudBlobDirectoryWrapper(new URI(
            directoryName + "/")));
      }
    }
  }
  return ret;
}
 
Example #13
Source File: MockStorageInterface.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  ArrayList<ListBlobItem> ret = new ArrayList<ListBlobItem>();
  URI searchUri = null;
  if (prefix == null) {
    searchUri = uri;
  } else {
    try {
      searchUri = UriBuilder.fromUri(uri).path(prefix).build();
    } catch (UriBuilderException e) {
      throw new AssertionError("Failed to encode path: " + prefix);
    }
  }

  String fullPrefix = convertUriToDecodedString(searchUri);
  boolean includeMetadata = listingDetails.contains(BlobListingDetails.METADATA);
  HashSet<String> addedDirectories = new HashSet<String>();
  for (InMemoryBlockBlobStore.ListBlobEntry current : backingStore.listBlobs(
      fullPrefix, includeMetadata)) {
    int indexOfSlash = current.getKey().indexOf('/', fullPrefix.length());
    if (useFlatBlobListing || indexOfSlash < 0) {
      if (current.isPageBlob()) {
        ret.add(new MockCloudPageBlobWrapper(
            convertKeyToEncodedUri(current.getKey()),
            current.getMetadata(),
            current.getContentLength()));
      } else {
      ret.add(new MockCloudBlockBlobWrapper(
          convertKeyToEncodedUri(current.getKey()),
          current.getMetadata(),
          current.getContentLength()));
      }
    } else {
      String directoryName = current.getKey().substring(0, indexOfSlash);
      if (!addedDirectories.contains(directoryName)) {
        addedDirectories.add(current.getKey());
        ret.add(new MockCloudBlobDirectoryWrapper(new URI(
            directoryName + "/")));
      }
    }
  }
  return ret;
}
 
Example #14
Source File: ListAzureBlobStorage.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
protected List<BlobInfo> performListing(final ProcessContext context, final Long minTimestamp) throws IOException {
    String containerName = context.getProperty(AzureStorageUtils.CONTAINER).evaluateAttributeExpressions().getValue();
    String prefix = context.getProperty(PROP_PREFIX).evaluateAttributeExpressions().getValue();
    if (prefix == null) {
        prefix = "";
    }
    final List<BlobInfo> listing = new ArrayList<>();
    try {
        CloudBlobClient blobClient = AzureStorageUtils.createCloudBlobClient(context, getLogger(), null);
        CloudBlobContainer container = blobClient.getContainerReference(containerName);

        final OperationContext operationContext = new OperationContext();
        AzureStorageUtils.setProxy(operationContext, context);

        for (ListBlobItem blob : container.listBlobs(prefix, true, EnumSet.of(BlobListingDetails.METADATA), null, operationContext)) {
            if (blob instanceof CloudBlob) {
                CloudBlob cloudBlob = (CloudBlob) blob;
                BlobProperties properties = cloudBlob.getProperties();
                StorageUri uri = cloudBlob.getSnapshotQualifiedStorageUri();

                Builder builder = new BlobInfo.Builder()
                                          .primaryUri(uri.getPrimaryUri().toString())
                                          .blobName(cloudBlob.getName())
                                          .containerName(containerName)
                                          .contentType(properties.getContentType())
                                          .contentLanguage(properties.getContentLanguage())
                                          .etag(properties.getEtag())
                                          .lastModifiedTime(properties.getLastModified().getTime())
                                          .length(properties.getLength());

                if (uri.getSecondaryUri() != null) {
                    builder.secondaryUri(uri.getSecondaryUri().toString());
                }

                if (blob instanceof CloudBlockBlob) {
                    builder.blobType(AzureStorageUtils.BLOCK);
                } else {
                    builder.blobType(AzureStorageUtils.PAGE);
                }
                listing.add(builder.build());
            }
        }
    } catch (Throwable t) {
        throw new IOException(ExceptionUtils.getRootCause(t));
    }
    return listing;
}
 
Example #15
Source File: AzureNativeFileSystemStore.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container depending on whether the
 * original file system object was constructed with a short- or long-form URI.
 * If the root directory is non-null the URI in the file constructor was in
 * the long form.
 * 
 * @param includeMetadata
 *          if set, the listed items will have their metadata populated
 *          already.
 * 
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(boolean includeMetadata)
    throws StorageException, URISyntaxException {
  return rootDirectory.listBlobs(
      null, false,
      includeMetadata ?
          EnumSet.of(BlobListingDetails.METADATA) :
            EnumSet.noneOf(BlobListingDetails.class),
      null,
            getInstrumentedContext());
}
 
Example #16
Source File: AzureNativeFileSystemStore.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container given a specified prefix for
 * the directory depending on whether the original file system object was
 * constructed with a short- or long-form URI. If the root directory is
 * non-null the URI in the file constructor was in the long form.
 * 
 * @param aPrefix
 *          : string name representing the prefix of containing blobs.
 * @param includeMetadata
 *          if set, the listed items will have their metadata populated
 *          already.
 * 
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(String aPrefix,
    boolean includeMetadata) throws StorageException, URISyntaxException {

  Iterable<ListBlobItem> list = rootDirectory.listBlobs(aPrefix,
      false,
      includeMetadata ?
          EnumSet.of(BlobListingDetails.METADATA) :
            EnumSet.noneOf(BlobListingDetails.class),
            null,
            getInstrumentedContext());
  return list;
}
 
Example #17
Source File: AzureNativeFileSystemStore.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container given a specified prefix for
 * the directory depending on whether the original file system object was
 * constructed with a short- or long-form URI. It also uses the specified flat
 * or hierarchical option, listing details options, request options, and
 * operation context.
 * 
 * @param aPrefix
 *          string name representing the prefix of containing blobs.
 * @param useFlatBlobListing
 *          - the list is flat if true, or hierarchical otherwise.
 * @param listingDetails
 *          - determine whether snapshots, metadata, committed/uncommitted
 *          data
 * @param options
 *          - object specifying additional options for the request. null =
 *          default options
 * @param opContext
 *          - context of the current operation
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(String aPrefix, boolean useFlatBlobListing,
    EnumSet<BlobListingDetails> listingDetails, BlobRequestOptions options,
    OperationContext opContext) throws StorageException, URISyntaxException {

  CloudBlobDirectoryWrapper directory =  this.container.getDirectoryReference(aPrefix);
  return directory.listBlobs(
      null,
      useFlatBlobListing,
      listingDetails,
      options,
      opContext);
}
 
Example #18
Source File: CloudAnalyticsClient.java    From azure-storage-android with Apache License 2.0 3 votes vote down vote up
/**
 * Returns an enumerable collection of log records, retrieved lazily.
 * 
 * @param service
 *            A {@link StorageService} enumeration value that indicates which storage service to use.
 * @param startTime
 *            A <code>java.util.Date</code> object representing the start of the time range for which logs should
 *            be retrieved.
 * @param endTime
 *            A <code>java.util.Date</code> object representing the end of the time range for which logs should
 *            be retrieved.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies additional options for the request.
 * @param operationContext
 *            An {@link OperationContext} object that represents the context for the current operation.
 * @return
 *         An enumerable collection of objects that implement {@link ListBlobItem} and are retrieved lazily.
 * @throws StorageException
 * @throws URISyntaxException
 */
public Iterable<LogRecord> listLogRecords(StorageService service, Date startTime, Date endTime,
        BlobRequestOptions options, OperationContext operationContext) throws StorageException, URISyntaxException {
    Utility.assertNotNull("service", service);
    EnumSet<LoggingOperations> operations = EnumSet.allOf(LoggingOperations.class);
    EnumSet<BlobListingDetails> metadataDetails = EnumSet.noneOf(BlobListingDetails.class);
    Iterator<ListBlobItem> blobIterator = new LogBlobIterable(this.getLogDirectory(service), startTime, endTime,
            operations, metadataDetails, options, operationContext).iterator();

    return new LogRecordIterable(blobIterator);
}
 
Example #19
Source File: AzureNativeFileSystemStore.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container given a specified prefix for
 * the directory depending on whether the original file system object was
 * constructed with a short- or long-form URI. It also uses the specified flat
 * or hierarchical option, listing details options, request options, and
 * operation context.
 * 
 * @param aPrefix
 *          string name representing the prefix of containing blobs.
 * @param useFlatBlobListing
 *          - the list is flat if true, or hierarchical otherwise.
 * @param listingDetails
 *          - determine whether snapshots, metadata, committed/uncommitted
 *          data
 * @param options
 *          - object specifying additional options for the request. null =
 *          default options
 * @param opContext
 *          - context of the current operation
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(String aPrefix, boolean useFlatBlobListing,
    EnumSet<BlobListingDetails> listingDetails, BlobRequestOptions options,
    OperationContext opContext) throws StorageException, URISyntaxException {

  CloudBlobDirectoryWrapper directory =  this.container.getDirectoryReference(aPrefix);
  return directory.listBlobs(
      null,
      useFlatBlobListing,
      listingDetails,
      options,
      opContext);
}
 
Example #20
Source File: AzureNativeFileSystemStore.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container given a specified prefix for
 * the directory depending on whether the original file system object was
 * constructed with a short- or long-form URI. If the root directory is
 * non-null the URI in the file constructor was in the long form.
 * 
 * @param aPrefix
 *          : string name representing the prefix of containing blobs.
 * @param includeMetadata
 *          if set, the listed items will have their metadata populated
 *          already.
 * 
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(String aPrefix,
    boolean includeMetadata) throws StorageException, URISyntaxException {

  Iterable<ListBlobItem> list = rootDirectory.listBlobs(aPrefix,
      false,
      includeMetadata ?
          EnumSet.of(BlobListingDetails.METADATA) :
            EnumSet.noneOf(BlobListingDetails.class),
            null,
            getInstrumentedContext());
  return list;
}
 
Example #21
Source File: AzureNativeFileSystemStore.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * This private method uses the root directory or the original container to
 * list blobs under the directory or container depending on whether the
 * original file system object was constructed with a short- or long-form URI.
 * If the root directory is non-null the URI in the file constructor was in
 * the long form.
 * 
 * @param includeMetadata
 *          if set, the listed items will have their metadata populated
 *          already.
 * 
 * @returns blobItems : iterable collection of blob items.
 * @throws URISyntaxException
 * 
 */
private Iterable<ListBlobItem> listRootBlobs(boolean includeMetadata)
    throws StorageException, URISyntaxException {
  return rootDirectory.listBlobs(
      null, false,
      includeMetadata ?
          EnumSet.of(BlobListingDetails.METADATA) :
            EnumSet.noneOf(BlobListingDetails.class),
      null,
            getInstrumentedContext());
}
 
Example #22
Source File: StorageInterface.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an enumerable collection of blob items whose names begin with the
 * specified prefix, using the specified flat or hierarchical option,
 * listing details options, request options, and operation context.
 * 
 * @param prefix
 *          A <code>String</code> that represents the prefix of the blob
 *          name.
 * @param useFlatBlobListing
 *          <code>true</code> to indicate that the returned list will be
 *          flat; <code>false</code> to indicate that the returned list will
 *          be hierarchical.
 * @param listingDetails
 *          A <code>java.util.EnumSet</code> object that contains
 *          {@link BlobListingDetails} values that indicate whether
 *          snapshots, metadata, and/or uncommitted blocks are returned.
 *          Committed blocks are always returned.
 * @param options
 *          A {@link BlobRequestOptions} object that specifies any
 *          additional options for the request. Specifying <code>null</code>
 *          will use the default request options from the associated service
 *          client ( {@link CloudBlobClient}).
 * @param opContext
 *          An {@link OperationContext} object that represents the context
 *          for the current operation. This object is used to track requests
 *          to the storage service, and to provide additional runtime
 *          information about the operation.
 * 
 * @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.
 */
public abstract Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException;
 
Example #23
Source File: StorageInterface.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an enumerable collection of blob items whose names begin with the
 * specified prefix, using the specified flat or hierarchical option,
 * listing details options, request options, and operation context.
 * 
 * @param prefix
 *          A <code>String</code> that represents the prefix of the blob
 *          name.
 * @param useFlatBlobListing
 *          <code>true</code> to indicate that the returned list will be
 *          flat; <code>false</code> to indicate that the returned list will
 *          be hierarchical.
 * @param listingDetails
 *          A <code>java.util.EnumSet</code> object that contains
 *          {@link BlobListingDetails} values that indicate whether
 *          snapshots, metadata, and/or uncommitted blocks are returned.
 *          Committed blocks are always returned.
 * @param options
 *          A {@link BlobRequestOptions} object that specifies any
 *          additional options for the request. Specifying <code>null</code>
 *          will use the default request options from the associated service
 *          client ( {@link CloudBlobClient}).
 * @param opContext
 *          An {@link OperationContext} object that represents the context
 *          for the current operation. This object is used to track requests
 *          to the storage service, and to provide additional runtime
 *          information about the operation.
 * 
 * @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.
 */
public abstract Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException;