Example usage for com.amazonaws.services.kinesisfirehose.model ServiceUnavailableException getErrorMessage

List of usage examples for com.amazonaws.services.kinesisfirehose.model ServiceUnavailableException getErrorMessage

Introduction

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

Prototype

public String getErrorMessage() 

Source Link

Usage

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 {//w  w  w  . ja va 2s. com
            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--;
    }
}

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

License:Open Source License

public void syncWrite(Queue<List<Record>> records) {

    for (List<Record> recordsList : records) {
        int retry = MAX_RETRY;
        while (retry > 0) {
            try {
                PutRecordBatchRequest batchRequest = new PutRecordBatchRequest()
                        .withDeliveryStreamName(m_streamName).withRecords(recordsList);
                PutRecordBatchResult res = m_client.putRecordBatch(batchRequest);
                if (res.getFailedPutCount() > 0) {
                    String msg = "Records failed with the batch: %d, retry: #%d";
                    if (retry == 1) {
                        throw new FirehoseExportException(msg, res.getFailedPutCount(),
                                (MAX_RETRY - retry + 1));
                    } else {
                        LOG.warn(msg, res.getFailedPutCount(), (MAX_RETRY - retry + 1));
                        backoffSleep(retry);
                    }// ww  w. ja v  a 2  s. c o m
                } else {
                    recordsList.clear();
                    break;
                }
            } catch (ServiceUnavailableException e) {
                if (retry == 1) {
                    throw new FirehoseExportException("Failed to send record batch", e, true);
                } else {
                    LOG.warn("Failed to send record batch: %s. Retry #%d", e.getErrorMessage(),
                            (MAX_RETRY - retry + 1));
                    backoffSleep(retry);
                }
            }
            retry--;
        }
    }
}