Example usage for com.amazonaws.services.ec2.model DescribeSnapshotsRequest toString

List of usage examples for com.amazonaws.services.ec2.model DescribeSnapshotsRequest toString

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DescribeSnapshotsRequest toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of this object.

Usage

From source file:com.pearson.eidetic.aws.EC2ClientMethods.java

public static DescribeSnapshotsResult describeSnapshots(AmazonEC2Client ec2Client,
        DescribeSnapshotsRequest describeSnapshotsRequest, Integer numRetries, Integer maxApiRequestsPerSecond,
        String uniqueAwsAccountIdentifier) {
    DescribeSnapshotsResult describeSnapshotsResult = null;
    for (int i = 0; i <= numRetries; i++) {
        try {// w  w  w. j  av  a 2s .com
            // if the initial download attempt failed, wait for i * 500ms 
            if (i > 0) {
                long sleepTimeInMilliseconds = 500 * i;
                Threads.sleepMilliseconds(sleepTimeInMilliseconds);
            }

            AtomicLong requestAttemptCounter = GlobalVariables.apiRequestAttemptCountersByAwsAccount
                    .get(uniqueAwsAccountIdentifier);
            long currentRequestCount = requestAttemptCounter.incrementAndGet();

            while (currentRequestCount > maxApiRequestsPerSecond) {
                Threads.sleepMilliseconds(50);
                currentRequestCount = requestAttemptCounter.incrementAndGet();
            }

            describeSnapshotsResult = ec2Client.describeSnapshots(describeSnapshotsRequest);

            if (describeSnapshotsResult != null) {
                GlobalVariables.apiRequestCountersByAwsAccount.get(uniqueAwsAccountIdentifier)
                        .incrementAndGet();
                break;
            }
        } catch (Exception e) {
            logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\","
                    + describeSnapshotsRequest.toString() + System.lineSeparator() + e.toString()
                    + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
        }
    }

    return describeSnapshotsResult;

}