com.google.api.client.http
Interface BackOffPolicy

All Known Implementing Classes:
ExponentialBackOffPolicy

public interface BackOffPolicy

Strategy interface to control back off between retry attempts.

Since:
1.7
Author:
Ravi Mistry

Field Summary
static long STOP
          Value indicating that no more retries should be made, see getNextBackOffMillis().
 
Method Summary
 long getNextBackOffMillis()
          Gets the number of milliseconds to wait before retrying an HTTP request.
 boolean isBackOffRequired(int statusCode)
          Determines if back off is required based on the specified status code.
 void reset()
          Reset Back off counters (if any) in an implementation-specific fashion.
 

Field Detail

STOP

static final long STOP
Value indicating that no more retries should be made, see getNextBackOffMillis().

See Also:
Constant Field Values
Method Detail

isBackOffRequired

boolean isBackOffRequired(int statusCode)
Determines if back off is required based on the specified status code.

Implementations may want to back off on server or product-specific errors.

Parameters:
statusCode - HTTP status code

reset

void reset()
Reset Back off counters (if any) in an implementation-specific fashion.


getNextBackOffMillis

long getNextBackOffMillis()
                          throws IOException
Gets the number of milliseconds to wait before retrying an HTTP request. If 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.
   }
 

Upgrade warning: getNextBackOffMillis() now throws an IOException, it was not thrown prior to 1.9.

Returns:
the number of milliseconds to wait when backing off requests, or STOP if no more retries should be made
Throws:
IOException


Copyright © 2011-2012 Google. All Rights Reserved.