HDFS-16343. Add some debug logs when the dfsUsed are not used during Datanode startup. (#3694)

(cherry picked from commit faa4eeacb1)
This commit is contained in:
Mukul Kumar Singh 2021-11-23 19:06:14 +05:30 committed by Chao Sun
parent 8ae7691216
commit 7729505f8a
1 changed files with 16 additions and 2 deletions

View File

@ -293,9 +293,13 @@ class BlockPoolSlice {
long mtime; long mtime;
Scanner sc; Scanner sc;
File duCacheFile = new File(currentDir, DU_CACHE_FILE);
try { try {
sc = new Scanner(new File(currentDir, DU_CACHE_FILE), "UTF-8"); sc = new Scanner(duCacheFile, "UTF-8");
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
FsDatasetImpl.LOG.warn("{} file missing in {}, will proceed with Du " +
"for space computation calculation, ",
DU_CACHE_FILE, currentDir);
return -1; return -1;
} }
@ -304,21 +308,31 @@ class BlockPoolSlice {
if (sc.hasNextLong()) { if (sc.hasNextLong()) {
cachedDfsUsed = sc.nextLong(); cachedDfsUsed = sc.nextLong();
} else { } else {
FsDatasetImpl.LOG.warn("cachedDfsUsed not found in file:{}, will " +
"proceed with Du for space computation calculation, ",
duCacheFile);
return -1; return -1;
} }
// Get the recorded mtime from the file. // Get the recorded mtime from the file.
if (sc.hasNextLong()) { if (sc.hasNextLong()) {
mtime = sc.nextLong(); mtime = sc.nextLong();
} else { } else {
FsDatasetImpl.LOG.warn("mtime not found in file:{}, will proceed" +
" with Du for space computation calculation, ", duCacheFile);
return -1; return -1;
} }
long elapsedTime = timer.now() - mtime;
// Return the cached value if mtime is okay. // Return the cached value if mtime is okay.
if (mtime > 0 && (timer.now() - mtime < cachedDfsUsedCheckTime)) { if (mtime > 0 && (elapsedTime < cachedDfsUsedCheckTime)) {
FsDatasetImpl.LOG.info("Cached dfsUsed found for " + currentDir + ": " + FsDatasetImpl.LOG.info("Cached dfsUsed found for " + currentDir + ": " +
cachedDfsUsed); cachedDfsUsed);
return cachedDfsUsed; return cachedDfsUsed;
} }
FsDatasetImpl.LOG.warn("elapsed time:{} is greater than threshold:{}," +
" mtime:{} in file:{}, will proceed with Du for space" +
" computation calculation",
elapsedTime, cachedDfsUsedCheckTime, mtime, duCacheFile);
return -1; return -1;
} finally { } finally {
sc.close(); sc.close();