Search in sources :

Example 1 with DescribeJournalKinesisStreamRequest

use of com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamRequest in project amazon-qldb-dmv-sample-java by aws-samples.

the class StreamJournal method waitForQldbStreamCompletion.

/**
 * Wait for Kinesis Data Stream completion.
 */
public static void waitForQldbStreamCompletion() {
    DescribeJournalKinesisStreamRequest describeStreamRequest = new DescribeJournalKinesisStreamRequest().withStreamId(streamId).withLedgerName(ledgerName);
    int retries = 0;
    while (retries < MAX_RETRIES) {
        DescribeJournalKinesisStreamResult describeStreamResponse = qldb.describeJournalKinesisStream(describeStreamRequest);
        String streamStatus = describeStreamResponse.getStream().getStatus();
        log.info("Waiting for Stream Completion. Current streamStatus: {}.", streamStatus);
        if (streamStatus.equals("COMPLETED")) {
            break;
        }
        try {
            Thread.sleep(1000);
        } catch (Exception ignore) {
        }
        retries++;
    }
    if (retries >= MAX_RETRIES) {
        throw new RuntimeException("Kinesis Stream with name " + kdsName + " never went completed.");
    }
}
Also used : DescribeJournalKinesisStreamResult(com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamResult) DescribeJournalKinesisStreamRequest(com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamRequest) NoSuchEntityException(com.amazonaws.services.identitymanagement.model.NoSuchEntityException) ResourceNotFoundException(com.amazonaws.services.kinesis.model.ResourceNotFoundException) IOException(java.io.IOException)

Aggregations

NoSuchEntityException (com.amazonaws.services.identitymanagement.model.NoSuchEntityException)1 ResourceNotFoundException (com.amazonaws.services.kinesis.model.ResourceNotFoundException)1 DescribeJournalKinesisStreamRequest (com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamRequest)1 DescribeJournalKinesisStreamResult (com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamResult)1 IOException (java.io.IOException)1