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. {@link RetryingCallerInterceptorContext} is
025 * the piece of information unique to a retrying call that transfers information from the call into
026 * the {@link RetryingCallerInterceptor} so that {@link RetryingCallerInterceptor} can take
027 * appropriate action according to the specific logic
028 */
029@InterfaceAudience.Private
030abstract class RetryingCallerInterceptorContext {
031  protected RetryingCallerInterceptorContext() {
032  }
033
034  /**
035   * This function clears the internal state of the context object.
036   */
037  public abstract void clear();
038
039  /**
040   * This prepares the context object by populating it with information specific to the
041   * implementation of the {@link RetryingCallerInterceptor} along with which this will be used. n *
042   * : The {@link RetryingCallable} that contains the information about the call that is being made.
043   * @return A new {@link RetryingCallerInterceptorContext} object that can be used for use in the
044   *         current retrying call
045   */
046  public abstract RetryingCallerInterceptorContext prepare(RetryingCallable<?> callable);
047
048  /**
049   * Telescopic extension that takes which of the many retries we are currently in. n * : The
050   * {@link RetryingCallable} that contains the information about the call that is being made. n * :
051   * The retry number that we are currently in.
052   * @return A new context object that can be used for use in the current retrying call
053   */
054  public abstract RetryingCallerInterceptorContext prepare(RetryingCallable<?> callable, int tries);
055}