HDFS-5890. Avoid NPE in Datanode heartbeat. Contributed by Vinay

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1565023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Li 2014-02-06 00:40:24 +00:00
parent 35e59eeaa2
commit b2ce764093
3 changed files with 16 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -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();
}