Exemplo n.º 1
0
 public void handleHTTPError(SyncStorageResponse response, String reason) {
   // TODO: handling of 50x (backoff), 401 (node reassignment or auth error).
   // Fall back to aborting.
   Logger.warn(LOG_TAG, "Aborting sync due to HTTP " + response.getStatusCode());
   this.interpretHTTPFailure(response.httpResponse());
   this.abort(new HTTPFailureException(response), reason);
 }
Exemplo n.º 2
0
  /**
   * We failed to sync this engine! Do not persist timestamps (which means that the next sync will
   * include this sync's data), but do advance the session (if we didn't get a Retry-After header).
   *
   * @param synchronizer the <code>Synchronizer</code> that failed.
   */
  @Override
  public void onSynchronizeFailed(
      Synchronizer synchronizer, Exception lastException, String reason) {
    Logger.warn(LOG_TAG, "Synchronize failed: " + reason, lastException);

    // This failure could be due to a 503 or a 401 and it could have headers.
    // Interrogate the headers but only abort the global session if Retry-After header is set.
    if (lastException instanceof HTTPFailureException) {
      SyncStorageResponse response = ((HTTPFailureException) lastException).response;
      if (response.retryAfterInSeconds() > 0) {
        session.handleHTTPError(response, reason); // Calls session.abort().
        return;
      } else {
        session.interpretHTTPFailure(response.httpResponse()); // Does not call session.abort().
      }
    }

    Logger.info(LOG_TAG, "Advancing session even though stage failed. Timestamps not persisted.");
    session.advance();
  }