{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/pinot/pulls/comments/224312064","pull_request_review_id":163646308,"id":224312064,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDMxMjA2NA==","diff_hunk":"@@ -0,0 +1,181 @@\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+package com.linkedin.pinot.core.periodictask;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.concurrent.atomic.AtomicInteger;\n+import java.util.concurrent.atomic.AtomicLong;\n+import org.testng.Assert;\n+import org.testng.annotations.Test;\n+\n+\n+public class PeriodicTaskSchedulerTest {\n+\n+  @Test\n+  public void testSchedulerWithOneTask() {\n+    AtomicInteger count = new AtomicInteger(0);\n+    PeriodicTaskScheduler periodicTaskScheduler = new PeriodicTaskScheduler(0L);\n+    long runFrequencyInSeconds = 1L;\n+    long totalRunTimeInMilliseconds = 4_000L;\n+\n+    List<PeriodicTask> periodicTasks = new ArrayList<>();\n+    PeriodicTask task = new BasePeriodicTask(\"Task\", runFrequencyInSeconds, 0L) {\n+      @Override\n+      public void run() {\n+        // Execute task.\n+        count.incrementAndGet();\n+      }\n+    };\n+    periodicTasks.add(task);\n+\n+    long start = System.currentTimeMillis();\n+    periodicTaskScheduler.start(periodicTasks);\n+    try {\n+      Thread.sleep(totalRunTimeInMilliseconds);\n+    } catch (InterruptedException e) {\n+      e.printStackTrace();\n+    }\n+    periodicTaskScheduler.stop();\n+\n+    Assert.assertTrue(count.get() > 0);\n+    Assert.assertTrue(count.get() < (totalRunTimeInMilliseconds / runFrequencyInSeconds));\n+    Assert.assertTrue(totalRunTimeInMilliseconds < (System.currentTimeMillis() - start));\n+  }\n+\n+  @Test\n+  public void testSchedulerWithTwoStaggeredTasks() {\n+    AtomicInteger count = new AtomicInteger(0);\n+    PeriodicTaskScheduler periodicTaskScheduler = new PeriodicTaskScheduler(0L);\n+    long runFrequencyInSeconds = 4L;\n+    long totalRunTimeInMilliseconds = 15_000L;\n+\n+    List<PeriodicTask> periodicTasks = new ArrayList<>();\n+    PeriodicTask task1 = new BasePeriodicTask(\"Task1\", runFrequencyInSeconds, 0L) {\n+      @Override\n+      public void run() {\n+        // Execute task.\n+        count.incrementAndGet();\n+      }\n+    };\n+    periodicTasks.add(task1);\n+\n+    // Stagger 2 tasks.\n+    PeriodicTask task2 = new BasePeriodicTask(\"Task2\", runFrequencyInSeconds, runFrequencyInSeconds / 2) {\n+      @Override\n+      public void run() {\n+        // Execute task.\n+        count.decrementAndGet();\n+      }\n+    };\n+    periodicTasks.add(task2);\n+\n+    long start = System.currentTimeMillis();\n+    periodicTaskScheduler.start(periodicTasks);\n+    try {\n+      Thread.sleep(totalRunTimeInMilliseconds);\n+    } catch (InterruptedException e) {\n+      e.printStackTrace();","path":"pinot-core/src/test/java/com/linkedin/pinot/core/periodictask/PeriodicTaskSchedulerTest.java","position":91,"original_position":91,"commit_id":"91fb2e74cc6f5b101bd7492015867e26ddd6acf0","original_commit_id":"91fb2e74cc6f5b101bd7492015867e26ddd6acf0","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":"I am not sure catching interrupted exception is a good idea. You can add throws to the method signature and let the test fail and bail instead of continue on.","created_at":"2018-10-11T04:32:54Z","updated_at":"2018-10-11T04:32:54Z","html_url":"https://github.com/linkedin/pinot/pull/3264#discussion_r224312064","pull_request_url":"https://api.github.com/repos/linkedin/pinot/pulls/3264","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/comments/224312064"},"html":{"href":"https://github.com/linkedin/pinot/pull/3264#discussion_r224312064"},"pull_request":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/3264"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/pinot/pulls/3264","id":220472178,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNDcyMTc4","html_url":"https://github.com/linkedin/pinot/pull/3264","diff_url":"https://github.com/linkedin/pinot/pull/3264.diff","patch_url":"https://github.com/linkedin/pinot/pull/3264.patch","issue_url":"https://api.github.com/repos/linkedin/pinot/issues/3264","number":3264,"state":"open","locked":false,"title":"Add abstract class PeriodicTask to unify duplicate code","user":{"login":"jackjlli","id":35080149,"node_id":"MDQ6VXNlcjM1MDgwMTQ5","avatar_url":"https://avatars1.githubusercontent.com/u/35080149?v=4","gravatar_id":"","url":"https://api.github.com/users/jackjlli","html_url":"https://github.com/jackjlli","followers_url":"https://api.github.com/users/jackjlli/followers","following_url":"https://api.github.com/users/jackjlli/following{/other_user}","gists_url":"https://api.github.com/users/jackjlli/gists{/gist_id}","starred_url":"https://api.github.com/users/jackjlli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackjlli/subscriptions","organizations_url":"https://api.github.com/users/jackjlli/orgs","repos_url":"https://api.github.com/users/jackjlli/repos","events_url":"https://api.github.com/users/jackjlli/events{/privacy}","received_events_url":"https://api.github.com/users/jackjlli/received_events","type":"User","site_admin":false},"body":"This RB adds abstract class PeriodicTask to unify some duplicate code.\r\nIn future, we need another class to specify Controller's PeriodicTask, which can only be run by Pinot controller only.\r\n","created_at":"2018-10-04T18:21:10Z","updated_at":"2018-10-11T04:32:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e47d7c915cff418264e599d2c0abdd651323548","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/pinot/pulls/3264/commits","review_comments_url":"https://api.github.com/repos/linkedin/pinot/pulls/3264/comments","review_comment_url":"https://api.github.com/repos/linkedin/pinot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/pinot/issues/3264/comments","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/91fb2e74cc6f5b101bd7492015867e26ddd6acf0","head":{"label":"linkedin:refactor-periodic-task-for-controller","ref":"refactor-periodic-task-for-controller","sha":"91fb2e74cc6f5b101bd7492015867e26ddd6acf0","user":{"login":"linkedin","id":357098,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NzA5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":19961085,"node_id":"MDEwOlJlcG9zaXRvcnkxOTk2MTA4NQ==","name":"pinot","full_name":"linkedin/pinot","private":false,"owner":{"login":"linkedin","id":357098,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NzA5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/linkedin/pinot","description":"A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/linkedin/pinot","forks_url":"https://api.github.com/repos/linkedin/pinot/forks","keys_url":"https://api.github.com/repos/linkedin/pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/pinot/teams","hooks_url":"https://api.github.com/repos/linkedin/pinot/hooks","issue_events_url":"https://api.github.com/repos/linkedin/pinot/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/pinot/events","assignees_url":"https://api.github.com/repos/linkedin/pinot/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/pinot/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/pinot/tags","blobs_url":"https://api.github.com/repos/linkedin/pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/pinot/languages","stargazers_url":"https://api.github.com/repos/linkedin/pinot/stargazers","contributors_url":"https://api.github.com/repos/linkedin/pinot/contributors","subscribers_url":"https://api.github.com/repos/linkedin/pinot/subscribers","subscription_url":"https://api.github.com/repos/linkedin/pinot/subscription","commits_url":"https://api.github.com/repos/linkedin/pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/pinot/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/pinot/merges","archive_url":"https://api.github.com/repos/linkedin/pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/pinot/downloads","issues_url":"https://api.github.com/repos/linkedin/pinot/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/pinot/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/pinot/releases{/id}","deployments_url":"https://api.github.com/repos/linkedin/pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2018-10-11T03:25:31Z","pushed_at":"2018-10-11T02:41:14Z","git_url":"git://github.com/linkedin/pinot.git","ssh_url":"git@github.com:linkedin/pinot.git","clone_url":"https://github.com/linkedin/pinot.git","svn_url":"https://github.com/linkedin/pinot","homepage":"https://github.com/linkedin/pinot/wiki","size":156134,"stargazers_count":1985,"watchers_count":1985,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":356,"mirror_url":null,"archived":false,"open_issues_count":182,"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":356,"open_issues":182,"watchers":1985,"default_branch":"master"}},"base":{"label":"linkedin:master","ref":"master","sha":"0d3be35b54dc3b64b6cd063931c568d85b10c01a","user":{"login":"linkedin","id":357098,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NzA5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":19961085,"node_id":"MDEwOlJlcG9zaXRvcnkxOTk2MTA4NQ==","name":"pinot","full_name":"linkedin/pinot","private":false,"owner":{"login":"linkedin","id":357098,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NzA5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/linkedin/pinot","description":"A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/linkedin/pinot","forks_url":"https://api.github.com/repos/linkedin/pinot/forks","keys_url":"https://api.github.com/repos/linkedin/pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/pinot/teams","hooks_url":"https://api.github.com/repos/linkedin/pinot/hooks","issue_events_url":"https://api.github.com/repos/linkedin/pinot/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/pinot/events","assignees_url":"https://api.github.com/repos/linkedin/pinot/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/pinot/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/pinot/tags","blobs_url":"https://api.github.com/repos/linkedin/pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/pinot/languages","stargazers_url":"https://api.github.com/repos/linkedin/pinot/stargazers","contributors_url":"https://api.github.com/repos/linkedin/pinot/contributors","subscribers_url":"https://api.github.com/repos/linkedin/pinot/subscribers","subscription_url":"https://api.github.com/repos/linkedin/pinot/subscription","commits_url":"https://api.github.com/repos/linkedin/pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/pinot/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/pinot/merges","archive_url":"https://api.github.com/repos/linkedin/pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/pinot/downloads","issues_url":"https://api.github.com/repos/linkedin/pinot/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/pinot/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/pinot/releases{/id}","deployments_url":"https://api.github.com/repos/linkedin/pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2018-10-11T03:25:31Z","pushed_at":"2018-10-11T02:41:14Z","git_url":"git://github.com/linkedin/pinot.git","ssh_url":"git@github.com:linkedin/pinot.git","clone_url":"https://github.com/linkedin/pinot.git","svn_url":"https://github.com/linkedin/pinot","homepage":"https://github.com/linkedin/pinot/wiki","size":156134,"stargazers_count":1985,"watchers_count":1985,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":356,"mirror_url":null,"archived":false,"open_issues_count":182,"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":356,"open_issues":182,"watchers":1985,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/3264"},"html":{"href":"https://github.com/linkedin/pinot/pull/3264"},"issue":{"href":"https://api.github.com/repos/linkedin/pinot/issues/3264"},"comments":{"href":"https://api.github.com/repos/linkedin/pinot/issues/3264/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/3264/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/3264/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/pinot/statuses/91fb2e74cc6f5b101bd7492015867e26ddd6acf0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sunithabeeram"}}