use of org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto in project hadoop by apache.
the class PBHelper method convert.
public static BlocksWithLocations convert(BlocksWithLocationsProto blocks) {
List<BlockWithLocationsProto> b = blocks.getBlocksList();
BlockWithLocations[] ret = new BlockWithLocations[b.size()];
int i = 0;
for (BlockWithLocationsProto entry : b) {
ret[i++] = convert(entry);
}
return new BlocksWithLocations(ret);
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto in project hadoop by apache.
the class TestPBHelper method testConvertBlockWithLocations.
@Test
public void testConvertBlockWithLocations() {
boolean[] testSuite = new boolean[] { false, true };
for (int i = 0; i < testSuite.length; i++) {
BlockWithLocations locs = getBlockWithLocations(1, testSuite[i]);
BlockWithLocationsProto locsProto = PBHelper.convert(locs);
BlockWithLocations locs2 = PBHelper.convert(locsProto);
compare(locs, locs2);
}
}
use of org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto in project hadoop by apache.
the class PBHelper method convert.
public static BlockWithLocationsProto convert(BlockWithLocations blk) {
BlockWithLocationsProto.Builder builder = BlockWithLocationsProto.newBuilder().setBlock(PBHelperClient.convert(blk.getBlock())).addAllDatanodeUuids(Arrays.asList(blk.getDatanodeUuids())).addAllStorageUuids(Arrays.asList(blk.getStorageIDs())).addAllStorageTypes(PBHelperClient.convertStorageTypes(blk.getStorageTypes()));
if (blk instanceof StripedBlockWithLocations) {
StripedBlockWithLocations sblk = (StripedBlockWithLocations) blk;
builder.setIndices(PBHelperClient.getByteString(sblk.getIndices()));
builder.setDataBlockNum(sblk.getDataBlockNum());
builder.setCellSize(sblk.getCellSize());
}
return builder.build();
}
Aggregations