Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 53286 invoked from network); 10 Jul 2009 06:18:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jul 2009 06:18:20 -0000 Received: (qmail 7960 invoked by uid 500); 10 Jul 2009 06:18:30 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 7881 invoked by uid 500); 10 Jul 2009 06:18:29 -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 7872 invoked by uid 99); 10 Jul 2009 06:18:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 06:18:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 10 Jul 2009 06:18:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B9E4B23888C5; Fri, 10 Jul 2009 06:17:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r792812 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/ipc/Client.java src/test/core/org/apache/hadoop/ipc/TestRPC.java Date: Fri, 10 Jul 2009 06:17:55 -0000 To: common-commits@hadoop.apache.org From: dhruba@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090710061755.B9E4B23888C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dhruba Date: Fri Jul 10 06:17:55 2009 New Revision: 792812 URL: http://svn.apache.org/viewvc?rev=792812&view=rev Log: HADOOP-6099. The RPC module can be configured to not send period pings. The default behaviour remains unchanged. (dhruba) Modified: hadoop/common/trunk/CHANGES.txt hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Client.java hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java Modified: hadoop/common/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=792812&r1=792811&r2=792812&view=diff ============================================================================== --- hadoop/common/trunk/CHANGES.txt (original) +++ hadoop/common/trunk/CHANGES.txt Fri Jul 10 06:17:55 2009 @@ -471,6 +471,9 @@ HADOOP-2366. Support trimmed strings in Configuration. (Michele Catasta via szetszwo) + HADOOP-6099. The RPC module can be configured to not send period pings. + The default behaviour of sending periodic pings remain unchanged. (dhruba) + OPTIMIZATIONS HADOOP-5595. NameNode does not need to run a replicator to choose a Modified: hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Client.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Client.java?rev=792812&r1=792811&r2=792812&view=diff ============================================================================== --- hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Client.java (original) +++ hadoop/common/trunk/src/java/org/apache/hadoop/ipc/Client.java Fri Jul 10 06:17:55 2009 @@ -73,6 +73,7 @@ final private int maxRetries; //the max. no. of retries for socket connections private boolean tcpNoDelay; // if T then disable Nagle's Algorithm private int pingInterval; // how often sends ping to the server in msecs + final private boolean doPing; //do we need to send ping message private SocketFactory socketFactory; // how to create sockets private int refCount = 1; @@ -101,6 +102,22 @@ final static int getPingInterval(Configuration conf) { return conf.getInt(PING_INTERVAL_NAME, DEFAULT_PING_INTERVAL); } + + /** + * The time after which a RPC will timeout. + * If ping is not enabled (via ipc.client.ping), then the timeout value is the + * same as the pingInterval. + * If ping is enabled, then there is no timeout value. + * + * @param conf Configuration + * @return the timeout period in milliseconds. -1 if no timeout value is set + */ + final public static int getTimeout(Configuration conf) { + if (!conf.getBoolean("ipc.client.ping", true)) { + return getPingInterval(conf); + } + return -1; + } /** * Increment this client's reference count @@ -317,8 +334,13 @@ handleConnectionFailure(ioFailures++, maxRetries, ie); } } - this.in = new DataInputStream(new BufferedInputStream + if (doPing) { + this.in = new DataInputStream(new BufferedInputStream (new PingInputStream(NetUtils.getInputStream(socket)))); + } else { + this.in = new DataInputStream(new BufferedInputStream + (NetUtils.getInputStream(socket))); + } this.out = new DataOutputStream (new BufferedOutputStream(NetUtils.getOutputStream(socket))); writeHeader(); @@ -634,6 +656,7 @@ conf.getInt("ipc.client.connection.maxidletime", 10000); //10s this.maxRetries = conf.getInt("ipc.client.connect.max.retries", 10); this.tcpNoDelay = conf.getBoolean("ipc.client.tcpnodelay", false); + this.doPing = conf.getBoolean("ipc.client.ping", true); this.pingInterval = getPingInterval(conf); if (LOG.isDebugEnabled()) { LOG.debug("The ping interval is" + this.pingInterval + "ms."); Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java?rev=792812&r1=792811&r2=792812&view=diff ============================================================================== --- hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java (original) +++ hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestRPC.java Fri Jul 10 06:17:55 2009 @@ -231,7 +231,7 @@ } - public void testCalls() throws Exception { + public void testCalls(Configuration conf) throws Exception { Server server = RPC.getServer(new TestImpl(), ADDRESS, 0, conf); TestProtocol proxy = null; try { @@ -382,10 +382,20 @@ conf.set(ACL_CONFIG, "invalid invalid"); doRPCs(conf, true); } + + /** + * Switch off setting socketTimeout values on RPC sockets. + * Verify that RPC calls still work ok. + */ + public void testNoPings() throws Exception { + Configuration conf = new Configuration(); + conf.setBoolean("ipc.client.ping", false); + new TestRPC("testnoPings").testCalls(conf); + } public static void main(String[] args) throws Exception { - new TestRPC("test").testCalls(); + new TestRPC("test").testCalls(conf); } }