hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077194 - in /hadoop/common/branches/branch-0.20-security-patches: CHANGES.txt src/core/org/apache/hadoop/ipc/Client.java src/test/org/apache/hadoop/ipc/TestIPC.java
Date Fri, 04 Mar 2011 03:50:40 GMT
Author: omalley
Date: Fri Mar  4 03:50:39 2011
New Revision: 1077194

URL: http://svn.apache.org/viewvc?rev=1077194&view=rev
Log:
commit f916bb83c80f3ebe90821b016a7fc63e05c134d6
Author: Hairong Kuang <hairong@ucdev21.inktomisearch.com>
Date:   Mon Feb 8 20:23:13 2010 +0000

    hadoop-6498 from http://issues.apache.org/jira/secure/attachment/12431372/hangClient-0.20.patch.

Modified:
    hadoop/common/branches/branch-0.20-security-patches/CHANGES.txt
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Client.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestIPC.java

Modified: hadoop/common/branches/branch-0.20-security-patches/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/CHANGES.txt?rev=1077194&r1=1077193&r2=1077194&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-patches/CHANGES.txt Fri Mar  4 03:50:39 2011
@@ -7,6 +7,9 @@ Release 0.20.2 - Unreleased
     MAPREDUCE-112. Add counters for reduce input, output records to the new API.
     (Jothi Padmanabhan via cdouglas)
 
+    HADOOP-6498. IPC client bug may cause rpc call hang. (Ruyue Ma and hairong
+    via hairong)
+
 Release 0.20.1 - 2009-09-01
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Client.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Client.java?rev=1077194&r1=1077193&r2=1077194&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Client.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Client.java
Fri Mar  4 03:50:39 2011
@@ -622,13 +622,14 @@ public class Client {
         if (LOG.isDebugEnabled())
           LOG.debug(getName() + " got value #" + id);
 
-        Call call = calls.remove(id);
+        Call call = calls.get(id);
 
         int state = in.readInt();     // read call status
         if (state == Status.SUCCESS.state) {
           Writable value = ReflectionUtils.newInstance(valueClass, conf);
           value.readFields(in);                 // read value
           call.setValue(value);
+          calls.remove(id);
         } else if (state == Status.ERROR.state) {
           call.setException(new RemoteException(WritableUtils.readString(in),
                                                 WritableUtils.readString(in)));

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestIPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestIPC.java?rev=1077194&r1=1077193&r2=1077194&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestIPC.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestIPC.java
Fri Mar  4 03:50:39 2011
@@ -26,6 +26,7 @@ import org.apache.hadoop.util.StringUtil
 import org.apache.hadoop.net.NetUtils;
 
 import java.util.Random;
+import java.io.DataInput;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
@@ -88,7 +89,7 @@ public class TestIPC extends TestCase {
         try {
           LongWritable param = new LongWritable(RANDOM.nextLong());
           LongWritable value =
-            (LongWritable)client.call(param, server);
+            (LongWritable)client.call(param, server, null, null);
           if (!param.equals(value)) {
             LOG.fatal("Call failed!");
             failed = true;
@@ -121,7 +122,7 @@ public class TestIPC extends TestCase {
           Writable[] params = new Writable[addresses.length];
           for (int j = 0; j < addresses.length; j++)
             params[j] = new LongWritable(RANDOM.nextLong());
-          Writable[] values = client.call(params, addresses);
+          Writable[] values = client.call(params, addresses, null, null);
           for (int j = 0; j < addresses.length; j++) {
             if (!params[j].equals(values[j])) {
               LOG.fatal("Call failed!");
@@ -216,7 +217,7 @@ public class TestIPC extends TestCase {
     InetSocketAddress address = new InetSocketAddress("127.0.0.1", 10);
     try {
       client.call(new LongWritable(RANDOM.nextLong()),
-              address);
+              address, null, null);
       fail("Expected an exception to have been thrown");
     } catch (IOException e) {
       String message = e.getMessage();
@@ -231,6 +232,41 @@ public class TestIPC extends TestCase {
     }
   }
 
+  private static class LongErrorWritable extends LongWritable {
+    private final static String ERR_MSG =
+      "Come across an exception while reading";
+
+    LongErrorWritable() {}
+
+    LongErrorWritable(long longValue) {
+      super(longValue);
+    }
+
+    public void readFields(DataInput in) throws IOException {
+      super.readFields(in);
+      throw new IOException(ERR_MSG);
+    }
+  }
+
+  public void testErrorClient() throws Exception {
+    // start server
+    Server server = new TestServer(1, false);
+    InetSocketAddress addr = NetUtils.getConnectAddress(server);
+    server.start();
+
+    // start client
+    Client client = new Client(LongErrorWritable.class, conf);
+    try {
+      client.call(new LongErrorWritable(RANDOM.nextLong()),
+          addr, null, null);
+      fail("Expected an exception to have been thrown");
+    } catch (IOException e) {
+      // check error
+      Throwable cause = e.getCause();
+      assertTrue(cause instanceof IOException);
+      assertEquals(LongErrorWritable.ERR_MSG, cause.getMessage());
+    }
+  }
 
   public static void main(String[] args) throws Exception {
 



Mime
View raw message