List of usage examples for com.amazonaws.services.ec2.model DeleteSnapshotRequest getSnapshotId
public String getSnapshotId()
The ID of the EBS snapshot.
From source file:com.pearson.eidetic.aws.EC2ClientMethods.java
public static void deleteSnapshot(AmazonEC2Client ec2Client, DeleteSnapshotRequest deletesnapshotRequest, Integer numRetries, Integer maxApiRequestsPerSecond, String uniqueAwsAccountIdentifier) { for (int i = 0; i <= numRetries; i++) { try {/* w w w . jav a 2 s. co m*/ // 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(); } try { ec2Client.deleteSnapshot(deletesnapshotRequest); try { GlobalVariables.apiRequestCountersByAwsAccount.get(uniqueAwsAccountIdentifier) .incrementAndGet(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\"," + deletesnapshotRequest.toString() + System.lineSeparator() + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); } break; } catch (Exception e) { if (e.toString().contains("InvalidSnapshot.InUse")) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\"," + deletesnapshotRequest.toString() + System.lineSeparator() + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); break; } logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\"," + deletesnapshotRequest.toString() + System.lineSeparator() + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); } } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\"," + deletesnapshotRequest.toString() + System.lineSeparator() + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); } } logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier + "\",Event=\"Snapshot Deleted\", Snapshot_id=\"" + deletesnapshotRequest.getSnapshotId() + "\""); }
From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java
License:Open Source License
@Override public DeleteSnapshotResult deleteSnapshot(DeleteSnapshotRequest deleteSnapshotRequest) { try {/*w w w . jav a 2s. c o m*/ jec2.deleteSnapshot(deleteSnapshotRequest.getSnapshotId()); return new DeleteSnapshotResult(); } catch (EC2Exception e) { throw new AmazonClientException(e); } }