Search in sources :

Example 1 with BlockWithLocationsProto

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);
}
Also used : BlocksWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations) StripedBlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.StripedBlockWithLocations) BlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.BlockWithLocations) BlockWithLocationsProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto)

Example 2 with BlockWithLocationsProto

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);
    }
}
Also used : StripedBlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.StripedBlockWithLocations) BlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.BlockWithLocations) BlockWithLocationsProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto) Test(org.junit.Test)

Example 3 with BlockWithLocationsProto

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();
}
Also used : StripedBlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.StripedBlockWithLocations) BlockWithLocationsProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto)

Aggregations

BlockWithLocationsProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockWithLocationsProto)3 StripedBlockWithLocations (org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.StripedBlockWithLocations)3 BlockWithLocations (org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.BlockWithLocations)2 BlocksWithLocations (org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations)1 Test (org.junit.Test)1