@ VisibleForTesting public static void writeYMLFile ( Collection < ? extends PropertyKey > defaultKeys , String filePath ) throws IOException { if ( defaultKeys . size ( ) == 0 ) { return ; } FileWriter fileWriter ; Closer closer = Closer . create ( ) ; String [ ] fileNames = { "user-configuration.yml" , "master-configuration.yml" , "worker-configuration.yml" , "security-configuration.yml" , "common-configuration.yml" , "cluster-management-configuration.yml" } ; try { // HashMap for FileWriter per each category Map < String , FileWriter > fileWriterMap = new HashMap <> ( ) ; for ( String fileName : fileNames ) { fileWriter = new FileWriter ( PathUtils . concatPath ( filePath , fileName ) ) ; //put fileWriter String key = fileName . substring ( 0 , fileName . indexOf ( "configuration" ) - 1 ) ; fileWriterMap . put ( key , fileWriter ) ; //register file writer closer . register ( fileWriter ) ; } // Sort defaultKeys List < PropertyKey > dfkeys = new ArrayList <> ( defaultKeys ) ; Collections . sort ( dfkeys ) ; for ( PropertyKey iteratorPK : dfkeys ) { String pKey = iteratorPK . toString ( ) ; // Puts descriptions in single quotes to avoid having to escaping reserved characters. // Still needs to escape single quotes with double single quotes. String description = iteratorPK . getDescription ( ) . replace ( "'" , "''" ) ; // Write property key and default value to yml files if ( iteratorPK . isIgnoredSiteProperty ( ) ) { description += " Note: This property must be specified as a JVM property; " + "it is not accepted in alluxio-site.properties." ; } String keyValueStr = pKey + ":\n '" + description + "'\n" ; if ( pKey . startsWith ( "alluxio.user." ) ) { fileWriter = fileWriterMap . get ( "user" ) ; } else if ( pKey . startsWith ( "alluxio.master." ) ) { fileWriter = fileWriterMap . get ( "master" ) ; } else if ( pKey . startsWith ( "alluxio.worker." ) ) { fileWriter = fileWriterMap . get ( "worker" ) ; } else if ( pKey . startsWith ( "alluxio.security." ) ) { fileWriter = fileWriterMap . get ( "security" ) ; } else if ( pKey . startsWith ( "alluxio.keyvalue." ) ) { fileWriter = fileWriterMap . get ( "key-value" ) ; } else if ( pKey . startsWith ( "alluxio.integration." ) ) { fileWriter = fileWriterMap . get ( "cluster-management" ) ; } else { fileWriter = fileWriterMap . get ( "common" ) ; } fileWriter . append ( keyValueStr ) ; } LOG . info ( "YML files for description of Property Keys were created successfully." ) ; } catch ( Exception e ) { throw closer . rethrow ( e ) ; } finally { try { closer . close ( ) ; } catch ( IOException e ) { LOG . error ( "Error while flushing/closing YML files for description of Property Keys " + "FileWriter" , e ) ; } } }
Writes description of property key to yml files .