fencingTokenSupplier,
+ boolean captureAskCallStacks) {
+ super(address, hostname, rpcEndpoint, timeout, maximumFramesize, terminationFuture, captureAskCallStacks);
this.fencingTokenSupplier = Preconditions.checkNotNull(fencingTokenSupplier);
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java
index 486816de8e80d..db7a2042c80b9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java
@@ -29,8 +29,8 @@
/**
* Remote rpc invocation message which is used when the actor communication is remote and, thus, the
* message has to be serialized.
- *
- * In order to fail fast and report an appropriate error message to the user, the method name, the
+ *
+ *
In order to fail fast and report an appropriate error message to the user, the method name, the
* parameter types and the arguments are eagerly serialized. In case the invocation call
* contains a non-serializable object, then an {@link IOException} is thrown.
*/
@@ -138,7 +138,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
// -------------------------------------------------------------------
/**
- * Wrapper class for the method invocation information
+ * Wrapper class for the method invocation information.
*/
private static final class MethodInvocation implements Serializable {
private static final long serialVersionUID = 9187962608946082519L;
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
index 553b07ce924ed..3a1632cac27e4 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
@@ -51,7 +51,6 @@
import org.apache.flink.util.FlinkException;
import org.apache.flink.util.TestLogger;
-import akka.pattern.AskTimeoutException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -63,9 +62,11 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
@@ -249,7 +250,9 @@ public void testDelayedRegisterTaskExecutor() throws Exception {
firstFuture.get();
fail("Should have failed because connection to taskmanager is delayed beyond timeout");
} catch (Exception e) {
- assertThat(ExceptionUtils.stripExecutionException(e), instanceOf(AskTimeoutException.class));
+ final Throwable cause = ExceptionUtils.stripExecutionException(e);
+ assertThat(cause, instanceOf(TimeoutException.class));
+ assertThat(cause.getMessage(), containsString("ResourceManagerGateway.registerTaskExecutor"));
}
startConnection.await();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/TimeoutCallStackTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/TimeoutCallStackTest.java
new file mode 100644
index 0000000000000..445702608a33c
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/TimeoutCallStackTest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rpc.akka;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.rpc.RpcEndpoint;
+import org.apache.flink.runtime.rpc.RpcGateway;
+import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcTimeout;
+import org.apache.flink.util.IOUtils;
+
+import akka.actor.ActorSystem;
+import akka.actor.Terminated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests that ask timeouts report the call stack of the calling function.
+ */
+public class TimeoutCallStackTest {
+
+ private static ActorSystem actorSystem;
+ private static RpcService rpcService;
+
+ private final List endpointsToStop = new ArrayList<>();
+
+ @BeforeClass
+ public static void setup() {
+ actorSystem = AkkaUtils.createDefaultActorSystem();
+ rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
+ }
+
+ @AfterClass
+ public static void teardown() throws Exception {
+
+ final CompletableFuture rpcTerminationFuture = rpcService.stopService();
+ final CompletableFuture actorSystemTerminationFuture = FutureUtils.toJava(actorSystem.terminate());
+
+ FutureUtils
+ .waitForAll(Arrays.asList(rpcTerminationFuture, actorSystemTerminationFuture))
+ .get(10_000, TimeUnit.MILLISECONDS);
+ }
+
+ @After
+ public void stopTestEndpoints() {
+ endpointsToStop.forEach(IOUtils::closeQuietly);
+ }
+
+ @Test
+ public void testTimeoutException() throws Exception {
+ final TestingGateway gateway = createTestingGateway();
+
+ final CompletableFuture future = gateway.callThatTimesOut(Time.milliseconds(1));
+
+ Throwable failureCause = null;
+ try {
+ future.get();
+ fail("test buggy: the call should never have completed");
+ } catch (ExecutionException e) {
+ failureCause = e.getCause();
+ }
+
+ assertThat(failureCause, instanceOf(TimeoutException.class));
+ assertThat(failureCause.getMessage(), containsString("callThatTimesOut"));
+ assertThat(failureCause.getStackTrace()[0].getMethodName(), equalTo("testTimeoutException"));
+ }
+
+ // ------------------------------------------------------------------------
+ // setup helpers
+ // ------------------------------------------------------------------------
+
+ private TestingGateway createTestingGateway() throws Exception {
+ final TestingRpcEndpoint endpoint = new TestingRpcEndpoint(rpcService, "test_name");
+ endpointsToStop.add(endpoint);
+ endpoint.start();
+
+ return rpcService.connect(endpoint.getAddress(), TestingGateway.class).get();
+ }
+
+ // ------------------------------------------------------------------------
+ // testing mocks / stubs
+ // ------------------------------------------------------------------------
+
+ private interface TestingGateway extends RpcGateway {
+
+ CompletableFuture callThatTimesOut(@RpcTimeout Time timeout);
+ }
+
+ private static final class TestingRpcEndpoint extends RpcEndpoint implements TestingGateway {
+
+ TestingRpcEndpoint(RpcService rpcService, String endpointId) {
+ super(rpcService, endpointId);
+ }
+
+ @Override
+ public CompletableFuture callThatTimesOut(@RpcTimeout Time timeout) {
+ // return a future that never completes, so the call is guaranteed to time out
+ return new CompletableFuture<>();
+ }
+ }
+}