How to convert Livy curl call to Livy Rest API call

我们两清 提交于 2020-01-06 07:53:59

问题


I am getting started with Livy, in my setup Livy server is running on Unix machine and I am able to do curl to it and execute the job. I have created a fat jar and uploaded it on hdfs and I am simply calling its main method from Livy. My Json payload for Livy looks like below:

{
"file" : "hdfs:///user/data/restcheck/spark_job_2.11-3.0.0-RC1-
SNAPSHOT.jar",
"proxyUser" : "test_user",
"className" : "com.local.test.spark.pipeline.path.LivyTest",
"files" : ["hdfs:///user/data/restcheck/hivesite.xml","hdfs:///user/data/restcheck/log4j.properties"],
"driverMemory" : "5G",
"executorMemory" : "10G",
"executorCores" : 5,
"numExecutors" : 10,
"queue" : "user.queue",
"name"  : "LivySampleTest2",
"conf" : {"spark.master" : "yarn","spark.executor.extraClassPath" : 
"/etc/hbase/conf/","spark.executor.extraJavaOptions" : "-Dlog4j.configuration=file:log4j.properties","spark.driver.extraJavaOptions" : "-Dlog4j.configuration=file:log4j.properties","spark.ui.port" : 4100,"spark.port.maxRetries" : 100,"JAVA_HOME" : "/usr/java/jdk1.8.0_60","HADOOP_CONF_DIR" : 
"/etc/hadoop/conf:/etc/hive/conf:/etc/hbase/conf","HIVE_CONF_DIR" : 
"/etc/hive/conf"}
}

and below is my curl call to it:

curl -X POST --negotiate -u:"test_user" --data @/user/data/Livy/SampleFile.json  -H "Content-Type: application/json" https://livyhost:8998/batches 

I am trying to convert this a REST API call and following the WordCount example provided by Cloudera but not able to covert my curl call to the REST API. I have all the jars already added in HDFS so I dont think I need to do the upload jar call.


回答1:


It should work with curl also

Please try the below JSON.

curl -H "Content-Type: application/json" https://livyhost:8998/batches
 -X POST --data '{
  "name" : "LivyREST",
  "className" :  "com.local.test.spark.pipeline.path.LivyTest",
  "file"  : "/user/data/restcheck/spark_job_2.11-3.0.0-RC1-
SNAPSHOT.jar"
}' 

Also, I am adding some more references

http://gethue.com/how-to-use-the-livy-spark-rest-job-server-api-for-submitting-batch-jar-python-and-streaming-spark-jobs/



来源:https://stackoverflow.com/questions/58191185/how-to-convert-livy-curl-call-to-livy-rest-api-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!