{"action":"created","comment":{"url":"https://api.github.com/repos/apache/samza/pulls/comments/193922017","pull_request_review_id":126996503,"id":193922017,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzkyMjAxNw==","diff_hunk":"@@ -0,0 +1,80 @@\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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.apache.samza.util;\n+\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.ThreadFactory;\n+import java.util.concurrent.TimeUnit;\n+import java.util.concurrent.atomic.AtomicInteger;\n+import java.util.function.Function;\n+\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+\n+/**\n+ * Shutdown related utils\n+ */\n+public class ShutdownUtil {\n+  private static final Logger LOG = LoggerFactory.getLogger(ShutdownUtil.class);\n+\n+  /**\n+   * A helper to facilitate shutting down a set of resources in parallel to enforce a bounded shutdown time.\n+   * The helper function instantiates an {@link ExecutorService} to execute the \"shutdown function\", and will\n+   * await the termination for given timeout. If shutdown remains unfinished in the end, the whole thread dump\n+   * will be printed to help debugging.\n+   *\n+   * The shutdown is performed with best-effort. Depending on the implementation of the shutdown function, resource\n+   * leak might be possible.\n+   *\n+   * @param shutdownFunction the shutdown function will be provided with an ExecutorService and is supposed to\n+   *                         submit all the shutdown tasks via the given executor\n+   * @param message message that will show in the thread name and the thread dump\n+   * @param timeoutMs timeout in ms\n+   */\n+  public static void boundedShutdown(Function<ExecutorService, Void> shutdownFunction, String message, long timeoutMs) {","path":"samza-core/src/main/java/org/apache/samza/util/ShutdownUtil.java","position":53,"original_position":53,"commit_id":"e440177da3ffd15dd95e27ee43426d567f55f75a","original_commit_id":"e440177da3ffd15dd95e27ee43426d567f55f75a","user":{"login":"prateekm","id":1085859,"node_id":"MDQ6VXNlcjEwODU4NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1085859?v=4","gravatar_id":"","url":"https://api.github.com/users/prateekm","html_url":"https://github.com/prateekm","followers_url":"https://api.github.com/users/prateekm/followers","following_url":"https://api.github.com/users/prateekm/following{/other_user}","gists_url":"https://api.github.com/users/prateekm/gists{/gist_id}","starred_url":"https://api.github.com/users/prateekm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prateekm/subscriptions","organizations_url":"https://api.github.com/users/prateekm/orgs","repos_url":"https://api.github.com/users/prateekm/repos","events_url":"https://api.github.com/users/prateekm/events{/privacy}","received_events_url":"https://api.github.com/users/prateekm/received_events","type":"User","site_admin":false},"body":"1. Does the caller need access to the executor service? Can they caller provide a `List<Runnable> tasks`.\r\n2. [Optional] Can this be a general method unrelated to shutdown? Seems like it essentially takes a List<Runnable/Callable>, executes them concurrently and tries to cancel them and return after waiting for a bounded amount of time.","created_at":"2018-06-08T00:04:09Z","updated_at":"2018-06-08T00:04:09Z","html_url":"https://github.com/apache/samza/pull/548#discussion_r193922017","pull_request_url":"https://api.github.com/repos/apache/samza/pulls/548","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/samza/pulls/comments/193922017"},"html":{"href":"https://github.com/apache/samza/pull/548#discussion_r193922017"},"pull_request":{"href":"https://api.github.com/repos/apache/samza/pulls/548"}}},"pull_request":{"url":"https://api.github.com/repos/apache/samza/pulls/548","id":193169281,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzMTY5Mjgx","html_url":"https://github.com/apache/samza/pull/548","diff_url":"https://github.com/apache/samza/pull/548.diff","patch_url":"https://github.com/apache/samza/pull/548.patch","issue_url":"https://api.github.com/repos/apache/samza/issues/548","number":548,"state":"open","locked":false,"title":"SAMZA-1741: fix issue that EH consumer taking too long to shutdown","user":{"login":"lhaiesp","id":2789450,"node_id":"MDQ6VXNlcjI3ODk0NTA=","avatar_url":"https://avatars0.githubusercontent.com/u/2789450?v=4","gravatar_id":"","url":"https://api.github.com/users/lhaiesp","html_url":"https://github.com/lhaiesp","followers_url":"https://api.github.com/users/lhaiesp/followers","following_url":"https://api.github.com/users/lhaiesp/following{/other_user}","gists_url":"https://api.github.com/users/lhaiesp/gists{/gist_id}","starred_url":"https://api.github.com/users/lhaiesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhaiesp/subscriptions","organizations_url":"https://api.github.com/users/lhaiesp/orgs","repos_url":"https://api.github.com/users/lhaiesp/repos","events_url":"https://api.github.com/users/lhaiesp/events{/privacy}","received_events_url":"https://api.github.com/users/lhaiesp/received_events","type":"User","site_admin":false},"body":"1.  lower the shutdown timeout from 1 min to 15 seconds\r\n2. make sure EventHubManagers are shutdown in parallel\r\n3. print a thread dump when we do fail during shutdown","created_at":"2018-06-06T23:41:37Z","updated_at":"2018-06-08T00:04:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39bfc58207646420a25946743ab56fc3e1eddb2b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/samza/pulls/548/commits","review_comments_url":"https://api.github.com/repos/apache/samza/pulls/548/comments","review_comment_url":"https://api.github.com/repos/apache/samza/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/samza/issues/548/comments","statuses_url":"https://api.github.com/repos/apache/samza/statuses/e440177da3ffd15dd95e27ee43426d567f55f75a","head":{"label":"lhaiesp:master","ref":"master","sha":"e440177da3ffd15dd95e27ee43426d567f55f75a","user":{"login":"lhaiesp","id":2789450,"node_id":"MDQ6VXNlcjI3ODk0NTA=","avatar_url":"https://avatars0.githubusercontent.com/u/2789450?v=4","gravatar_id":"","url":"https://api.github.com/users/lhaiesp","html_url":"https://github.com/lhaiesp","followers_url":"https://api.github.com/users/lhaiesp/followers","following_url":"https://api.github.com/users/lhaiesp/following{/other_user}","gists_url":"https://api.github.com/users/lhaiesp/gists{/gist_id}","starred_url":"https://api.github.com/users/lhaiesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhaiesp/subscriptions","organizations_url":"https://api.github.com/users/lhaiesp/orgs","repos_url":"https://api.github.com/users/lhaiesp/repos","events_url":"https://api.github.com/users/lhaiesp/events{/privacy}","received_events_url":"https://api.github.com/users/lhaiesp/received_events","type":"User","site_admin":false},"repo":{"id":125094234,"node_id":"MDEwOlJlcG9zaXRvcnkxMjUwOTQyMzQ=","name":"samza","full_name":"lhaiesp/samza","owner":{"login":"lhaiesp","id":2789450,"node_id":"MDQ6VXNlcjI3ODk0NTA=","avatar_url":"https://avatars0.githubusercontent.com/u/2789450?v=4","gravatar_id":"","url":"https://api.github.com/users/lhaiesp","html_url":"https://github.com/lhaiesp","followers_url":"https://api.github.com/users/lhaiesp/followers","following_url":"https://api.github.com/users/lhaiesp/following{/other_user}","gists_url":"https://api.github.com/users/lhaiesp/gists{/gist_id}","starred_url":"https://api.github.com/users/lhaiesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhaiesp/subscriptions","organizations_url":"https://api.github.com/users/lhaiesp/orgs","repos_url":"https://api.github.com/users/lhaiesp/repos","events_url":"https://api.github.com/users/lhaiesp/events{/privacy}","received_events_url":"https://api.github.com/users/lhaiesp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lhaiesp/samza","description":"Mirror of Apache Samza","fork":true,"url":"https://api.github.com/repos/lhaiesp/samza","forks_url":"https://api.github.com/repos/lhaiesp/samza/forks","keys_url":"https://api.github.com/repos/lhaiesp/samza/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lhaiesp/samza/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lhaiesp/samza/teams","hooks_url":"https://api.github.com/repos/lhaiesp/samza/hooks","issue_events_url":"https://api.github.com/repos/lhaiesp/samza/issues/events{/number}","events_url":"https://api.github.com/repos/lhaiesp/samza/events","assignees_url":"https://api.github.com/repos/lhaiesp/samza/assignees{/user}","branches_url":"https://api.github.com/repos/lhaiesp/samza/branches{/branch}","tags_url":"https://api.github.com/repos/lhaiesp/samza/tags","blobs_url":"https://api.github.com/repos/lhaiesp/samza/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lhaiesp/samza/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lhaiesp/samza/git/refs{/sha}","trees_url":"https://api.github.com/repos/lhaiesp/samza/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lhaiesp/samza/statuses/{sha}","languages_url":"https://api.github.com/repos/lhaiesp/samza/languages","stargazers_url":"https://api.github.com/repos/lhaiesp/samza/stargazers","contributors_url":"https://api.github.com/repos/lhaiesp/samza/contributors","subscribers_url":"https://api.github.com/repos/lhaiesp/samza/subscribers","subscription_url":"https://api.github.com/repos/lhaiesp/samza/subscription","commits_url":"https://api.github.com/repos/lhaiesp/samza/commits{/sha}","git_commits_url":"https://api.github.com/repos/lhaiesp/samza/git/commits{/sha}","comments_url":"https://api.github.com/repos/lhaiesp/samza/comments{/number}","issue_comment_url":"https://api.github.com/repos/lhaiesp/samza/issues/comments{/number}","contents_url":"https://api.github.com/repos/lhaiesp/samza/contents/{+path}","compare_url":"https://api.github.com/repos/lhaiesp/samza/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lhaiesp/samza/merges","archive_url":"https://api.github.com/repos/lhaiesp/samza/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lhaiesp/samza/downloads","issues_url":"https://api.github.com/repos/lhaiesp/samza/issues{/number}","pulls_url":"https://api.github.com/repos/lhaiesp/samza/pulls{/number}","milestones_url":"https://api.github.com/repos/lhaiesp/samza/milestones{/number}","notifications_url":"https://api.github.com/repos/lhaiesp/samza/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lhaiesp/samza/labels{/name}","releases_url":"https://api.github.com/repos/lhaiesp/samza/releases{/id}","deployments_url":"https://api.github.com/repos/lhaiesp/samza/deployments","created_at":"2018-03-13T18:06:32Z","updated_at":"2018-06-07T23:51:41Z","pushed_at":"2018-06-07T23:51:39Z","git_url":"git://github.com/lhaiesp/samza.git","ssh_url":"git@github.com:lhaiesp/samza.git","clone_url":"https://github.com/lhaiesp/samza.git","svn_url":"https://github.com/lhaiesp/samza","homepage":null,"size":20160,"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":"apache:master","ref":"master","sha":"36c4c4b02df36027fc3516407085175fb565bd70","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":32199982,"node_id":"MDEwOlJlcG9zaXRvcnkzMjE5OTk4Mg==","name":"samza","full_name":"apache/samza","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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/samza","description":"Mirror of Apache Samza","fork":false,"url":"https://api.github.com/repos/apache/samza","forks_url":"https://api.github.com/repos/apache/samza/forks","keys_url":"https://api.github.com/repos/apache/samza/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/samza/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/samza/teams","hooks_url":"https://api.github.com/repos/apache/samza/hooks","issue_events_url":"https://api.github.com/repos/apache/samza/issues/events{/number}","events_url":"https://api.github.com/repos/apache/samza/events","assignees_url":"https://api.github.com/repos/apache/samza/assignees{/user}","branches_url":"https://api.github.com/repos/apache/samza/branches{/branch}","tags_url":"https://api.github.com/repos/apache/samza/tags","blobs_url":"https://api.github.com/repos/apache/samza/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/samza/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/samza/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/samza/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/samza/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/samza/languages","stargazers_url":"https://api.github.com/repos/apache/samza/stargazers","contributors_url":"https://api.github.com/repos/apache/samza/contributors","subscribers_url":"https://api.github.com/repos/apache/samza/subscribers","subscription_url":"https://api.github.com/repos/apache/samza/subscription","commits_url":"https://api.github.com/repos/apache/samza/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/samza/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/samza/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/samza/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/samza/contents/{+path}","compare_url":"https://api.github.com/repos/apache/samza/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/samza/merges","archive_url":"https://api.github.com/repos/apache/samza/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/samza/downloads","issues_url":"https://api.github.com/repos/apache/samza/issues{/number}","pulls_url":"https://api.github.com/repos/apache/samza/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/samza/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/samza/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/samza/labels{/name}","releases_url":"https://api.github.com/repos/apache/samza/releases{/id}","deployments_url":"https://api.github.com/repos/apache/samza/deployments","created_at":"2015-03-14T07:00:05Z","updated_at":"2018-06-07T23:52:14Z","pushed_at":"2018-06-07T23:52:09Z","git_url":"git://github.com/apache/samza.git","ssh_url":"git@github.com:apache/samza.git","clone_url":"https://github.com/apache/samza.git","svn_url":"https://github.com/apache/samza","homepage":null,"size":20169,"stargazers_count":431,"watchers_count":431,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":188,"mirror_url":null,"archived":false,"open_issues_count":26,"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":188,"open_issues":26,"watchers":431,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/samza/pulls/548"},"html":{"href":"https://github.com/apache/samza/pull/548"},"issue":{"href":"https://api.github.com/repos/apache/samza/issues/548"},"comments":{"href":"https://api.github.com/repos/apache/samza/issues/548/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/samza/pulls/548/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/samza/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/samza/pulls/548/commits"},"statuses":{"href":"https://api.github.com/repos/apache/samza/statuses/e440177da3ffd15dd95e27ee43426d567f55f75a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"prateekm"}}