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.
Merge pull request #22 from jianghaolu/master
Updates from Java SDK
- Loading branch information
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.