SparkLauncher spark = new SparkLauncher(env)
.setDeployMode("client")
.setAppName("test")
.setSparkHome(sparkHome)
.setAppResource("/Users/aruntanwar/samplepython.py")
.setMaster("spark://Apples-MacBook-Pro-2.local:7077")
.setVerbose(true);
Process pr = spark.launch();
pr.waitFor();
BufferedReader buf = new BufferedReader(new
InputStreamReader(pr.getInputStream()));
String line = "";
while ((line= buf.readLine())!= null) {
System.out.println(line);
}
基本上,Process构建器对象包含cmd数组,其中包含命令行spark submit中使用的所有数据。我不知道为什么它不起作用。