You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tillrohrmann <gi...@git.apache.org> on 2017/07/31 18:14:18 UTC

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

GitHub user tillrohrmann opened a pull request:

    https://github.com/apache/flink/pull/4440

    [FLINK-7326] [futures] Replace Flink's future with Java 8's CompletableFuture in RegisteredRpcConnection

    ## What is the purpose of the change
    
    Replace Flink's future with Java 8's CompletableFuture in RegisteredRpcConnection.
    
    This PR is based on #4429.
    
    ## Verifying this change
    
    This change is a trivial rework / code cleanup without any test coverage.
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): (no)
      - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
      - The serializers: (no)
      - The runtime per-record code paths (performance sensitive): (no)
      - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
    
    ## Documentation
    
      - Does this pull request introduce a new feature? (no)
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tillrohrmann/flink rfRegisteredRpcConnection

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4440.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4440
    
----
commit afe1d171132bb3724e672a1c4ce74a3f7c185908
Author: Till Rohrmann <tr...@apache.org>
Date:   2017-07-31T13:07:18Z

    [FLINK-7313] [futures] Add Flink future and Scala future to Java 8 CompletableFuture conversion
    
    Add DirectExecutionContext
    
    Add Scala Future to Java 8 CompletableFuture utility to FutureUtils
    
    Add Flink future to Java 8's CompletableFuture conversion utility to FutureUtils
    
    Add base class for Flink's unchecked future exceptions

commit f20a4a083e545cb36d5ee11ccdff2f86244464f1
Author: Till Rohrmann <tr...@apache.org>
Date:   2017-07-31T18:11:30Z

    [FLINK-7326] [futures] Replace Flink's future with Java 8's CompletableFuture in RegisteredRpcConnection

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4440: [FLINK-7326] [futures] Replace Flink's future with Java 8...

Posted by tillrohrmann <gi...@git.apache.org>.
Github user tillrohrmann commented on the issue:

    https://github.com/apache/flink/pull/4440
  
    Thanks for your review @zentol. Addressed your comment and merging this PR now.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/4440


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4440#discussion_r130429770
  
    --- 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
    --- End diff --
    
    We could keep this comment, or is it no longer valid?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

Posted by tillrohrmann <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4440#discussion_r130429986
  
    --- 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'm wondering whether we should revert the condition so that the "successful" path comes first.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4440: [FLINK-7326] [futures] Replace Flink's future with...

Posted by tillrohrmann <gi...@git.apache.org>.
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4440#discussion_r130588394
  
    --- 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
    --- End diff --
    
    True. I will re-add it.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---