本文整理汇总了Scala中org.apache.spark.launcher.SparkAppHandle类的典型用法代码示例。如果您正苦于以下问题:Scala SparkAppHandle类的具体用法?Scala SparkAppHandle怎么用?Scala SparkAppHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SparkAppHandle类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: SparkJobActor
//设置package包名称以及导入依赖的类
package com.example
import akka.actor.{Actor, ActorLogging, ActorRef}
import org.apache.spark.launcher.{SparkAppHandle, SparkLauncher}
class SparkJobActor extends Actor with ActorLogging {
import SparkJobActor._
def receive: Receive = {
case Launch(appResource, mainClass, master, conf) => {
val launcher = new SparkLauncher()
.setAppResource(appResource)
.setMainClass(mainClass)
.setMaster(master)
for ((key, value) <- conf.toList) {
launcher.setConf(key, value)
}
val listener = new SparkAppHandle.Listener {
override def infoChanged(handle: SparkAppHandle): Unit = {}
override def stateChanged(handle: SparkAppHandle): Unit = self ! StateChanged
}
val handle = launcher.startApplication(listener)
context become launched(handle, sender)
}
}
def launched(handle: SparkAppHandle, origSender: ActorRef): Receive = {
case StateChanged => {
if (handle.getState.isFinal) {
origSender ! Finished(handle.getState)
context stop self
}
}
}
}
object SparkJobActor {
case class Launch(appResource: String, mainClass: String, master: String, conf: Map[String, String])
case object StateChanged
case class Finished(state: SparkAppHandle.State)
}
开发者ID:njrich28,项目名称:akka-spark,代码行数:45,代码来源:SparkJobActor.scala
注:本文中的org.apache.spark.launcher.SparkAppHandle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论