Scala 如何将基于TypeSafe Activator的应用程序部署到Apache Spark群集?

Scala 如何将基于TypeSafe Activator的应用程序部署到Apache Spark群集?,scala,apache-spark,typesafe-activator,Scala,Apache Spark,Typesafe Activator,我的应用程序使用ApacheSpark进行后台数据处理,并使用Play框架进行前端接口 在Scala应用程序中使用Play框架的最佳方法是将其与TypeSafe activator一起使用 现在,问题是我想将此应用程序部署到spark集群。 关于如何使用spark submit将SBT应用程序部署到集群,有很好的文档,但是如何使用基于activator的应用程序呢 请注意,我了解如何将Spark与activator一起使用,我的问题是如何在集群上部署应用程序,如EC2等 顺便说一下,应用程序是用

我的应用程序使用ApacheSpark进行后台数据处理,并使用Play框架进行前端接口

在Scala应用程序中使用Play框架的最佳方法是将其与TypeSafe activator一起使用

现在,问题是我想将此应用程序部署到spark集群。 关于如何使用
spark submit
将SBT应用程序部署到集群,有很好的文档,但是如何使用基于activator的应用程序呢

请注意,我了解如何将Spark与activator一起使用,我的问题是如何在集群上部署应用程序,如EC2等

顺便说一下,应用程序是用Scala编写的

我愿意接受一些建议,比如将这两个应用程序分离并允许它们进行交互。除非我不知道怎么做,所以如果你建议推荐人,我将不胜感激

更新:

我曾尝试在activator项目中向
build.sbt
文件添加依赖项,但出现以下错误:

[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[error] impossible to get artifacts when data has not been loaded. IvyNode = org.slf4j#slf4j-api;1.6.1
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) java.lang.IllegalStateException: impossible to get artifacts when data has not been loaded. IvyNode = org.slf4j#slf4j-api;1.6.1
以下是我如何在build.sbt文件中添加依赖项:

// All the apache spark dependencies
libraryDependencies ++= Seq(
  "org.apache.spark" % "spark-core_2.10" % sparkVersion % "provided" withSources(),
  "org.apache.spark" % "spark-sql_2.10" % sparkVersion % "provided" withSources(),
  "org.apache.spark" % "spark-streaming_2.10" % sparkVersion % "provided" withSources(),
  "org.apache.spark" % "spark-mllib_2.10" % sparkVersion % "provided" withSources()
)
和解析器:

// All the Apache Spark resolvers
resolvers ++= Seq(
  "Apache repo" at     "https://repository.apache.org/content/repositories/releases",
  "Local Repo" at Path.userHome.asFile.toURI.toURL + "/.m2/repository", // Added local repository
  Resolver.mavenLocal )

任何解决方法?

activator只是sbt,有三个更改:

  • 用于从模板创建项目的“新建”命令
  • 打开教程用户界面的“ui”命令
  • 如果自己键入“activator”,尝试猜测是否打开ui。要强制命令行,请使用“激活器外壳”
所以你读到的关于sbt的所有内容都适用。如果愿意,您也可以在项目中使用sbt,但除非您使用的是“新建”或“ui”,否则这是一样的


您的问题的简短答案可能是使用sbt native packager插件及其“stage”任务;play文档有一个部署部分描述了这一点。

事实证明,play框架和Apache Spark的一个问题是依赖关系冲突,可以通过从Spark依赖关系列表中排除依赖关系来轻松解决

// All the apache spark dependencies
libraryDependencies ++= Seq(
  "org.apache.spark" % "spark-core_2.10" % sparkVersion % "provided" withSources() excludeAll(
    ExclusionRule(organization = "org.slf4j")
    ),
  "org.apache.spark" % "spark-sql_2.10" % sparkVersion % "provided" withSources(),
  "org.apache.spark" % "spark-streaming_2.10" % sparkVersion % "provided" withSources(),
  "org.apache.spark" % "spark-mllib_2.10" % sparkVersion % "provided" withSources()
)
此外,要在console中使用,可以轻松地将以下内容添加到
build.sbt
文件中,以便直接导入基本的spark软件包

/// console

// define the statements initially evaluated when entering 'console', 'consoleQuick', or 'consoleProject'
// but still keep the console settings in the sbt-spark-package plugin

// If you want to use yarn-client for spark cluster mode, override the environment variable
// SPARK_MODE=yarn-client <cmd>
val sparkMode = sys.env.getOrElse("SPARK_MODE", "local[2]")


initialCommands in console :=
  s"""
     |import org.apache.spark.SparkConf
     |import org.apache.spark.SparkContext
     |import org.apache.spark.SparkContext._
     |
     |@transient val sc = new SparkContext(
     |  new SparkConf()
     |    .setMaster("$sparkMode")
                                  |    .setAppName("Console test"))
                                  |implicit def sparkContext = sc
                                  |import sc._
                                  |
                                  |@transient val sqlc = new org.apache.spark.sql.SQLContext(sc)
                                  |implicit def sqlContext = sqlc
                                  |import sqlc._
                                  |
                                  |def time[T](f: => T): T = {
                                  |  import System.{currentTimeMillis => now}
                                  |  val start = now
                                  |  try { f } finally { println("Elapsed: " + (now - start)/1000.0 + " s") }
                                  |}
                                  |
                                  |""".stripMargin

cleanupCommands in console :=
  s"""
     |sc.stop()
   """.stripMargin
///控制台
//定义在输入“console”、“ConsoleEquick”或“consoleProject”时最初计算的语句
//但仍然保留sbt spark软件包插件中的控制台设置
//如果要将Thread client用于spark cluster模式,请重写环境变量
//SPARK_模式=纱线客户机
val sparkMode=sys.env.getOrElse(“SPARK_模式”、“本地[2]”)
控制台中的初始化命令:=
s“”
|导入org.apache.spark.SparkConf
|导入org.apache.spark.SparkContext
|导入org.apache.spark.SparkContext_
|
|@瞬态val sc=新SparkContext(
|新SparkConf()
|.setMaster($sparkMode)
|.setAppName(“控制台测试”))
|隐式def sparkContext=sc
|进口sc_
|
|@transient val sqlc=new org.apache.spark.sql.SQLContext(sc)
|隐式def sqlContext=sqlc
|导入sqlc_
|
|定义时间[T](f:=>T):T={
|导入系统。{currentTimeMillis=>now}
|val start=now
|试试{f}最后{println(“经过:+(现在开始)/1000.0+“s”)}
|}
|
|“.stripMargin”
控制台中的清除命令:=
s“”
|sc.停止()
“.stripMargin”
现在,主要问题是应用程序的部署。通过运行play framework,在集群上启动多个节点的应用程序很麻烦,因为HTTP请求处理程序必须有一个特定的URL。
这个问题可以通过在主节点上启动Play Framework实例并将URL指向其IP来解决。

在Scala应用程序中使用Play Framework与TypeSafe activator一起使用的最佳方法是什么@kaktusito Play框架应用程序可以使用activator轻松管理。虽然我也可以将其用作SBT依赖项,但activator实际上是管理播放应用程序的方式。是的,但每当我尝试向项目添加依赖项时,就会出现一个错误:
[error]在未加载数据时无法获取工件。IvyNode=org.slf4j#slf4j api;1.6.1
我不知道这个问题的答案,您可以将其作为带有sbt标签的新问题发布。