[ 
https://issues.apache.org/jira/browse/HADOOP-12021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14559985#comment-14559985
 ] 

Andrew Wang commented on HADOOP-12021:
--------------------------------------

Gotcha, thanks Lewis. One more q, do you think loading a Configuration is 
easier than doing this yourself? I wrote up a little snippet which might be a 
nice starting point.

{code}
public class Hadooper {

  public static void main(String[] args) throws Exception {

    ClassLoader cl = Configuration.class.getClassLoader();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = 
builder.parse(cl.getResourceAsStream("core-default.xml"));
    NodeList nodeList = document.getDocumentElement().getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
      Node node = nodeList.item(i);
      if (node instanceof Element) {
        if (node.getNodeName().equals("property")) {
          System.out
              .println(((Element) 
node).getElementsByTagName("name").item(0).getTextContent());
          System.out.println(
              ((Element) 
node).getElementsByTagName("description").item(0).getTextContent());
        }
      }
    }
  }
}
{code}

> Augmenting Configuration to accomodate <description>
> ----------------------------------------------------
>
>                 Key: HADOOP-12021
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12021
>             Project: Hadoop Common
>          Issue Type: New Feature
>          Components: conf
>            Reporter: Lewis John McGibbney
>            Priority: Minor
>             Fix For: 1.3.0, 2.8.0
>
>         Attachments: Screen Shot 2015-05-26 at 2.22.26 PM (2).png
>
>
> Over on the 
> [common-dev|http://www.mail-archive.com/common-dev%40hadoop.apache.org/msg16099.html]
>  ML I explained a use case which requires me to obtain the value of the 
> Configuration <description> tags.
> [~cnauroth] advised me to raise the issue to Jira for discussion.
> I am happy to provide a patch so that the <description> values are parsed out 
> of the various XML files and stored, and also that the Configuration class is 
> augmented to provide accessors to accommodate the use case.
> I wanted to find out what people think about this one and whether I should 
> check out Hadoop source and submit a patch. If you guys could provide some 
> advice it would be appreciated.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to