@VisibleForTesting
  public static void writeCSVFile(Collection<? extends PropertyKey> defaultKeys, String filePath)
      throws IOException {
    if (defaultKeys.size() == 0) {
      return;
    }

    FileWriter fileWriter;
    Closer closer = Closer.create();
    String[] fileNames = {"user-configuration.csv", "master-configuration.csv",
        "worker-configuration.csv", "security-configuration.csv",
        "common-configuration.csv", "cluster-management-configuration.csv"};

    try {
      // HashMap for FileWriter per each category
      Map<String, FileWriter> fileWriterMap = new HashMap<>();
      for (String fileName : fileNames) {
        fileWriter = new FileWriter(PathUtils.concatPath(filePath, fileName));
        // Write the CSV file header and line separator after the header
        fileWriter.append(CSV_FILE_HEADER + "\n");
        //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 propertyKey : dfkeys) {
        String pKey = propertyKey.toString();
        String defaultDescription;
        if (propertyKey.getDefaultSupplier().get() == null) {
          defaultDescription = "";
        } else {
          defaultDescription = propertyKey.getDefaultSupplier().getDescription();
        }
        // Quote the whole description to escape characters such as commas.
        defaultDescription = String.format("\"%s\"", defaultDescription);

        // Write property key and default value to CSV
        String keyValueStr = pKey + "," + defaultDescription + "\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("Property Key CSV files were created successfully.");
    } catch (Exception e) {
      throw closer.rethrow(e);
    } finally {
      try {
        closer.close();
      } catch (IOException e) {
        LOG.error("Error while flushing/closing Property Key CSV FileWriter", e);
      }
    }
  }
@ VisibleForTesting public static void writeCSVFile ( Collection < ? extends PropertyKey > defaultKeys , String filePath ) throws IOException { if ( defaultKeys . size ( ) == 0 ) { return ; } FileWriter fileWriter ; Closer closer = Closer . create ( ) ; String [ ] fileNames = { "user-configuration.csv" , "master-configuration.csv" , "worker-configuration.csv" , "security-configuration.csv" , "common-configuration.csv" , "cluster-management-configuration.csv" } ; try { Map < String , FileWriter > fileWriterMap = new HashMap < > ( ) ; for ( String fileName : fileNames ) { fileWriter = new FileWriter ( PathUtils . concatPath ( filePath , fileName ) ) ; fileWriter . append ( CSV_FILE_HEADER + "\n" ) ; String key = fileName . substring ( 0 , fileName . indexOf ( "configuration" ) - 1 ) ; fileWriterMap . put ( key , fileWriter ) ; closer . register ( fileWriter ) ; } List < PropertyKey > dfkeys = new ArrayList < > ( defaultKeys ) ; Collections . sort ( dfkeys ) ; for ( PropertyKey propertyKey : dfkeys ) { String pKey = propertyKey . toString ( ) ; String defaultDescription ; if ( propertyKey . getDefaultSupplier ( ) . get ( ) == null ) { defaultDescription = "" ; } else { defaultDescription = propertyKey . getDefaultSupplier ( ) . getDescription ( ) ; } defaultDescription = String . format ( "\"%s\"" , defaultDescription ) ; String keyValueStr = pKey + "," + defaultDescription + "\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 ( "Property Key CSV files were created successfully." ) ; } catch ( Exception e ) { throw closer . rethrow ( e ) ; } finally { try { closer . close ( ) ; } catch ( IOException e ) { LOG . error ( "Error while flushing/closing Property Key CSV FileWriter" , e ) ; } } }
Writes property key to csv files.

@param defaultKeys Collection which is from PropertyKey DEFAULT_KEYS_MAP.values()
@param filePath    path for csv files