Java 类com.amazonaws.services.s3.model.AbortMultipartUploadRequest 实例源码

项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest)
        throws SdkClientException, AmazonServiceException {
    abortMultipartUploadRequest = beforeClientExecution(abortMultipartUploadRequest);
    rejectNull(abortMultipartUploadRequest,
        "The request parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getBucketName(),
        "The bucket name parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getKey(),
        "The key parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getUploadId(),
        "The upload ID parameter must be specified when aborting a multipart upload");

    String bucketName = abortMultipartUploadRequest.getBucketName();
    String key = abortMultipartUploadRequest.getKey();

    Request<AbortMultipartUploadRequest> request = createRequest(bucketName, key, abortMultipartUploadRequest, HttpMethodName.DELETE);
    request.addParameter("uploadId", abortMultipartUploadRequest.getUploadId());
    populateRequesterPaysHeader(request, abortMultipartUploadRequest.isRequesterPays());

    invoke(request, voidResponseHandler, bucketName, key);
}
项目:ibm-cos-sdk-java    文件:TransferManager.java   
/**
 * <p>
 * Aborts any multipart uploads that were initiated before the specified date.
 * </p>
 * <p>
 * This method is useful for cleaning up any interrupted multipart uploads.
 * <code>TransferManager</code> attempts to abort any failed uploads,
 * but in some cases this may not be possible, such as if network connectivity
 * is completely lost.
 * </p>
 *
 * @param bucketName
 *            The name of the bucket containing the multipart uploads to
 *            abort.
 * @param date
 *            The date indicating which multipart uploads should be aborted.
 */
public void abortMultipartUploads(String bucketName, Date date)
        throws AmazonServiceException, AmazonClientException {
    MultipartUploadListing uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(
            new ListMultipartUploadsRequest(bucketName)));
    do {
        for (MultipartUpload upload : uploadListing.getMultipartUploads()) {
            if (upload.getInitiated().compareTo(date) < 0) {
                s3.abortMultipartUpload(appendSingleObjectUserAgent(new AbortMultipartUploadRequest(
                        bucketName, upload.getKey(), upload.getUploadId())));
            }
        }

        ListMultipartUploadsRequest request = new ListMultipartUploadsRequest(bucketName)
            .withUploadIdMarker(uploadListing.getNextUploadIdMarker())
            .withKeyMarker(uploadListing.getNextKeyMarker());
        uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(request));
    } while (uploadListing.isTruncated());
}
项目:ibm-cos-sdk-java    文件:UploadCallable.java   
/**
 * Performs an
 * {@link AmazonS3#abortMultipartUpload(AbortMultipartUploadRequest)}
 * operation for the given multi-part upload.
 */
void performAbortMultipartUpload() {
    if (multipartUploadId == null) {
        return;
    }
    try {
        AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest(origReq.getBucketName(), origReq.getKey(),
                multipartUploadId)
                .withRequesterPays(origReq.isRequesterPays());
        s3.abortMultipartUpload(abortRequest);
    } catch (Exception e2) {
        log.info(
                "Unable to abort multipart upload, you may need to manually remove uploaded parts: "
                        + e2.getMessage(), e2);
    }
}
项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * Deletes all existing buckets
 */
@After
public void cleanupFilestore() {
  for (final Bucket bucket : s3Client.listBuckets()) {
    if (!INITIAL_BUCKET_NAMES.contains(bucket.getName())) {
      s3Client.listMultipartUploads(new ListMultipartUploadsRequest(bucket.getName()))
          .getMultipartUploads()
          .forEach(upload ->
              s3Client.abortMultipartUpload(
                  new AbortMultipartUploadRequest(bucket.getName(), upload.getKey(),
                      upload.getUploadId()))
          );
      s3Client.deleteBucket(bucket.getName());
    }
  }
}
项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * Tests if a multipart upload can be aborted.
 *
 * @throws Exception not expected
 */
