{"action":"created","comment":{"url":"https://api.github.com/repos/exodev/commons/pulls/comments/90639020","pull_request_review_id":11157778,"id":90639020,"diff_hunk":"@@ -0,0 +1,230 @@\n+package org.exoplatform.commons.cluster;\n+\n+import org.exoplatform.commons.api.settings.SettingService;\n+import org.exoplatform.commons.api.settings.SettingValue;\n+import org.exoplatform.commons.api.settings.data.Context;\n+import org.exoplatform.commons.api.settings.data.Scope;\n+import org.exoplatform.commons.chromattic.ChromatticManager;\n+import org.exoplatform.commons.utils.CommonsUtils;\n+import org.exoplatform.commons.utils.PropertyManager;\n+import org.exoplatform.commons.utils.SecurityHelper;\n+import org.exoplatform.container.ExoContainer;\n+import org.exoplatform.container.ExoContainerContext;\n+import org.exoplatform.container.spi.ComponentAdapter;\n+import org.exoplatform.container.xml.InitParams;\n+import org.exoplatform.services.log.ExoLogger;\n+import org.exoplatform.services.log.Log;\n+import org.exoplatform.settings.impl.SettingServiceImpl;\n+import org.picocontainer.Startable;\n+\n+import java.security.PrivilegedAction;\n+import java.util.*;\n+\n+/**\n+ * This service allow to running a specific service (implements ClusterAware interface) on one cluster node.\n+ */\n+public class StartableClusterService implements Startable {\n+\n+    private static final Log LOG = ExoLogger.getLogger(StartableClusterService.class);\n+\n+    private ExoContainer container;\n+    private SettingService settingService;\n+\n+    /**\n+     * Registers shutdown hook.\n+     */\n+    private final Thread hook = new ShutdownThread();\n+\n+    /**\n+     * Timer to schedule check runnable cluster aware service after some idle time.\n+     */\n+    private static final Timer CLUSTER_AWARE_TIMER = new Timer(\"CLUSTER AWARE Timer\", true);\n+\n+    /**\n+     * Task that is periodically called by {@link #CLUSTER_AWARE_TIMER} and checks if\n+     * service should be started\n+     */\n+    private TimerTask task;\n+\n+\n+    private static final String CLUSTER_NODE_NAME = \"exo.cluster.node.name\";\n+    private static final String CLUSTER_CHECK_PERIOD = \"exo.cluster.check.period\";\n+    private static final String EXO_PROFILE = \"exo.profiles\";\n+    private static final String SETTING_LIFECYCLE = \"setting\";\n+    private static final String CLUSTER_SERVICE_SETTING_GLOBAL_KEY = \"CLUSTER_SERVICE_SETTING_GLOBAL_KEY\";","path":"commons-component-common/src/main/java/org/exoplatform/commons/cluster/StartableClusterService.java","position":54,"original_position":54,"commit_id":"90bac54a2453bbe24c4e03a72f0f49fac2b3d4ea","original_commit_id":"90bac54a2453bbe24c4e03a72f0f49fac2b3d4ea","user":{"login":"thomasdelhomenie","id":342645,"avatar_url":"https://avatars.githubusercontent.com/u/342645?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasdelhomenie","html_url":"https://github.com/thomasdelhomenie","followers_url":"https://api.github.com/users/thomasdelhomenie/followers","following_url":"https://api.github.com/users/thomasdelhomenie/following{/other_user}","gists_url":"https://api.github.com/users/thomasdelhomenie/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasdelhomenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasdelhomenie/subscriptions","organizations_url":"https://api.github.com/users/thomasdelhomenie/orgs","repos_url":"https://api.github.com/users/thomasdelhomenie/repos","events_url":"https://api.github.com/users/thomasdelhomenie/events{/privacy}","received_events_url":"https://api.github.com/users/thomasdelhomenie/received_events","type":"User","site_admin":false},"body":"No need to suffix the value with \"SETTING_GLOBAL_KEY\". I would rename it to \"CLUSTER_STARTABLE_SERVICE\".","created_at":"2016-12-02T13:09:53Z","updated_at":"2016-12-02T13:09:53Z","html_url":"https://github.com/exodev/commons/pull/76#discussion_r90639020","pull_request_url":"https://api.github.com/repos/exodev/commons/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/exodev/commons/pulls/comments/90639020"},"html":{"href":"https://github.com/exodev/commons/pull/76#discussion_r90639020"},"pull_request":{"href":"https://api.github.com/repos/exodev/commons/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/exodev/commons/pulls/76","id":94206027,"html_url":"https://github.com/exodev/commons/pull/76","diff_url":"https://github.com/exodev/commons/pull/76.diff","patch_url":"https://github.com/exodev/commons/pull/76.patch","issue_url":"https://api.github.com/repos/exodev/commons/issues/76","number":76,"state":"open","locked":false,"title":"COMMONS-509 : ClusterAwar API","user":{"login":"aboughzela","id":1576285,"avatar_url":"https://avatars.githubusercontent.com/u/1576285?v=3","gravatar_id":"","url":"https://api.github.com/users/aboughzela","html_url":"https://github.com/aboughzela","followers_url":"https://api.github.com/users/aboughzela/followers","following_url":"https://api.github.com/users/aboughzela/following{/other_user}","gists_url":"https://api.github.com/users/aboughzela/gists{/gist_id}","starred_url":"https://api.github.com/users/aboughzela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aboughzela/subscriptions","organizations_url":"https://api.github.com/users/aboughzela/orgs","repos_url":"https://api.github.com/users/aboughzela/repos","events_url":"https://api.github.com/users/aboughzela/events{/privacy}","received_events_url":"https://api.github.com/users/aboughzela/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-17T16:51:10Z","updated_at":"2016-12-02T13:18:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d442dc4b4386f90f051a9c5b36f6ac6b2d4b78e7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/exodev/commons/pulls/76/commits","review_comments_url":"https://api.github.com/repos/exodev/commons/pulls/76/comments","review_comment_url":"https://api.github.com/repos/exodev/commons/pulls/comments{/number}","comments_url":"https://api.github.com/repos/exodev/commons/issues/76/comments","statuses_url":"https://api.github.com/repos/exodev/commons/statuses/90bac54a2453bbe24c4e03a72f0f49fac2b3d4ea","head":{"label":"exodev:fix/COMMONS-509","ref":"fix/COMMONS-509","sha":"90bac54a2453bbe24c4e03a72f0f49fac2b3d4ea","user":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"repo":{"id":3999538,"name":"commons","full_name":"exodev/commons","owner":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exodev/commons","description":"eXo Commons","fork":true,"url":"https://api.github.com/repos/exodev/commons","forks_url":"https://api.github.com/repos/exodev/commons/forks","keys_url":"https://api.github.com/repos/exodev/commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exodev/commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exodev/commons/teams","hooks_url":"https://api.github.com/repos/exodev/commons/hooks","issue_events_url":"https://api.github.com/repos/exodev/commons/issues/events{/number}","events_url":"https://api.github.com/repos/exodev/commons/events","assignees_url":"https://api.github.com/repos/exodev/commons/assignees{/user}","branches_url":"https://api.github.com/repos/exodev/commons/branches{/branch}","tags_url":"https://api.github.com/repos/exodev/commons/tags","blobs_url":"https://api.github.com/repos/exodev/commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exodev/commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exodev/commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/exodev/commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exodev/commons/statuses/{sha}","languages_url":"https://api.github.com/repos/exodev/commons/languages","stargazers_url":"https://api.github.com/repos/exodev/commons/stargazers","contributors_url":"https://api.github.com/repos/exodev/commons/contributors","subscribers_url":"https://api.github.com/repos/exodev/commons/subscribers","subscription_url":"https://api.github.com/repos/exodev/commons/subscription","commits_url":"https://api.github.com/repos/exodev/commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/exodev/commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/exodev/commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/exodev/commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/exodev/commons/contents/{+path}","compare_url":"https://api.github.com/repos/exodev/commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exodev/commons/merges","archive_url":"https://api.github.com/repos/exodev/commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exodev/commons/downloads","issues_url":"https://api.github.com/repos/exodev/commons/issues{/number}","pulls_url":"https://api.github.com/repos/exodev/commons/pulls{/number}","milestones_url":"https://api.github.com/repos/exodev/commons/milestones{/number}","notifications_url":"https://api.github.com/repos/exodev/commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exodev/commons/labels{/name}","releases_url":"https://api.github.com/repos/exodev/commons/releases{/id}","deployments_url":"https://api.github.com/repos/exodev/commons/deployments","created_at":"2012-04-11T23:36:57Z","updated_at":"2016-08-30T21:02:19Z","pushed_at":"2016-12-01T18:51:02Z","git_url":"git://github.com/exodev/commons.git","ssh_url":"git@github.com:exodev/commons.git","clone_url":"https://github.com/exodev/commons.git","svn_url":"https://github.com/exodev/commons","homepage":null,"size":17357,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":11,"forks":19,"open_issues":11,"watchers":3,"default_branch":"develop"}},"base":{"label":"exodev:develop","ref":"develop","sha":"b0af969ada03ddb4f7aea966c64d26d5bff64e69","user":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"repo":{"id":3999538,"name":"commons","full_name":"exodev/commons","owner":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exodev/commons","description":"eXo Commons","fork":true,"url":"https://api.github.com/repos/exodev/commons","forks_url":"https://api.github.com/repos/exodev/commons/forks","keys_url":"https://api.github.com/repos/exodev/commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exodev/commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exodev/commons/teams","hooks_url":"https://api.github.com/repos/exodev/commons/hooks","issue_events_url":"https://api.github.com/repos/exodev/commons/issues/events{/number}","events_url":"https://api.github.com/repos/exodev/commons/events","assignees_url":"https://api.github.com/repos/exodev/commons/assignees{/user}","branches_url":"https://api.github.com/repos/exodev/commons/branches{/branch}","tags_url":"https://api.github.com/repos/exodev/commons/tags","blobs_url":"https://api.github.com/repos/exodev/commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exodev/commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exodev/commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/exodev/commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exodev/commons/statuses/{sha}","languages_url":"https://api.github.com/repos/exodev/commons/languages","stargazers_url":"https://api.github.com/repos/exodev/commons/stargazers","contributors_url":"https://api.github.com/repos/exodev/commons/contributors","subscribers_url":"https://api.github.com/repos/exodev/commons/subscribers","subscription_url":"https://api.github.com/repos/exodev/commons/subscription","commits_url":"https://api.github.com/repos/exodev/commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/exodev/commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/exodev/commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/exodev/commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/exodev/commons/contents/{+path}","compare_url":"https://api.github.com/repos/exodev/commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exodev/commons/merges","archive_url":"https://api.github.com/repos/exodev/commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exodev/commons/downloads","issues_url":"https://api.github.com/repos/exodev/commons/issues{/number}","pulls_url":"https://api.github.com/repos/exodev/commons/pulls{/number}","milestones_url":"https://api.github.com/repos/exodev/commons/milestones{/number}","notifications_url":"https://api.github.com/repos/exodev/commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exodev/commons/labels{/name}","releases_url":"https://api.github.com/repos/exodev/commons/releases{/id}","deployments_url":"https://api.github.com/repos/exodev/commons/deployments","created_at":"2012-04-11T23:36:57Z","updated_at":"2016-08-30T21:02:19Z","pushed_at":"2016-12-01T18:51:02Z","git_url":"git://github.com/exodev/commons.git","ssh_url":"git@github.com:exodev/commons.git","clone_url":"https://github.com/exodev/commons.git","svn_url":"https://github.com/exodev/commons","homepage":null,"size":17357,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":11,"forks":19,"open_issues":11,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/exodev/commons/pulls/76"},"html":{"href":"https://github.com/exodev/commons/pull/76"},"issue":{"href":"https://api.github.com/repos/exodev/commons/issues/76"},"comments":{"href":"https://api.github.com/repos/exodev/commons/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/exodev/commons/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/exodev/commons/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/exodev/commons/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/exodev/commons/statuses/90bac54a2453bbe24c4e03a72f0f49fac2b3d4ea"}}}}
{"actor":{"display_login":"thomasdelhomenie"}}