@@ -293,9 +293,13 @@ long loadDfsUsed() {
293293 long mtime ;
294294 Scanner sc ;
295295
296+ File duCacheFile = new File (currentDir , DU_CACHE_FILE );
296297 try {
297- sc = new Scanner (new File ( currentDir , DU_CACHE_FILE ) , "UTF-8" );
298+ sc = new Scanner (duCacheFile , "UTF-8" );
298299 } catch (FileNotFoundException fnfe ) {
300+ FsDatasetImpl .LOG .warn ("{} file missing in {}, will proceed with Du " +
301+ "for space computation calculation, " ,
302+ DU_CACHE_FILE , currentDir );
299303 return -1 ;
300304 }
301305
@@ -304,21 +308,31 @@ long loadDfsUsed() {
304308 if (sc .hasNextLong ()) {
305309 cachedDfsUsed = sc .nextLong ();
306310 } else {
311+ FsDatasetImpl .LOG .warn ("cachedDfsUsed not found in file:{}, will " +
312+ "proceed with Du for space computation calculation, " ,
313+ duCacheFile );
307314 return -1 ;
308315 }
309316 // Get the recorded mtime from the file.
310317 if (sc .hasNextLong ()) {
311318 mtime = sc .nextLong ();
312319 } else {
320+ FsDatasetImpl .LOG .warn ("mtime not found in file:{}, will proceed" +
321+ " with Du for space computation calculation, " , duCacheFile );
313322 return -1 ;
314323 }
315324
325+ long elapsedTime = timer .now () - mtime ;
316326 // Return the cached value if mtime is okay.
317- if (mtime > 0 && (timer . now () - mtime < cachedDfsUsedCheckTime )) {
327+ if (mtime > 0 && (elapsedTime < cachedDfsUsedCheckTime )) {
318328 FsDatasetImpl .LOG .info ("Cached dfsUsed found for " + currentDir + ": " +
319329 cachedDfsUsed );
320330 return cachedDfsUsed ;
321331 }
332+ FsDatasetImpl .LOG .warn ("elapsed time:{} is greater than threshold:{}," +
333+ " mtime:{} in file:{}, will proceed with Du for space" +
334+ " computation calculation" ,
335+ elapsedTime , cachedDfsUsedCheckTime , mtime , duCacheFile );
322336 return -1 ;
323337 } finally {
324338 sc .close ();
0 commit comments