Search in sources :

Example 1 with THRegionLocation

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;
}
Also used : THRegionInfo(org.apache.hadoop.hbase.thrift2.generated.THRegionInfo) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) THRegionInfo(org.apache.hadoop.hbase.thrift2.generated.THRegionInfo) THRegionLocation(org.apache.hadoop.hbase.thrift2.generated.THRegionLocation) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName) ServerName(org.apache.hadoop.hbase.ServerName) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName)

Example 2 with 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);
            }
        }
    }
}
Also used : RegionLocator(org.apache.hadoop.hbase.client.RegionLocator) THRegionLocation(org.apache.hadoop.hbase.thrift2.generated.THRegionLocation) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) IOException(java.io.IOException)

Aggregations

THRegionLocation (org.apache.hadoop.hbase.thrift2.generated.THRegionLocation)2 IOException (java.io.IOException)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 ServerName (org.apache.hadoop.hbase.ServerName)1 RegionLocator (org.apache.hadoop.hbase.client.RegionLocator)1 THRegionInfo (org.apache.hadoop.hbase.thrift2.generated.THRegionInfo)1 TServerName (org.apache.hadoop.hbase.thrift2.generated.TServerName)1