|
@@ -168,7 +168,6 @@ import org.apache.hadoop.hdfs.server.namenode.ha.EditLogTailer;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.HAContext;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.HAState;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.StandbyCheckpointer;
|
|
|
-import org.apache.hadoop.hdfs.server.namenode.ha.StandbyState;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.metrics.FSNamesystemMBean;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.metrics.NameNodeMetrics;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.web.resources.NamenodeWebHdfsMethods;
|
|
@@ -1003,8 +1002,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
// start in active.
|
|
|
return haEnabled;
|
|
|
}
|
|
|
-
|
|
|
- return haContext.getState() instanceof StandbyState;
|
|
|
+
|
|
|
+ return HAServiceState.STANDBY == haContext.getState().getServiceState();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -3437,15 +3436,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
|
|
|
private NNHAStatusHeartbeat createHaStatusHeartbeat() {
|
|
|
HAState state = haContext.getState();
|
|
|
- NNHAStatusHeartbeat.State hbState;
|
|
|
- if (state.getServiceState() == HAServiceState.ACTIVE) {
|
|
|
- hbState = NNHAStatusHeartbeat.State.ACTIVE;
|
|
|
- } else if (state.getServiceState() == HAServiceState.STANDBY) {
|
|
|
- hbState = NNHAStatusHeartbeat.State.STANDBY;
|
|
|
- } else {
|
|
|
- throw new AssertionError("Invalid state: " + state.getClass());
|
|
|
- }
|
|
|
- return new NNHAStatusHeartbeat(hbState,
|
|
|
+ return new NNHAStatusHeartbeat(state.getServiceState(),
|
|
|
getFSImage().getLastAppliedOrWrittenTxId());
|
|
|
}
|
|
|
|
|
@@ -3874,7 +3865,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
private synchronized void leave() {
|
|
|
// if not done yet, initialize replication queues.
|
|
|
// In the standby, do not populate repl queues
|
|
|
- if (!isPopulatingReplQueues() && !isInStandbyState()) {
|
|
|
+ if (!isPopulatingReplQueues() && shouldPopulateReplQueues()) {
|
|
|
initializeReplQueues();
|
|
|
}
|
|
|
long timeInSafemode = now() - startTime;
|
|
@@ -3917,7 +3908,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
* initializing replication queues.
|
|
|
*/
|
|
|
private synchronized boolean canInitializeReplQueues() {
|
|
|
- return !isInStandbyState() && blockSafe >= blockReplQueueThreshold;
|
|
|
+ return shouldPopulateReplQueues()
|
|
|
+ && blockSafe >= blockReplQueueThreshold;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -4257,7 +4249,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
|
|
|
@Override
|
|
|
public boolean isPopulatingReplQueues() {
|
|
|
- if (isInStandbyState()) {
|
|
|
+ if (!shouldPopulateReplQueues()) {
|
|
|
return false;
|
|
|
}
|
|
|
// safeMode is volatile, and may be set to null at any time
|
|
@@ -4266,7 +4258,13 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
return true;
|
|
|
return safeMode.isPopulatingReplQueues();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private boolean shouldPopulateReplQueues() {
|
|
|
+ if(haContext == null || haContext.getState() == null)
|
|
|
+ return false;
|
|
|
+ return haContext.getState().shouldPopulateReplQueues();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void incrementSafeBlockCount(int replication) {
|
|
|
// safeMode is volatile, and may be set to null at any time
|