@Test
public void shouldAbortMultipartUpload() throws Exception {
  s3Client.createBucket(BUCKET_NAME);

  assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
      .getMultipartUploads(), is(empty()));

  final InitiateMultipartUploadResult initiateMultipartUploadResult = s3Client
      .initiateMultipartUpload(new InitiateMultipartUploadRequest(BUCKET_NAME, UPLOAD_FILE_NAME));
  final String uploadId = initiateMultipartUploadResult.getUploadId();

  assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
      .getMultipartUploads(), is(not(empty())));

  s3Client.abortMultipartUpload(
      new AbortMultipartUploadRequest(BUCKET_NAME, UPLOAD_FILE_NAME, uploadId));

  assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
      .getMultipartUploads(), is(empty()));
}
项目:s3proxy    文件:AwsSdkTest.java   
@Test
public void testAtomicMpuAbort() throws Exception {
    String key = "testAtomicMpuAbort";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());
    client.putObject(containerName, key, BYTE_SOURCE.openStream(),
            metadata);

    InitiateMultipartUploadRequest initRequest =
            new InitiateMultipartUploadRequest(containerName, key);
    InitiateMultipartUploadResult initResponse =
            client.initiateMultipartUpload(initRequest);
    String uploadId = initResponse.getUploadId();

    client.abortMultipartUpload(new AbortMultipartUploadRequest(
                containerName, key, uploadId));

    S3Object object = client.getObject(containerName, key);
    assertThat(object.getObjectMetadata().getContentLength()).isEqualTo(
            BYTE_SOURCE.size());
    try (InputStream actual = object.getObjectContent();
            InputStream expected = BYTE_SOURCE.openStream()) {
        assertThat(actual).hasContentEqualTo(expected);
    }
}
项目:s3-channels    文件:S3AppendableObjectChannel.java   
@Override
public CompletableFuture<Void> cancel() {
    if (cancellation == null) {
        cancellation = CompletableFuture.runAsync(() ->
                s3.abortMultipartUpload(new AbortMultipartUploadRequest(bucket, key, uploadId)));
    }
    return cancellation;
}
项目:hadoop    文件:S3AFastOutputStream.java   
public void abort() {
  LOG.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    client.abortMultipartUpload(new AbortMultipartUploadRequest(bucket,
        key, uploadId));
  } catch (Exception e2) {
    LOG.warn("Unable to abort multipart upload, you may need to purge  " +
        "uploaded parts: " + e2, e2);
  }
}
项目:ibm-cos-sdk-java    文件:CopyCallable.java   
private void abortMultipartCopy() {
    try {
        AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest(
                copyObjectRequest.getDestinationBucketName(),
                copyObjectRequest.getDestinationKey(), multipartUploadId)
                .withRequesterPays(copyObjectRequest.isRequesterPays());
        s3.abortMultipartUpload(abortRequest);
    } catch (Exception e) {
        log.info(
                "Unable to abort multipart upload, you may need to manually remove uploaded parts: "
                        + e.getMessage(), e);
    }
}
项目:ibm-cos-sdk-java    文件:CryptoModuleDispatcher.java   
@Override
public void abortMultipartUploadSecurely(AbortMultipartUploadRequest req) {
    if (defaultCryptoMode == EncryptionOnly)
        eo.abortMultipartUploadSecurely(req);
    else
        ae.abortMultipartUploadSecurely(req);
}
项目:ibm-cos-sdk-java    文件:UploadObjectObserver.java   
/**
 * Notified from
 * {@link AmazonS3EncryptionClient#uploadObject(UploadObjectRequest)} when
 * failed to upload any part. This method is responsible for cancelling
 * ongoing uploads and aborting the multi-part upload request.
 */
