희안하게 할 때마다 헤매는 xml parsing...
왜 매번...
참... 씁쓸하구먼...
벌써 xml parsing을 수행한 횟수가 10번도 넘은거 같은데 왜 할때마다 헤매는 것인지 알 수가 없네...
그 것보다 심각한 건 역시... 잊어버리지 않기 위해 블로그에 기록했던 사실까지 잊어버린다.
미치고 환장할 노릇이 분명하다.
ANODE1 150 2048 1024 6 ANODE2 70 2048 1024 6 ANODE3 50 2048 1024 6 ANODE4 50 2048 1024 6 recommend 50 60 30
public void FileParsing() throws IOException, ParserConfigurationException, org.xml.sax.SAXException { File file = new File(CLUSTER_CAPACITY_INFORMATION_FILE_PATH); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = docBuilder.parse(file); NodeList nodeList = document.getDocumentElement().getElementsByTagName("DATANODE"); for( int nodeIndex = 0; nodeIndex < nodeList.getLength(); ++nodeIndex ) { Node node = nodeList.item(nodeIndex); NodeProperty np = new NodeProperty(); if( node.getNodeType() == Node.ELEMENT_NODE ) { NodeList childList = node.getChildNodes(); for( int childIndex = 0; childIndex < childList.getLength(); ++childIndex ) { Node ele = childList.item(childIndex); if( ele != null ) { if( ele.getNodeType() == Node.ELEMENT_NODE ) { String name = ele.getNodeName(); String value = ele.getTextContent(); if( name.equalsIgnoreCase("NODENAME") ) { np.setNodeName(value); } else if( name.equalsIgnoreCase("DISKIOBANDWIDTH") ) { np.setDiskIOBandwidth(Integer.parseInt(value)); } else if( name.equalsIgnoreCase("AVAILABLEPMEMORY") ) { np.setAvailablePMemory(Integer.parseInt(value)); } else if( name.equalsIgnoreCase("NETWORKBANDWIDTH") ) { np.setNetworkBandwidth(Integer.parseInt(value)); } System.out.println(name + "\n" //+ subnode.getNodeType() + "\n" + value); }// if }// if }// for }// if env_Variants.put(np.getNodeName(), np); } System.out.println(env_Variants); }
'MISCELLANEOUSNESS' 카테고리의 다른 글
hadoop terasort patitioner 소스 보기.. (0) | 2013.01.15 |
---|---|
프로토콜 버퍼(Protocol Buffer) 설치. (2) | 2013.01.08 |
티스토리 초대장 배포[종료] (91) | 2012.12.10 |