void fsync ( String src , String clientName ) throws IOException { NameNode . stateChangeLog . info ( "BLOCK* NameSystem.fsync: file " + src + " for " + clientName ) ; writeLock ( ) ; try { if ( isInSafeMode ( ) ) { throw new SafeModeException ( "Cannot fsync file " + src , safeMode ) ; } INodeFileUnderConstruction pendingFile = checkLease ( src , clientName ) ; // If the block has a length of zero, set it to size 1 so // that lease recovery will not discard it. Block last = pendingFile . getLastBlock ( ) ; if ( last . getNumBytes ( ) == 0 ) { last . setNumBytes ( 1 ) ; } dir . persistBlocks ( src , pendingFile ) ; } finally { writeUnlock ( ) ; } getEditLog ( ) . logSync ( ) ; }
Persist all metadata about this file .