我使用spark 2.0.0。是否有一种方法将参数从spark驱动程序传递到执行程序?我尝试了以下方法。
class SparkDriver {
public static void main(String argv[]){
SparkConf conf = new SparkConf().setAppName("test").setMaster("yarn");
SparkSession sparkSession = SparkSession.builder().config(conf).getOrCreate();
Dataset<Row> input = sparkSession.read().load("inputfilepath");
Dataset<Row> modifiedinput = input.mapPartitions(new customMapPartition(5),Encoders.bean(Row.class));
}
class customMapPartition implements MapPartitionsFunction{
private static final long serialVersionUID = -6513655566985939627L;
private static Integer variableThatHastobePassed = null;
public customMapPartition(Integer passedInteger){
customMapPartition.variableThatHastobePassed= passedInteger;
}
@Override
public Iterator<Row> call(Iterator<Row> input) throws Exception {
System.out.println("number that is passed " + variableThatHastobePassed);
}
}
如上所述,我编写了一个自定义mappartitionfunction来传递参数。并通过调用分区函数的方法来访问静态变量。这工作时,我在我的本地运行"setmaster("本地")。但是当使用.setmaster("yarn")在集群上运行时不起作用。(在system.out.println语句中打印null)
是否有方法将参数从驱动程序传递给执行程序
我的坏我正在使用