@Test public void close() throws Exception { mStream.close(); Mockito.verify(mMockS3Client, never()) .initiateMultipartUpload(any(InitiateMultipartUploadRequest.class)); Mockito.verify(mMockS3Client, never()) .completeMultipartUpload(any(CompleteMultipartUploadRequest.class)); }
@Override public void close() throws IOException { if (mClosed) { return; } mClosed = true; if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest() .withBucketName(mBucketName) .withKey(mKey) .withUploadId(mUploadId) .withPartNumber(partNumber) .withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } }
S3ALowLevelOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mClosed = true; if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest() .withBucketName(mBucketName) .withKey(mKey) .withUploadId(mUploadId) .withPartNumber(partNumber) .withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } } }
S3ALowLevelOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mClosed = true; if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest() .withBucketName(mBucketName) .withKey(mKey) .withUploadId(mUploadId) .withPartNumber(partNumber) .withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } } S3ALowLevelOutputStream(String bucketName, String key, AmazonS3 s3Client,
      ListeningExecutorService executor, long streamingUploadPartitionSize, List<String> tmpDirs,
      boolean sseEnabled); }
S3ALowLevelOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mClosed = true; if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest() .withBucketName(mBucketName) .withKey(mKey) .withUploadId(mUploadId) .withPartNumber(partNumber) .withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } } S3ALowLevelOutputStream(String bucketName, String key, AmazonS3 s3Client,
      ListeningExecutorService executor, long streamingUploadPartitionSize, List<String> tmpDirs,
      boolean sseEnabled); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close(); }
S3ALowLevelOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mClosed = true; if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest() .withBucketName(mBucketName) .withKey(mKey) .withUploadId(mUploadId) .withPartNumber(partNumber) .withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } } S3ALowLevelOutputStream(String bucketName, String key, AmazonS3 s3Client,
      ListeningExecutorService executor, long streamingUploadPartitionSize, List<String> tmpDirs,
      boolean sseEnabled); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close();  }