public static Runnable writeHashinatorConfig ( InstanceId instId , String path , String nonce , int hostId , HashinatorSnapshotData hashData , boolean isTruncationSnapshot ) throws IOException { final File file = new VoltFile ( path , constructHashinatorConfigFilenameForNonce ( nonce , hostId ) ) ; if ( file . exists ( ) ) { if ( ! file . delete ( ) ) { if ( isTruncationSnapshot ) { VoltDB . crashLocalVoltDB ( "Unexpected exception while attempting to delete old hash file for truncation snapshot" ) ; } throw new IOException ( "Unable to replace existing hashinator config " + file ) ; } } boolean success = false ; try { final FileOutputStream fos = new FileOutputStream ( file ) ; ByteBuffer fileBuffer = hashData . saveToBuffer ( instId ) ; fos . getChannel ( ) . write ( fileBuffer ) ; success = true ; return new Runnable ( ) { @ Override public void run ( ) { try { fos . getChannel ( ) . force ( true ) ; } catch ( IOException e ) { if ( isTruncationSnapshot ) { VoltDB . crashLocalVoltDB ( "Unexpected exception while attempting to create hash file for truncation snapshot" , true , e ) ; } throw new RuntimeException ( e ) ; } finally { try { fos . close ( ) ; } catch ( IOException e ) { if ( isTruncationSnapshot ) { VoltDB . crashLocalVoltDB ( "Unexpected exception while attempting to create hash file for truncation snapshot" , true , e ) ; } throw new RuntimeException ( e ) ; } } } } ; } finally { if ( ! success ) { file . delete ( ) ; } } }
Write the hashinator config file for a snapshot