PBHelper { public static List<SlowPeerReportProto> convertSlowPeerInfo( SlowPeerReports slowPeers) { if (slowPeers.getSlowPeers().size() == 0) { return Collections.emptyList(); } List<SlowPeerReportProto> slowPeerInfoProtos = new ArrayList<>(slowPeers.getSlowPeers().size()); for (Map.Entry<String, Double> entry : slowPeers.getSlowPeers().entrySet()) { slowPeerInfoProtos.add(SlowPeerReportProto.newBuilder() .setDataNodeId(entry.getKey()) .setAggregateLatency(entry.getValue()) .build()); } return slowPeerInfoProtos; } private  PBHelper(); static NamenodeRole convert(NamenodeRoleProto role); static NamenodeRoleProto convert(NamenodeRole role); static StorageInfoProto convert(StorageInfo info); static StorageInfo convert(StorageInfoProto info, NodeType type); static NamenodeRegistrationProto convert(NamenodeRegistration reg); static NamenodeRegistration convert(NamenodeRegistrationProto reg); static BlockWithLocationsProto convert(BlockWithLocations blk); static BlockWithLocations convert(BlockWithLocationsProto b); static BlocksWithLocationsProto convert(BlocksWithLocations blks); static BlocksWithLocations convert(BlocksWithLocationsProto blocks); static BlockKeyProto convert(BlockKey key); static BlockKey convert(BlockKeyProto k); static ExportedBlockKeysProto convert(ExportedBlockKeys keys); static ExportedBlockKeys convert(ExportedBlockKeysProto keys); static CheckpointSignatureProto convert(CheckpointSignature s); static CheckpointSignature convert(CheckpointSignatureProto s); static RemoteEditLogProto convert(RemoteEditLog log); static RemoteEditLog convert(RemoteEditLogProto l); static RemoteEditLogManifestProto convert(
      RemoteEditLogManifest manifest); static RemoteEditLogManifest convert(
      RemoteEditLogManifestProto manifest); static CheckpointCommandProto convert(CheckpointCommand cmd); static NamenodeCommandProto convert(NamenodeCommand cmd); static BlockKey[] convertBlockKeys(List<BlockKeyProto> list); static NamespaceInfo convert(NamespaceInfoProto info); static NamenodeCommand convert(NamenodeCommandProto cmd); static RecoveringBlockProto convert(RecoveringBlock b); static RecoveringBlock convert(RecoveringBlockProto b); static ReplicaState convert(ReplicaStateProto state); static ReplicaStateProto convert(ReplicaState state); static DatanodeRegistrationProto convert(
      DatanodeRegistration registration); static DatanodeRegistration convert(DatanodeRegistrationProto proto); static DatanodeCommand convert(DatanodeCommandProto proto); static BalancerBandwidthCommandProto convert(
      BalancerBandwidthCommand bbCmd); static KeyUpdateCommandProto convert(KeyUpdateCommand cmd); static BlockRecoveryCommandProto convert(BlockRecoveryCommand cmd); static FinalizeCommandProto convert(FinalizeCommand cmd); static BlockCommandProto convert(BlockCommand cmd); static BlockIdCommandProto convert(BlockIdCommand cmd); static DatanodeCommandProto convert(DatanodeCommand datanodeCommand); static KeyUpdateCommand convert(KeyUpdateCommandProto keyUpdateCmd); static FinalizeCommand convert(FinalizeCommandProto finalizeCmd); static BlockRecoveryCommand convert(
      BlockRecoveryCommandProto recoveryCmd); static BlockCommand convert(BlockCommandProto blkCmd); static BlockIdCommand convert(BlockIdCommandProto blkIdCmd); static BalancerBandwidthCommand convert(
      BalancerBandwidthCommandProto balancerCmd); static ReceivedDeletedBlockInfoProto convert(
      ReceivedDeletedBlockInfo receivedDeletedBlockInfo); static ReceivedDeletedBlockInfo convert(
      ReceivedDeletedBlockInfoProto proto); static NamespaceInfoProto convert(NamespaceInfo info); static HAServiceState convert(NNHAStatusHeartbeatProto.State s); static NNHAStatusHeartbeatProto.State convert(HAServiceState s); static NNHAStatusHeartbeat convert(NNHAStatusHeartbeatProto s); static NNHAStatusHeartbeatProto convert(NNHAStatusHeartbeat hb); static VolumeFailureSummary convertVolumeFailureSummary(
      VolumeFailureSummaryProto proto); static VolumeFailureSummaryProto convertVolumeFailureSummary(
      VolumeFailureSummary volumeFailureSummary); static List<SlowPeerReportProto> convertSlowPeerInfo(
      SlowPeerReports slowPeers); static SlowPeerReports convertSlowPeerInfo(
      List<SlowPeerReportProto> slowPeerProtos); static List<SlowDiskReportProto> convertSlowDiskInfo(
      SlowDiskReports slowDisks); static SlowDiskReports convertSlowDiskInfo(
      List<SlowDiskReportProto> slowDiskProtos); static JournalInfo convert(JournalInfoProto info); static JournalInfoProto convert(JournalInfo j); static BlockReportContext convert(BlockReportContextProto proto); static BlockReportContextProto convert(BlockReportContext context); static BlockECReconstructionInfo convertBlockECReconstructionInfo(
      BlockECReconstructionInfoProto blockEcReconstructionInfoProto); static BlockECReconstructionInfoProto convertBlockECRecoveryInfo(
      BlockECReconstructionInfo blockEcRecoveryInfo); static BlockECReconstructionCommandProto convert(
      BlockECReconstructionCommand blkECReconstructionCmd); static BlockECReconstructionCommand convert(
      BlockECReconstructionCommandProto blkECReconstructionCmdProto); static KeyValueProto convert(FileRegion fileRegion); static FileRegion convert(KeyValueProto keyValueProto);  }
@Test public void testSlowPeerInfoPBHelper() { final SlowPeerReports slowPeers = SlowPeerReports.create( ImmutableMap.of("peer1", 0.0, "peer2", 1.0, "peer3", 2.0)); SlowPeerReports slowPeersConverted1 = PBHelper.convertSlowPeerInfo( PBHelper.convertSlowPeerInfo(slowPeers)); assertTrue( "Expected map:" + slowPeers + ", got map:" + slowPeersConverted1.getSlowPeers(), slowPeersConverted1.equals(slowPeers)); SlowPeerReports slowPeersConverted2 = PBHelper.convertSlowPeerInfo( PBHelper.convertSlowPeerInfo(SlowPeerReports.EMPTY_REPORT)); assertTrue( "Expected empty map:" + ", got map:" + slowPeersConverted2, slowPeersConverted2.equals(SlowPeerReports.EMPTY_REPORT)); }