public void onAbort() {
    for (Future<?> future : getFutures()) {
        future.cancel(true);
    }
    if (uploadId != null) {
        try {
            s3.abortMultipartUpload(new AbortMultipartUploadRequest(
                req.getBucketName(), req.getKey(), uploadId));
        } catch (Exception e) {
            LogFactory.getLog(getClass())
                .debug("Failed to abort multi-part upload: " + uploadId, e);
        }
    }
}
项目:tdl-auth    文件:RemoteTestBucket.java   
private void abortAllMultipartUploads() {
    ListMultipartUploadsRequest multipartUploadsRequest = new ListMultipartUploadsRequest(bucketName);
    amazonS3.listMultipartUploads(multipartUploadsRequest)
            .getMultipartUploads()
            .forEach(upload -> {
                AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucketName, upload.getKey(), upload.getUploadId());
                amazonS3.abortMultipartUpload(request);
            });
}
项目:nifi-minifi    文件:S3OutputStream.java   
public void abort() {
  log.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    s3.abortMultipartUpload(new AbortMultipartUploadRequest(bucket, key, uploadId));
  } catch (Exception e) {
    // ignoring failure on abort.
    log.warn("Unable to abort multipart upload, you may need to purge uploaded parts: ", e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:S3AFastOutputStream.java   
public void abort() {
  LOG.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    client.abortMultipartUpload(new AbortMultipartUploadRequest(bucket,
        key, uploadId));
  } catch (Exception e2) {
    LOG.warn("Unable to abort multipart upload, you may need to purge  " +
        "uploaded parts: " + e2, e2);
  }
}
项目:big-c    文件:S3AFastOutputStream.java   
public void abort() {
  LOG.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    client.abortMultipartUpload(new AbortMultipartUploadRequest(bucket,
        key, uploadId));
  } catch (Exception e2) {
    LOG.warn("Unable to abort multipart upload, you may need to purge  " +
        "uploaded parts: " + e2, e2);
  }
}
项目:kafka-connect-storage-cloud    文件:S3OutputStream.java   
public void abort() {
  log.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    s3.abortMultipartUpload(new AbortMultipartUploadRequest(bucket, key, uploadId));
  } catch (Exception e) {
    // ignoring failure on abort.
    log.warn("Unable to abort multipart upload, you may need to purge uploaded parts: ", e);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:S3AFastOutputStream.java   
public void abort() {
  LOG.warn("Aborting multi-part upload with id '{}'", uploadId);
  try {
    client.abortMultipartUpload(new AbortMultipartUploadRequest(bucket,
        key, uploadId));
  } catch (Exception e2) {
    LOG.warn("Unable to abort multipart upload, you may need to purge  " +
        "uploaded parts: " + e2, e2);
  }
}
项目:omakase    文件:S3Client.java   
public void abortMultipartUpload(S3Upload upload) {
    try {
        runtimeCredentialsProvider.setAwsCredentials(upload.getAwsCredentials());
        amazonS3.setRegion(Region.getRegion(Regions.fromName(upload.getRegion())));
        amazonS3.abortMultipartUpload(new AbortMultipartUploadRequest(upload.getBucket(), upload.getKey(), upload.getUploadId()));
    } catch (AmazonClientException e) {
        throw new OmakaseRuntimeException(e);
    }
}
项目:herd    文件:MockS3OperationsImpl.java   
/**
 * {@inheritDoc}
 * <p/>
 * This implementation simulates abort multipart upload operation.
 */
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest, AmazonS3 s3Client)
{
    // This method does nothing.
}
项目:vs.msc.ws14    文件:S3DataOutputStream.java   
private void abortUpload() {

        if (this.uploadId == null) {
            // This is not a multipart upload, nothing to do here
            return;
        }

        try {
            final AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(this.bucket, this.object,
                this.uploadId);
            this.s3Client.abortMultipartUpload(request);
        } catch (AmazonServiceException e) {
            // Ignore exception
        }
    }
项目:Singularity    文件:SingularityS3Uploader.java   
private void multipartUpload(String key, File file, ObjectMetadata objectMetadata, Optional<StorageClass> maybeStorageClass) throws Exception {
  List<PartETag> partETags = new ArrayList<>();
  InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucketName, key, objectMetadata);
  if (maybeStorageClass.isPresent()) {
    initRequest.setStorageClass(maybeStorageClass.get());
  }
  InitiateMultipartUploadResult initResponse = s3Client.initiateMultipartUpload(initRequest);

  long contentLength = file.length();
  long partSize = configuration.getUploadPartSize();

  try {
    long filePosition = 0;
    for (int i = 1; filePosition < contentLength; i++) {
      partSize = Math.min(partSize, (contentLength - filePosition));
      UploadPartRequest uploadRequest = new UploadPartRequest()
          .withBucketName(bucketName)
          .withKey(key)
          .withUploadId(initResponse.getUploadId())
          .withPartNumber(i)
          .withFileOffset(filePosition)
          .withFile(file)
          .withPartSize(partSize);
      partETags.add(s3Client.uploadPart(uploadRequest).getPartETag());
      filePosition += partSize;
    }

    CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest(bucketName, key, initResponse.getUploadId(), partETags);
    s3Client.completeMultipartUpload(completeRequest);
  } catch (Exception e) {
    s3Client.abortMultipartUpload(new AbortMultipartUploadRequest(bucketName, key, initResponse.getUploadId()));
    Throwables.propagate(e);
  }
}
项目:s3distcp    文件:MultipartUploadOutputStream.java   
public void abort()
/*     */   {
/* 175 */     for (Future future : this.futures) {
/* 176 */       future.cancel(true);
/*     */     }
/* 178 */     this.s3.abortMultipartUpload(new AbortMultipartUploadRequest(this.bucketName, this.key, this.uploadId));
/*     */   }
项目:elasticsearch_my    文件:DefaultS3OutputStream.java   
protected void doAbortMultipart(S3BlobStore blobStore, String bucketName, String blobName, String uploadId)
        throws AmazonS3Exception {
    blobStore.client().abortMultipartUpload(new AbortMultipartUploadRequest(bucketName, blobName, uploadId));
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest request) throws AmazonClientException, AmazonServiceException {
    delegate.abortMultipartUpload(request);
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:ibm-cos-sdk-java    文件:S3CryptoModuleBase.java   
@Override
public final void abortMultipartUploadSecurely(AbortMultipartUploadRequest req) {
    s3.abortMultipartUpload(req);
    multipartUploadContexts.remove(req.getUploadId());
}
项目:ibm-cos-sdk-java    文件:AmazonS3EncryptionClient.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest req) {
    crypto.abortMultipartUploadSecurely(req);
}
项目:ibm-cos-sdk-java    文件:AmazonS3EncryptionClient.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest req) {
    AmazonS3EncryptionClient.super.abortMultipartUpload(req);
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest request) {
  run(() -> getDelegate().abortMultipartUpload(request));
}
项目:stocator    文件:COSAPIClient.java   
/**
 * Abort a multipart upload operation
 * @param uploadId multipart operation Id
 * @throws AmazonClientException on problems
 */
