[ https://issues.apache.org/jira/browse/MAPREDUCE-2863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13126665#comment-13126665 ]
Thomas Graves commented on MAPREDUCE-2863: ------------------------------------------ Ok so I compared hamlet to jersey. I wrote a small app to list the nodes from RM in json (equivalent of webapp page <your_RM>:8088/cluster/nodes). here is what I came up with. If anyone see better ways to do these or sees something I did wrong please point it out. Any comments/opinions are welcome! Note since jersey is integrated into httpserver its a simple call to that to add the jersey resource and you get all the filtering/security already in httpserver if you register it properly. It would take a few functions to add that into existing WebApp yarn framework but not much at all. I verified that both go through any filters you have defined. Could be as simple as (In RMWebApp which extends WebApp): setJerseyPackageName(TomJerseyResource.class.getPackage().getName()); setJerseyPath("/jersey/*"); setAttribute("rm", this.rm); // inject RM instance to jersey HttpServer server = new HttpServer(name, bindAddress, port, findPort, conf, webapp.getServePathSpecs() and webapp.getJerseyPath ); Assuming we have a data structure or produce data structure with info we want to dump in json since that is needed for regular webapp html and its the same in either hamlet or jersey here is the code I came up with: Jersey: @Path("") public class TestJerseyResource { @GET @Produces({MediaType.APPLICATION_JSON}) public Response get() throws IOException { final ResourceManager rm = (ResourceManager)context.getAttribute("rm"); final RMContext rmContext = rm.getRMContext(); Map<String, Object> allNodes = getNodesInfoMap(rm, rmContext); final String js = JSON.toString(allNodes); return Response.ok(js).type(MediaType.APPLICATION_JSON).build(); } } Hamlet: in RMController.java public void nodesjson() { RMContext rmContext = getInstance(RMContext.class); ResourceManager rm = getInstance(ResourceManager.class); Map<String, Object> allNodes = getNodesInfoMap(rm, rmContext); renderJSON(allNodes); } A few side notes. It took me longer to figure out how to do the hamlet stuff then jersey. Probably because jersey is well documented and I was able to copy example from existing hdfs code. I also still need to look further on how to make it integrate nicely with the html stuff as some of the functions like renderJSON were only available at the Controller level. I also need to see how hamlet handles requesting different content type (I'm assuming it will) so that you could go to same uri and just ask for the content type differently. So in conclusion the code sizes seems pretty comparable. If we want to keep with one framework I could do it in hamlet. I found it a little harder to use but that is probably just a learning curve. Ideally whichever we use the html for web ui and json web services use the same underlying functions to get the data although looking at a bit of the html render stuff that looks harder then I expected but perhaps there is some fancy hamlet stuff I haven't found yet. > Support web-services for RM & NM > -------------------------------- > > Key: MAPREDUCE-2863 > URL: https://issues.apache.org/jira/browse/MAPREDUCE-2863 > Project: Hadoop Map/Reduce > Issue Type: Improvement > Components: mrv2, nodemanager, resourcemanager > Reporter: Arun C Murthy > Assignee: Thomas Graves > > It will be very useful for RM and NM to support web-services to export > json/xml. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira