001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import org.apache.yetus.audience.InterfaceAudience;
021
022/**
023 * The context object used in the {@link RpcRetryingCaller} to enable
024 * {@link RetryingCallerInterceptor} to intercept calls.
025 * {@link RetryingCallerInterceptorContext} is the piece of information unique
026 * to a retrying call that transfers information from the call into the
027 * {@link RetryingCallerInterceptor} so that {@link RetryingCallerInterceptor}
028 * can take appropriate action according to the specific logic
029 *
030 */
031@InterfaceAudience.Private
032abstract class RetryingCallerInterceptorContext {
033  protected RetryingCallerInterceptorContext() {
034  }
035
036  /**
037   * This function clears the internal state of the context object.
038   */
039  public abstract void clear();
040
041  /**
042   * This prepares the context object by populating it with information specific
043   * to the implementation of the {@link RetryingCallerInterceptor} along with
044   * which this will be used.
045   * 
046   * @param callable
047   *          : The {@link RetryingCallable} that contains the information about
048   *          the call that is being made.
049   * @return A new {@link RetryingCallerInterceptorContext} object that can be
050   *         used for use in the current retrying call
051   */
052  public abstract RetryingCallerInterceptorContext prepare(RetryingCallable<?> callable);
053
054  /**
055   * Telescopic extension that takes which of the many retries we are currently
056   * in.
057   * 
058   * @param callable
059   *          : The {@link RetryingCallable} that contains the information about
060   *          the call that is being made.
061   * @param tries
062   *          : The retry number that we are currently in.
063   * @return A new context object that can be used for use in the current
064   *         retrying call
065   */
066  public abstract RetryingCallerInterceptorContext prepare(RetryingCallable<?> callable, int tries);
067}