From: <bi...@us...> - 2010-02-23 00:50:17
|
Revision: 2970 http://archive-access.svn.sourceforge.net/archive-access/?rev=2970&view=rev Author: binzino Date: 2010-02-23 00:50:11 +0000 (Tue, 23 Feb 2010) Log Message: ----------- Additional logging, especially for error conditions. Modified Paths: -------------- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchMaster.java trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchSlave.java Modified: trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchMaster.java =================================================================== --- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchMaster.java 2010-02-23 00:25:39 UTC (rev 2969) +++ trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchMaster.java 2010-02-23 00:50:11 UTC (rev 2970) @@ -27,6 +27,9 @@ import java.util.ArrayList; import java.util.LinkedList; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.jdom.Document; import org.jdom.Element; import org.jdom.Namespace; @@ -38,8 +41,10 @@ */ public class OpenSearchMaster { + public static final Log LOG = LogFactory.getLog( OpenSearchMaster.class ); + List<OpenSearchSlave> slaves = new ArrayList<OpenSearchSlave>( ); - long timeout = 30 * 1000; + long timeout = 0; public OpenSearchMaster( String slavesFile, long timeout ) throws IOException @@ -102,22 +107,21 @@ { if ( sqt.throwable != null ) { - // TODO: Handle problems with slaves continue ; } - // Dump all the results ("item" elements) into a single list. - Element channel = sqt.response.getRootElement( ).getChild( "channel" ); - items.addAll( (List<Element>) channel.getChildren( "item" ) ); - channel.removeChildren( "item" ); - try { + // Dump all the results ("item" elements) into a single list. + Element channel = sqt.response.getRootElement( ).getChild( "channel" ); + items.addAll( (List<Element>) channel.getChildren( "item" ) ); + channel.removeChildren( "item" ); + totalResults += Integer.parseInt( channel.getChild( "totalResults", Namespace.getNamespace( "http://a9.com/-/spec/opensearchrss/1.0/" ) ).getTextTrim( ) ); } catch ( Exception e ) { - // TODO: Log error getting total. + LOG.error( "Error processing response from slave: " + sqt.slave, e ); } } @@ -146,10 +150,6 @@ collapsed.add( item ); count++; } - else - { - // TODO: Log collapse of item. - } } // Replace the list of items with the collapsed list. Modified: trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchSlave.java =================================================================== --- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchSlave.java 2010-02-23 00:25:39 UTC (rev 2969) +++ trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/OpenSearchSlave.java 2010-02-23 00:50:11 UTC (rev 2970) @@ -27,6 +27,9 @@ import java.net.URLEncoder; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.jdom.Document; import org.jdom.Element; import org.jdom.Namespace; @@ -38,6 +41,8 @@ */ public class OpenSearchSlave { + public static final Log LOG = LogFactory.getLog( OpenSearchSlave.class ); + private String urlTemplate; public OpenSearchSlave( String urlTemplate ) @@ -53,6 +58,8 @@ InputStream is = null; try { + LOG.info( "Querying slave: " + url ); + is = getInputStream( url ); Document doc = (new SAXBuilder()).build( is ); @@ -61,6 +68,11 @@ return doc; } + catch ( Exception e ) + { + LOG.error( url.toString(), e ); + throw e; + } finally { // Ensure the InputStream is closed, which should trigger the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |