Map<HRegionInfo, ServerName> regionLocations =
table.getRegionLocations();
List<TRegionInfo> results = new ArrayList<TRegionInfo>();
for (Map.Entry<HRegionInfo, ServerName> entry :
regionLocations.entrySet()) {
HRegionInfo info = entry.getKey();
ServerName serverName = entry.getValue();
TRegionInfo region = new TRegionInfo();
region.serverName = ByteBuffer.wrap(
Bytes.toBytes(serverName.getHostname()));
region.port = serverName.getPort();
region.startKey = ByteBuffer.wrap(info.getStartKey());
region.endKey = ByteBuffer.wrap(info.getEndKey());
region.id = info.getRegionId();
region.name = ByteBuffer.wrap(info.getRegionName());
region.version = info.getVersion();
results.add(region);
}
return results;
} catch (TableNotFoundException e) {
// Return empty list for non-existing table