Example usage for com.amazonaws.services.s3.transfer ObjectMetadataProvider ObjectMetadataProvider

List of usage examples for com.amazonaws.services.s3.transfer ObjectMetadataProvider ObjectMetadataProvider

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.transfer ObjectMetadataProvider ObjectMetadataProvider.

Prototype

ObjectMetadataProvider

Source Link

Usage

From source file:org.finra.dm.dao.impl.S3DaoImpl.java

License:Apache License

@Override
public S3FileTransferResultsDto uploadFileList(final S3FileTransferRequestParamsDto params)
        throws InterruptedException {
    LOGGER.info(String.format("Uploading %d files from %s local directory to s3://%s/%s ...",
            params.getFiles().size(), params.getLocalPath(), params.getS3BucketName(),
            params.getS3KeyPrefix()));//from ww w .  j av  a  2  s  .c o  m

    if (LOGGER.isInfoEnabled()) {
        for (File file : params.getFiles()) {
            LOGGER.info(String.format("    %s", file.getPath()));
        }
    }

    // Perform the transfer.
    S3FileTransferResultsDto results = performTransfer(params, new Transferer() {
        @Override
        public Transfer performTransfer(TransferManager transferManager) {
            return s3Operations.uploadFileList(params.getS3BucketName(), params.getS3KeyPrefix(),
                    new File(params.getLocalPath()), params.getFiles(), new ObjectMetadataProvider() {
                        @Override
                        public void provideObjectMetadata(File file, ObjectMetadata metadata) {
                            prepareMetadata(params, metadata);
                        }
                    }, transferManager);
        }
    });

    LOGGER.info("List of files relative to the common local parent directory \"" + params.getLocalPath()
            + "\" contains " + results.getTotalFilesTransferred() + " file(s) and "
            + results.getTotalBytesTransferred()
            + " byte(s) which was successfully transferred to S3 key prefix \"" + params.getS3KeyPrefix()
            + "\" in bucket \"" + params.getS3BucketName() + "\" in "
            + DmDateUtils.formatDuration(results.getDurationMillis(), true));

    LOGGER.info(String.format("Overall transfer rate: %.2f kBytes/s (%.2f Mbits/s)",
            getTransferRateInKilobytesPerSecond(results.getTotalBytesTransferred(),
                    results.getDurationMillis()),
            getTransferRateInMegabitsPerSecond(results.getTotalBytesTransferred(),
                    results.getDurationMillis())));

    return results;
}

From source file:org.finra.dm.dao.impl.S3DaoImpl.java

License:Apache License

@Override
public S3FileTransferResultsDto uploadDirectory(final S3FileTransferRequestParamsDto params)
        throws InterruptedException {
    LOGGER.info(String.format("Uploading %s local directory to s3://%s/%s ...", params.getLocalPath(),
            params.getS3BucketName(), params.getS3KeyPrefix()));

    // Perform the transfer.
    S3FileTransferResultsDto results = performTransfer(params, new Transferer() {
        @Override// w w  w  .j a va2 s.  c o m
        public Transfer performTransfer(TransferManager transferManager) {
            return s3Operations.uploadDirectory(params.getS3BucketName(), params.getS3KeyPrefix(),
                    new File(params.getLocalPath()), params.getRecursive(), new ObjectMetadataProvider() {
                        @Override
                        public void provideObjectMetadata(File file, ObjectMetadata metadata) {
                            prepareMetadata(params, metadata);
                        }
                    }, transferManager);
        }
    });

    LOGGER.info("Local directory \"" + params.getLocalPath() + "\" contains "
            + results.getTotalFilesTransferred() + " file(s) and " + results.getTotalBytesTransferred()
            + " byte(s) which was successfully transferred to S3 key prefix \"" + params.getS3KeyPrefix()
            + "\" in bucket \"" + params.getS3BucketName() + "\" in "
            + DmDateUtils.formatDuration(results.getDurationMillis(), true));

    LOGGER.info(String.format("Overall transfer rate: %.2f kBytes/s (%.2f Mbits/s)",
            getTransferRateInKilobytesPerSecond(results.getTotalBytesTransferred(),
                    results.getDurationMillis()),
            getTransferRateInMegabitsPerSecond(results.getTotalBytesTransferred(),
                    results.getDurationMillis())));

    return results;
}

