use of org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoRequest in project phoenix by apache.
the class MetaDataUtil method tableRegionsOnline.
/**
* This function checks if all regions of a table is online
* @param table
* @return true when all regions of a table are online
* @throws IOException
* @throws
*/
public static boolean tableRegionsOnline(Configuration conf, PTable table) {
HConnection hcon = null;
try {
hcon = HConnectionManager.getConnection(conf);
List<HRegionLocation> locations = hcon.locateRegions(org.apache.hadoop.hbase.TableName.valueOf(table.getTableName().getBytes()));
for (HRegionLocation loc : locations) {
try {
ServerName sn = loc.getServerName();
if (sn == null)
continue;
AdminService.BlockingInterface admin = hcon.getAdmin(sn);
GetRegionInfoRequest request = RequestConverter.buildGetRegionInfoRequest(loc.getRegionInfo().getRegionName());
admin.getRegionInfo(null, request);
} catch (ServiceException e) {
IOException ie = ProtobufUtil.getRemoteException(e);
logger.debug("Region " + loc.getRegionInfo().getEncodedName() + " isn't online due to:" + ie);
return false;
} catch (RemoteException e) {
logger.debug("Cannot get region " + loc.getRegionInfo().getEncodedName() + " info due to error:" + e);
return false;
}
}
} catch (IOException ex) {
logger.warn("tableRegionsOnline failed due to:" + ex);
return false;
} finally {
if (hcon != null) {
try {
hcon.close();
} catch (IOException ignored) {
}
}
}
return true;
}
Aggregations