svn commit: r1454593 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: ./ dev-support/ src/main/java/org/apache/hadoop/ipc/ src/main/proto/

2013-03-08 Thread sradia
Author: sradia
Date: Fri Mar  8 21:47:57 2013
New Revision: 1454593

URL: http://svn.apache.org/r1454593
Log:
HADOOP-9151 Include RPC error info in RpcResponseHeader instead of sending it 
separately (sanjay Radia)

Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt

hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml

hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java

hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/proto/RpcHeader.proto

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1454593&r1=1454592&r2=1454593&view=diff
==
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt 
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Fri Mar 
 8 21:47:57 2013
@@ -8,6 +8,12 @@ Trunk (Unreleased)
 FSDataOutputStream.sync() and Syncable.sync().  (szetszwo)
 
 HADOOP-8886. Remove KFS support. (eli)
+
+HADOOP-9163 The rpc msg in ProtobufRpcEngine.proto should be moved out to
+avoid an extra copy (Sanjay Radia)
+
+HADOOP-9151 Include RPC error info in RpcResponseHeader instead of sending
+it separately (sanjay Radia)
 
   NEW FEATURES
 
@@ -157,8 +163,6 @@ Trunk (Unreleased)
 HADOOP-9112. test-patch should -1 for @Tests without a timeout 
 (Surenkumar Nihalani via bobby)
 
-HADOOP-9163 The rpc msg in ProtobufRpcEngine.proto should be moved out to
-avoid an extra copy (Sanjay Radia)
 
   BUG FIXES
 

Modified: 
hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml
URL: 
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml?rev=1454593&r1=1454592&r2=1454593&view=diff
==
--- 
hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml
 (original)
+++ 
hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml
 Fri Mar  8 21:47:57 2013
@@ -308,4 +308,11 @@


  
+ 
+ 
+ 
+   
+   
+   
+ 
  

Modified: 
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java?rev=1454593&r1=1454592&r2=1454593&view=diff
==
--- 
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java
 (original)
+++ 
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java
 Fri Mar  8 21:47:57 2013
@@ -59,7 +59,6 @@ import org.apache.hadoop.fs.CommonConfig
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableUtils;
 import org.apache.hadoop.io.retry.RetryPolicies;
 import org.apache.hadoop.io.retry.RetryPolicy;
 import org.apache.hadoop.io.retry.RetryPolicy.RetryAction;
