Search in sources :

Example 1 with RecoveringBlockProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto 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();
}
Also used : LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) RecoveringStripedBlock(org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringStripedBlock) RecoveringBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto)

Example 2 with RecoveringBlockProto

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

the class PBHelper method convert.

public static BlockRecoveryCommand convert(BlockRecoveryCommandProto recoveryCmd) {
    List<RecoveringBlockProto> list = recoveryCmd.getBlocksList();
    List<RecoveringBlock> recoveringBlocks = new ArrayList<RecoveringBlock>(list.size());
    for (RecoveringBlockProto rbp : list) {
        recoveringBlocks.add(PBHelper.convert(rbp));
    }
    return new BlockRecoveryCommand(recoveringBlocks);
}
Also used : BlockRecoveryCommand(org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand) RecoveringBlock(org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringBlock) ArrayList(java.util.ArrayList) RecoveringBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto)

Example 3 with RecoveringBlockProto

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

the class TestPBHelper method testConvertRecoveringBlock.

@Test
public void testConvertRecoveringBlock() {
    DatanodeInfo di1 = DFSTestUtil.getLocalDatanodeInfo();
    DatanodeInfo di2 = DFSTestUtil.getLocalDatanodeInfo();
    DatanodeInfo[] dnInfo = new DatanodeInfo[] { di1, di2 };
    RecoveringBlock b = new RecoveringBlock(getExtendedBlock(), dnInfo, 3);
    RecoveringBlockProto bProto = PBHelper.convert(b);
    RecoveringBlock b1 = PBHelper.convert(bProto);
    assertEquals(b.getBlock(), b1.getBlock());
    DatanodeInfo[] dnInfo1 = b1.getLocations();
    assertEquals(dnInfo.length, dnInfo1.length);
    for (int i = 0; i < dnInfo.length; i++) {
        compare(dnInfo[0], dnInfo1[0]);
    }
}
Also used : DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) RecoveringBlock(org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringBlock) RecoveringBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto) Test(org.junit.Test)

Aggregations

RecoveringBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto)3 RecoveringBlock (org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringBlock)2 ArrayList (java.util.ArrayList)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 LocatedBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto)1 BlockRecoveryCommand (org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand)1 RecoveringStripedBlock (org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringStripedBlock)1 Test (org.junit.Test)1