{"action":"created","comment":{"url":"https://api.github.com/repos/confluentinc/ksql/pulls/comments/204934198","pull_request_review_id":140102393,"id":204934198,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDkzNDE5OA==","diff_hunk":"@@ -0,0 +1,94 @@\n+/*\n+ * Copyright 2017 Confluent Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * 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 io.confluent.ksql.util;\n+\n+import org.apache.kafka.common.errors.RetriableException;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import java.util.concurrent.Callable;\n+import java.util.concurrent.CompletableFuture;\n+import java.util.concurrent.Future;\n+import java.util.function.Supplier;\n+\n+public final class ExecutorWithRetries {\n+\n+  private static final int NUM_RETRIES = 5;\n+  private static final int RETRY_BACKOFF_MS = 500;\n+  private static final Logger log = LoggerFactory.getLogger(ExecutorWithRetries.class);\n+\n+  private ExecutorWithRetries() {\n+  }\n+\n+  public enum RetryBehaviour {\n+    ALWAYS,\n+    ON_RETRYABLE\n+  }\n+\n+  @FunctionalInterface\n+  public interface Function {\n+    void call() throws Exception;\n+  }\n+\n+  public static void execute(final Function function,\n+                             final RetryBehaviour retryBehaviour) throws Exception {\n+    execute(() -> {\n+      function.call();\n+      return null;\n+    }, retryBehaviour);\n+  }\n+\n+  public static <T> T execute(final Callable<T> supplier,\n+                              final RetryBehaviour retryBehaviour) throws Exception {\n+    return executeSync(() -> {\n+      final CompletableFuture<T> f = new CompletableFuture<>();\n+      try {\n+        final T result = supplier.call();\n+        f.complete(result);\n+      } catch (final Exception e) {\n+        f.completeExceptionally(e);\n+      }\n+      return f;\n+    }, retryBehaviour);\n+  }\n+\n+  public static <T> T executeSync(final Supplier<? extends Future<T>> supplier,","path":"ksql-engine/src/main/java/io/confluent/ksql/util/ExecutorWithRetries.java","position":68,"original_position":68,"commit_id":"643cb99ee765fb7e2ba230a734c1e608b6b23e8c","original_commit_id":"643cb99ee765fb7e2ba230a734c1e608b6b23e8c","user":{"login":"rodesai","id":2610028,"node_id":"MDQ6VXNlcjI2MTAwMjg=","avatar_url":"https://avatars0.githubusercontent.com/u/2610028?v=4","gravatar_id":"","url":"https://api.github.com/users/rodesai","html_url":"https://github.com/rodesai","followers_url":"https://api.github.com/users/rodesai/followers","following_url":"https://api.github.com/users/rodesai/following{/other_user}","gists_url":"https://api.github.com/users/rodesai/gists{/gist_id}","starred_url":"https://api.github.com/users/rodesai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodesai/subscriptions","organizations_url":"https://api.github.com/users/rodesai/orgs","repos_url":"https://api.github.com/users/rodesai/repos","events_url":"https://api.github.com/users/rodesai/events{/privacy}","received_events_url":"https://api.github.com/users/rodesai/received_events","type":"User","site_admin":false},"body":"I think the functions here can be simplified. It looks like we want two functions - one that takes a Supplier, and one that takes a Function, that call their argument in a retry loop and returns a value in the case of the Supplier. The fact that the admin client returns futures shouldn't leak into this class.","created_at":"2018-07-24T22:41:59Z","updated_at":"2018-07-24T22:45:01Z","html_url":"https://github.com/confluentinc/ksql/pull/1338#discussion_r204934198","pull_request_url":"https://api.github.com/repos/confluentinc/ksql/pulls/1338","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/comments/204934198"},"html":{"href":"https://github.com/confluentinc/ksql/pull/1338#discussion_r204934198"},"pull_request":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/1338"}}},"pull_request":{"url":"https://api.github.com/repos/confluentinc/ksql/pulls/1338","id":190134807,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkwMTM0ODA3","html_url":"https://github.com/confluentinc/ksql/pull/1338","diff_url":"https://github.com/confluentinc/ksql/pull/1338.diff","patch_url":"https://github.com/confluentinc/ksql/pull/1338.patch","issue_url":"https://api.github.com/repos/confluentinc/ksql/issues/1338","number":1338,"state":"open","locked":false,"title":"#1314 Unify 'executeWithRetries' implementation","user":{"login":"uurl","id":2509572,"node_id":"MDQ6VXNlcjI1MDk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/2509572?v=4","gravatar_id":"","url":"https://api.github.com/users/uurl","html_url":"https://github.com/uurl","followers_url":"https://api.github.com/users/uurl/followers","following_url":"https://api.github.com/users/uurl/following{/other_user}","gists_url":"https://api.github.com/users/uurl/gists{/gist_id}","starred_url":"https://api.github.com/users/uurl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uurl/subscriptions","organizations_url":"https://api.github.com/users/uurl/orgs","repos_url":"https://api.github.com/users/uurl/repos","events_url":"https://api.github.com/users/uurl/events{/privacy}","received_events_url":"https://api.github.com/users/uurl/received_events","type":"User","site_admin":false},"body":"### Description \r\nThis PR fixes #1314 Unify 'executeWithRetries' implementation\r\n\r\n### Testing done \r\nmvn clean package\r\n\r\n### Reviewer checklist\r\n- [ ] Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).\r\n- [ ] Ensure relevant issues are linked (description should include text like \"Fixes #<issue number>\")\r\n","created_at":"2018-05-23T23:48:04Z","updated_at":"2018-07-24T22:45:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"355997f7293adc0f6923fe034741900815857ed1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/confluentinc/ksql/pulls/1338/commits","review_comments_url":"https://api.github.com/repos/confluentinc/ksql/pulls/1338/comments","review_comment_url":"https://api.github.com/repos/confluentinc/ksql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/confluentinc/ksql/issues/1338/comments","statuses_url":"https://api.github.com/repos/confluentinc/ksql/statuses/643cb99ee765fb7e2ba230a734c1e608b6b23e8c","head":{"label":"uurl:issue1314","ref":"issue1314","sha":"643cb99ee765fb7e2ba230a734c1e608b6b23e8c","user":{"login":"uurl","id":2509572,"node_id":"MDQ6VXNlcjI1MDk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/2509572?v=4","gravatar_id":"","url":"https://api.github.com/users/uurl","html_url":"https://github.com/uurl","followers_url":"https://api.github.com/users/uurl/followers","following_url":"https://api.github.com/users/uurl/following{/other_user}","gists_url":"https://api.github.com/users/uurl/gists{/gist_id}","starred_url":"https://api.github.com/users/uurl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uurl/subscriptions","organizations_url":"https://api.github.com/users/uurl/orgs","repos_url":"https://api.github.com/users/uurl/repos","events_url":"https://api.github.com/users/uurl/events{/privacy}","received_events_url":"https://api.github.com/users/uurl/received_events","type":"User","site_admin":false},"repo":{"id":132240504,"node_id":"MDEwOlJlcG9zaXRvcnkxMzIyNDA1MDQ=","name":"ksql","full_name":"uurl/ksql","owner":{"login":"uurl","id":2509572,"node_id":"MDQ6VXNlcjI1MDk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/2509572?v=4","gravatar_id":"","url":"https://api.github.com/users/uurl","html_url":"https://github.com/uurl","followers_url":"https://api.github.com/users/uurl/followers","following_url":"https://api.github.com/users/uurl/following{/other_user}","gists_url":"https://api.github.com/users/uurl/gists{/gist_id}","starred_url":"https://api.github.com/users/uurl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uurl/subscriptions","organizations_url":"https://api.github.com/users/uurl/orgs","repos_url":"https://api.github.com/users/uurl/repos","events_url":"https://api.github.com/users/uurl/events{/privacy}","received_events_url":"https://api.github.com/users/uurl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/uurl/ksql","description":"KSQL - the Streaming SQL Engine for Apache Kafka ","fork":true,"url":"https://api.github.com/repos/uurl/ksql","forks_url":"https://api.github.com/repos/uurl/ksql/forks","keys_url":"https://api.github.com/repos/uurl/ksql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uurl/ksql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uurl/ksql/teams","hooks_url":"https://api.github.com/repos/uurl/ksql/hooks","issue_events_url":"https://api.github.com/repos/uurl/ksql/issues/events{/number}","events_url":"https://api.github.com/repos/uurl/ksql/events","assignees_url":"https://api.github.com/repos/uurl/ksql/assignees{/user}","branches_url":"https://api.github.com/repos/uurl/ksql/branches{/branch}","tags_url":"https://api.github.com/repos/uurl/ksql/tags","blobs_url":"https://api.github.com/repos/uurl/ksql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uurl/ksql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uurl/ksql/git/refs{/sha}","trees_url":"https://api.github.com/repos/uurl/ksql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uurl/ksql/statuses/{sha}","languages_url":"https://api.github.com/repos/uurl/ksql/languages","stargazers_url":"https://api.github.com/repos/uurl/ksql/stargazers","contributors_url":"https://api.github.com/repos/uurl/ksql/contributors","subscribers_url":"https://api.github.com/repos/uurl/ksql/subscribers","subscription_url":"https://api.github.com/repos/uurl/ksql/subscription","commits_url":"https://api.github.com/repos/uurl/ksql/commits{/sha}","git_commits_url":"https://api.github.com/repos/uurl/ksql/git/commits{/sha}","comments_url":"https://api.github.com/repos/uurl/ksql/comments{/number}","issue_comment_url":"https://api.github.com/repos/uurl/ksql/issues/comments{/number}","contents_url":"https://api.github.com/repos/uurl/ksql/contents/{+path}","compare_url":"https://api.github.com/repos/uurl/ksql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uurl/ksql/merges","archive_url":"https://api.github.com/repos/uurl/ksql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uurl/ksql/downloads","issues_url":"https://api.github.com/repos/uurl/ksql/issues{/number}","pulls_url":"https://api.github.com/repos/uurl/ksql/pulls{/number}","milestones_url":"https://api.github.com/repos/uurl/ksql/milestones{/number}","notifications_url":"https://api.github.com/repos/uurl/ksql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uurl/ksql/labels{/name}","releases_url":"https://api.github.com/repos/uurl/ksql/releases{/id}","deployments_url":"https://api.github.com/repos/uurl/ksql/deployments","created_at":"2018-05-05T11:08:55Z","updated_at":"2018-05-25T00:24:47Z","pushed_at":"2018-07-23T08:33:26Z","git_url":"git://github.com/uurl/ksql.git","ssh_url":"git@github.com:uurl/ksql.git","clone_url":"https://github.com/uurl/ksql.git","svn_url":"https://github.com/uurl/ksql","homepage":"","size":8616,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"confluentinc:master","ref":"master","sha":"6aa4f1163e83dcd13a26d29d052b66c3cca5b4aa","user":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"repo":{"id":69400326,"node_id":"MDEwOlJlcG9zaXRvcnk2OTQwMDMyNg==","name":"ksql","full_name":"confluentinc/ksql","owner":{"login":"confluentinc","id":9439498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0Mzk0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/9439498?v=4","gravatar_id":"","url":"https://api.github.com/users/confluentinc","html_url":"https://github.com/confluentinc","followers_url":"https://api.github.com/users/confluentinc/followers","following_url":"https://api.github.com/users/confluentinc/following{/other_user}","gists_url":"https://api.github.com/users/confluentinc/gists{/gist_id}","starred_url":"https://api.github.com/users/confluentinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/confluentinc/subscriptions","organizations_url":"https://api.github.com/users/confluentinc/orgs","repos_url":"https://api.github.com/users/confluentinc/repos","events_url":"https://api.github.com/users/confluentinc/events{/privacy}","received_events_url":"https://api.github.com/users/confluentinc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/confluentinc/ksql","description":"KSQL - the Streaming SQL Engine for Apache Kafka ","fork":false,"url":"https://api.github.com/repos/confluentinc/ksql","forks_url":"https://api.github.com/repos/confluentinc/ksql/forks","keys_url":"https://api.github.com/repos/confluentinc/ksql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/confluentinc/ksql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/confluentinc/ksql/teams","hooks_url":"https://api.github.com/repos/confluentinc/ksql/hooks","issue_events_url":"https://api.github.com/repos/confluentinc/ksql/issues/events{/number}","events_url":"https://api.github.com/repos/confluentinc/ksql/events","assignees_url":"https://api.github.com/repos/confluentinc/ksql/assignees{/user}","branches_url":"https://api.github.com/repos/confluentinc/ksql/branches{/branch}","tags_url":"https://api.github.com/repos/confluentinc/ksql/tags","blobs_url":"https://api.github.com/repos/confluentinc/ksql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/confluentinc/ksql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/confluentinc/ksql/git/refs{/sha}","trees_url":"https://api.github.com/repos/confluentinc/ksql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/confluentinc/ksql/statuses/{sha}","languages_url":"https://api.github.com/repos/confluentinc/ksql/languages","stargazers_url":"https://api.github.com/repos/confluentinc/ksql/stargazers","contributors_url":"https://api.github.com/repos/confluentinc/ksql/contributors","subscribers_url":"https://api.github.com/repos/confluentinc/ksql/subscribers","subscription_url":"https://api.github.com/repos/confluentinc/ksql/subscription","commits_url":"https://api.github.com/repos/confluentinc/ksql/commits{/sha}","git_commits_url":"https://api.github.com/repos/confluentinc/ksql/git/commits{/sha}","comments_url":"https://api.github.com/repos/confluentinc/ksql/comments{/number}","issue_comment_url":"https://api.github.com/repos/confluentinc/ksql/issues/comments{/number}","contents_url":"https://api.github.com/repos/confluentinc/ksql/contents/{+path}","compare_url":"https://api.github.com/repos/confluentinc/ksql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/confluentinc/ksql/merges","archive_url":"https://api.github.com/repos/confluentinc/ksql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/confluentinc/ksql/downloads","issues_url":"https://api.github.com/repos/confluentinc/ksql/issues{/number}","pulls_url":"https://api.github.com/repos/confluentinc/ksql/pulls{/number}","milestones_url":"https://api.github.com/repos/confluentinc/ksql/milestones{/number}","notifications_url":"https://api.github.com/repos/confluentinc/ksql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/confluentinc/ksql/labels{/name}","releases_url":"https://api.github.com/repos/confluentinc/ksql/releases{/id}","deployments_url":"https://api.github.com/repos/confluentinc/ksql/deployments","created_at":"2016-09-27T21:30:15Z","updated_at":"2018-07-24T21:55:53Z","pushed_at":"2018-07-24T21:55:49Z","git_url":"git://github.com/confluentinc/ksql.git","ssh_url":"git@github.com:confluentinc/ksql.git","clone_url":"https://github.com/confluentinc/ksql.git","svn_url":"https://github.com/confluentinc/ksql","homepage":"","size":9041,"stargazers_count":1803,"watchers_count":1803,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":340,"mirror_url":null,"archived":false,"open_issues_count":334,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":340,"open_issues":334,"watchers":1803,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/1338"},"html":{"href":"https://github.com/confluentinc/ksql/pull/1338"},"issue":{"href":"https://api.github.com/repos/confluentinc/ksql/issues/1338"},"comments":{"href":"https://api.github.com/repos/confluentinc/ksql/issues/1338/comments"},"review_comments":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/1338/comments"},"review_comment":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/confluentinc/ksql/pulls/1338/commits"},"statuses":{"href":"https://api.github.com/repos/confluentinc/ksql/statuses/643cb99ee765fb7e2ba230a734c1e608b6b23e8c"}},"author_association":"NONE"}}
{"actor":{"display_login":"rodesai"}}