1 Star 0 Fork 0

穆孜 / emr-serverless-samples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
Damon P. Cortesi 提交于 2022-06-01 11:08 . Update java example

EMR Serverless Java SDK Example

This example shows how to call the EMR Serverless API using the Java SDK.

In it, we use a new maven project with the latest preview jar for EMR Serverless.

Pre-requisites

Example Java Usage

The example below will:

  • Create a new EMR Serverless Application
  • Start a new Spark job with a sample SparkPi application
  • Stop and delete your Application when done

It is intended as a high-level demo of how to call the EMR Serverless API from the Java SDK.

In the myapp folder.

  • Ensure you install the necessary dependencies
mvn install
  • Run the sample app with your own S3 bucket and IAM role
mvn exec:java -Dexec.mainClass="com.example.myapp.App" -Dexec.args="--bucket <S3_BUCKET> --role-arn arn:aws:iam::123456789012:role/emr-serverless-job-role"

Once the job is running, you can also view Spark logs.

# View Spark logs
aws s3 ls s3://<S3_BUCKET>/emr-serverless/logs/applications/<application_id>/jobs/<job_run_id>/

Or copy the stdout to view the results.

aws s3 cp s3://<S3_BUCKET>/emr-serverless/logs/applications/<application_id>/jobs/<job_run_id>/SPARK_DRIVER/stdout.gz - | gunzip

If you like, you can build a jar and run it independently and modify the Spark job arguments as well.

mvn package
java -cp target/myapp-1.0-SNAPSHOT.jar com.example.myapp.App -h
1
https://gitee.com/baby_muxin/emr-serverless-samples.git
git@gitee.com:baby_muxin/emr-serverless-samples.git
baby_muxin
emr-serverless-samples
emr-serverless-samples
main

搜索帮助