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 dh...@apache.org on 2009/07/10 08:17:55 UTC
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
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);
}
}