Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 有多个作业,如何作为一个唯一的作业提交?_Scala_Apache Spark_Jobs - Fatal编程技术网

Scala 有多个作业,如何作为一个唯一的作业提交?

Scala 有多个作业,如何作为一个唯一的作业提交?,scala,apache-spark,jobs,Scala,Apache Spark,Jobs,我有一些使用script.sh运行的作业,如下所示: JobA JobB 每个作业都通过脚本运行,集群“查看”每个作业 因此,我的意图是将所有作业打包到一个大作业中,这样集群过程就像一个唯一的作业一样 我一直像这样使用图书馆的火花发射器 class jobLaunch{ val spark = new SparkLauncher() .setAppResource("../lib/assembly-4.0.0-SNAPSHOT.jar") // TODO .setM

我有一些使用script.sh运行的作业,如下所示:

JobA
JobB
每个作业都通过脚本运行,集群“查看”每个作业

因此,我的意图是将所有作业打包到一个大作业中,这样集群过程就像一个唯一的作业一样

我一直像这样使用图书馆的火花发射器

class jobLaunch{
 val spark = new SparkLauncher()

      .setAppResource("../lib/assembly-4.0.0-SNAPSHOT.jar") // TODO
      .setMainClass("com.main.class")
      .setMaster("yarn")
      .setConf("spark.ui.port","1234")
      .launch()

def startExternalProcess = {
  val processOut = spark.getInputStream
  var is_finished = false

  new Thread(new Runnable() {
    def run() {
      val exit = spark.exitValue()
      is_finished = true
    }
  }).start()

  new Thread(new Runnable() {
    def run() {
      while (!is_finished) {
        scala.io.Source.fromInputStream(processOut).getLines.foreach{info(_)}
        Thread.sleep(1000)
      }
    }
  }).start()
  info("hello there")
  val exit = spark.exitValue()
}

这段代码是为了测试目的,当我运行时,我意识到这些作业就像一个进程一样运行,而不使用集群


因此,我仍然不知道是否可以在一个作业中运行子作业。

该作业是在sparkContext中定义的,因此要做到这两个作业应该共享相同的scGracias,@rhernando。你能解释一下什么是“sc”吗?
override def run(sc: SparkContext, hivec: HiveContext): Unit = {
   val jl = new jobLaunch
   val jl2 = new jobLaunch
   jl.startExternalProcess
   jl2.startExternalProcess

 }
}