Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C09BEDCC0 for ; Fri, 8 Mar 2013 20:36:45 +0000 (UTC) Received: (qmail 85633 invoked by uid 500); 8 Mar 2013 20:36:45 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 85577 invoked by uid 500); 8 Mar 2013 20:36:45 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 85568 invoked by uid 99); 8 Mar 2013 20:36:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 20:36:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 20:36:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BAB852388A33; Fri, 8 Mar 2013 20:36:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/TestServer.java Date: Fri, 08 Mar 2013 20:36:24 -0000 To: common-commits@hadoop.apache.org From: kihwal@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130308203624.BAB852388A33@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestServer.java (original) +++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestServer.java Fri Mar 8 20:36:24 2013 @@ -20,6 +20,7 @@ package org.apache.hadoop.ipc; import static org.junit.Assert.*; +import java.io.IOException; import java.net.BindException; import java.net.InetSocketAddress; import java.net.ServerSocket; @@ -115,4 +116,15 @@ public class TestServer { socket.close(); } } + + @Test + public void testExceptionsHandler() throws IOException { + Server.ExceptionsHandler handler = new Server.ExceptionsHandler(); + handler.addTerseExceptions(IOException.class); + handler.addTerseExceptions(RpcServerException.class); + + assertTrue(handler.isTerse(IOException.class)); + assertTrue(handler.isTerse(RpcServerException.class)); + assertFalse(handler.isTerse(RpcClientException.class)); + } }