Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to get Livy session information in java ?

How to get Livy session information in java ?

New Contributor

Got many examples in other languagues but how this is possible in java,which property and API to use.

1 REPLY 1

Re: How to get Livy session information in java ?

New Contributor

Here I am providing the small snippet:

String uri=livyServerModel.getUrl()+"/sessions";

JSONObject jsonObject= getPOSTRequestResponse(request,uri);

/**/

getgetPOSTRequestResponse:

URL url = new URL(uri);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);

conn.setRequestMethod("POST");

conn.setRequestProperty("Content-Type", "application/json");

OutputStream os = conn.getOutputStream();

os.write(request.toString().getBytes());

os.flush();

BufferedReader br = new BufferedReader(new InputStreamReader(

(conn.getInputStream())));

String output;

while ((output = br.readLine()) != null) {

response = output;

}

conn.disconnect();