-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MWAA CFn Resource Provider (#6)
Co-authored-by: Jake He <[email protected]>
- Loading branch information
1 parent
b518a5a
commit 5a603c3
Showing
14 changed files
with
337 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...onment/src/main/java/software/amazon/mwaa/environment/CreateEnvironmentRetryListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
package software.amazon.mwaa.environment; | ||
|
||
import com.github.rholder.retry.Attempt; | ||
import com.github.rholder.retry.RetryListener; | ||
import software.amazon.cloudformation.proxy.Logger; | ||
|
||
/** | ||
* Listener for CreateEnvironment retries. | ||
*/ | ||
public class CreateEnvironmentRetryListener implements RetryListener { | ||
private long attemptNumber = 0; | ||
private long delaySinceFirstAttempt = 0; | ||
|
||
private final Logger logger; | ||
private final int maxRetries; | ||
private final String environmentName; | ||
|
||
/** | ||
* | ||
* @param logger logger for retry logging. | ||
* @param maxRetries maximum retry attempts before failure. | ||
* @param environmentName name of environment to be created. | ||
*/ | ||
public CreateEnvironmentRetryListener(Logger logger, int maxRetries, String environmentName) { | ||
this.logger = logger; | ||
this.maxRetries = maxRetries; | ||
this.environmentName = environmentName; | ||
} | ||
|
||
@Override | ||
public <V> void onRetry(Attempt<V> attempt) { | ||
attemptNumber = attempt.getAttemptNumber(); | ||
delaySinceFirstAttempt = attempt.getDelaySinceFirstAttempt(); | ||
|
||
if (attempt.hasResult()) { | ||
log("CreateEnvironment [%s]: retry attempt %d/%d successful. Total delay since first attempt: %dms", | ||
environmentName, attemptNumber, maxRetries, delaySinceFirstAttempt); | ||
} else { | ||
log("CreateEnvironment [%s]: retry attempt %d/%d failed with error message: %s. " | ||
+ "Total delay since first attempt: %dms", | ||
environmentName, | ||
attemptNumber, | ||
maxRetries, | ||
attempt.getExceptionCause().getMessage(), | ||
delaySinceFirstAttempt); | ||
} | ||
} | ||
|
||
private void log(final String format, final Object... args) { | ||
if (logger != null) { | ||
logger.log(String.format(format, args)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.