code: protected static int getTotalAttempts(ClientRequestContext ctx) {
          final State state = ctx.attr(STATE).get();
          if (state == null) {
              return 0;
          }
          return state.totalAttemptNo;
      }
docs: Returns the total number of attempts of the current request represented by the specified
  {@link ClientRequestContext}.