org.apache.hadoop.hbase.client.MultiResponse results =
new org.apache.hadoop.hbase.client.MultiResponse();
for (int i = 0; i < responseRegionActionResultCount; i++) {
RegionAction actions = request.getRegionAction(i);
RegionActionResult actionResult = response.getRegionActionResult(i);
HBaseProtos.RegionSpecifier rs = actions.getRegion();
if (rs.hasType() &&
(rs.getType() != HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)){
throw new IllegalArgumentException(
"We support only encoded types for protobuf multi response.");
}
byte[] regionName = rs.getValue().toByteArray();
if (actionResult.hasException()){
Throwable regionException = ProtobufUtil.toException(actionResult.getException());
results.addException(regionName, regionException);
continue;
}
if (actions.getActionCount() != actionResult.getResultOrExceptionCount()) {
throw new IllegalStateException("actions.getActionCount=" + actions.getActionCount() +
", actionResult.getResultOrExceptionCount=" +
actionResult.getResultOrExceptionCount() + " for region " + actions.getRegion());
}
for (ResultOrException roe : actionResult.getResultOrExceptionList()) {
if (roe.hasException()) {
results.add(regionName, new Pair<Integer, Object>(roe.getIndex(),
ProtobufUtil.toException(roe.getException())));
} else if (roe.hasResult()) {
results.add(regionName, new Pair<Integer, Object>(roe.getIndex(),