java调用spark,Spark - 使用参数从java调用Spark jar

I would like to call spark jar from java (to run spark process on yarn), and try to use this link code.

It looks fit in my case, but I need to pass hashmap and some java values to spakr jar. Is it able to pass java object to spark jar?

And is java side able to know how mush spark jar process or is it done? if so, how?

解决方案

I think you misunderstood the content given in data-algorithms

There are 2 ways to submit job

1) Spark-submit like below example from shell script

cat run_secondarysorting.sh

#!/bin/bash

export JAVA_HOME=/usr/java/jdk7

export SPARK_HOME=/home/hadoop/spark-1.1.0

export SPARK_MASTER=spark://myserver100:7077

BOOK_HOME=/home/mp/data-algorithms-book

APP_JAR=$BOOK_HOME/dist/data_algorithms_book.jar

INPUT=/home/hadoop/testspark/timeseries.txt

# Run on a Spark standalone cluster

prog=org.dataalgorithms.chap01.spark.SparkSecondarySort

$SPARK_HOME/bin/spark-submit \

--class $prog \

--master $SPARK_MASTER \

--executor-memory 2G \

--total-executor-cores 20 \

$APP_JAR

2) From Yarn Client which was described in the link.

Usage of Yarn Client is

want to submit Spark jobs from Java code (such as Java servlets or

other Java code such as REST servers).

When you are calling this yarn client... then you need to call as method in your rest-service or servlet etc... (i.e. through web) in which you can also pass parameters like HashMap or any java object kind...

For demo purpose he has written standalone client (with public static void main)

Hope you understood..

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值