use of org.apache.hadoop.hbase.thrift2.generated.THRegionLocation in project hbase by apache.
the class ThriftUtilities method regionLocationFromHBase.
public static THRegionLocation regionLocationFromHBase(HRegionLocation hrl) {
HRegionInfo hri = hrl.getRegionInfo();
ServerName serverName = hrl.getServerName();
THRegionInfo thRegionInfo = new THRegionInfo();
THRegionLocation thRegionLocation = new THRegionLocation();
TServerName tServerName = new TServerName();
tServerName.setHostName(serverName.getHostname());
tServerName.setPort(serverName.getPort());
tServerName.setStartCode(serverName.getStartcode());
thRegionInfo.setTableName(hri.getTable().getName());
thRegionInfo.setEndKey(hri.getEndKey());
thRegionInfo.setStartKey(hri.getStartKey());
thRegionInfo.setOffline(hri.isOffline());
thRegionInfo.setSplit(hri.isSplit());
thRegionInfo.setReplicaId(hri.getReplicaId());
thRegionLocation.setRegionInfo(thRegionInfo);
thRegionLocation.setServerName(tServerName);
return thRegionLocation;
}
use of org.apache.hadoop.hbase.thrift2.generated.THRegionLocation in project hbase by apache.
the class ThriftHBaseServiceHandler method getRegionLocation.
@Override
public THRegionLocation getRegionLocation(ByteBuffer table, ByteBuffer row, boolean reload) throws TIOError, TException {
RegionLocator locator = null;
try {
locator = getLocator(table);
byte[] rowBytes = byteBufferToByteArray(row);
HRegionLocation hrl = locator.getRegionLocation(rowBytes, reload);
return ThriftUtilities.regionLocationFromHBase(hrl);
} catch (IOException e) {
throw getTIOError(e);
} finally {
if (locator != null) {
try {
locator.close();
} catch (IOException e) {
LOG.warn("Couldn't close the locator.", e);
}
}
}
}
Aggregations