private void renameReadOnlyV2Files ( int masterPartitionId , int correctReplicaType ) { for ( int replica = 0 ; replica < routingStrategy . getNumReplicas ( ) ; replica ++ ) { if ( replica != correctReplicaType ) { int chunkId = 0 ; while ( true ) { String fileName = Integer . toString ( masterPartitionId ) + "_" + Integer . toString ( replica ) + "_" + Integer . toString ( chunkId ) ; File index = getIndexFile ( fileName ) ; File data = getDataFile ( fileName ) ; if ( index . exists ( ) && data . exists ( ) ) { // We found files with the "wrong" replica type, so let's rename them String correctFileName = Integer . toString ( masterPartitionId ) + "_" + Integer . toString ( correctReplicaType ) + "_" + Integer . toString ( chunkId ) ; File indexWithCorrectReplicaType = getIndexFile ( correctFileName ) ; File dataWithCorrectReplicaType = getDataFile ( correctFileName ) ; Utils . move ( index , indexWithCorrectReplicaType ) ; Utils . move ( data , dataWithCorrectReplicaType ) ; // Maybe change this to DEBUG? logger . info ( "Renamed files with wrong replica type: " + index . getAbsolutePath ( ) + "|data -> " + indexWithCorrectReplicaType . getName ( ) + "|data" ) ; } else if ( index . exists ( ) ^ data . exists ( ) ) { throw new VoldemortException ( "One of the following does not exist: " + index . toString ( ) + " or " + data . toString ( ) + "." ) ; } else { // The files don't exist, or we've gone over all available chunks, // so let's move on. break ; } chunkId ++ ; } } } }
This function looks for files with the wrong replica type in their name and if it finds any renames them .