Copyright Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
/** * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
package com.microsoft.azure.storage; import com.microsoft.azure.storage.core.Utility;
Represents the context for a retry of a request made against the storage services.
/** * Represents the context for a retry of a request made against the storage services. */
public class RetryInfo {
The location that the next retry should target.
/** * The location that the next retry should target. */
private StorageLocation targetLocation;
The location mode for subsequent retries.
/** * The location mode for subsequent retries. */
private LocationMode updatedLocationMode;
The interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds.
/** * The interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds. */
private int retryInterval = 3000;
Initializes a new instance of the RetryInfo class.
/** * Initializes a new instance of the {@link RetryInfo} class. */
public RetryInfo() { this.targetLocation = StorageLocation.PRIMARY; this.updatedLocationMode = LocationMode.PRIMARY_ONLY; }
Initializes a new instance of the RetryInfo class.
Params:
  • retryContext – The RetryContext object that was passed in to the retry policy.
/** * Initializes a new instance of the {@link RetryInfo} class. * * @param retryContext * The {@link RetryContext} object that was passed in to the retry policy. */
public RetryInfo(RetryContext retryContext) { Utility.assertNotNull("retryContext", retryContext); this.targetLocation = retryContext.getNextLocation(); this.updatedLocationMode = retryContext.getLocationMode(); }
Gets the interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds.
Returns:An int which represents the retry interval (in milliseconds).
/** * Gets the interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds. * * @return An <code>int</code> which represents the retry interval (in milliseconds). */
public int getRetryInterval() { return this.retryInterval; }
Gets the location that the next retry should target.
Returns:A StorageLocation object which represents the location for the next retry.
/** * Gets the location that the next retry should target. * * @return A {@link StorageLocation} object which represents the location for the next retry. */
public final StorageLocation getTargetLocation() { return this.targetLocation; }
Gets the location mode for subsequent retries.
Returns:A LocationMode object which represents the location mode for subsequent retries.
/** * Gets the location mode for subsequent retries. * * @return A {@link LocationMode} object which represents the location mode for subsequent retries. */
public LocationMode getUpdatedLocationMode() { return this.updatedLocationMode; }
Sets the interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds.
Params:
  • retryInterval – An int which represents the retry interval to set.
/** * Sets the interval in milliseconds until the next retry. The minimum back-off interval is 3 seconds. * * @param retryInterval * An <code>int</code> which represents the retry interval to set. */
public void setRetryInterval(int retryInterval) { this.retryInterval = (retryInterval > 0 ? retryInterval : 0); }
Sets the location that the next retry should target.
Params:
  • targetLocation – A StorageLocation object which represents the location to set.
/** * Sets the location that the next retry should target. * * @param targetLocation * A {@link StorageLocation} object which represents the location to set. */
public void setTargetLocation(StorageLocation targetLocation) { this.targetLocation = targetLocation; }
Sets the location mode for subsequent retries.
Params:
  • updatedLocationMode – A LocationMode object which represents the the location mode to set.
/** * Sets the location mode for subsequent retries. * * @param updatedLocationMode * A {@link LocationMode} object which represents the the location mode to set. */
public void setUpdatedLocationMode(LocationMode updatedLocationMode) { this.updatedLocationMode = updatedLocationMode; }
Returns a string that represents the current RetryInfo instance.
Returns:A String which represents the current RetryInfo instance.
/** * Returns a string that represents the current {@link RetryInfo} instance. * * @return A <code>String</code> which represents the current <code>RetryInfo</code> instance. */
@Override public String toString() { return String.format(Utility.LOCALE_US, "(%s,%s)", this.targetLocation, this.retryInterval); } }