com.rt.storage.api.client.http.BackOffPolicy Maven / Gradle / Ivy
package com.rt.storage.api.client.http;
import com.rt.storage.api.client.util.Beta;
import java.io.IOException;
/**
* {@link Beta}
* Strategy interface to control back off between retry attempts.
*
* @since 1.7
* @author Ravi Mistry
* @deprecated (scheduled to be removed in 1.18) Use {@link HttpBackOffUnsuccessfulResponseHandler}
* instead.
*/
@Deprecated
@Beta
public interface BackOffPolicy {
/** Value indicating that no more retries should be made, see {@link #getNextBackOffMillis()}. */
public static final long STOP = -1L;
/**
* Determines if back off is required based on the specified status code.
*
* Implementations may want to back off on server or product-specific errors.
*
* @param statusCode HTTP status code
*/
public boolean isBackOffRequired(int statusCode);
/** Reset Back off counters (if any) in an implementation-specific fashion. */
public void reset();
/**
* Gets the number of milliseconds to wait before retrying an HTTP request. If {@link #STOP} is
* returned, no retries should be made.
*
*
This method should be used as follows:
*
*
* long backoffTime = backoffPolicy.getNextBackoffMs();
* if (backoffTime == BackoffPolicy.STOP) {
* // Stop retrying.
* } else {
* // Retry after backoffTime.
* }
*
*
* @return the number of milliseconds to wait when backing off requests, or {@link #STOP} if no
* more retries should be made
*/
public long getNextBackOffMillis() throws IOException;
}