1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 package org.apache.hadoop.hbase.client; 20 21 import org.apache.hadoop.hbase.classification.InterfaceAudience; 22 import org.apache.hadoop.hbase.classification.InterfaceStability; 23 import org.apache.hadoop.hbase.HRegionLocation; 24 import org.apache.hadoop.hbase.TableName; 25 import org.apache.hadoop.hbase.util.Pair; 26 27 import java.io.Closeable; 28 import java.io.IOException; 29 import java.util.List; 30 31 /** 32 * Used to view region location information for a single HBase table. 33 * Obtain an instance from an {@link Connection}. 34 * 35 * @see ConnectionFactory 36 * @see Connection 37 * @see Table 38 * @since 0.99.0 39 */ 40 @InterfaceAudience.Public 41 @InterfaceStability.Evolving 42 public interface RegionLocator extends Closeable { 43 /** 44 * Finds the region on which the given row is being served. Does not reload the cache. 45 * @param row Row to find. 46 * @return Location of the row. 47 * @throws IOException if a remote or network exception occurs 48 */ 49 public HRegionLocation getRegionLocation(final byte [] row) throws IOException; 50 51 /** 52 * Finds the region on which the given row is being served. 53 * @param row Row to find. 54 * @param reload true to reload information or false to use cached information 55 * @return Location of the row. 56 * @throws IOException if a remote or network exception occurs 57 */ 58 public HRegionLocation getRegionLocation(final byte [] row, boolean reload) 59 throws IOException; 60 61 /** 62 * Retrieves all of the regions associated with this table. 63 * @return a {@link List} of all regions associated with this table. 64 * @throws IOException if a remote or network exception occurs 65 */ 66 public List<HRegionLocation> getAllRegionLocations() 67 throws IOException; 68 69 /** 70 * Gets the starting row key for every region in the currently open table. 71 * <p> 72 * This is mainly useful for the MapReduce integration. 73 * @return Array of region starting row keys 74 * @throws IOException if a remote or network exception occurs 75 */ 76 public byte [][] getStartKeys() throws IOException; 77 78 /** 79 * Gets the ending row key for every region in the currently open table. 80 * <p> 81 * This is mainly useful for the MapReduce integration. 82 * @return Array of region ending row keys 83 * @throws IOException if a remote or network exception occurs 84 */ 85 public byte[][] getEndKeys() throws IOException; 86 87 /** 88 * Gets the starting and ending row keys for every region in the currently 89 * open table. 90 * <p> 91 * This is mainly useful for the MapReduce integration. 92 * @return Pair of arrays of region starting and ending row keys 93 * @throws IOException if a remote or network exception occurs 94 */ 95 public Pair<byte[][],byte[][]> getStartEndKeys() throws IOException; 96 97 /** 98 * Gets the fully qualified table name instance of this table. 99 */ 100 TableName getName(); 101 }