@@ -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