Skip to content

Instantly share code, notes, and snippets.

@drmalex07
Last active December 30, 2021 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmalex07/76df2860f427d17e61083520386b5531 to your computer and use it in GitHub Desktop.
Save drmalex07/76df2860f427d17e61083520386b5531 to your computer and use it in GitHub Desktop.
An example submit to Apache Livy. #livy #spark

README - Submit to Livy using REST API

See https://livy.apache.org/docs/latest/rest-api.html

Let app.json be the JSON payload that represents the application:

{
    "file": "hdfs:///user/user/apps/hello-spark-0.0.1.jar",
    "className": "acme.hello_spark.Grep",
    "args": ["input/1.txt", "[Mm]agic"],
    "jars": [
       "hdfs:///user/user/jars/log4j-api-2.7.jar",
       "hdfs:///user/user/jars/log4j-core-2.7.jar"
    ],
    "driverMemory": "1g", 
    "executorMemory": "1g",
    "executorCores": 2, 
    "numExecutors": 2
}

Submit the application:

curl -d @app.json -H 'Content-Type: application/json' -X POST http://hadoop.example.net:8998/batches

The submission endpoint supports doAs request parameter to allow proxying other users (corresponds to --proxy-user option of spark-submit):

curl -d @app.json -H 'Content-Type: application/json' -X POST http://hadoop.example.net:8998/batches?doAs=someone

Fetch the status of submitted batch jobs:

curl http://hadoop.example.net:8998/batches

Fetch logs for a specific job (eg the one identified as 17):

curl http://hadoop.example.net:8998/batches/17/log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment