use of com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamResult in project amazon-qldb-dmv-sample-java by aws-samples.
the class StreamJournal method createQldbStream.
/**
* Create a QLDB Stream.
*
* @return the QLDB Stream description.
* @throws InterruptedException if the thread is interrupted while waiting
* for stream creation.
*/
public static JournalKinesisStreamDescription createQldbStream() throws InterruptedException {
log.info("Creating Kinesis data stream with name: '{}'...", kdsName);
createKdsIfNotExists();
log.info("Creating QLDB stream...");
StreamJournalToKinesisRequest request = new StreamJournalToKinesisRequest().withKinesisConfiguration(getKdsConfig()).withInclusiveStartTime(Date.from(Instant.now().minus(Duration.ofDays(1)))).withRoleArn(getOrCreateKdsRole()).withLedgerName(ledgerName).withStreamName(streamName);
if (exclusiveEndTime != null) {
request = request.withExclusiveEndTime(exclusiveEndTime);
}
StreamJournalToKinesisResult result = qldb.streamJournalToKinesis(request);
streamId = result.getStreamId();
DescribeJournalKinesisStreamResult describeResult = describeQldbStream();
log.info("Created QLDB stream: {} Current status: {}.", streamId, describeResult.getStream().getStatus());
return describeResult.getStream();
}
use of com.amazonaws.services.qldb.model.DescribeJournalKinesisStreamResult 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.");
}
}
Aggregations