001/** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.client; 020 021import java.io.Closeable; 022import java.io.IOException; 023import java.util.List; 024 025import org.apache.hadoop.hbase.HRegionLocation; 026import org.apache.hadoop.hbase.TableName; 027import org.apache.yetus.audience.InterfaceAudience; 028import org.apache.hadoop.hbase.util.Pair; 029 030/** 031 * Used to view region location information for a single HBase table. 032 * Obtain an instance from an {@link Connection}. 033 * 034 * @see ConnectionFactory 035 * @see Connection 036 * @see Table 037 * @since 0.99.0 038 */ 039@InterfaceAudience.Public 040public interface RegionLocator extends Closeable { 041 /** 042 * Finds the region on which the given row is being served. Does not reload the cache. 043 * @param row Row to find. 044 * @return Location of the row. 045 * @throws IOException if a remote or network exception occurs 046 */ 047 public HRegionLocation getRegionLocation(final byte [] row) throws IOException; 048 049 /** 050 * Finds the region on which the given row is being served. 051 * @param row Row to find. 052 * @param reload true to reload information or false to use cached information 053 * @return Location of the row. 054 * @throws IOException if a remote or network exception occurs 055 */ 056 public HRegionLocation getRegionLocation(final byte [] row, boolean reload) 057 throws IOException; 058 059 /** 060 * Retrieves all of the regions associated with this table. 061 * @return a {@link List} of all regions associated with this table. 062 * @throws IOException if a remote or network exception occurs 063 */ 064 public List<HRegionLocation> getAllRegionLocations() 065 throws IOException; 066 067 /** 068 * Gets the starting row key for every region in the currently open table. 069 * <p> 070 * This is mainly useful for the MapReduce integration. 071 * @return Array of region starting row keys 072 * @throws IOException if a remote or network exception occurs 073 */ 074 public byte [][] getStartKeys() throws IOException; 075 076 /** 077 * Gets the ending row key for every region in the currently open table. 078 * <p> 079 * This is mainly useful for the MapReduce integration. 080 * @return Array of region ending row keys 081 * @throws IOException if a remote or network exception occurs 082 */ 083 public byte[][] getEndKeys() throws IOException; 084 085 /** 086 * Gets the starting and ending row keys for every region in the currently 087 * open table. 088 * <p> 089 * This is mainly useful for the MapReduce integration. 090 * @return Pair of arrays of region starting and ending row keys 091 * @throws IOException if a remote or network exception occurs 092 */ 093 public Pair<byte[][],byte[][]> getStartEndKeys() throws IOException; 094 095 /** 096 * Gets the fully qualified table name instance of this table. 097 */ 098 TableName getName(); 099}