我已经为Namenode和ResourceManager设置了一个带有HA的3节点hadoop集群。 我还在其中一个NameNode机器上安装了Spark Job Server。
我已经测试了运行作业服务器测试示例,如WordCount示例和LongPi作业,它完美无缺。我也可以从远程主机发出curl命令,通过Spark Job Server读出结果。
但是,当我上传" spark-examples-1.6.0-hadoop2.6.0.jar"进入spark-job-server / jar并尝试运行SparkPi作业失败,
[hduser@ptfhadoop02v lib]$ curl -d "" 'ptfhadoop01v:8090/jobs?appName=SparkPi&classPath=org.apache.spark.examples.SparkPi'
{
"status": "ERROR",
"result": {
"message": "Ask timed out on [Actor[akka://JobServer/user/context-supervisor/ece2be39-org.apache.spark.examples.SparkPi#-630965857]] after [10000 ms]",
"errorClass": "akka.pattern.AskTimeoutException",
"stack":["akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:334)", "akka.actor.Scheduler$$anon$7.run(Scheduler.scala:117)", "scala.concurrent.Future$InternalCallbackExecutor$.scala$concurrent$Future$InternalCallbackExecutor$$unbatchedExecute(Future.scala:694)", "scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:691)", "akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(Scheduler.scala:467)", "akka.actor.LightArrayRevolverScheduler$$anon$8.executeBucket$1(Scheduler.scala:419)", "akka.actor.LightArrayRevolverScheduler$$anon$8.nextTick(Scheduler.scala:423)", "akka.actor.LightArrayRevolverScheduler$$anon$8.run(Scheduler.scala:375)", "java.lang.Thread.run(Thread.java:745)"]
}
我还尝试手动将 SparkPi.scala 作业放在/ usr / local / hadoop / spark-jobserver / job-server-tests / src / spark.jobserver 下并使用SBT构建软件包,但它会抛出相同的错误。
版本信息
[hduser@ptfhadoop01v spark.jobserver]$ sbt sbtVersion
[info] Set current project to spark-jobserver (in build file:/usr/local/hadoop/spark-jobserver/job-server-tests/src/spark.jobserver/)
[info] 0.13.11
Spark Version - spark-1.6.0
Scala Version - 2.10.4
有关如何摆脱此错误并从spark-examples jar文件中获取输出的任何建议
答案 0 :(得分:0)
package spark.jobserver
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.spark._
import org.apache.spark.SparkContext._
import scala.math.random
/** Computes an approximation to pi */
object SparkPi extends SparkJob {
def main(args: Array[String]) {
val conf = new SparkConf().setMaster("local[4]").setAppName("SparkPi")
val sc = new SparkContext(conf)
val config = ConfigFactory.parseString("")
val results = runJob(sc, config)
println("Pi is roughly " + results)
}
override def validate(sc: SparkContext, config: Config):SparkJobValidation = {
SparkJobValid
}
override def runJob(sc: SparkContext, config: Config): Any = {
val slices = if (args.length > 0) args(0).toInt else 2
val n = math.min(100000L * slices, Int.MaxValue).toInt
val count = sc.parallelize(1 until n, slices).map { i =>
val x = random * 2 - 1
val y = random * 2 - 1
if (x*x + y*y < 1) 1 else 0
}.reduce(_ + _)
(4.0 * count / n)
}
}
我设法通过修改代码来扩展SparkJob来实现它 谢谢你的澄清