Make connect timeout configurable

This commit is contained in:
Shivaram Venkataraman 2013-05-31 23:32:18 -07:00
parent 91aca92249
commit 038cfc1a9a
2 changed files with 6 additions and 3 deletions

View file

@ -17,9 +17,11 @@ class FileClient {
private FileClientHandler handler = null;
private Channel channel = null;
private Bootstrap bootstrap = null;
private int connectTimeout = 60*1000; // 1 min
public FileClient(FileClientHandler handler) {
public FileClient(FileClientHandler handler, int connectTimeout) {
this.handler = handler;
this.connectTimeout = connectTimeout;
}
public void init() {
@ -28,7 +30,7 @@ class FileClient {
.channel(OioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 0) // Disable connect timeout
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout) // Disable connect timeout
.handler(new FileClientChannelInitializer(handler));
}

View file

@ -18,7 +18,8 @@ private[spark] class ShuffleCopier extends Logging {
resultCollectCallback: (String, Long, ByteBuf) => Unit) {
val handler = new ShuffleCopier.ShuffleClientHandler(resultCollectCallback)
val fc = new FileClient(handler)
val fc = new FileClient(handler,
System.getProperty("spark.shuffle.netty.connect.timeout", "60000").toInt)
try {
fc.init()
fc.connect(host, port)