/** * Closes the current stream. */ // TODO(calvin): Investigate if close instead of abort will bring performance benefits. private void closeStream() { if (mIn == null) { return; } mIn.abort(); mIn = null; } }
private void closeStream() { if (in != null) { try { if (in instanceof S3ObjectInputStream) { ((S3ObjectInputStream) in).abort(); } else { in.close(); } } catch (IOException | AbortedException ignored) { // thrown if the current thread is in the interrupted state } in = null; STATS.connectionReleased(); } } }
/** * Cancels this download. * * @throws IOException */ public synchronized void abort() throws IOException { this.monitor.getFuture().cancel(true); if ( s3Object != null ) { s3Object.getObjectContent().abort(); } setState(TransferState.Canceled); }
s3Object.getObjectContent().abort(); throw new SdkClientException( "Unable to store object contents to disk: " + e.getMessage(), e);
private ObjectMetadata downloadTo0(final OutputStream output, RequestMetricCollector requestMetricCollector) { GetObjectRequest req = new GetObjectRequest(getBucketName(), getKey()) .withRequestMetricCollector(requestMetricCollector); S3Object s3Object = getAmazonS3Client().getObject(req); S3ObjectInputStream objectContent = s3Object.getObjectContent(); try { byte[] buffer = new byte[1024 * 10]; int bytesRead = -1; while ((bytesRead = objectContent.read(buffer)) > -1) { output.write(buffer, 0, bytesRead); } } catch (IOException ioe) { objectContent.abort(); throw new SdkClientException("Unable to transfer content from Amazon S3 to the output stream", ioe); } finally { try { objectContent.close(); } catch (IOException ioe) {} } return s3Object.getObjectMetadata(); }
s3Object.getObjectContent().abort();
/** * Cancels this download. * * @throws IOException */ @Override public synchronized void abort() throws IOException { this.monitor.getFuture().cancel(true); if (s3Object != null) { s3Object.getObjectContent().abort(); } setState(TransferState.Canceled); }
s3Object.getObjectContent().abort(); throw new AmazonClientException( "Unable to store object contents to disk: " + e.getMessage(), e);
@Override public void abort() { s3input.abort(); }
objectContent.abort(); throw new AmazonClientException( "Unable to transfer content from Amazon S3 to the output stream", ioe);
@Override public void close() throws IOException { raw.abort(); } };
@Override public void abort() { wrapped.abort(); }
@Override public void abort() { s3input.abort(); }
s3Object.getObjectContent().abort();
@Override public void close() throws IOException { final long amtLeft; amtLeft = size - amtRead; if (amtLeft > 12000) { // ~ 4 packets ((S3ObjectInputStream)in).abort(); } else { in.close(); } } }
/** * Cancels this download. * * @throws IOException */ public synchronized void abort() throws IOException { this.monitor.getFuture().cancel(true); if ( s3Object != null ) { s3Object.getObjectContent().abort(); } setState(TransferState.Canceled); }
/** * Cancels this download. * * @throws IOException */ @Override public synchronized void abort() throws IOException { this.monitor.getFuture().cancel(true); if (s3Object != null) { s3Object.getObjectContent().abort(); } setState(TransferState.Canceled); }
private synchronized void reopen(long pos) throws IOException { if (wrappedStream != null) { if (LOG.isDebugEnabled()) { LOG.debug("Aborting old stream to open at pos " + pos); } wrappedStream.abort(); } LOG.info("Actually opening file " + key + " at pos " + pos); GetObjectRequest request = new GetObjectRequest(bucket, key); request.setRange(pos, contentLength-1); wrappedObject = client.getObject(request); wrappedStream = wrappedObject.getObjectContent(); if (wrappedStream == null) { throw new IOException("Null IO stream"); } this.pos = pos; }
@Override public synchronized void close() throws IOException { super.close(); closed = true; if (wrappedStream != null) { if (contentLength - pos <= CLOSE_THRESHOLD) { // Close, rather than abort, so that the http connection can be reused. wrappedStream.close(); } else { // Abort, rather than just close, the underlying stream. Otherwise, the // remaining object payload is read from S3 while closing the stream. wrappedStream.abort(); } } }