From 9e75c67999243204cdea7e214ee910aa43aa57d7 Mon Sep 17 00:00:00 2001 From: Atanu Ghosh Date: Fri, 8 May 2020 14:49:19 -0700 Subject: [PATCH] Add connection timed out to list of connection failures for uncaught exception handler --- .../java/org/apache/giraph/graph/GraphTaskManager.java | 10 +++++++--- .../org/apache/giraph/worker/BspServiceWorker.java | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/giraph-core/src/main/java/org/apache/giraph/graph/GraphTaskManager.java b/giraph-core/src/main/java/org/apache/giraph/graph/GraphTaskManager.java index 6db19344c..0c5528dff 100644 --- a/giraph-core/src/main/java/org/apache/giraph/graph/GraphTaskManager.java +++ b/giraph-core/src/main/java/org/apache/giraph/graph/GraphTaskManager.java @@ -1193,8 +1193,12 @@ public boolean checkIfWorkerShouldFail(Thread thread, Throwable exception) { * @return True if the throwable is a "connection reset by peer", * false otherwise. */ - public static boolean isConnectionResetByPeer(Throwable throwable) { - return throwable.getMessage().startsWith( - "Connection reset by peer") ? true : false; + public static boolean isConnectionFailure(Throwable throwable) { + String throwableMessage = throwable.getMessage().toLowerCase(); + if (throwableMessage.startsWith("connection reset by peer") || + throwableMessage.startsWith("connection timed out")) { + return true; + } + return false; } } diff --git a/giraph-core/src/main/java/org/apache/giraph/worker/BspServiceWorker.java b/giraph-core/src/main/java/org/apache/giraph/worker/BspServiceWorker.java index a745b1e9f..9a8f59258 100644 --- a/giraph-core/src/main/java/org/apache/giraph/worker/BspServiceWorker.java +++ b/giraph-core/src/main/java/org/apache/giraph/worker/BspServiceWorker.java @@ -121,7 +121,7 @@ import com.google.common.collect.Lists; -import static org.apache.giraph.graph.GraphTaskManager.isConnectionResetByPeer; +import static org.apache.giraph.graph.GraphTaskManager.isConnectionFailure; /** * ZooKeeper-based implementation of {@link CentralizedServiceWorker}. @@ -224,7 +224,7 @@ public BspServiceWorker( // If the connection was closed by the client, then we just log // the error, we do not fail the job, since the client will // attempt to reconnect. - return !isConnectionResetByPeer(throwable); + return !isConnectionFailure(throwable); } ) );