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

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

Introduction

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

Prototype

public Long getLastByte() 

Source Link

Document

Returns the optional zero-based byte offset to stop copying the source.

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;//from ww w  .  j  a v  a 2s. c  o  m
    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;
}