使用REST触发spark工作

cha*_*uru 24 rest job-scheduling spring-batch apache-spark spring-data-hadoop

我一直在尝试apache火花.我的问题更具体地触发火花工作.在这里,我发布了关于理解火花工作的问题.在弄脏工作后,我转向了我的要求.

我有一个REST端点,我公开API来触发Jobs,我使用Spring4.0进行Rest实现.现在继续我想在Spring中实现Job as Service,我将以编程方式提交Job,这意味着当触发端点时,使用给定的参数我将触发该作业.我现在有很少的设计选择.

  • 类似于下面的写作,我需要维护几个由抽象类调用的作业JobScheduler.

     /*Can this Code be abstracted from the application and written as 
      as a seperate job. Because my understanding is that the 
     Application code itself has to have the addJars embedded 
     which internally  sparkContext takes care.*/
    
     SparkConf sparkConf = new SparkConf().setAppName("MyApp").setJars(
     new String[] { "/path/to/jar/submit/cluster" })
     .setMaster("/url/of/master/node");
      sparkConf.setSparkHome("/path/to/spark/");
    
            sparkConf.set("spark.scheduler.mode", "FAIR");
            JavaSparkContext sc = new JavaSparkContext(sparkConf);
            sc.setLocalProperty("spark.scheduler.pool", "test");
    
        // Application with Algorithm , transformations
    
    Run Code Online (Sandbox Code Playgroud)
  • 扩展到上面有服务处理的多个版本的作业.

  • 或者使用Spark Job Server来执行此操作.

首先,我想知道在这种情况下最佳解决方案是什么,执行方式和扩展方式.

注意:我正在使用来自spark的独立群集.善意的帮助.

Art*_*yan 27

事实证明,Spark有一个隐藏的REST API来提交作业,检查状态并杀死.

查看完整示例:http://arturmkrtchyan.com/apache-spark-hidden-rest-api

  • 听起来很有意思,发现这个https://issues.apache.org/jira/secure/attachment/12696651/stable-spark-submit-in-standalone-mode-2-4-15.pdf所以它的意思是火花本身现在有了暴露了这个功能? (2认同)
  • 您链接的网页并没有真正说明任何内容,因为页面上的图片已经死亡. (2认同)
  • 当所提供的主要链接有损坏的图片时,这可能会有所帮助:https://gist.github.com/arturmkrtchyan/5d8559b2911ac951d34a (2认同)

Dav*_*vid 7

只需使用Spark JobServer https://github.com/spark-jobserver/spark-jobserver即可

制作服务时需要考虑很多事情,Spark JobServer已经覆盖了大部分内容.如果您发现不够好的东西,应该很容易发出请求并将代码添加到他们的系统而不是从头开始重新创建它


Jos*_*emy 5

Livy是一个开源的REST接口,可以从任何地方与Apache Spark进行交互.它支持在本地或Apache Hadoop YARN中运行的Spark上下文中执行代码或程序的代码段.