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 * http://www.apache.org/licenses/LICENSE-2.0
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.apache.hadoop.hbase.client;
017
018import org.apache.yetus.audience.InterfaceAudience;
019
020/**
021 * <p>There are two modes with catalog replica support. </p>
022 *
023 * <ol>
024 *   <li>HEDGED_READ  - Client sends requests to the primary region first, within a
025 *                 configured amount of time, if there is no response coming back,
026 *                 client sends requests to all replica regions and takes the first
027 *                 response. </li>
028 *
029 *   <li>LOAD_BALANCE - Client sends requests to replica regions in a round-robin mode,
030 *                 if results from replica regions are stale, next time, client sends requests for
031 *                 these stale locations to the primary region. In this mode, scan
032 *                 requests are load balanced across all replica regions.</li>
033 * </ol>
034 */
035@InterfaceAudience.Private
036enum CatalogReplicaMode {
037  NONE {
038    @Override
039    public String toString() {
040      return "None";
041    }
042  },
043  HEDGED_READ {
044    @Override
045    public String toString() {
046      return "HedgedRead";
047    }
048  },
049  LOAD_BALANCE {
050    @Override
051    public String toString() {
052      return "LoadBalance";
053    }
054  };
055
056  public static CatalogReplicaMode fromString(final String value) {
057    for(CatalogReplicaMode mode : values()) {
058      if (mode.toString().equalsIgnoreCase(value)) {
059        return mode;
060      }
061    }
062    throw new IllegalArgumentException();
063  }
064}