Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/4440#discussion_r130587841
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/registration/RegisteredRpcConnection.java
---
@@ -88,24 +86,17 @@ public void start() {
pendingRegistration = checkNotNull(generateRegistration());
pendingRegistration.startRegistration();
- Future<Tuple2<Gateway, Success>> future =
pendingRegistration.getFuture();
-
- Future<Void> registrationSuccessFuture =
future.thenAcceptAsync(new AcceptFunction<Tuple2<Gateway, Success>>() {
- @Override
- public void accept(Tuple2<Gateway, Success> result) {
- targetGateway = result.f0;
- onRegistrationSuccess(result.f1);
- }
- }, executor);
-
- // this future should only ever fail if there is a bug, not if
the registration is declined
- registrationSuccessFuture.exceptionallyAsync(new
ApplyFunction<Throwable, Void>() {
- @Override
- public Void apply(Throwable failure) {
- onRegistrationFailure(failure);
- return null;
- }
- }, executor);
+ CompletableFuture<Tuple2<Gateway, Success>> future =
pendingRegistration.getFuture();
+
+ future.whenCompleteAsync(
+ (Tuple2<Gateway, Success> result, Throwable failure) ->
{
+ if (failure != null) {
--- End diff --
I somehow like the failure case treating being first. It something like a
termination condition for recursion, you also start with it instead of the
recursion step.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---