Example usage for com.amazonaws.services.kinesisfirehose.model CompressionFormat UNCOMPRESSED

List of usage examples for com.amazonaws.services.kinesisfirehose.model CompressionFormat UNCOMPRESSED

Introduction

In this page you can find the example usage for com.amazonaws.services.kinesisfirehose.model CompressionFormat UNCOMPRESSED.

Prototype

CompressionFormat UNCOMPRESSED

To view the source code for com.amazonaws.services.kinesisfirehose.model CompressionFormat UNCOMPRESSED.

Click Source Link

Usage

From source file:AmazonKinesisFirehoseToS3Sample.java

License:Open Source License

/**
 * Method to create delivery stream for S3 destination configuration.
 *
 * @throws Exception// w w  w .  j ava 2s . c  om
 */
private static void createDeliveryStream() throws Exception {

    boolean deliveryStreamExists = false;

    LOG.info("Checking if " + deliveryStreamName + " already exits");
    List<String> deliveryStreamNames = listDeliveryStreams();
    if (deliveryStreamNames != null && deliveryStreamNames.contains(deliveryStreamName)) {
        deliveryStreamExists = true;
        LOG.info("DeliveryStream " + deliveryStreamName
                + " already exists. Not creating the new delivery stream");
    } else {
        LOG.info("DeliveryStream " + deliveryStreamName + " does not exist");
    }

    if (!deliveryStreamExists) {
        // Create deliveryStream
        CreateDeliveryStreamRequest createDeliveryStreamRequest = new CreateDeliveryStreamRequest();
        createDeliveryStreamRequest.setDeliveryStreamName(deliveryStreamName);

        S3DestinationConfiguration s3DestinationConfiguration = new S3DestinationConfiguration();
        s3DestinationConfiguration.setBucketARN(s3BucketARN);
        s3DestinationConfiguration.setPrefix(s3ObjectPrefix);
        // Could also specify GZIP or ZIP
        s3DestinationConfiguration.setCompressionFormat(CompressionFormat.UNCOMPRESSED);

        // Encryption configuration is optional
        EncryptionConfiguration encryptionConfiguration = new EncryptionConfiguration();
        if (!StringUtils.isNullOrEmpty(s3DestinationAWSKMSKeyId)) {
            encryptionConfiguration.setKMSEncryptionConfig(
                    new KMSEncryptionConfig().withAWSKMSKeyARN(s3DestinationAWSKMSKeyId));
        } else {
            encryptionConfiguration.setNoEncryptionConfig(NoEncryptionConfig.NoEncryption);
        }
        s3DestinationConfiguration.setEncryptionConfiguration(encryptionConfiguration);

        BufferingHints bufferingHints = null;
        if (s3DestinationSizeInMBs != null || s3DestinationIntervalInSeconds != null) {
            bufferingHints = new BufferingHints();
            bufferingHints.setSizeInMBs(s3DestinationSizeInMBs);
            bufferingHints.setIntervalInSeconds(s3DestinationIntervalInSeconds);
        }
        s3DestinationConfiguration.setBufferingHints(bufferingHints);

        // Create and set IAM role so that firehose service has access to the S3Buckets to put data 
        // and KMS keys (if provided) to encrypt data. Please check the trustPolicyDocument.json and 
        // permissionsPolicyDocument.json files for the trust and permissions policies set for the role.
        String iamRoleArn = createIamRole(s3ObjectPrefix);
        s3DestinationConfiguration.setRoleARN(iamRoleArn);

        createDeliveryStreamRequest.setS3DestinationConfiguration(s3DestinationConfiguration);

        firehoseClient.createDeliveryStream(createDeliveryStreamRequest);

        // The Delivery Stream is now being created.
        LOG.info("Creating DeliveryStream : " + deliveryStreamName);
        waitForDeliveryStreamToBecomeAvailable(deliveryStreamName);
    }
}

From source file:ch.bbv.application.lambda.KinesisToFirehose.java

private void createFirehose() {
    BufferingHints buffHints = new BufferingHints().withIntervalInSeconds(intervalInSec)
            .withSizeInMBs(buffSizeInMB);

    S3DestinationConfiguration s3DestConf = new S3DestinationConfiguration().withBucketARN(targetBucketARN)
            .withCompressionFormat(CompressionFormat.UNCOMPRESSED).withPrefix(targetPrefix)
            .withBufferingHints(buffHints).withRoleARN(deliveryStreamRoleARN);

    CreateDeliveryStreamRequest createHoseRequest = new CreateDeliveryStreamRequest()
            .withDeliveryStreamName(deliveryStreamName).withS3DestinationConfiguration(s3DestConf);

    logIt("Sending create firehose request");
    firehoseClient.createDeliveryStream(createHoseRequest);
    try {// ww w .  j  av a2s .c  o m
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}