Author: mc
Date: Mon Aug 22 11:19:54 2005
New Revision: 239210

URL: http://svn.apache.org/viewcvs?rev=239210&view=rev
Log:

  Set socket timeouts at client...


Modified:
    lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java

Modified: 
lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java
URL: 
http://svn.apache.org/viewcvs/lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java?rev=239210&r1=239209&r2=239210&view=diff
==============================================================================
--- lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java 
(original)
+++ lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java 
Mon Aug 22 11:19:54 2005
@@ -33,6 +33,7 @@
  ********************************************************/
 public class NDFSClient implements FSConstants {
     public static final Logger LOG = 
LogFormatter.getLogger("org.apache.nutch.fs.NDFSClient");
+    static int READ_TIMEOUT = 20 * 1000;
     static int BUFFER_SIZE = 4096;
     static int MAX_BLOCK_ACQUIRE_FAILURES = 10;
     ClientProtocol namenode;
@@ -346,6 +347,7 @@
                 }
                 try {
                     s = new Socket(targetAddr.getAddress(), 
targetAddr.getPort());
+                    s.setSoTimeout(READ_TIMEOUT);
 
                     //
                     // Xmit header info to datanode
@@ -377,6 +379,12 @@
                     // Put chosen node into dead list, continue
                     LOG.info("Could not connect to " + target);
                     deadNodes.add(chosenNode);
+                    if (s != null) {
+                        try {
+                            s.close();
+                        } catch (IOException iex) {
+                        }                        
+                    }
                     s = null;
                 }
             }
@@ -588,6 +596,7 @@
                 Socket s = null;
                 try {
                     s = new Socket(target.getAddress(), target.getPort());
+                    s.setSoTimeout(READ_TIMEOUT);
                 } catch (IOException ie) {
                     // Connection failed.  Let's wait a little bit and retry
                     try {


Reply via email to