Search in sources :

Example 1 with ListObjectsV2Result

use of com.amazonaws.services.s3.model.ListObjectsV2Result in project alluxio by Alluxio.

the class S3AUnderFileSystem method getObjectListingChunk.

@Override
protected ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException {
    String delimiter = recursive ? "" : PATH_SEPARATOR;
    key = PathUtils.normalizePath(key, PATH_SEPARATOR);
    // In case key is root (empty string) do not normalize prefix
    key = key.equals(PATH_SEPARATOR) ? "" : key;
    ListObjectsV2Request request = new ListObjectsV2Request().withBucketName(mBucketName).withPrefix(key).withDelimiter(delimiter).withMaxKeys(getListingChunkLength());
    ListObjectsV2Result result = getObjectListingChunk(request);
    if (result != null) {
        return new S3AObjectListingChunk(request, result);
    }
    return null;
}
Also used : ListObjectsV2Request(com.amazonaws.services.s3.model.ListObjectsV2Request) ListObjectsV2Result(com.amazonaws.services.s3.model.ListObjectsV2Result)

Example 2 with ListObjectsV2Result

use of com.amazonaws.services.s3.model.ListObjectsV2Result in project alluxio by Alluxio.

the class S3AUnderFileSystem method getObjectListingChunk.

// Get next chunk of listing result
private ListObjectsV2Result getObjectListingChunk(ListObjectsV2Request request) {
    ListObjectsV2Result result;
    try {
        // Query S3 for the next batch of objects
        result = mClient.listObjectsV2(request);
        // Advance the request continuation token to the next set of objects
        request.setContinuationToken(result.getNextContinuationToken());
    } catch (AmazonClientException e) {
        LOG.error("Failed to list path {}", request.getPrefix(), e);
        result = null;
    }
    return result;
}
Also used : ListObjectsV2Result(com.amazonaws.services.s3.model.ListObjectsV2Result) AmazonClientException(com.amazonaws.AmazonClientException)

Aggregations

ListObjectsV2Result (com.amazonaws.services.s3.model.ListObjectsV2Result)2 AmazonClientException (com.amazonaws.AmazonClientException)1 ListObjectsV2Request (com.amazonaws.services.s3.model.ListObjectsV2Request)1