Example usage for com.amazonaws.services.kinesisfirehose.model PutRecordRequest setDeliveryStreamName

List of usage examples for com.amazonaws.services.kinesisfirehose.model PutRecordRequest setDeliveryStreamName

Introduction

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

Prototype


public void setDeliveryStreamName(String deliveryStreamName) 

Source Link

Document

The name of the delivery stream.

Usage

From source file:AbstractAmazonKinesisFirehoseDelivery.java

License:Open Source License

/**
 * Method to put records in the specified delivery stream by reading
 * contents from sample input file using PutRecord API.
 *
 * @throws IOException/*  w ww. ja v a  2s .  co m*/
 */
protected static void putRecordIntoDeliveryStream() throws IOException {
    try (InputStream inputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(PUT_RECORD_STREAM_SOURCE)) {
        if (inputStream == null) {
            throw new FileNotFoundException("Could not find file " + PUT_RECORD_STREAM_SOURCE);
        }

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                PutRecordRequest putRecordRequest = new PutRecordRequest();
                putRecordRequest.setDeliveryStreamName(deliveryStreamName);

                String data = line + "\n";
                Record record = createRecord(data);
                putRecordRequest.setRecord(record);

                // Put record into the DeliveryStream
                firehoseClient.putRecord(putRecordRequest);
            }
        }
    }
}

From source file:org.voltdb.exportclient.FirehoseSink.java

License:Open Source License

public void writeRow(Record record) {
    int retry = MAX_RETRY;
    while (retry > 0) {
        try {//from w  w w . java2 s  .c  om
            PutRecordRequest putRecordRequest = new PutRecordRequest();
            putRecordRequest.setDeliveryStreamName(m_streamName);
            putRecordRequest.setRecord(record);
            m_client.putRecord(putRecordRequest);
        } catch (ServiceUnavailableException e) {
            if (retry == 1) {
                throw new FirehoseExportException("Failed to send record", e, true);
            } else {
                LOG.warn("Failed to send record: %s. Retry #%d", e.getErrorMessage(), (MAX_RETRY - retry + 1));
                backoffSleep(retry);
            }
        }
        retry--;
    }
}