- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
how to get data from Yarn Resource Manager REST API using JAVA
- Labels:
-
Apache YARN
Created ‎04-24-2018 02:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created ‎04-25-2018 08:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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()); }
