You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ha...@apache.org on 2008/11/25 22:38:58 UTC
svn commit: r720608 - in /hadoop/core/branches/branch-0.19: ./ CHANGES.txt
src/core/org/apache/hadoop/ipc/Client.java
src/core/org/apache/hadoop/ipc/RPC.java
src/test/org/apache/hadoop/ipc/TestRPC.java
Author: hairong
Date: Tue Nov 25 13:38:57 2008
New Revision: 720608
URL: http://svn.apache.org/viewvc?rev=720608&view=rev
Log:
Merge -r 720601:720602 from trunk to move the change log of HADOOP-4659 to branch 0.19.
Modified:
hadoop/core/branches/branch-0.19/ (props changed)
hadoop/core/branches/branch-0.19/CHANGES.txt (contents, props changed)
hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/Client.java
hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/RPC.java
hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/ipc/TestRPC.java
Propchange: hadoop/core/branches/branch-0.19/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 25 13:38:57 2008
@@ -1 +1 @@
-/hadoop/core/trunk:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628,700923,701273,701398,703923,704203,704261,704701,704703,704707,704712,704732,704748,704989,705391,705420,705430,705762,706350,706707,706719,706796,706802,707258,707262,708623,708641,708710,709040,709303,712881,713888
+/hadoop/core/trunk:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628,700923,701273,701398,703923,704203,704261,704701,704703,704707,704712,704732,704748,704989,705391,705420,705430,705762,706350,706707,706719,706796,706802,707258,707262,708623,708641,708710,709040,709303,712881,713888,720602
Modified: hadoop/core/branches/branch-0.19/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/CHANGES.txt?rev=720608&r1=720607&r2=720608&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.19/CHANGES.txt Tue Nov 25 13:38:57 2008
@@ -1023,6 +1023,9 @@
HADOOP-4061. Throttle Datanode decommission monitoring in Namenode.
(szetszwo)
+ HADOOP-4659. Root cause of connection failure is being ost to code that
+ uses it for delaying startup. (Steve Loughran and Hairong via hairong)
+
Release 0.18.2 - 2008-11-03
BUG FIXES
Propchange: hadoop/core/branches/branch-0.19/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 25 13:38:57 2008
@@ -1 +1 @@
-/hadoop/core/trunk/CHANGES.txt:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628,700923,701273,701398,703923,704203,704261,704701,704703,704707,704712,704732,704748,704989,705391,705420,705430,705762,706350,706707,706719,706796,706802,707258,707262,708623,708641,708710,708723,709040,709303,711717,712881,713888
+/hadoop/core/trunk/CHANGES.txt:697306,698176,699056,699098,699415,699424,699444,699490,699517,700163,700628,700923,701273,701398,703923,704203,704261,704701,704703,704707,704712,704732,704748,704989,705391,705420,705430,705762,706350,706707,706719,706796,706802,707258,707262,708623,708641,708710,708723,709040,709303,711717,712881,713888,720602
Modified: hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/Client.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/Client.java?rev=720608&r1=720607&r2=720608&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/Client.java (original)
+++ hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/Client.java Tue Nov 25 13:38:57 2008
@@ -22,6 +22,7 @@
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
+import java.net.ConnectException;
import java.io.IOException;
import java.io.DataInputStream;
@@ -352,7 +353,7 @@
socket = null;
// throw the exception if the maximum number of retries is reached
- if (curRetries == maxRetries) {
+ if (curRetries >= maxRetries) {
throw ioe;
}
@@ -696,10 +697,7 @@
call.error.fillInStackTrace();
throw call.error;
} else { // local exception
- throw (IOException)new IOException(
- "Call to "+ addr + " failed on local exception: "
- + call.error.getMessage())
- .initCause(call.error);
+ throw wrapException(addr, call.error);
}
} else {
return call.value;
@@ -707,6 +705,37 @@
}
}
+ /**
+ * Take an IOException and the address we were trying to connect to
+ * and return an IOException with the input exception as the cause.
+ * The new exception provides the stack trace of the place where
+ * the exception is thrown and some extra diagnostics information.
+ * If the exception is ConnectException or SocketTimeoutException,
+ * return a new one of the same type; Otherwise return an IOException.
+ *
+ * @param addr target address
+ * @param exception the relevant exception
+ * @return an exception to throw
+ */
+ private IOException wrapException(InetSocketAddress addr,
+ IOException exception) {
+ if (exception instanceof ConnectException) {
+ //connection refused; include the host:port in the error
+ return (ConnectException)new ConnectException(
+ "Call to " + addr + " failed on connection exception: " + exception)
+ .initCause(exception);
+ } else if (exception instanceof SocketTimeoutException) {
+ return (SocketTimeoutException)new SocketTimeoutException(
+ "Call to " + addr + " failed on socket timeout exception: "
+ + exception).initCause(exception);
+ } else {
+ return (IOException)new IOException(
+ "Call to " + addr + " failed on local exception: " + exception)
+ .initCause(exception);
+
+ }
+ }
+
/** Makes a set of calls in parallel. Each parameter is sent to the
* corresponding address. When all values are available, or have timed out
* or errored, the collected results are returned in an array. The array
Modified: hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/RPC.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/RPC.java?rev=720608&r1=720607&r2=720608&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/RPC.java (original)
+++ hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/ipc/RPC.java Tue Nov 25 13:38:57 2008
@@ -279,18 +279,47 @@
}
public static VersionedProtocol waitForProxy(Class protocol,
+ long clientVersion,
+ InetSocketAddress addr,
+ Configuration conf
+ ) throws IOException {
+ return waitForProxy(protocol, clientVersion, addr, conf, Long.MAX_VALUE);
+ }
+
+ /**
+ * Get a proxy connection to a remote server
+ * @param protocol protocol class
+ * @param clientVersion client version
+ * @param addr remote address
+ * @param conf configuration to use
+ * @param timeout time in milliseconds before giving up
+ * @return the proxy
+ * @throws IOException if the far end through a RemoteException
+ */
+ static VersionedProtocol waitForProxy(Class protocol,
long clientVersion,
InetSocketAddress addr,
- Configuration conf
- ) throws IOException {
+ Configuration conf,
+ long timeout
+ ) throws IOException {
+ long startTime = System.currentTimeMillis();
+ IOException ioe;
while (true) {
try {
return getProxy(protocol, clientVersion, addr, conf);
} catch(ConnectException se) { // namenode has not been started
LOG.info("Server at " + addr + " not available yet, Zzzzz...");
+ ioe = se;
} catch(SocketTimeoutException te) { // namenode is busy
LOG.info("Problem connecting to server: " + addr);
+ ioe = te;
}
+ // check if timed out
+ if (System.currentTimeMillis()-timeout >= startTime) {
+ throw ioe;
+ }
+
+ // wait for retry
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
Modified: hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/ipc/TestRPC.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/ipc/TestRPC.java?rev=720608&r1=720607&r2=720608&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/ipc/TestRPC.java (original)
+++ hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/ipc/TestRPC.java Tue Nov 25 13:38:57 2008
@@ -19,6 +19,7 @@
package org.apache.hadoop.ipc;
import java.io.IOException;
+import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.lang.reflect.Method;
@@ -32,7 +33,6 @@
import org.apache.hadoop.io.UTF8;
import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.ipc.VersionedProtocol;
import org.apache.hadoop.net.NetUtils;
/** Unit tests for RPC. */
@@ -117,7 +117,6 @@
}
public int[] exchange(int[] values) {
- int sum = 0;
for (int i = 0; i < values.length; i++) {
values[i] = i;
}
@@ -309,6 +308,17 @@
if(proxy!=null) RPC.stopProxy(proxy);
}
}
+
+ public void testStandaloneClient() throws IOException {
+ try {
+ RPC.waitForProxy(TestProtocol.class,
+ TestProtocol.versionID, new InetSocketAddress(ADDRESS, 20), conf, 15000L);
+ fail("We should not have reached here");
+ } catch (ConnectException ioe) {
+ //this is what we expected
+ }
+ }
+
public static void main(String[] args) throws Exception {
new TestRPC("test").testCalls();