use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto in project hadoop by apache.
the class TestPBHelper method testConvertLocatedBlock.
@Test
public void testConvertLocatedBlock() {
LocatedBlock lb = createLocatedBlock();
LocatedBlockProto lbProto = PBHelperClient.convertLocatedBlock(lb);
LocatedBlock lb2 = PBHelperClient.convertLocatedBlockProto(lbProto);
compare(lb, lb2);
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto in project hadoop by apache.
the class PBHelperClient method convertLocatedBlock.
public static List<LocatedBlock> convertLocatedBlock(List<LocatedBlockProto> lb) {
if (lb == null)
return null;
final int len = lb.size();
List<LocatedBlock> result = new ArrayList<>(len);
for (LocatedBlockProto aLb : lb) {
result.add(convertLocatedBlockProto(aLb));
}
return result;
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto in project hadoop by apache.
the class PBHelper method convert.
public static RecoveringBlockProto convert(RecoveringBlock b) {
if (b == null) {
return null;
}
LocatedBlockProto lb = PBHelperClient.convertLocatedBlock(b);
RecoveringBlockProto.Builder builder = RecoveringBlockProto.newBuilder();
builder.setBlock(lb).setNewGenStamp(b.getNewGenerationStamp());
if (b.getNewBlock() != null)
builder.setTruncateBlock(PBHelperClient.convert(b.getNewBlock()));
if (b instanceof RecoveringStripedBlock) {
RecoveringStripedBlock sb = (RecoveringStripedBlock) b;
builder.setEcPolicy(PBHelperClient.convertErasureCodingPolicy(sb.getErasureCodingPolicy()));
builder.setBlockIndices(PBHelperClient.getByteString(sb.getBlockIndices()));
}
return builder.build();
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto in project hadoop by apache.
the class DatanodeProtocolServerSideTranslatorPB method reportBadBlocks.
@Override
public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller, ReportBadBlocksRequestProto request) throws ServiceException {
List<LocatedBlockProto> lbps = request.getBlocksList();
LocatedBlock[] blocks = new LocatedBlock[lbps.size()];
for (int i = 0; i < lbps.size(); i++) {
blocks[i] = PBHelperClient.convertLocatedBlockProto(lbps.get(i));
}
try {
impl.reportBadBlocks(blocks);
} catch (IOException e) {
throw new ServiceException(e);
}
return VOID_REPORT_BAD_BLOCK_RESPONSE;
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto in project hadoop by apache.
the class PBHelperClient method convertLocatedBlocks.
public static List<LocatedBlock> convertLocatedBlocks(List<LocatedBlockProto> lb) {
if (lb == null)
return null;
final int len = lb.size();
List<LocatedBlock> result = new ArrayList<>(len);
for (LocatedBlockProto aLb : lb) {
result.add(convertLocatedBlockProto(aLb));
}
return result;
}
Aggregations