Created 07-03-2018 03:34 PM
Good morning every one,
can someone help me with how to send a post request by ajax to the apache livy server? I tried my best but I don't see how to do that. I have a textarea in which user can put his spark code. I want to send that code to the apache livy by ajax and get the result. I don't if my question is clear. Thank you.
Created 07-03-2018 04:47 PM
You could use the following java script client package or similar:
https://www.npmjs.com/package/livy-client
Or you could code your own using javascript jquery or similar.
Overall steps you should consider:
1. Create a livy session to be able to submit code
2. Reference the session id when running the code
Also keep the livy api link handy when working with livy 🙂
https://livy.incubator.apache.org/docs/latest/rest-api.html
HTH
*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
Created 07-03-2018 04:47 PM
You could use the following java script client package or similar:
https://www.npmjs.com/package/livy-client
Or you could code your own using javascript jquery or similar.
Overall steps you should consider:
1. Create a livy session to be able to submit code
2. Reference the session id when running the code
Also keep the livy api link handy when working with livy 🙂
https://livy.incubator.apache.org/docs/latest/rest-api.html
HTH
*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
Created 07-03-2018 05:40 PM
@Melchicédec NDUWAYO If the above answer has helped please login and mark the answer as "Accepted"
Created 07-04-2018 02:29 PM
@Felix Albani I don't see exactly how to create that livy session with javascript or jquery. Can you help me please? Is there any documentation about that? Using the livy client package will not be easy for me also because I must use nodejs to get the package and me I created my webapp using java ee with maven. I am weak in javascript programming. Please, help me.
Thank you.
This is how, normally I send posts to the server using ajax:
$.ajax({ type: 'POST', url: 'TraitementsServletPartialAgre', data: {drag: drag}, success: function (resultat) { var myTrees = resultat.split("|"); for (var myTree in myTrees) { var myTree = JSON.parse(myTrees[myTree]); new Treant(myTree); } } }); And this is what I tried with apache livy: $.ajax({ type: 'POST', dataType:'json', url: 'http://localhost:8998/', data: {kind: 'spark', code: CodeMirrorString}, success: function (resultat) { document.getElementById(response).innerHTML = resultat; } });
Created 07-03-2018 05:33 PM
Thank you very much for your answer. I will see that deeply. It seems that it can help me.
Thank you again.