Search in sources :

Example 1 with InvalidParameterException

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

the class ExportJournal method createExport.

/**
 * Request QLDB to export the contents of the journal for the given time
 * period and s3 configuration. Before calling this function the S3 bucket
 * should be created, see {@link #createS3BucketIfNotExists(String, AmazonS3)}.
 *
 * @param name
 *              Name of the ledger.
 * @param startTime
 *              Time from when the journal contents should be exported.
 * @param endTime
 *              Time until which the journal contents should be exported.
 * @param bucket
 *              S3 bucket to write the data to.
 * @param prefix
 *              S3 prefix to be prefixed to the files written.
 * @param s3EncryptionConfiguration
 *              Encryption configuration for S3.
 * @param roleArn
 *              The IAM role ARN to be used when exporting the journal.
 * @return {@link ExportJournalToS3Result} from QLDB.
 */
public static ExportJournalToS3Result createExport(String name, Date startTime, Date endTime, String bucket, String prefix, S3EncryptionConfiguration s3EncryptionConfiguration, String roleArn) {
    log.info("Let's create a journal export for ledger with name: {}...", name);
    S3ExportConfiguration s3ExportConfiguration = new S3ExportConfiguration().withBucket(bucket).withPrefix(prefix).withEncryptionConfiguration(s3EncryptionConfiguration);
    ExportJournalToS3Request request = new ExportJournalToS3Request().withName(name).withInclusiveStartTime(startTime).withExclusiveEndTime(endTime).withS3ExportConfiguration(s3ExportConfiguration).withRoleArn(roleArn);
    try {
        ExportJournalToS3Result result = client.exportJournalToS3(request);
        log.info("Requested QLDB to export contents of the journal.");
        return result;
    } catch (InvalidParameterException ipe) {
        log.error("The eventually consistent behavior of the IAM service may cause this export" + " to fail its first attempts, please retry.");
        throw ipe;
    }
}
Also used : ExportJournalToS3Request(com.amazonaws.services.qldb.model.ExportJournalToS3Request) InvalidParameterException(com.amazonaws.services.qldb.model.InvalidParameterException) ExportJournalToS3Result(com.amazonaws.services.qldb.model.ExportJournalToS3Result) S3ExportConfiguration(com.amazonaws.services.qldb.model.S3ExportConfiguration)

Aggregations

ExportJournalToS3Request (com.amazonaws.services.qldb.model.ExportJournalToS3Request)1 ExportJournalToS3Result (com.amazonaws.services.qldb.model.ExportJournalToS3Result)1 InvalidParameterException (com.amazonaws.services.qldb.model.InvalidParameterException)1 S3ExportConfiguration (com.amazonaws.services.qldb.model.S3ExportConfiguration)1