void cleanupClusterConfigFiles ( ) throws IOException { Zxid latestZxid = getLatestZxid ( ) ; List < File > files = getFilesWithPrefix ( this . rootDir , "cluster_config" ) ; if ( files . isEmpty ( ) ) { LOG . error ( "There's no cluster_config files in log directory." ) ; throw new RuntimeException ( "There's no cluster_config files!" ) ; } Iterator < File > iter = files . iterator ( ) ; while ( iter . hasNext ( ) ) { File file = iter . next ( ) ; String fileName = file . getName ( ) ; String strZxid = fileName . substring ( fileName . indexOf ( ' ' ) + 1 ) ; Zxid zxid = Zxid . fromSimpleString ( strZxid ) ; if ( zxid . compareTo ( latestZxid ) > 0 ) { // Deletes the config file if its zxid is larger than the latest zxid on // disk. file . delete ( ) ; iter . remove ( ) ; } } if ( files . isEmpty ( ) ) { LOG . error ( "There's no cluster_config files after cleaning up." ) ; throw new RuntimeException ( "There's no cluster_config files!" ) ; } // Persists changes. fsyncDirectory ( ) ; }
cluster_config files .