in rsc/src/main/java/org/apache/livy/rsc/ContextLauncher.java [269:316]
private static File writeConfToFile(RSCConf conf) throws IOException {
Properties confView = new Properties();
for (Map.Entry<String, String> e : conf) {
String key = e.getKey();
if (!key.startsWith(RSCConf.SPARK_CONF_PREFIX)) {
key = RSCConf.LIVY_SPARK_PREFIX + key;
}
confView.setProperty(key, e.getValue());
}
// Load the default Spark configuration.
String confDir = System.getenv("SPARK_CONF_DIR");
if (confDir == null && System.getenv(SPARK_HOME_ENV) != null) {
confDir = System.getenv(SPARK_HOME_ENV) + File.separator + "conf";
}
if (confDir != null) {
File sparkDefaults = new File(confDir + File.separator + "spark-defaults.conf");
if (sparkDefaults.isFile()) {
Properties sparkConf = new Properties();
Reader r = new InputStreamReader(new FileInputStream(sparkDefaults), UTF_8);
try {
sparkConf.load(r);
} finally {
r.close();
}
for (String key : sparkConf.stringPropertyNames()) {
if (!confView.containsKey(key)) {
confView.put(key, sparkConf.getProperty(key));
}
}
}
}
File file = File.createTempFile("livyConf", ".properties");
Files.setPosixFilePermissions(file.toPath(), EnumSet.of(OWNER_READ, OWNER_WRITE));
//file.deleteOnExit();
Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF_8);
try {
confView.store(writer, "Livy App Context Configuration");
} finally {
writer.close();
}
return file;
}