{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/79623763","id":79623763,"diff_hunk":"@@ -0,0 +1,156 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.flink.runtime.concurrent;\n+\n+import java.util.concurrent.CancellationException;\n+import java.util.concurrent.ExecutionException;\n+import java.util.concurrent.Executor;\n+import java.util.concurrent.TimeUnit;\n+import java.util.concurrent.TimeoutException;\n+\n+/**\n+ * Flink's basic future abstraction. A future represents an asynchronous operation whose result\n+ * will be contained in this instance upon completion.\n+ *\n+ * @param <T> type of the future's result\n+ */\n+public interface Future<T> {\n+\n+\t/**\n+\t * Checks if the future has been completed. A future is completed, if the result has been\n+\t * delivered.\n+\t *\n+\t * @return true if the future is completed; otherwise false\n+\t */\n+\tboolean isDone();\n+\n+\t/**\n+\t * Tries to cancel the future's operation. Note that not all future operations can be canceled.\n+\t * The result of the cancelling will be returned.\n+\t *\n+\t * @param mayInterruptIfRunning true iff the future operation may be interrupted\n+\t * @return true if the cancelling was successful; otherwise false\n+\t */\n+\tboolean cancel(boolean mayInterruptIfRunning);\n+\n+\t/**\n+\t * Gets the result value of the future. If the future has not been completed, then this\n+\t * operation will block indefinitely until the result has been delivered.\n+\t *\n+\t * @return the result value\n+\t * @throws CancellationException if the future has been cancelled\n+\t * @throws InterruptedException if the current thread was interrupted while waiting for the result\n+\t * @throws ExecutionException if the future has been completed with an exception\n+\t */\n+\tT get() throws InterruptedException, ExecutionException;\n+\n+\t/**\n+\t * Gets the result value of the future. If the future has not been done, then this operation\n+\t * will block the given timeout value. If the result has not been delivered within the timeout,\n+\t * then the method throws an {@link TimeoutException}.\n+\t *\n+\t * @param timeout the time to wait for the future to be done\n+\t * @param unit time unit for the timeout argument\n+\t * @return the result value\n+\t * @throws CancellationException if the future has been cancelled\n+\t * @throws InterruptedException if the current thread was interrupted while waiting for the result\n+\t * @throws ExecutionException if the future has been completed with an exception\n+\t * @throws TimeoutException if the future has not been completed within the given timeout\n+\t */\n+\tT get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;\n+\n+\t/**\n+\t * Gets the value of the future. If the future has not been completed when calling this\n+\t * function, the given value is returned.\n+\t *\n+\t * @param valueIfAbsent value which is returned if the future has not been completed\n+\t * @return value of the future or the given value if the future has not been completed\n+\t * @throws ExecutionException if the future has been completed with an exception\n+\t */\n+\tT getNow(T valueIfAbsent) throws ExecutionException;\n+\n+\t/**\n+\t * Applies the given function to the value of the future. The result of the apply function is\n+\t * the value of the newly returned future.\n+\t * <p>\n+\t * The apply function is executed asynchronously by the given executor.\n+\t *\n+\t * @param applyFunction function to apply to the future's value\n+\t * @param executor used to execute the given apply function asynchronously\n+\t * @param <R> type of the apply function's return value\n+\t * @return future representing the return value of the given apply function\n+\t */\n+\t<R> Future<R> thenApplyAsync(ApplyFunction<? super T, ? extends R> applyFunction, Executor executor);\n+\n+\t/**\n+\t * Applies the accept function to the value of the future. Unlike the {@link ApplyFunction}, the\n+\t * {@link AcceptFunction} does not return a value. The returned future, thus, represents only\n+\t * the completion of the accept callback.\n+\t * <p>\n+\t * The accept function is executed asynchronously by the given executor.\n+\t *\n+\t * @param acceptFunction function to apply to the future's value\n+\t * @param executor used to execute the given apply function asynchronously\n+\t * @return future representing the completion of the accept callback\n+\t */\n+\tFuture<Void> thenAcceptAsync(AcceptFunction<? super T> acceptFunction, Executor executor);\n+\n+\t/**\n+\t * Applies the given function to the value of the future if the future has been completed\n+\t * exceptionally. The completing exception is given to the apply function which can return a new\n+\t * value which is the value of the returned future.\n+\t * <p>\n+\t * The apply function is executed asynchronously by the given executor.\n+\t *\n+\t * @param exceptionallyFunction to apply to the future's value if it is an exception\n+\t * @param executor used to execute the given apply function asynchronously\n+\t * @param <R> type of the apply function's return value\n+\t * @return future representing the return value of the given apply function\n+\t */\n+\t<R> Future<R> exceptionallyAsync(ApplyFunction<Throwable, ? extends R> exceptionallyFunction, Executor executor);\n+\n+\t/**\n+\t * Applies the given function to the value of the future. The apply function can return a future","path":"flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/Future.java","position":129,"original_position":129,"commit_id":"9952bd80a1351d8a2a88f70ff290e0ddfd67f643","original_commit_id":"14023bb0df8e1a263d4082fb0e747a831e82f4cd","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"body":"You're right. The \"can\" should be removed. Will change it.","created_at":"2016-09-20T14:27:57Z","updated_at":"2016-09-20T14:27:57Z","html_url":"https://github.com/apache/flink/pull/2472#discussion_r79623763","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/2472","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/79623763"},"html":{"href":"https://github.com/apache/flink/pull/2472#discussion_r79623763"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/2472"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/2472","id":83963958,"html_url":"https://github.com/apache/flink/pull/2472","diff_url":"https://github.com/apache/flink/pull/2472.diff","patch_url":"https://github.com/apache/flink/pull/2472.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/2472","number":2472,"state":"open","locked":false,"title":"[FLINK-4361] Introduce Flink's own future abstraction","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"body":"Flink's future abstraction whose API is similar to Java 8's CompletableFuture.\r\nThat's in order to ease a future transition to this class once we ditch Java 7.\r\nAt the moment, the current future implementation is backed by Scala's futures.\r\n\r\nThe current set of operations comprises:\r\n\r\n- isDone to check the completion of the future\r\n- get/getNow to obtain the future's value\r\n- cancel to cancel the future (best effort basis)\r\n- thenApplyAsync to transform the future's value into another value\r\n- thenAcceptAsync to register a callback for a successful completion of the future\r\n- exceptionallyAsync to register a callback for an exception completion of the future\r\n- thenComposeAsync to transform the future's value and flatten the returned future\r\n- handleAsync to register a callback which is called either with the regular result\r\nor the exceptional result\r\n\r\nAdditionally, Flink offers a CompletableFuture which can be completed with a regular\r\nvalue or an exception:\r\n\r\n- complete/completeExceptionally","created_at":"2016-09-05T08:07:22Z","updated_at":"2016-09-20T14:27:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"539e2223b1fa7e80d6affcb94f00da13c02fdec5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/2472/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/2472/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/2472/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/9952bd80a1351d8a2a88f70ff290e0ddfd67f643","head":{"label":"tillrohrmann:futures","ref":"futures","sha":"9952bd80a1351d8a2a88f70ff290e0ddfd67f643","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"repo":{"id":20681108,"name":"flink","full_name":"tillrohrmann/flink","owner":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tillrohrmann/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/tillrohrmann/flink","forks_url":"https://api.github.com/repos/tillrohrmann/flink/forks","keys_url":"https://api.github.com/repos/tillrohrmann/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tillrohrmann/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tillrohrmann/flink/teams","hooks_url":"https://api.github.com/repos/tillrohrmann/flink/hooks","issue_events_url":"https://api.github.com/repos/tillrohrmann/flink/issues/events{/number}","events_url":"https://api.github.com/repos/tillrohrmann/flink/events","assignees_url":"https://api.github.com/repos/tillrohrmann/flink/assignees{/user}","branches_url":"https://api.github.com/repos/tillrohrmann/flink/branches{/branch}","tags_url":"https://api.github.com/repos/tillrohrmann/flink/tags","blobs_url":"https://api.github.com/repos/tillrohrmann/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tillrohrmann/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tillrohrmann/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/tillrohrmann/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tillrohrmann/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/tillrohrmann/flink/languages","stargazers_url":"https://api.github.com/repos/tillrohrmann/flink/stargazers","contributors_url":"https://api.github.com/repos/tillrohrmann/flink/contributors","subscribers_url":"https://api.github.com/repos/tillrohrmann/flink/subscribers","subscription_url":"https://api.github.com/repos/tillrohrmann/flink/subscription","commits_url":"https://api.github.com/repos/tillrohrmann/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/tillrohrmann/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/tillrohrmann/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/tillrohrmann/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/tillrohrmann/flink/contents/{+path}","compare_url":"https://api.github.com/repos/tillrohrmann/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tillrohrmann/flink/merges","archive_url":"https://api.github.com/repos/tillrohrmann/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tillrohrmann/flink/downloads","issues_url":"https://api.github.com/repos/tillrohrmann/flink/issues{/number}","pulls_url":"https://api.github.com/repos/tillrohrmann/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/tillrohrmann/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/tillrohrmann/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tillrohrmann/flink/labels{/name}","releases_url":"https://api.github.com/repos/tillrohrmann/flink/releases{/id}","deployments_url":"https://api.github.com/repos/tillrohrmann/flink/deployments","created_at":"2014-06-10T10:19:35Z","updated_at":"2016-05-12T12:46:07Z","pushed_at":"2016-09-20T12:42:20Z","git_url":"git://github.com/tillrohrmann/flink.git","ssh_url":"git@github.com:tillrohrmann/flink.git","clone_url":"https://github.com/tillrohrmann/flink.git","svn_url":"https://github.com/tillrohrmann/flink","homepage":null,"size":92224,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"6e40f59015dcdb8529691318e8f5a33e831252b8","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":20587599,"name":"flink","full_name":"apache/flink","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","deployments_url":"https://api.github.com/repos/apache/flink/deployments","created_at":"2014-06-07T07:00:10Z","updated_at":"2016-09-19T08:01:54Z","pushed_at":"2016-09-20T14:12:58Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":126379,"stargazers_count":1588,"watchers_count":1588,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1064,"mirror_url":"git://git.apache.org/flink.git","open_issues_count":151,"forks":1064,"open_issues":151,"watchers":1588,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/2472"},"html":{"href":"https://github.com/apache/flink/pull/2472"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/2472"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/2472/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/2472/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/2472/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/9952bd80a1351d8a2a88f70ff290e0ddfd67f643"}}}}
{"actor":{"display_login":"tillrohrmann"}}