HADOOP-9106. Allow configuration of IPC connect timeout. Contributed by Rober Parker.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1433747 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40a0ed4507
commit
06f086dd23
|
@ -439,6 +439,9 @@ Release 2.0.3-alpha - Unreleased
|
||||||
HADOOP-8712. Change default hadoop.security.group.mapping to
|
HADOOP-8712. Change default hadoop.security.group.mapping to
|
||||||
JniBasedUnixGroupsNetgroupMappingWithFallback (Robert Parker via todd)
|
JniBasedUnixGroupsNetgroupMappingWithFallback (Robert Parker via todd)
|
||||||
|
|
||||||
|
HADOOP-9106. Allow configuration of IPC connect timeout.
|
||||||
|
(Rober Parker via suresh)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-8866. SampleQuantiles#query is O(N^2) instead of O(N). (Andrew Wang
|
HADOOP-8866. SampleQuantiles#query is O(N^2) instead of O(N). (Andrew Wang
|
||||||
|
|
|
@ -173,6 +173,11 @@ public class CommonConfigurationKeysPublic {
|
||||||
/** Default value for IPC_CLIENT_CONNECTION_MAXIDLETIME_KEY */
|
/** Default value for IPC_CLIENT_CONNECTION_MAXIDLETIME_KEY */
|
||||||
public static final int IPC_CLIENT_CONNECTION_MAXIDLETIME_DEFAULT = 10000; // 10s
|
public static final int IPC_CLIENT_CONNECTION_MAXIDLETIME_DEFAULT = 10000; // 10s
|
||||||
/** See <a href="{@docRoot}/../core-default.html">core-default.xml</a> */
|
/** See <a href="{@docRoot}/../core-default.html">core-default.xml</a> */
|
||||||
|
public static final String IPC_CLIENT_CONNECT_TIMEOUT_KEY =
|
||||||
|
"ipc.client.connect.timeout";
|
||||||
|
/** Default value for IPC_CLIENT_CONNECT_TIMEOUT_KEY */
|
||||||
|
public static final int IPC_CLIENT_CONNECT_TIMEOUT_DEFAULT = 20000; // 20s
|
||||||
|
/** See <a href="{@docRoot}/../core-default.html">core-default.xml</a> */
|
||||||
public static final String IPC_CLIENT_CONNECT_MAX_RETRIES_KEY =
|
public static final String IPC_CLIENT_CONNECT_MAX_RETRIES_KEY =
|
||||||
"ipc.client.connect.max.retries";
|
"ipc.client.connect.max.retries";
|
||||||
/** Default value for IPC_CLIENT_CONNECT_MAX_RETRIES_KEY */
|
/** Default value for IPC_CLIENT_CONNECT_MAX_RETRIES_KEY */
|
||||||
|
|
|
@ -106,6 +106,8 @@ public class Client {
|
||||||
|
|
||||||
private SocketFactory socketFactory; // how to create sockets
|
private SocketFactory socketFactory; // how to create sockets
|
||||||
private int refCount = 1;
|
private int refCount = 1;
|
||||||
|
|
||||||
|
private final int connectionTimeout;
|
||||||
|
|
||||||
final static int PING_CALL_ID = -1;
|
final static int PING_CALL_ID = -1;
|
||||||
|
|
||||||
|
@ -159,7 +161,16 @@ public class Client {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* set the connection timeout value in configuration
|
||||||
|
*
|
||||||
|
* @param conf Configuration
|
||||||
|
* @param timeout the socket connect timeout value
|
||||||
|
*/
|
||||||
|
public static final void setConnectTimeout(Configuration conf, int timeout) {
|
||||||
|
conf.setInt(CommonConfigurationKeys.IPC_CLIENT_CONNECT_TIMEOUT_KEY, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment this client's reference count
|
* Increment this client's reference count
|
||||||
*
|
*
|
||||||
|
@ -494,8 +505,7 @@ public class Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection time out is 20s
|
NetUtils.connect(this.socket, server, connectionTimeout);
|
||||||
NetUtils.connect(this.socket, server, 20000);
|
|
||||||
if (rpcTimeout > 0) {
|
if (rpcTimeout > 0) {
|
||||||
pingInterval = rpcTimeout; // rpcTimeout overwrites pingInterval
|
pingInterval = rpcTimeout; // rpcTimeout overwrites pingInterval
|
||||||
}
|
}
|
||||||
|
@ -1034,6 +1044,8 @@ public class Client {
|
||||||
this.valueClass = valueClass;
|
this.valueClass = valueClass;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
this.socketFactory = factory;
|
this.socketFactory = factory;
|
||||||
|
this.connectionTimeout = conf.getInt(CommonConfigurationKeys.IPC_CLIENT_CONNECT_TIMEOUT_KEY,
|
||||||
|
CommonConfigurationKeys.IPC_CLIENT_CONNECT_TIMEOUT_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -573,6 +573,14 @@
|
||||||
</description>
|
</description>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<property>
|
||||||
|
<name>ipc.client.connect.timeout</name>
|
||||||
|
<value>20000</value>
|
||||||
|
<description>Indicates the number of milliseconds a client will wait for the
|
||||||
|
socket to establish a server connection.
|
||||||
|
</description>
|
||||||
|
</property>
|
||||||
|
|
||||||
<property>
|
<property>
|
||||||
<name>ipc.client.connect.max.retries.on.timeouts</name>
|
<name>ipc.client.connect.max.retries.on.timeouts</name>
|
||||||
<value>45</value>
|
<value>45</value>
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class TestIPC {
|
||||||
final private static Configuration conf = new Configuration();
|
final private static Configuration conf = new Configuration();
|
||||||
final static private int PING_INTERVAL = 1000;
|
final static private int PING_INTERVAL = 1000;
|
||||||
final static private int MIN_SLEEP_TIME = 1000;
|
final static private int MIN_SLEEP_TIME = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag used to turn off the fault injection behavior
|
* Flag used to turn off the fault injection behavior
|
||||||
* of the various writables.
|
* of the various writables.
|
||||||
|
@ -499,6 +498,26 @@ public class TestIPC {
|
||||||
client.call(new LongWritable(RANDOM.nextLong()),
|
client.call(new LongWritable(RANDOM.nextLong()),
|
||||||
addr, null, null, 3*PING_INTERVAL+MIN_SLEEP_TIME, conf);
|
addr, null, null, 3*PING_INTERVAL+MIN_SLEEP_TIME, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIpcConnectTimeout() throws Exception {
|
||||||
|
// start server
|
||||||
|
Server server = new TestServer(1, true);
|
||||||
|
InetSocketAddress addr = NetUtils.getConnectAddress(server);
|
||||||
|
//Intentionally do not start server to get a connection timeout
|
||||||
|
|
||||||
|
// start client
|
||||||
|
Client.setConnectTimeout(conf, 100);
|
||||||
|
Client client = new Client(LongWritable.class, conf);
|
||||||
|
// set the rpc timeout to twice the MIN_SLEEP_TIME
|
||||||
|
try {
|
||||||
|
client.call(new LongWritable(RANDOM.nextLong()),
|
||||||
|
addr, null, null, MIN_SLEEP_TIME*2, conf);
|
||||||
|
fail("Expected an exception to have been thrown");
|
||||||
|
} catch (SocketTimeoutException e) {
|
||||||
|
LOG.info("Get a SocketTimeoutException ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that file descriptors aren't leaked by starting
|
* Check that file descriptors aren't leaked by starting
|
||||||
|
|
Loading…
Reference in New Issue