private void runConsistencyCheck ( AlluxioURI path , boolean repairConsistency ) throws AlluxioException , IOException { List < AlluxioURI > inconsistentUris = checkConsistency ( path , FileSystemOptions . checkConsistencyDefaults ( mFsContext . getPathConf ( path ) ) ) ; if ( inconsistentUris . isEmpty ( ) ) { System . out . println ( path + " is consistent with the under storage system." ) ; return ; } if ( ! repairConsistency ) { Collections . sort ( inconsistentUris ) ; System . out . println ( "The following files are inconsistent:" ) ; for ( AlluxioURI uri : inconsistentUris ) { System . out . println ( uri ) ; } } else { Collections . sort ( inconsistentUris ) ; System . out . println ( path + " has: " + inconsistentUris . size ( ) + " inconsistent files." ) ; List < AlluxioURI > inconsistentDirs = new ArrayList < AlluxioURI > ( ) ; for ( AlluxioURI inconsistentUri : inconsistentUris ) { URIStatus status = mFileSystem . getStatus ( inconsistentUri ) ; if ( status . isFolder ( ) ) { inconsistentDirs . add ( inconsistentUri ) ; continue ; } System . out . println ( "repairing path: " + inconsistentUri ) ; DeletePOptions deleteOptions = DeletePOptions . newBuilder ( ) . setAlluxioOnly ( true ) . build ( ) ; mFileSystem . delete ( inconsistentUri , deleteOptions ) ; mFileSystem . exists ( inconsistentUri ) ; System . out . println ( inconsistentUri + " repaired" ) ; System . out . println ( ) ; } for ( AlluxioURI uri : inconsistentDirs ) { DeletePOptions deleteOptions = DeletePOptions . newBuilder ( ) . setAlluxioOnly ( true ) . setRecursive ( true ) . build ( ) ; System . out . println ( "repairing path: " + uri ) ; mFileSystem . delete ( uri , deleteOptions ) ; mFileSystem . exists ( uri ) ; System . out . println ( uri + "repaired" ) ; System . out . println ( ) ; } } }
Checks the inconsistent files and directories which exist in Alluxio but don t exist in the under storage repairs the inconsistent paths by deleting them if repairConsistency is true .