0

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.

Explorer
  • 1,491
  • 4
  • 26
  • 67

1 Answers1

0

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/

dassum
  • 4,727
  • 2
  • 25
  • 38
  • It is working fine with Curl however I need to submit it from a JVM now and wanted to find out how to covert this curl call to rest call from JVM. – Explorer Oct 03 '19 at 02:49