是否可以在单个火花应用程序中为两个不同的火花混合创建两个火花上下文
因为我为从gz文件读取数据而创建了一个spark conf,而另一个用于从cassandra读取数据。
这是我的代码
public class SparkCassandraDriver implements Serializable {
private transient SparkConf conf;
private SparkCassandraDriver(SparkConf conf) {
this.conf = conf;
}
private void run() throws JSONException, IOException, InterruptedException {
JavaSparkContext sc = new JavaSparkContext(conf);
getDataFromCassandra(sc);
sc.stop();
}
private void run1() throws JSONException, IOException, InterruptedException {
JavaSparkContext sc = new JavaSparkContext(conf);
getDataFromS3(sc);
sc.stop();
}
public static void main(String[] args) throws JSONException, IOException, InterruptedException {
//First Spark Conf
SparkConf conf = new SparkConf();
conf.setAppName("Spark-Cassandra Integration");
conf.setMaster("local");
conf.set("spark.cassandra.connection.host", "IP");
conf.set("spark.cassandra.connection.native.port", "9042");
conf.set("spark.cassandra.connection.rpc.port", "9160");
conf.set("spark.cassandra.connection.timeout_ms", "40000");
conf.set("spark.cassandra.read.timeout_ms", "200000");
SparkCassandraDriver app = new SparkCassandraDriver(conf);
app.run();
//Second Spark Conf
SparkConf conf1 = new SparkConf().setAppName("SparkAutomation").setMaster("local");
SparkCassandraDriver app1 = new SparkCassandraDriver(conf1);
app1.run1();
System.out.println("Both RDD has been generated");
}
}
或者我有什么方法可以使用具有两个不同火花conf对象的单个火花上下文