@@ -945,31 +944,38 @@ public class Client {
   touch();
   
   try {
-RpcResponseHeaderProto response = 
+RpcResponseHeaderProto header = 
 RpcResponseHeaderProto.parseDelimitedFrom(in);
-if (response == null) {
+if (header == null) {
   throw new IOException("Response is null.");
 }
 
-int callId = response.getCallId();
+int callId = header.getCallId();
 if (LOG.isDebugEnabled())
   LOG.debug(getName() + " got value #" + callId);
 
 Call call = calls.get(callId);
-RpcStatusProto status = response.getStatus();
+RpcStatusProto status = header.getStatus();
 if (status == RpcStatusProto.SUCCESS) {
   Writable value = ReflectionUtils.newInstance(valueClass, conf);
   value.readFields(in); // read value
   call.setRpcResponse(value);
   calls.remove(callId);
-} else if (status == RpcStatusProto.ERROR) {
-  call.setException(new RemoteException(WritableUtils.readString(in),
-WritableUtils.readString(in)));
-  calls.remove(callId);
-} else if (status == RpcStatusProto.FATAL) {
-  // Close the connection
-  markClosed(new RemoteException(WritableUtils.readString(in), 
- Writa

svn commit: r1454534 - in /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/ipc/Server.java src/test/java/org/apache/hadoop/ipc/TestS

2013-03-08 Thread kihwal
Author: kihwal
Date: Fri Mar  8 20:36:24 2013
New Revision: 1454534

URL: http://svn.apache.org/r1454534
Log:
svn merge -c 1375790 Merging from trunk to branch-0.23 to fix HADOOP-8711.

Modified:

hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt

hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestServer.java

Modified: 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1454534&r1=1454533&r2=1454534&view=diff
==
--- 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
 (original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
 Fri Mar  8 20:36:24 2013
@@ -36,6 +36,10 @@ Release 0.23.7 - UNRELEASED
 HADOOP-7358. Improve log levels when exceptions caught in RPC handler
 (Todd Lipcon via shv)
 
+HADOOP-8711. IPC Server supports adding exceptions for which
+the message is printed and the stack trace is not printed to avoid chatter.
+(Brandon Li via Suresh)
+
   OPTIMIZATIONS
 
 HADOOP-9147. Add missing fields to FIleStatus.toString.

Modified: 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java?rev=1454534&r1=1454533&r2=1454534&view=diff
==
--- 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
 (original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
 Fri Mar  8 20:36:24 2013
@@ -43,11 +43,13 @@ import java.nio.channels.WritableByteCha
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -98,6 +100,42 @@ import org.apache.hadoop.util.StringUtil
 public abstract class Server {
   private final boolean authorize;
   private boolean isSecurityEnabled;
+  private ExceptionsHandler exceptionsHandler = new ExceptionsHandler();
+  
+  public void addTerseExceptions(Class... exceptionClass) {
+exceptionsHandler.addTerseExceptions(exceptionClass);
+  }
+
+  /**
+   * ExceptionsHandler manages Exception groups for special handling
+   * e.g., terse exception group for concise logging messages
+   */
+  static class ExceptionsHandler {
+private volatile Set terseExceptions = new HashSet();
+
+/**
+ * Add exception class so server won't log its stack trace.
+ * Modifying the terseException through this method is thread safe.
+ *
+ * @param exceptionClass exception classes 
+ */
+void addTerseExceptions(Class... exceptionClass) {
+
+  // Make a copy of terseException for performing modification
+  final HashSet newSet = new HashSet(terseExceptions);
+
+  // Add all class names into the HashSet
+  for (Class name : exceptionClass) {
+newSet.add(name.toString());
+  }
+  // Replace terseException set
+  terseExceptions = Collections.unmodifiableSet(newSet);
+}
+
+boolean isTerse(Class t) {
+  return terseExceptions.contains(t.toString());
+}
+  }
   
   /**
* The first four bytes of Hadoop RPC connections
@@ -1544,6 +1582,10 @@ public abstract class Server {
   // on the server side, as opposed to just a normal exceptional
   // result.
   LOG.warn(logMsg, e);
+} else if (exceptionsHandler.isTerse(e.getClass())) {
+ // Don't log the whole stack trace of these exceptions.
+  // Way too noisy!
+  LOG.info(logMsg);
 } else {
   LOG.info(logMsg, e);
 }

Modified: 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestServer.java?rev=1454534&r1=1454533&r2=1454534&view=diff
==
--- 
ha

svn commit: r1454530 - in /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/ipc/Server.java

2013-03-08 Thread kihwal
Author: kihwal
Date: Fri Mar  8 20:18:47 2013
New Revision: 1454530

URL: http://svn.apache.org/r1454530
Log:
svn merge -c 1205697 Merging from trunk to branch-0.23 to fix HADOOP-7358.

Modified:

hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt

hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

Modified: 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1454530&r1=1454529&r2=1454530&view=diff
==
--- 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
 (original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
 Fri Mar  8 20:18:47 2013
@@ -33,6 +33,9 @@ Release 0.23.7 - UNRELEASED
 
 HADOOP-9374. Add tokens from -tokenCacheFile into UGI (daryn)
 
+HADOOP-7358. Improve log levels when exceptions caught in RPC handler
+(Todd Lipcon via shv)
+
   OPTIMIZATIONS
 
 HADOOP-9147. Add missing fields to FIleStatus.toString.

Modified: 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java?rev=1454530&r1=1454529&r2=1454530&view=diff
==
--- 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
 (original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
 Fri Mar  8 20:18:47 2013
@@ -1538,7 +1538,16 @@ public abstract class Server {
   );
 }
   } catch (Throwable e) {
-LOG.info(getName() + ", call: " + call + ", error: ", e);
+String logMsg = getName() + ", call " + call + ": error: " + e;
+if (e instanceof RuntimeException || e instanceof Error) {
+  // These exception types indicate something is probably wrong
+  // on the server side, as opposed to just a normal exceptional
+  // result.
+  LOG.warn(logMsg, e);
+} else {
+  LOG.info(logMsg, e);
+}
+
 errorClass = e.getClass().getName();
 error = StringUtils.stringifyException(e);
 // Remove redundant error class name from the beginning of the 
stack trace