diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt index 1bae747730..5feb1c47f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-5535.txt @@ -20,3 +20,5 @@ HDFS-5535 subtasks: DataNodeLayoutVersion. (Brandon Li via szetszwo) HDFS-5848. Add rolling upgrade status to heartbeat response. (szetszwo) + + HDFS-5890. Avoid NPE in Datanode heartbeat. (Vinay via brandonli) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolClientSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolClientSideTranslatorPB.java index aa3695e82e..9a8503c99c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolClientSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolClientSideTranslatorPB.java @@ -34,6 +34,7 @@ import org.apache.hadoop.hdfs.protocol.ExtendedBlock; import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.LocatedBlock; +import org.apache.hadoop.hdfs.protocol.RollingUpgradeStatus; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReceivedAndDeletedRequestProto; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportResponseProto; @@ -183,9 +184,12 @@ public HeartbeatResponse sendHeartbeat(DatanodeRegistration registration, cmds[index] = PBHelper.convert(p); index++; } - return new HeartbeatResponse(cmds, - PBHelper.convert(resp.getHaStatus()), - PBHelper.convert(resp.getRollingUpgradeStatus())); + RollingUpgradeStatus rollingUpdateStatus = null; + if (resp.hasRollingUpgradeStatus()) { + rollingUpdateStatus = PBHelper.convert(resp.getRollingUpgradeStatus()); + } + return new HeartbeatResponse(cmds, PBHelper.convert(resp.getHaStatus()), + rollingUpdateStatus); } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java index d3063c9290..b7071f6036 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java @@ -23,6 +23,7 @@ import org.apache.hadoop.hdfs.protocol.DatanodeID; import org.apache.hadoop.hdfs.protocol.LocatedBlock; +import org.apache.hadoop.hdfs.protocol.RollingUpgradeStatus; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReceivedAndDeletedRequestProto; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReceivedAndDeletedResponseProto; import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; @@ -121,8 +122,12 @@ public HeartbeatResponseProto sendHeartbeat(RpcController controller, } } builder.setHaStatus(PBHelper.convert(response.getNameNodeHaState())); - builder.setRollingUpgradeStatus(PBHelper.convertRollingUpgradeStatus( - response.getRollingUpdateStatus())); + RollingUpgradeStatus rollingUpdateStatus = response + .getRollingUpdateStatus(); + if (rollingUpdateStatus != null) { + builder.setRollingUpgradeStatus(PBHelper + .convertRollingUpgradeStatus(rollingUpdateStatus)); + } return builder.build(); }