コード例 #1
0
  /** Perform appropriate backoff etc. extraction. */
  public void interpretHTTPFailure(HttpResponse response) {
    // TODO: handle permanent rejection.
    long responseBackoff = (new SyncResponse(response)).totalBackoffInMilliseconds();
    if (responseBackoff > 0) {
      callback.requestBackoff(responseBackoff);
    }

    if (response.getStatusLine() != null) {
      final int statusCode = response.getStatusLine().getStatusCode();
      switch (statusCode) {
        case 400:
          SyncStorageResponse storageResponse = new SyncStorageResponse(response);
          this.interpretHTTPBadRequestBody(storageResponse);
          break;

        case 401:
          /*
           * Alert our callback we have a 401 on a cluster URL. This GlobalSession
           * will fail, but the next one will fetch a new cluster URL and will
           * distinguish between "node reassignment" and "user password changed".
           */
          callback.informUnauthorizedResponse(this, config.getClusterURL());
          break;
      }
    }
  }