Search in sources :

Example 1 with BlocksWithLocationsProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlocksWithLocationsProto in project hadoop by apache.

the class TestPBHelper method testConvertBlocksWithLocations.

@Test
public void testConvertBlocksWithLocations() {
    boolean[] testSuite = new boolean[] { false, true };
    for (int i = 0; i < testSuite.length; i++) {
        BlockWithLocations[] list = new BlockWithLocations[] { getBlockWithLocations(1, testSuite[i]), getBlockWithLocations(2, testSuite[i]) };
        BlocksWithLocations locs = new BlocksWithLocations(list);
        BlocksWithLocationsProto locsProto = PBHelper.convert(locs);
        BlocksWithLocations locs2 = PBHelper.convert(locsProto);
        BlockWithLocations[] blocks = locs.getBlocks();
        BlockWithLocations[] blocks2 = locs2.getBlocks();
        assertEquals(blocks.length, blocks2.length);
        for (int j = 0; j < blocks.length; j++) {
            compare(blocks[j], blocks2[j]);
        }
    }
}
Also used : BlocksWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations) BlocksWithLocationsProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlocksWithLocationsProto) StripedBlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.StripedBlockWithLocations) BlockWithLocations(org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.BlockWithLocations) Test(org.junit.Test)

Aggregations

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