forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
3fa32be Merge pull request #22 from jianghaolu/master cf2fdb5 Adding publicIp sample, only mark sub-DAGs as non-prepare - the root DAG stay as preparer 1d5e9c1 improving comment as per review 25beef0 Addressing review comments [javadoc, simplfying the map iteration] cfbafd0 comment corrections ac633da Making DAG to work correctly to handle more cases 45c3d88 couple of javadoc fixes 57288f4 Merge pull request Azure#819 from jianghaolu/async 999fb18 Add retry for 404 GET 9c048fc Add a bunch of configs to RestClient 46a53cd Merge branch 'master' of github.com:Azure/azure-sdk-for-java into async 76e3ae9 Merge pull request Azure#832 from jianghaolu/restclient 7be25fe Merge commit '486acdc633c498d4335711e30817cc70faacc487' into restclient f84d8eb making dag::prepare to work for update bb4a917 Fixing the bug of trying to create created resources during update, adding better way to name gen resource names 738d121 use AZURE_GERMANY insteadof AZURE_GERMAN 6c8f63a ensuring trailing slash for urls c8db8d3 correcting environment name 0261a6e Adding few more Azure environments 5aac1fa Add applyAsync() bc57070 Basic prototyping of async in fluent git-subtree-dir: runtimes git-subtree-split: 3fa32be
- Loading branch information
1 parent
75623b4
commit c0aa849
Showing
13 changed files
with
304 additions
and
66 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
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
48 changes: 48 additions & 0 deletions
48
...runtime/src/main/java/com/microsoft/azure/ResourceGetExponentialBackoffRetryStrategy.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,48 @@ | ||
/** | ||
* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* | ||
*/ | ||
|
||
package com.microsoft.azure; | ||
|
||
import com.microsoft.rest.retry.RetryStrategy; | ||
import okhttp3.Response; | ||
|
||
/** | ||
* A retry strategy with backoff parameters for calculating the exponential | ||
* delay between retries for 404s from GET calls. | ||
*/ | ||
public class ResourceGetExponentialBackoffRetryStrategy extends RetryStrategy { | ||
/** | ||
* Represents the default number of retries. | ||
*/ | ||
private static final int DEFAULT_NUMBER_OF_ATTEMPTS = 3; | ||
|
||
/** | ||
* Creates an instance of the retry strategy. | ||
*/ | ||
public ResourceGetExponentialBackoffRetryStrategy() { | ||
this(null, DEFAULT_FIRST_FAST_RETRY); | ||
} | ||
|
||
/** | ||
* Initializes a new instance of the {@link RetryStrategy} class. | ||
* | ||
* @param name The name of the retry strategy. | ||
* @param firstFastRetry true to immediately retry in the first attempt; otherwise, false. | ||
*/ | ||
private ResourceGetExponentialBackoffRetryStrategy(String name, boolean firstFastRetry) { | ||
super(name, firstFastRetry); | ||
} | ||
|
||
@Override | ||
public boolean shouldRetry(int retryCount, Response response) { | ||
int code = response.code(); | ||
//CHECKSTYLE IGNORE MagicNumber FOR NEXT 2 LINES | ||
return retryCount < DEFAULT_NUMBER_OF_ATTEMPTS | ||
&& code == 404 | ||
&& response.request().method().equalsIgnoreCase("GET"); | ||
} | ||
} |
Oops, something went wrong.