HBASE-7488 Implement HConnectionManager.locateRegions which is currently returning null (Jean-Marc)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1428907 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a88563783a
commit
e107a64087
|
@ -412,6 +412,15 @@ public class HRegionInfo implements Comparable<HRegionInfo> {
|
|||
return tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start key from the specified region name.
|
||||
* @param regionName
|
||||
* @return Start key.
|
||||
*/
|
||||
public static byte[] getStartKey(final byte[] regionName) throws IOException {
|
||||
return parseRegionName(regionName)[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Separate elements of a regionName.
|
||||
* @param regionName
|
||||
|
|
|
@ -176,8 +176,20 @@ public interface HConnection extends Abortable, Closeable {
|
|||
* @return list of region locations for all regions of table
|
||||
* @throws IOException
|
||||
*/
|
||||
public List<HRegionLocation> locateRegions(byte[] tableName)
|
||||
public List<HRegionLocation> locateRegions(final byte[] tableName)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Gets the locations of all regions in the specified table, <i>tableName</i>.
|
||||
* @param tableName table to get regions of
|
||||
* @param useCache Should we use the cache to retrieve the region information.
|
||||
* @param offlined True if we are to include offlined regions, false and we'll leave out offlined
|
||||
* regions from returned list.
|
||||
* @return list of region locations for all regions of table
|
||||
* @throws IOException
|
||||
*/
|
||||
public List<HRegionLocation> locateRegions(final byte[] tableName, final boolean useCache,
|
||||
final boolean offlined) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a {@link MasterAdminProtocol} to the active master
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -893,17 +894,27 @@ public class HConnectionManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public HRegionLocation locateRegion(final byte [] regionName)
|
||||
throws IOException {
|
||||
// TODO implement. use old stuff or new stuff?
|
||||
return null;
|
||||
public HRegionLocation locateRegion(final byte[] regionName) throws IOException {
|
||||
return locateRegion(HRegionInfo.getTableName(regionName),
|
||||
HRegionInfo.getStartKey(regionName), false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HRegionLocation> locateRegions(final byte [] tableName)
|
||||
public List<HRegionLocation> locateRegions(final byte[] tableName)
|
||||
throws IOException {
|
||||
// TODO implement. use old stuff or new stuff?
|
||||
return null;
|
||||
return locateRegions (tableName, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HRegionLocation> locateRegions(final byte[] tableName, final boolean useCache,
|
||||
final boolean offlined) throws IOException {
|
||||
NavigableMap<HRegionInfo, ServerName> regions = MetaScanner.allTableRegions(conf, tableName,
|
||||
offlined);
|
||||
final List<HRegionLocation> locations = new ArrayList<HRegionLocation>();
|
||||
for (HRegionInfo regionInfo : regions.keySet()) {
|
||||
locations.add(locateRegion(tableName, regionInfo.getStartKey(), useCache, true));
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue