Created 04-24-2018 02:02 PM
Hi All,
Could someone help me out how to start fetching data from YARN Rest API using Java. please share me some sample links.
Tanx and Regards,
MJ
Created 04-25-2018 08:38 AM
Your question is not quite clear to me. If you really want to fetch data from the YARN Resource Manager REST API in Java, all you need to do is open an HttpURLConnection and get the data from any endpoint. E.g.:
URL url = new URL("http://" + rmHost + ":8088/ws/v1/cluster/apps"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); ... // read and process your data conn.disconnect();
But there is a much easier solution to get data from the RM in Java: YarnClient, which is basically a Java API for YARN.
YarnClient yarnClient = YarnClient.createYarnClient(); Configuration conf = new YarnConfiguration(); conf.set("yarn.resourcemanager.hostname", "your RM hostname"); yarnClient.init(conf); yarnClient.start(); for (ApplicationReport applicationReport : yarnClient.getApplications()) { System.out.println(applicationReport.getApplicationId()); }
Created 04-25-2018 01:43 AM
Created 04-25-2018 08:38 AM
Your question is not quite clear to me. If you really want to fetch data from the YARN Resource Manager REST API in Java, all you need to do is open an HttpURLConnection and get the data from any endpoint. E.g.:
URL url = new URL("http://" + rmHost + ":8088/ws/v1/cluster/apps"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); ... // read and process your data conn.disconnect();
But there is a much easier solution to get data from the RM in Java: YarnClient, which is basically a Java API for YARN.
YarnClient yarnClient = YarnClient.createYarnClient(); Configuration conf = new YarnConfiguration(); conf.set("yarn.resourcemanager.hostname", "your RM hostname"); yarnClient.init(conf); yarnClient.start(); for (ApplicationReport applicationReport : yarnClient.getApplications()) { System.out.println(applicationReport.getApplicationId()); }