From source file:org.finra.herd.dao.impl.S3DaoImpl.java

License:Apache License

@Override
public S3FileTransferResultsDto uploadDirectory(final S3FileTransferRequestParamsDto params)
        throws InterruptedException {
    LOGGER.info(/*from w w w.  j a  v  a 2 s .  co m*/
            "Uploading local directory to S3... localDirectory=\"{}\" s3KeyPrefix=\"{}\" s3BucketName=\"{}\"",
            params.getLocalPath(), params.getS3KeyPrefix(), params.getS3BucketName());

    // Perform the transfer.
    S3FileTransferResultsDto results = performTransfer(params, new Transferer() {
        @Override
        public Transfer performTransfer(TransferManager transferManager) {
            return s3Operations.uploadDirectory(params.getS3BucketName(), params.getS3KeyPrefix(),
                    new File(params.getLocalPath()), params.isRecursive(), new ObjectMetadataProvider() {
                        @Override
                        public void provideObjectMetadata(File file, ObjectMetadata metadata) {
                            prepareMetadata(params, metadata);
                        }
                    }, transferManager);
        }
    });

    LOGGER.info("Uploaded local directory to S3. "
            + "localDirectory=\"{}\" s3KeyPrefix=\"{}\" s3BucketName=\"{}\" s3KeyCount={} totalBytesTransferred={} transferDuration=\"{}\"",
            params.getLocalPath(), params.getS3KeyPrefix(), params.getS3BucketName(),
            results.getTotalFilesTransferred(), results.getTotalBytesTransferred(),
            HerdDateUtils.formatDuration(results.getDurationMillis()));

    logOverallTransferRate(results);

    return results;
}

From source file:org.finra.herd.dao.impl.S3DaoImpl.java

License:Apache License

@Override
public S3FileTransferResultsDto uploadFileList(final S3FileTransferRequestParamsDto params)
        throws InterruptedException {
    LOGGER.info(/*from   www .  j a va2  s  . c o m*/
            "Uploading a list of files from the local directory to S3... localDirectory=\"{}\" s3KeyPrefix=\"{}\" s3BucketName=\"{}\" s3KeyCount={}",
            params.getLocalPath(), params.getS3KeyPrefix(), params.getS3BucketName(), params.getFiles().size());

    if (LOGGER.isInfoEnabled()) {
        for (File file : params.getFiles()) {
            LOGGER.info("s3Key=\"{}\"", file.getPath());
        }
    }

    // Perform the transfer.
    S3FileTransferResultsDto results = performTransfer(params, new Transferer() {
        @Override
        public Transfer performTransfer(TransferManager transferManager) {
            return s3Operations.uploadFileList(params.getS3BucketName(), params.getS3KeyPrefix(),
                    new File(params.getLocalPath()), params.getFiles(), new ObjectMetadataProvider() {
                        @Override
                        public void provideObjectMetadata(File file, ObjectMetadata metadata) {
                            prepareMetadata(params, metadata);
                        }
                    }, transferManager);
        }
    });

    LOGGER.info("Uploaded list of files from the local directory to S3. "
            + "localDirectory=\"{}\" s3KeyPrefix=\"{}\" s3BucketName=\"{}\" s3KeyCount={} totalBytesTransferred={} transferDuration=\"{}\"",
            params.getLocalPath(), params.getS3KeyPrefix(), params.getS3BucketName(),
            results.getTotalFilesTransferred(), results.getTotalBytesTransferred(),
            HerdDateUtils.formatDuration(results.getDurationMillis()));

    logOverallTransferRate(results);

    return results;
}