|
@@ -495,9 +495,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
private final boolean haEnabled;
|
|
|
|
|
|
- /** flag indicating whether replication queues have been initialized */
|
|
|
- boolean initializedReplQueues = false;
|
|
|
-
|
|
|
/**
|
|
|
* Whether the namenode is in the middle of starting the active service
|
|
|
*/
|
|
@@ -1030,7 +1027,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
try {
|
|
|
nnResourceChecker = new NameNodeResourceChecker(conf);
|
|
|
checkAvailableResources();
|
|
|
- assert safeMode != null && !isPopulatingReplQueues();
|
|
|
+ assert safeMode != null && !blockManager.isPopulatingReplQueues();
|
|
|
StartupProgress prog = NameNode.getStartupProgress();
|
|
|
prog.beginPhase(Phase.SAFEMODE);
|
|
|
long completeBlocksTotal = getCompleteBlocksTotal();
|
|
@@ -1097,7 +1094,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
// Only need to re-process the queue, If not in SafeMode.
|
|
|
if (!isInSafeMode()) {
|
|
|
LOG.info("Reprocessing replication and invalidation queues");
|
|
|
- initializeReplQueues();
|
|
|
+ blockManager.initializeReplQueues();
|
|
|
}
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
@@ -1152,15 +1149,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Initialize replication queues.
|
|
|
- */
|
|
|
- private void initializeReplQueues() {
|
|
|
- LOG.info("initializing replication queues");
|
|
|
- blockManager.processMisReplicatedBlocks();
|
|
|
- initializedReplQueues = true;
|
|
|
- }
|
|
|
-
|
|
|
private boolean inActiveState() {
|
|
|
return haContext != null &&
|
|
|
haContext.getState().getServiceState() == HAServiceState.ACTIVE;
|
|
@@ -1217,8 +1205,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
blockManager.getDatanodeManager().setShouldSendCachingCommands(false);
|
|
|
// Don't want to keep replication queues when not in Active.
|
|
|
blockManager.clearQueues();
|
|
|
+ blockManager.setInitializedReplQueues(false);
|
|
|
}
|
|
|
- initializedReplQueues = false;
|
|
|
} finally {
|
|
|
writeUnlock();
|
|
|
}
|
|
@@ -4232,8 +4220,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
private synchronized void leave() {
|
|
|
// if not done yet, initialize replication queues.
|
|
|
// In the standby, do not populate repl queues
|
|
|
- if (!isPopulatingReplQueues() && shouldPopulateReplQueues()) {
|
|
|
- initializeReplQueues();
|
|
|
+ if (!blockManager.isPopulatingReplQueues() && blockManager.shouldPopulateReplQueues()) {
|
|
|
+ blockManager.initializeReplQueues();
|
|
|
}
|
|
|
long timeInSafemode = now() - startTime;
|
|
|
NameNode.stateChangeLog.info("STATE* Leaving safe mode after "
|
|
@@ -4269,7 +4257,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
* initializing replication queues.
|
|
|
*/
|
|
|
private synchronized boolean canInitializeReplQueues() {
|
|
|
- return shouldPopulateReplQueues()
|
|
|
+ return blockManager.shouldPopulateReplQueues()
|
|
|
&& blockSafe >= blockReplQueueThreshold;
|
|
|
}
|
|
|
|
|
@@ -4322,9 +4310,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
if (smmthread == null && needEnter()) {
|
|
|
enter();
|
|
|
// check if we are ready to initialize replication queues
|
|
|
- if (canInitializeReplQueues() && !isPopulatingReplQueues()
|
|
|
+ if (canInitializeReplQueues() && !blockManager.isPopulatingReplQueues()
|
|
|
&& !haEnabled) {
|
|
|
- initializeReplQueues();
|
|
|
+ blockManager.initializeReplQueues();
|
|
|
}
|
|
|
reportStatus("STATE* Safe mode ON.", false);
|
|
|
return;
|
|
@@ -4349,8 +4337,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
|
|
|
// check if we are ready to initialize replication queues
|
|
|
- if (canInitializeReplQueues() && !isPopulatingReplQueues() && !haEnabled) {
|
|
|
- initializeReplQueues();
|
|
|
+ if (canInitializeReplQueues() && !blockManager.isPopulatingReplQueues() && !haEnabled) {
|
|
|
+ blockManager.initializeReplQueues();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4653,24 +4641,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
&& safeMode.isOn();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Check if replication queues are to be populated
|
|
|
- * @return true when node is HAState.Active and not in the very first safemode
|
|
|
- */
|
|
|
- @Override
|
|
|
- public boolean isPopulatingReplQueues() {
|
|
|
- if (!shouldPopulateReplQueues()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return initializedReplQueues;
|
|
|
- }
|
|
|
-
|
|
|
- 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
|
|
@@ -5488,7 +5458,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- if (!isPopulatingReplQueues()) {
|
|
|
+ if (!blockManager.isPopulatingReplQueues()) {
|
|
|
throw new IOException("Cannot run listCorruptFileBlocks because " +
|
|
|
"replication queues have not been initialized.");
|
|
|
}
|
|
@@ -6164,6 +6134,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
return cacheManager;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HAContext getHAContext() {
|
|
|
+ return haContext;
|
|
|
+ }
|
|
|
+
|
|
|
@Override // NameNodeMXBean
|
|
|
public String getCorruptFiles() {
|
|
|
List<String> list = new ArrayList<String>();
|