/** * Forcefully shuts down this TransferManager instance - currently executing * transfers will not be allowed to finish. Callers should use this method * when they either: * <ul> * <li>have already verified that their transfers have completed by checking * each transfer's state * <li>need to exit quickly and don't mind stopping transfers before they * complete. * </ul> * <p> * Callers should also remember that uploaded parts from an interrupted * upload may not always be automatically cleaned up, but callers can use * {@link #abortMultipartUploads(String, Date)} to clean up any upload * parts. * * @param shutDownS3Client * Whether to shut down the underlying Amazon S3 client. */ public void shutdownNow(boolean shutDownS3Client) { if (shutDownThreadPools) { executorService.shutdownNow(); timedThreadPool.shutdownNow(); } if (shutDownS3Client) { s3.shutdown(); } }
private static void numberOfLinesInFile(ParameterTool params) { final String bucket = params.getRequired("bucket"); final String s3file = params.getRequired("s3file"); AmazonS3 s3client = AmazonS3ClientBuilder.defaultClient(); System.out.print(S3QueryUtil.queryFile(s3client, bucket, s3file, countQuery)); s3client.shutdown(); }
private static void numberOfLinesInFilesWithFullAndNamePrefix(ParameterTool params) { final String bucket = params.getRequired("bucket"); final String s3prefix = params.getRequired("s3prefix"); final String s3filePrefix = params.get("s3filePrefix", ""); int parallelism = params.getInt("parallelism", 10); List<String> files = listByFullPathPrefix(bucket, s3prefix); ExecutorService executor = Executors.newFixedThreadPool(parallelism); AmazonS3 s3client = AmazonS3ClientBuilder.defaultClient(); List<CompletableFuture<Integer>> requests = submitLineCountingRequestsForFilesAsync(executor, s3client, bucket, files, s3filePrefix); int count = waitAndComputeTotalLineCountResult(requests); executor.shutdownNow(); s3client.shutdown(); System.out.print(count); }
static void shutdown(AmazonS3 client) { try { client.shutdown(); } catch (final RuntimeException e) { // ignore } }
@Override public void doStop() throws Exception { if (s3Client != null) { s3Client.shutdown(); } super.doStop(); }
/** * Forcefully shuts down this TransferManager instance - currently executing * transfers will not be allowed to finish. Callers should use this method * when they either: * <ul> * <li>have already verified that their transfers have completed by checking * each transfer's state * <li>need to exit quickly and don't mind stopping transfers before they * complete. * </ul> * <p> * Callers should also remember that uploaded parts from an interrupted * upload may not always be automatically cleaned up, but callers can use * {@link #abortMultipartUploads(String, Date)} to clean up any upload * parts. * * @param shutDownS3Client * Whether to shut down the underlying Amazon S3 client. */ public void shutdownNow(boolean shutDownS3Client) { if (shutDownThreadPools) { executorService.shutdownNow(); timedThreadPool.shutdownNow(); } if (shutDownS3Client) { s3.shutdown(); } }
try { tx.shutdownNow(false); s3Service.shutdown(); } catch (Exception e) { SDFSLogger.getLog().debug("error while closing bucket " + this.name, e);
s3Client.shutdown();
s3_client.shutdown(); s3_client = null;
s3_client.shutdown(); s3_client = null;
s3Client.deleteBucket(bucketName); s3Client.shutdown();