zentol commented on a change in pull request #7723: [FLINK-10569] Remove
Instance usage in ExecutionVertexCancelTest
URL: https://github.com/apache/flink/pull/7723#discussion_r258405621
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
##########
@@ -399,33 +379,26 @@ public void testActionsWhileCancelling() {
}
}
- public static class CancelSequenceActorGateway extends
BaseTestingActorGateway {
+ public static class CancelSequenceSimpleAckingTaskManagerGateway
extends SimpleAckingTaskManagerGateway {
private final int successfulOperations;
private int index = -1;
- public CancelSequenceActorGateway(ExecutionContext
executionContext, int successfulOperations) {
- super(executionContext);
+ public CancelSequenceSimpleAckingTaskManagerGateway(int
successfulOperations) {
+ super();
this.successfulOperations = successfulOperations;
}
@Override
- public Object handleMessage(Object message) throws Exception {
- Object result;
- if(message instanceof SubmitTask) {
- result = Acknowledge.get();
- } else if(message instanceof CancelTask) {
- index++;
-
- if(index >= successfulOperations){
- throw new IOException("RPC call
failed.");
- } else {
- result = Acknowledge.get();
- }
+ public CompletableFuture<Acknowledge>
cancelTask(ExecutionAttemptID executionAttemptID, Time timeout) {
+ index++;
+
+ if (index >= successfulOperations) {
+ CompletableFuture<Acknowledge> result = new
CompletableFuture<>();
+ result.completeExceptionally(new
IOException("Rpc call fails"));
Review comment:
you can use `FutureUtils#completedExceptionally` for this
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services