diff --git a/spark-client/src/main/java/org/apache/hive/spark/client/RemoteDriver.java b/spark-client/src/main/java/org/apache/hive/spark/client/RemoteDriver.java index ede8ce9..8aa2d30 100644 --- a/spark-client/src/main/java/org/apache/hive/spark/client/RemoteDriver.java +++ b/spark-client/src/main/java/org/apache/hive/spark/client/RemoteDriver.java @@ -35,6 +35,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.io.FileUtils; @@ -140,9 +141,19 @@ private RemoteDriver(String[] args) throws Exception { .build()); this.protocol = new DriverProtocol(); - // The RPC library takes care of timing out this. - this.clientRpc = Rpc.createClient(mapConf, egroup, serverAddress, serverPort, - clientId, secret, protocol).get(); + try { + // The RPC library takes care of timing out this. + this.clientRpc = Rpc.createClient(mapConf, egroup, serverAddress, serverPort, + clientId, secret, protocol).get(); + } catch (Throwable e) { + if (e.getCause() instanceof TimeoutException) { + LOG.error("Timed out when handshaking RPC server.\nPossible reasons include network " + + "issues, resource issues at RPC server side (HS2) etc.", e); + } else { + LOG.error("Error while connecting to RPC server.", e); + } + throw e; + } this.running = true; this.clientRpc.addListener(new Rpc.Listener() { diff --git a/spark-client/src/main/java/org/apache/hive/spark/client/rpc/Rpc.java b/spark-client/src/main/java/org/apache/hive/spark/client/rpc/Rpc.java index 0489684..b2f133b 100644 --- a/spark-client/src/main/java/org/apache/hive/spark/client/rpc/Rpc.java +++ b/spark-client/src/main/java/org/apache/hive/spark/client/rpc/Rpc.java @@ -120,7 +120,7 @@ public void run() { } }; final ScheduledFuture timeoutFuture = eloop.schedule(timeoutTask, - connectTimeoutMs, TimeUnit.MILLISECONDS); + rpcConf.getServerConnectTimeoutMs(), TimeUnit.MILLISECONDS); // The channel listener instantiates the Rpc instance when the connection is established, // and initiates the SASL handshake.