void abortMultipartUpload(String uploadId) throws AmazonClientException {
  LOG.debug("Aborting multipart upload {}", uploadId);
  mClient.abortMultipartUpload(
      new AbortMultipartUploadRequest(mBucket, key, uploadId));
}
项目:bender    文件:MultiPartUpload.java   
public AbortMultipartUploadRequest getAbortMultipartUploadRequest() {
  return new AbortMultipartUploadRequest(this.bucketName, this.key, this.uploadId);
}
项目:cloudkeeper    文件:S3ConnectionImpl.java   
@Override
public CompletableFuture<Void> abortMultipartUpload(String bucketName, String key, String uploadId) {
    AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucketName, key, uploadId);
    return CompletableFuture.runAsync(() -> s3Client.abortMultipartUpload(request), executorService);
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:herd    文件:S3OperationsImpl.java   
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest, AmazonS3 s3Client)
{
    s3Client.abortMultipartUpload(abortMultipartUploadRequest);
}
项目:herd    文件:S3DaoImpl.java   
@Override
public int abortMultipartUploads(S3FileTransferRequestParamsDto params, Date thresholdDate)
{
    // Create an Amazon S3 client.
    AmazonS3Client s3Client = getAmazonS3(params);
    int abortedMultipartUploadsCount = 0;

    try
    {
        // List upload markers. Null implies initial list request.
        String uploadIdMarker = null;
        String keyMarker = null;

        boolean truncated;
        do
        {
            // Create the list multipart request, optionally using the last markers.
            ListMultipartUploadsRequest request = new ListMultipartUploadsRequest(params.getS3BucketName());
            request.setUploadIdMarker(uploadIdMarker);
            request.setKeyMarker(keyMarker);

            // Request the multipart upload listing.
            MultipartUploadListing uploadListing = s3Operations.listMultipartUploads(TransferManager.appendSingleObjectUserAgent(request), s3Client);

            for (MultipartUpload upload : uploadListing.getMultipartUploads())
            {
                if (upload.getInitiated().compareTo(thresholdDate) < 0)
                {
                    // Abort the upload.
                    s3Operations.abortMultipartUpload(TransferManager
                        .appendSingleObjectUserAgent(new AbortMultipartUploadRequest(params.getS3BucketName(), upload.getKey(), upload.getUploadId())),
                        s3Client);

                    // Log the information about the aborted multipart upload.
                    LOGGER.info("Aborted S3 multipart upload. s3Key=\"{}\" s3BucketName=\"{}\" s3MultipartUploadInitiatedDate=\"{}\"", upload.getKey(),
                        params.getS3BucketName(), upload.getInitiated());

                    // Increment the counter.
                    abortedMultipartUploadsCount++;
                }
            }

            // Determine whether there are more uploads to list.
            truncated = uploadListing.isTruncated();
            if (truncated)
            {
                // Record the list markers.
                uploadIdMarker = uploadListing.getNextUploadIdMarker();
                keyMarker = uploadListing.getNextKeyMarker();
            }
        }
        while (truncated);
    }
    finally
    {
        // Shutdown the Amazon S3 client instance to release resources.
        s3Client.shutdown();
    }

    return abortedMultipartUploadsCount;
}