Skip to content

Commit f5ff4e1

Browse files
mukul1987S O'Donnell
authored andcommitted
HDFS-16343. Add some debug logs when the dfsUsed are not used during Datanode startup. (#3694)
(cherry picked from commit faa4eea)
1 parent 2b0339c commit f5ff4e1

File tree

1 file changed

+16
-2
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl

1 file changed

+16
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,13 @@ long loadDfsUsed() {
272272
long mtime;
273273
Scanner sc;
274274

275+
File duCacheFile = new File(currentDir, DU_CACHE_FILE);
275276
try {
276-
sc = new Scanner(new File(currentDir, DU_CACHE_FILE), "UTF-8");
277+
sc = new Scanner(duCacheFile, "UTF-8");
277278
} catch (FileNotFoundException fnfe) {
279+
FsDatasetImpl.LOG.warn("{} file missing in {}, will proceed with Du " +
280+
"for space computation calculation, ",
281+
DU_CACHE_FILE, currentDir);
278282
return -1;
279283
}
280284

@@ -283,21 +287,31 @@ long loadDfsUsed() {
283287
if (sc.hasNextLong()) {
284288
cachedDfsUsed = sc.nextLong();
285289
} else {
290+
FsDatasetImpl.LOG.warn("cachedDfsUsed not found in file:{}, will " +
291+
"proceed with Du for space computation calculation, ",
292+
duCacheFile);
286293
return -1;
287294
}
288295
// Get the recorded mtime from the file.
289296
if (sc.hasNextLong()) {
290297
mtime = sc.nextLong();
291298
} else {
299+
FsDatasetImpl.LOG.warn("mtime not found in file:{}, will proceed" +
300+
" with Du for space computation calculation, ", duCacheFile);
292301
return -1;
293302
}
294303

304+
long elapsedTime = timer.now() - mtime;
295305
// Return the cached value if mtime is okay.
296-
if (mtime > 0 && (timer.now() - mtime < cachedDfsUsedCheckTime)) {
306+
if (mtime > 0 && (elapsedTime < cachedDfsUsedCheckTime)) {
297307
FsDatasetImpl.LOG.info("Cached dfsUsed found for " + currentDir + ": " +
298308
cachedDfsUsed);
299309
return cachedDfsUsed;
300310
}
311+
FsDatasetImpl.LOG.warn("elapsed time:{} is greater than threshold:{}," +
312+
" mtime:{} in file:{}, will proceed with Du for space" +
313+
" computation calculation",
314+
elapsedTime, cachedDfsUsedCheckTime, mtime, duCacheFile);
301315
return -1;
302316
} finally {
303317
sc.close();

0 commit comments

Comments
 (0)