Empty safe block and active block report tables when restarting all the NNs
@@ -842,6 +842,9 @@ void startCommonServices(Configuration conf) throws IOException {
nnResourceChecker = new NameNodeResourceChecker(conf);
checkAvailableResources();
if (isLeader()) {
+ // the node is starting and directly leader, this means that no NN was alive before
+ clearSafeBlocks();
+ clearActiveBlockReports();
HdfsVariables.setSafeModeInfo(new SafeModeInfo(conf), -1);
inSafeMode.set(true);
assert safeMode() != null && !isPopulatingReplQueues();
@@ -922,6 +925,7 @@ void startActiveServices() throws IOException {
// blockManager.getDatanodeManager().setShouldSendCachingCommands(true);
} finally {
startingActiveService = false;
+ checkSafeMode();
}
}
@@ -7156,6 +7160,7 @@ public Object performTask() throws IOException {
* @throws IOException
*/
private void clearSafeBlocks() throws IOException {
+ LOG.warn("cealring the safe blocks tabl, this may take some time.");
new LightWeightRequestHandler(HDFSOperationType.CLEAR_SAFE_BLOCKS) {
@Override
public Object performTask() throws IOException {
@@ -7167,6 +7172,18 @@ public Object performTask() throws IOException {
}.handle();
}
+ private void clearActiveBlockReports() throws IOException {
+ new LightWeightRequestHandler(HDFSOperationType.CLEAR_SAFE_BLOCKS) {
+ @Override
+ public Object performTask() throws IOException {
+ ActiveBlockReportsDataAccess da = (ActiveBlockReportsDataAccess) HdfsStorageFactory
+ .getDataAccess(ActiveBlockReportsDataAccess.class);
+ da.removeAll();
+ return null;
+ }
+ }.handle();
+ }
+
public ExecutorService getFSOperationsExecutor() {
return fsOperationsExecutor;
}
