{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-pinot/pulls/comments/240621899","pull_request_review_id":183690585,"id":240621899,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDYyMTg5OQ==","diff_hunk":"@@ -0,0 +1,116 @@\n+/**\n+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)\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 com.linkedin.pinot.controller;\n+\n+import java.util.Map;\n+import java.util.concurrent.ConcurrentHashMap;\n+import org.apache.helix.HelixManager;\n+import org.apache.helix.api.listeners.ControllerChangeListener;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+\n+/**\n+ * Single place for listening on controller changes\n+ * This should be created at controller startup and everyone who wants to listen to controller changes should subscribe\n+ */\n+public class ControllerLeadershipManager {\n+\n+  private static final Logger LOGGER = LoggerFactory.getLogger(ControllerLeadershipManager.class);\n+\n+  private static ControllerLeadershipManager INSTANCE = null;\n+\n+  private HelixManager _helixManager;\n+  private volatile boolean _amILeader = false;\n+\n+  private Map<String, ControllerChangeSubscriber> _subscribers = new ConcurrentHashMap<>();\n+\n+  private ControllerLeadershipManager(HelixManager helixManager) {\n+    _helixManager = helixManager;\n+    _helixManager.addControllerListener((ControllerChangeListener) notificationContext -> onControllerChange());\n+  }\n+\n+  /**\n+   * Create an instance of ControllerLeadershipManager\n+   * @param helixManager\n+   */\n+  public static synchronized void createInstance(HelixManager helixManager) {\n+    if (INSTANCE != null) {\n+      throw new RuntimeException(\"Instance of ControllerLeadershipManager already created\");\n+    }\n+    INSTANCE = new ControllerLeadershipManager(helixManager);\n+  }\n+\n+  /**\n+   * Get the instance of ControllerLeadershipManager\n+   * @return\n+   */\n+  public static ControllerLeadershipManager getInstance() {","path":"pinot-controller/src/main/java/com/linkedin/pinot/controller/ControllerLeadershipManager.java","position":62,"original_position":62,"commit_id":"1de62ecb85f896f250cc83b24810d995b70ee152","original_commit_id":"1de62ecb85f896f250cc83b24810d995b70ee152","user":{"login":"sunithabeeram","id":3123798,"node_id":"MDQ6VXNlcjMxMjM3OTg=","avatar_url":"https://avatars2.githubusercontent.com/u/3123798?v=4","gravatar_id":"","url":"https://api.github.com/users/sunithabeeram","html_url":"https://github.com/sunithabeeram","followers_url":"https://api.github.com/users/sunithabeeram/followers","following_url":"https://api.github.com/users/sunithabeeram/following{/other_user}","gists_url":"https://api.github.com/users/sunithabeeram/gists{/gist_id}","starred_url":"https://api.github.com/users/sunithabeeram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunithabeeram/subscriptions","organizations_url":"https://api.github.com/users/sunithabeeram/orgs","repos_url":"https://api.github.com/users/sunithabeeram/repos","events_url":"https://api.github.com/users/sunithabeeram/events{/privacy}","received_events_url":"https://api.github.com/users/sunithabeeram/received_events","type":"User","site_admin":false},"body":"This needs to be synchronized as well, else it might suffer improper publication. ","created_at":"2018-12-11T14:05:00Z","updated_at":"2018-12-11T14:18:09Z","html_url":"https://github.com/apache/incubator-pinot/pull/3604#discussion_r240621899","pull_request_url":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/comments/240621899"},"html":{"href":"https://github.com/apache/incubator-pinot/pull/3604#discussion_r240621899"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604","id":237535955,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3NTM1OTU1","html_url":"https://github.com/apache/incubator-pinot/pull/3604","diff_url":"https://github.com/apache/incubator-pinot/pull/3604.diff","patch_url":"https://github.com/apache/incubator-pinot/pull/3604.patch","issue_url":"https://api.github.com/repos/apache/incubator-pinot/issues/3604","number":3604,"state":"open","locked":false,"title":"Add ControllerLeadershipManager as single place to check controller leadership changes","user":{"login":"npawar","id":19693933,"node_id":"MDQ6VXNlcjE5NjkzOTMz","avatar_url":"https://avatars0.githubusercontent.com/u/19693933?v=4","gravatar_id":"","url":"https://api.github.com/users/npawar","html_url":"https://github.com/npawar","followers_url":"https://api.github.com/users/npawar/followers","following_url":"https://api.github.com/users/npawar/following{/other_user}","gists_url":"https://api.github.com/users/npawar/gists{/gist_id}","starred_url":"https://api.github.com/users/npawar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npawar/subscriptions","organizations_url":"https://api.github.com/users/npawar/orgs","repos_url":"https://api.github.com/users/npawar/repos","events_url":"https://api.github.com/users/npawar/events{/privacy}","received_events_url":"https://api.github.com/users/npawar/received_events","type":"User","site_admin":false},"body":"Step 1 of https://github.com/apache/incubator-pinot/issues/3600","created_at":"2018-12-11T03:03:34Z","updated_at":"2018-12-11T14:18:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b559abf33b3eb1242ae5c10fdeb20e3ae0fff7d5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-pinot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-pinot/issues/3604/comments","statuses_url":"https://api.github.com/repos/apache/incubator-pinot/statuses/1de62ecb85f896f250cc83b24810d995b70ee152","head":{"label":"apache:run_validation_manager_on_leadership_change","ref":"run_validation_manager_on_leadership_change","sha":"1de62ecb85f896f250cc83b24810d995b70ee152","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":19961085,"node_id":"MDEwOlJlcG9zaXRvcnkxOTk2MTA4NQ==","name":"incubator-pinot","full_name":"apache/incubator-pinot","private":false,"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},"html_url":"https://github.com/apache/incubator-pinot","description":"Apache Pinot (Incubating) - A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/apache/incubator-pinot","forks_url":"https://api.github.com/repos/apache/incubator-pinot/forks","keys_url":"https://api.github.com/repos/apache/incubator-pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-pinot/teams","hooks_url":"https://api.github.com/repos/apache/incubator-pinot/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-pinot/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-pinot/events","assignees_url":"https://api.github.com/repos/apache/incubator-pinot/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-pinot/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-pinot/tags","blobs_url":"https://api.github.com/repos/apache/incubator-pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-pinot/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-pinot/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-pinot/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-pinot/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-pinot/subscription","commits_url":"https://api.github.com/repos/apache/incubator-pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-pinot/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-pinot/merges","archive_url":"https://api.github.com/repos/apache/incubator-pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-pinot/downloads","issues_url":"https://api.github.com/repos/apache/incubator-pinot/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-pinot/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-pinot/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2018-12-11T12:13:45Z","pushed_at":"2018-12-11T03:05:17Z","git_url":"git://github.com/apache/incubator-pinot.git","ssh_url":"git@github.com:apache/incubator-pinot.git","clone_url":"https://github.com/apache/incubator-pinot.git","svn_url":"https://github.com/apache/incubator-pinot","homepage":"https://pinot.apache.org","size":159298,"stargazers_count":2057,"watchers_count":2057,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":376,"mirror_url":null,"archived":false,"open_issues_count":197,"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":376,"open_issues":197,"watchers":2057,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"6a6c1758aae34239c1e1baf13978de0e6b7b7005","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":19961085,"node_id":"MDEwOlJlcG9zaXRvcnkxOTk2MTA4NQ==","name":"incubator-pinot","full_name":"apache/incubator-pinot","private":false,"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},"html_url":"https://github.com/apache/incubator-pinot","description":"Apache Pinot (Incubating) - A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/apache/incubator-pinot","forks_url":"https://api.github.com/repos/apache/incubator-pinot/forks","keys_url":"https://api.github.com/repos/apache/incubator-pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-pinot/teams","hooks_url":"https://api.github.com/repos/apache/incubator-pinot/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-pinot/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-pinot/events","assignees_url":"https://api.github.com/repos/apache/incubator-pinot/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-pinot/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-pinot/tags","blobs_url":"https://api.github.com/repos/apache/incubator-pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-pinot/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-pinot/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-pinot/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-pinot/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-pinot/subscription","commits_url":"https://api.github.com/repos/apache/incubator-pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-pinot/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-pinot/merges","archive_url":"https://api.github.com/repos/apache/incubator-pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-pinot/downloads","issues_url":"https://api.github.com/repos/apache/incubator-pinot/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-pinot/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-pinot/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2018-12-11T12:13:45Z","pushed_at":"2018-12-11T03:05:17Z","git_url":"git://github.com/apache/incubator-pinot.git","ssh_url":"git@github.com:apache/incubator-pinot.git","clone_url":"https://github.com/apache/incubator-pinot.git","svn_url":"https://github.com/apache/incubator-pinot","homepage":"https://pinot.apache.org","size":159298,"stargazers_count":2057,"watchers_count":2057,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":376,"mirror_url":null,"archived":false,"open_issues_count":197,"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":376,"open_issues":197,"watchers":2057,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604"},"html":{"href":"https://github.com/apache/incubator-pinot/pull/3604"},"issue":{"href":"https://api.github.com/repos/apache/incubator-pinot/issues/3604"},"comments":{"href":"https://api.github.com/repos/apache/incubator-pinot/issues/3604/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-pinot/pulls/3604/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-pinot/statuses/1de62ecb85f896f250cc83b24810d995b70ee152"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sunithabeeram"}}