libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wood...@apache.org
Subject svn commit: r998940 - in /incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon: EC2Driver.java EC2Handler.java
Date Mon, 20 Sep 2010 14:13:36 GMT
Author: woodser
Date: Mon Sep 20 14:13:36 2010
New Revision: 998940

URL: http://svn.apache.org/viewvc?rev=998940&view=rev
Log:
Performance tweak in Amazon EC2 listImages() since ~7000 images exist.

Modified:
    incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Driver.java
    incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Handler.java

Modified: incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Driver.java
URL: http://svn.apache.org/viewvc/incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Driver.java?rev=998940&r1=998939&r2=998940&view=diff
==============================================================================
--- incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Driver.java (original)
+++ incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Driver.java Mon
Sep 20 14:13:36 2010
@@ -324,9 +324,11 @@ public abstract class EC2Driver extends 
 	private List<NodeImage> parseImages(Document doc) {
 		List<NodeImage> images = new ArrayList<NodeImage>();
 		try {
-			NodeList imageSet = (NodeList)xpath.evaluate("imagesSet/item", doc.getDocumentElement(),
XPathConstants.NODESET);
-			for (int i = 0; i < imageSet.getLength(); i++) {
-				images.add(parseImage((Element)imageSet.item(i)));
+			NodeList imageIds = (NodeList)xpath.evaluate("imagesSet/item/imageId", doc.getDocumentElement(),
XPathConstants.NODESET);
+			NodeList imageLocations = (NodeList)xpath.evaluate("imagesSet/item/imageLocation", doc.getDocumentElement(),
XPathConstants.NODESET);
+			for (int i = 0; i < imageIds.getLength(); i++) {
+				images.add(new NodeImage(imageIds.item(i).getTextContent(),
+						imageLocations.item(i).getTextContent(), null, this));
 			}
 			return images;
 		} catch (XPathExpressionException e) {
@@ -335,13 +337,6 @@ public abstract class EC2Driver extends 
 		return null;	// Error
 	}
 	
-	private NodeImage parseImage(Element elem) throws XPathExpressionException {
-		return new NodeImage(xpath.evaluate("imageId", elem),
-				xpath.evaluate("imageLocation", elem),
-				null,
-				this);
-	}
-	
 	/*
 	 * Converts a key and array of values into a map for AWS query parameters.
 	 * 

Modified: incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Handler.java
URL: http://svn.apache.org/viewvc/incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Handler.java?rev=998940&r1=998939&r2=998940&view=diff
==============================================================================
--- incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Handler.java (original)
+++ incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/amazon/EC2Handler.java Mon
Sep 20 14:13:36 2010
@@ -32,7 +32,7 @@ public class EC2Handler extends Response
 		try {
 			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 			DocumentBuilder db = dbf.newDocumentBuilder();
-			object = db.parse(new InputSource(new StringReader(response.getBody())));
+			object = db.parse(response.getBodyStream());
 		} catch (ParserConfigurationException e) {
 			e.printStackTrace();
 		} catch (SAXException e) {



Mime
View raw message