@@ -298,9 +298,13 @@ long loadDfsUsed() {
298298 long mtime ;
299299 Scanner sc ;
300300
301+ File duCacheFile = new File (currentDir , DU_CACHE_FILE );
301302 try {
302- sc = new Scanner (new File ( currentDir , DU_CACHE_FILE ) , "UTF-8" );
303+ sc = new Scanner (duCacheFile , "UTF-8" );
303304 } catch (FileNotFoundException fnfe ) {
305+ FsDatasetImpl .LOG .warn ("{} file missing in {}, will proceed with Du " +
306+ "for space computation calculation, " ,
307+ DU_CACHE_FILE , currentDir );
304308 return -1 ;
305309 }
306310
@@ -309,21 +313,31 @@ long loadDfsUsed() {
309313 if (sc .hasNextLong ()) {
310314 cachedDfsUsed = sc .nextLong ();
311315 } else {
316+ FsDatasetImpl .LOG .warn ("cachedDfsUsed not found in file:{}, will " +
317+ "proceed with Du for space computation calculation, " ,
318+ duCacheFile );
312319 return -1 ;
313320 }
314321 // Get the recorded mtime from the file.
315322 if (sc .hasNextLong ()) {
316323 mtime = sc .nextLong ();
317324 } else {
325+ FsDatasetImpl .LOG .warn ("mtime not found in file:{}, will proceed" +
326+ " with Du for space computation calculation, " , duCacheFile );
318327 return -1 ;
319328 }
320329
330+ long elapsedTime = timer .now () - mtime ;
321331 // Return the cached value if mtime is okay.
322- if (mtime > 0 && (timer . now () - mtime < cachedDfsUsedCheckTime )) {
332+ if (mtime > 0 && (elapsedTime < cachedDfsUsedCheckTime )) {
323333 FsDatasetImpl .LOG .info ("Cached dfsUsed found for " + currentDir + ": " +
324334 cachedDfsUsed );
325335 return cachedDfsUsed ;
326336 }
337+ FsDatasetImpl .LOG .warn ("elapsed time:{} is greater than threshold:{}," +
338+ " mtime:{} in file:{}, will proceed with Du for space" +
339+ " computation calculation" ,
340+ elapsedTime , cachedDfsUsedCheckTime , mtime , duCacheFile );
327341 return -1 ;
328342 } finally {
329343 sc .close ();
0 commit comments