diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java index 86f5f675ce..ffb2f1d39a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java @@ -36,9 +36,11 @@ public interface HAServiceProtocol extends VersionedProtocol { public static final long versionID = 1L; /** - * An HA service may be in active or standby state. + * An HA service may be in active or standby state. During + * startup, it is in an unknown INITIALIZING state. */ public enum HAServiceState { + INITIALIZING("initializing"), ACTIVE("active"), STANDBY("standby"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index 165d09578f..018dfeaa55 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -91,3 +91,5 @@ HDFS-2709. Appropriately handle error conditions in EditLogTailer (atm via todd) HDFS-2730. Refactor shared HA-related test code into HATestUtil class (todd) HDFS-2762. Fix TestCheckpoint timing out on HA branch. (Uma Maheswara Rao G via todd) + +HDFS-2724. NN web UI can throw NPE after startup, before standby state is entered. (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index c9af0ba05b..9b3375fca4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -926,6 +926,9 @@ synchronized void transitionToStandby() throws ServiceFailedException { } synchronized HAServiceState getServiceState() { + if (state == null) { + return HAServiceState.INITIALIZING; + } return state.getServiceState(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp index b6d96a0ff3..bc158a26f0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp @@ -31,7 +31,7 @@ NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application); FSNamesystem fsn = nn.getNamesystem(); String namenodeRole = nn.getRole().toString(); - String namenodeState = HAServiceState.ACTIVE.equals(nn.getServiceState()) ? "active" : "standby"; + String namenodeState = nn.getServiceState().toString(); String namenodeLabel = nn.getNameNodeAddress().getHostName() + ":" + nn.getNameNodeAddress().getPort(); %>