Example usage for com.amazonaws.services.s3.model CopyPartRequest getPartNumber

List of usage examples for com.amazonaws.services.s3.model CopyPartRequest getPartNumber

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model CopyPartRequest getPartNumber.

Prototype

public int getPartNumber() 

Source Link

Document

Returns the part number describing this part's position relative to the other parts in the multipart upload.

Usage

From source file:com.upplication.s3fs.AmazonS3Client.java

License:Open Source License

static CopyPartResult copyPart0(AmazonS3 client, CopyPartRequest request, S3MultipartOptions opts)
        throws IOException, InterruptedException {

    final String objectId = request.getUploadId();
    final int partNumber = request.getPartNumber();
    final long len = request.getLastByte() - request.getFirstByte();

    int attempt = 0;
    CopyPartResult result = null;/*w ww  .  java2 s  . com*/
    while (result == null) {
        attempt++;
        try {
            log.trace("Copying multipart {} with length {} attempt {} for {} ", partNumber, len, attempt,
                    objectId);
            result = client.copyPart(request);
        } catch (AmazonClientException e) {
            if (attempt >= opts.getMaxAttempts())
                throw new IOException("Failed to upload multipart data to Amazon S3", e);

            log.debug("Failed to upload part {} attempt {} for {} -- Caused by: {}", partNumber, attempt,
                    objectId, e.getMessage());
            Thread.sleep(opts.getRetrySleepWithAttempt(attempt));
        }
    }

    return result;
}