Search in sources :

Example 1 with LocatedBlockProto

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);
}
Also used : LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock) Test(org.junit.Test)

Example 2 with LocatedBlockProto

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;
}
Also used : LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) ArrayList(java.util.ArrayList) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock)

Example 3 with LocatedBlockProto

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();
}
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 4 with LocatedBlockProto

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;
}
Also used : ServiceException(com.google.protobuf.ServiceException) LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock) IOException(java.io.IOException)

Example 5 with LocatedBlockProto

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;
}
Also used : LocatedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto) ArrayList(java.util.ArrayList) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock)

Aggregations

LocatedBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto)8 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)6 ArrayList (java.util.ArrayList)3 ServiceException (com.google.protobuf.ServiceException)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 RecoveringBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.RecoveringBlockProto)1 RecoveringStripedBlock (org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringStripedBlock)1