public static RecoveringBlockProto convert(RecoveringBlock b) { if (b == null) { return null; } LocatedBlockProto lb = PBHelper.convert((LocatedBlock)b); RecoveringBlockProto.Builder builder = RecoveringBlockProto.newBuilder(); builder.setBlock(lb).setNewGenStamp(b.getNewGenerationStamp()); if(b.getNewBlock() != null) builder.setTruncateBlock(PBHelper.convert(b.getNewBlock())); return builder.build(); }
public static RecoveringBlock convert(RecoveringBlockProto b) { ExtendedBlock block = convert(b.getBlock().getB()); DatanodeInfo[] locs = convert(b.getBlock().getLocsList()); return (b.hasTruncateBlock()) ? new RecoveringBlock(block, locs, PBHelper.convert(b.getTruncateBlock())) : new RecoveringBlock(block, locs, b.getNewGenStamp()); }
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); }
@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]); } }
public static RecoveringBlockProto convert(RecoveringBlock b) { if (b == null) { return null; } LocatedBlockProto lb = PBHelper.convert((LocatedBlock)b); return RecoveringBlockProto.newBuilder().setBlock(lb) .setNewGenStamp(b.getNewGenerationStamp()).build(); }
public static RecoveringBlockProto convert(RecoveringBlock b) { if (b == null) { return null; } LocatedBlockProto lb = PBHelper.convert((LocatedBlock) b); return RecoveringBlockProto.newBuilder().setBlock(lb) .setNewGenStamp(b.getNewGenerationStamp()).build(); }
public static BlockRecoveryCommand convert( BlockRecoveryCommandProto recoveryCmd) { List<RecoveringBlockProto> list = recoveryCmd.getBlocksList(); List<RecoveringBlock> recoveringBlocks = new ArrayList<>(list.size()); for (RecoveringBlockProto rbp : list) { recoveringBlocks.add(PBHelper.convert(rbp)); } return new BlockRecoveryCommand(recoveringBlocks); }
@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 (DatanodeInfo aDnInfo : dnInfo) { compare(dnInfo[0], dnInfo1[0]); } }
public static RecoveringBlock convert(RecoveringBlockProto b) { ExtendedBlock block = convert(b.getBlock().getB()); DatanodeInfo[] locs = convert(b.getBlock().getLocsList()); return new RecoveringBlock(block, locs, b.getNewGenStamp()); }