{"action":"created","comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/comments/90021849","pull_request_review_id":10538121,"id":90021849,"diff_hunk":"@@ -0,0 +1,157 @@\n+/*\n+ * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.\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.hazelcast.scheduledexecutor.impl;\n+\n+import com.hazelcast.core.DistributedObject;\n+import com.hazelcast.spi.ManagedService;\n+import com.hazelcast.spi.MigrationAwareService;\n+import com.hazelcast.spi.NodeEngine;\n+import com.hazelcast.spi.Operation;\n+import com.hazelcast.spi.PartitionMigrationEvent;\n+import com.hazelcast.spi.PartitionReplicationEvent;\n+import com.hazelcast.spi.RemoteService;\n+import com.hazelcast.spi.impl.executionservice.InternalExecutionService;\n+import com.hazelcast.spi.partition.MigrationEndpoint;\n+\n+import java.util.Properties;\n+import java.util.concurrent.ConcurrentHashMap;\n+import java.util.concurrent.ConcurrentMap;\n+\n+public class DistributedScheduledExecutorService\n+        implements ManagedService, RemoteService, MigrationAwareService {\n+\n+    public static final String SERVICE_NAME = \"hz:impl:scheduledExecutorService\";\n+\n+    public static final int MEMBER_PARTITION = -1;\n+\n+    private NodeEngine nodeEngine;\n+\n+    private ScheduledExecutorPartition[] partitions;\n+\n+    private ScheduledExecutorPartition memberPartition;\n+\n+    private final ConcurrentMap<String, Boolean> shutdownExecutors\n+            = new ConcurrentHashMap<String, Boolean>();\n+\n+    public DistributedScheduledExecutorService() {\n+    }\n+\n+    @Override\n+    public void init(NodeEngine nodeEngine, Properties properties) {\n+        int partitionCount = nodeEngine.getPartitionService().getPartitionCount();\n+        this.nodeEngine = nodeEngine;\n+        this.partitions = new ScheduledExecutorPartition[partitionCount];\n+        reset();\n+    }\n+\n+    public ScheduledExecutorPartition getPartition(int partitionId) {\n+        if (partitionId == MEMBER_PARTITION) {\n+            return memberPartition;\n+        }\n+\n+        return partitions[partitionId];\n+    }\n+\n+    public NodeEngine getNodeEngine() {\n+        return nodeEngine;\n+    }\n+\n+    @Override\n+    public void reset() {\n+        shutdown(true);\n+\n+        memberPartition = new ScheduledExecutorPartition(nodeEngine, MEMBER_PARTITION);\n+\n+        for (int partitionId = 0; partitionId < partitions.length; partitionId++) {\n+            if (partitions[partitionId] != null) {\n+                partitions[partitionId].destroy();\n+            }\n+            partitions[partitionId] = new ScheduledExecutorPartition(nodeEngine, partitionId);\n+        }\n+    }\n+\n+    @Override\n+    public void shutdown(boolean terminate) {\n+        shutdownExecutors.clear();\n+\n+        if (memberPartition != null) {\n+            memberPartition.destroy();\n+        }\n+\n+        for (int partitionId = 0; partitionId < partitions.length; partitionId++) {\n+            if (partitions[partitionId] != null) {\n+                partitions[partitionId].destroy();\n+            }\n+        }\n+    }\n+\n+    @Override\n+    public DistributedObject createDistributedObject(String name) {\n+        return new ScheduledExecutorServiceProxy(name, nodeEngine, this);\n+    }\n+\n+    @Override\n+    public void destroyDistributedObject(String name) {\n+        if (shutdownExecutors.remove(name) != null) {","path":"hazelcast/src/main/java/com/hazelcast/scheduledexecutor/impl/DistributedScheduledExecutorService.java","position":109,"original_position":109,"commit_id":"d7a1948a4591999cbadec03822bf30a1355b7478","original_commit_id":"d7a1948a4591999cbadec03822bf30a1355b7478","user":{"login":"mmedenjak","id":17194871,"avatar_url":"https://avatars.githubusercontent.com/u/17194871?v=3","gravatar_id":"","url":"https://api.github.com/users/mmedenjak","html_url":"https://github.com/mmedenjak","followers_url":"https://api.github.com/users/mmedenjak/followers","following_url":"https://api.github.com/users/mmedenjak/following{/other_user}","gists_url":"https://api.github.com/users/mmedenjak/gists{/gist_id}","starred_url":"https://api.github.com/users/mmedenjak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmedenjak/subscriptions","organizations_url":"https://api.github.com/users/mmedenjak/orgs","repos_url":"https://api.github.com/users/mmedenjak/repos","events_url":"https://api.github.com/users/mmedenjak/events{/privacy}","received_events_url":"https://api.github.com/users/mmedenjak/received_events","type":"User","site_admin":false},"body":"So `InternalExecutionService#shutdownDurableExecutor` is called only if previously `DistributedScheduledExecutorService#shutdownExecutor` has been called?","created_at":"2016-11-29T14:44:31Z","updated_at":"2016-11-29T14:45:54Z","html_url":"https://github.com/hazelcast/hazelcast/pull/9087#discussion_r90021849","pull_request_url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087","_links":{"self":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/comments/90021849"},"html":{"href":"https://github.com/hazelcast/hazelcast/pull/9087#discussion_r90021849"},"pull_request":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087"}}},"pull_request":{"url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087","id":88792812,"html_url":"https://github.com/hazelcast/hazelcast/pull/9087","diff_url":"https://github.com/hazelcast/hazelcast/pull/9087.diff","patch_url":"https://github.com/hazelcast/hazelcast/pull/9087.patch","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/9087","number":9087,"state":"open","locked":false,"title":"Distributed scheduled executor service","user":{"login":"tkountis","id":3369598,"avatar_url":"https://avatars.githubusercontent.com/u/3369598?v=3","gravatar_id":"","url":"https://api.github.com/users/tkountis","html_url":"https://github.com/tkountis","followers_url":"https://api.github.com/users/tkountis/followers","following_url":"https://api.github.com/users/tkountis/following{/other_user}","gists_url":"https://api.github.com/users/tkountis/gists{/gist_id}","starred_url":"https://api.github.com/users/tkountis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkountis/subscriptions","organizations_url":"https://api.github.com/users/tkountis/orgs","repos_url":"https://api.github.com/users/tkountis/repos","events_url":"https://api.github.com/users/tkountis/events{/privacy}","received_events_url":"https://api.github.com/users/tkountis/received_events","type":"User","site_admin":false},"body":"Distributed & durable implementation of j.u.c.ScheduledExecutor (fixing #115) provides similar API to the ScheduledExecutorService with some exceptions but also additional methods like scheduling tasks on a specific member, on a member who is owner of a specific key, executing a tasks on multiple members etc.\r\n\r\n- Durable tasks that get re-scheduled on replica nodes in the event of node loss.\r\n- Support for retrieving a task if the original reference was lost\r\n- Support for PartitionAware tasks\r\n- Support for Stateful jobs\r\n- Support for Named jobs\r\n- Support for managed context (HazecastInstanceAware)\r\n- Relying on Durable executors to run tasks\r\n","created_at":"2016-10-11T08:46:18Z","updated_at":"2016-11-29T14:45:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f70807aeb89eb80176ad39e130fbff19db6c84a","assignee":{"login":"tkountis","id":3369598,"avatar_url":"https://avatars.githubusercontent.com/u/3369598?v=3","gravatar_id":"","url":"https://api.github.com/users/tkountis","html_url":"https://github.com/tkountis","followers_url":"https://api.github.com/users/tkountis/followers","following_url":"https://api.github.com/users/tkountis/following{/other_user}","gists_url":"https://api.github.com/users/tkountis/gists{/gist_id}","starred_url":"https://api.github.com/users/tkountis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkountis/subscriptions","organizations_url":"https://api.github.com/users/tkountis/orgs","repos_url":"https://api.github.com/users/tkountis/repos","events_url":"https://api.github.com/users/tkountis/events{/privacy}","received_events_url":"https://api.github.com/users/tkountis/received_events","type":"User","site_admin":false},"assignees":[{"login":"tkountis","id":3369598,"avatar_url":"https://avatars.githubusercontent.com/u/3369598?v=3","gravatar_id":"","url":"https://api.github.com/users/tkountis","html_url":"https://github.com/tkountis","followers_url":"https://api.github.com/users/tkountis/followers","following_url":"https://api.github.com/users/tkountis/following{/other_user}","gists_url":"https://api.github.com/users/tkountis/gists{/gist_id}","starred_url":"https://api.github.com/users/tkountis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkountis/subscriptions","organizations_url":"https://api.github.com/users/tkountis/orgs","repos_url":"https://api.github.com/users/tkountis/repos","events_url":"https://api.github.com/users/tkountis/events{/privacy}","received_events_url":"https://api.github.com/users/tkountis/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087/commits","review_comments_url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087/comments","review_comment_url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/9087/comments","statuses_url":"https://api.github.com/repos/hazelcast/hazelcast/statuses/d7a1948a4591999cbadec03822bf30a1355b7478","head":{"label":"tkountis:feature/distributed_scheduled_exec","ref":"feature/distributed_scheduled_exec","sha":"d7a1948a4591999cbadec03822bf30a1355b7478","user":{"login":"tkountis","id":3369598,"avatar_url":"https://avatars.githubusercontent.com/u/3369598?v=3","gravatar_id":"","url":"https://api.github.com/users/tkountis","html_url":"https://github.com/tkountis","followers_url":"https://api.github.com/users/tkountis/followers","following_url":"https://api.github.com/users/tkountis/following{/other_user}","gists_url":"https://api.github.com/users/tkountis/gists{/gist_id}","starred_url":"https://api.github.com/users/tkountis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkountis/subscriptions","organizations_url":"https://api.github.com/users/tkountis/orgs","repos_url":"https://api.github.com/users/tkountis/repos","events_url":"https://api.github.com/users/tkountis/events{/privacy}","received_events_url":"https://api.github.com/users/tkountis/received_events","type":"User","site_admin":false},"repo":{"id":66834097,"name":"hazelcast","full_name":"tkountis/hazelcast","owner":{"login":"tkountis","id":3369598,"avatar_url":"https://avatars.githubusercontent.com/u/3369598?v=3","gravatar_id":"","url":"https://api.github.com/users/tkountis","html_url":"https://github.com/tkountis","followers_url":"https://api.github.com/users/tkountis/followers","following_url":"https://api.github.com/users/tkountis/following{/other_user}","gists_url":"https://api.github.com/users/tkountis/gists{/gist_id}","starred_url":"https://api.github.com/users/tkountis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkountis/subscriptions","organizations_url":"https://api.github.com/users/tkountis/orgs","repos_url":"https://api.github.com/users/tkountis/repos","events_url":"https://api.github.com/users/tkountis/events{/privacy}","received_events_url":"https://api.github.com/users/tkountis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tkountis/hazelcast","description":"Open Source In-Memory Data Grid","fork":true,"url":"https://api.github.com/repos/tkountis/hazelcast","forks_url":"https://api.github.com/repos/tkountis/hazelcast/forks","keys_url":"https://api.github.com/repos/tkountis/hazelcast/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkountis/hazelcast/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkountis/hazelcast/teams","hooks_url":"https://api.github.com/repos/tkountis/hazelcast/hooks","issue_events_url":"https://api.github.com/repos/tkountis/hazelcast/issues/events{/number}","events_url":"https://api.github.com/repos/tkountis/hazelcast/events","assignees_url":"https://api.github.com/repos/tkountis/hazelcast/assignees{/user}","branches_url":"https://api.github.com/repos/tkountis/hazelcast/branches{/branch}","tags_url":"https://api.github.com/repos/tkountis/hazelcast/tags","blobs_url":"https://api.github.com/repos/tkountis/hazelcast/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkountis/hazelcast/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkountis/hazelcast/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkountis/hazelcast/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkountis/hazelcast/statuses/{sha}","languages_url":"https://api.github.com/repos/tkountis/hazelcast/languages","stargazers_url":"https://api.github.com/repos/tkountis/hazelcast/stargazers","contributors_url":"https://api.github.com/repos/tkountis/hazelcast/contributors","subscribers_url":"https://api.github.com/repos/tkountis/hazelcast/subscribers","subscription_url":"https://api.github.com/repos/tkountis/hazelcast/subscription","commits_url":"https://api.github.com/repos/tkountis/hazelcast/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkountis/hazelcast/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkountis/hazelcast/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkountis/hazelcast/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkountis/hazelcast/contents/{+path}","compare_url":"https://api.github.com/repos/tkountis/hazelcast/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkountis/hazelcast/merges","archive_url":"https://api.github.com/repos/tkountis/hazelcast/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkountis/hazelcast/downloads","issues_url":"https://api.github.com/repos/tkountis/hazelcast/issues{/number}","pulls_url":"https://api.github.com/repos/tkountis/hazelcast/pulls{/number}","milestones_url":"https://api.github.com/repos/tkountis/hazelcast/milestones{/number}","notifications_url":"https://api.github.com/repos/tkountis/hazelcast/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkountis/hazelcast/labels{/name}","releases_url":"https://api.github.com/repos/tkountis/hazelcast/releases{/id}","deployments_url":"https://api.github.com/repos/tkountis/hazelcast/deployments","created_at":"2016-08-29T10:27:48Z","updated_at":"2016-08-29T10:28:03Z","pushed_at":"2016-11-29T01:18:54Z","git_url":"git://github.com/tkountis/hazelcast.git","ssh_url":"git@github.com:tkountis/hazelcast.git","clone_url":"https://github.com/tkountis/hazelcast.git","svn_url":"https://github.com/tkountis/hazelcast","homepage":"www.hazelcast.com","size":99783,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hazelcast:master","ref":"master","sha":"174b3db30e001c2a1b60d870cfcc3138f10edecc","user":{"login":"hazelcast","id":1453152,"avatar_url":"https://avatars.githubusercontent.com/u/1453152?v=3","gravatar_id":"","url":"https://api.github.com/users/hazelcast","html_url":"https://github.com/hazelcast","followers_url":"https://api.github.com/users/hazelcast/followers","following_url":"https://api.github.com/users/hazelcast/following{/other_user}","gists_url":"https://api.github.com/users/hazelcast/gists{/gist_id}","starred_url":"https://api.github.com/users/hazelcast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hazelcast/subscriptions","organizations_url":"https://api.github.com/users/hazelcast/orgs","repos_url":"https://api.github.com/users/hazelcast/repos","events_url":"https://api.github.com/users/hazelcast/events{/privacy}","received_events_url":"https://api.github.com/users/hazelcast/received_events","type":"Organization","site_admin":false},"repo":{"id":3786237,"name":"hazelcast","full_name":"hazelcast/hazelcast","owner":{"login":"hazelcast","id":1453152,"avatar_url":"https://avatars.githubusercontent.com/u/1453152?v=3","gravatar_id":"","url":"https://api.github.com/users/hazelcast","html_url":"https://github.com/hazelcast","followers_url":"https://api.github.com/users/hazelcast/followers","following_url":"https://api.github.com/users/hazelcast/following{/other_user}","gists_url":"https://api.github.com/users/hazelcast/gists{/gist_id}","starred_url":"https://api.github.com/users/hazelcast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hazelcast/subscriptions","organizations_url":"https://api.github.com/users/hazelcast/orgs","repos_url":"https://api.github.com/users/hazelcast/repos","events_url":"https://api.github.com/users/hazelcast/events{/privacy}","received_events_url":"https://api.github.com/users/hazelcast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hazelcast/hazelcast","description":"Open Source In-Memory Data Grid","fork":false,"url":"https://api.github.com/repos/hazelcast/hazelcast","forks_url":"https://api.github.com/repos/hazelcast/hazelcast/forks","keys_url":"https://api.github.com/repos/hazelcast/hazelcast/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hazelcast/hazelcast/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hazelcast/hazelcast/teams","hooks_url":"https://api.github.com/repos/hazelcast/hazelcast/hooks","issue_events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/events{/number}","events_url":"https://api.github.com/repos/hazelcast/hazelcast/events","assignees_url":"https://api.github.com/repos/hazelcast/hazelcast/assignees{/user}","branches_url":"https://api.github.com/repos/hazelcast/hazelcast/branches{/branch}","tags_url":"https://api.github.com/repos/hazelcast/hazelcast/tags","blobs_url":"https://api.github.com/repos/hazelcast/hazelcast/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hazelcast/hazelcast/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hazelcast/hazelcast/git/refs{/sha}","trees_url":"https://api.github.com/repos/hazelcast/hazelcast/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hazelcast/hazelcast/statuses/{sha}","languages_url":"https://api.github.com/repos/hazelcast/hazelcast/languages","stargazers_url":"https://api.github.com/repos/hazelcast/hazelcast/stargazers","contributors_url":"https://api.github.com/repos/hazelcast/hazelcast/contributors","subscribers_url":"https://api.github.com/repos/hazelcast/hazelcast/subscribers","subscription_url":"https://api.github.com/repos/hazelcast/hazelcast/subscription","commits_url":"https://api.github.com/repos/hazelcast/hazelcast/commits{/sha}","git_commits_url":"https://api.github.com/repos/hazelcast/hazelcast/git/commits{/sha}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/comments{/number}","issue_comment_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments{/number}","contents_url":"https://api.github.com/repos/hazelcast/hazelcast/contents/{+path}","compare_url":"https://api.github.com/repos/hazelcast/hazelcast/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hazelcast/hazelcast/merges","archive_url":"https://api.github.com/repos/hazelcast/hazelcast/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hazelcast/hazelcast/downloads","issues_url":"https://api.github.com/repos/hazelcast/hazelcast/issues{/number}","pulls_url":"https://api.github.com/repos/hazelcast/hazelcast/pulls{/number}","milestones_url":"https://api.github.com/repos/hazelcast/hazelcast/milestones{/number}","notifications_url":"https://api.github.com/repos/hazelcast/hazelcast/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/labels{/name}","releases_url":"https://api.github.com/repos/hazelcast/hazelcast/releases{/id}","deployments_url":"https://api.github.com/repos/hazelcast/hazelcast/deployments","created_at":"2012-03-21T12:25:18Z","updated_at":"2016-11-29T06:09:30Z","pushed_at":"2016-11-29T13:46:00Z","git_url":"git://github.com/hazelcast/hazelcast.git","ssh_url":"git@github.com:hazelcast/hazelcast.git","clone_url":"https://github.com/hazelcast/hazelcast.git","svn_url":"https://github.com/hazelcast/hazelcast","homepage":"www.hazelcast.com","size":137590,"stargazers_count":1813,"watchers_count":1813,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":832,"mirror_url":null,"open_issues_count":638,"forks":832,"open_issues":638,"watchers":1813,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087"},"html":{"href":"https://github.com/hazelcast/hazelcast/pull/9087"},"issue":{"href":"https://api.github.com/repos/hazelcast/hazelcast/issues/9087"},"comments":{"href":"https://api.github.com/repos/hazelcast/hazelcast/issues/9087/comments"},"review_comments":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087/comments"},"review_comment":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hazelcast/hazelcast/pulls/9087/commits"},"statuses":{"href":"https://api.github.com/repos/hazelcast/hazelcast/statuses/d7a1948a4591999cbadec03822bf30a1355b7478"}}}}
{"actor":{"display_login":"mmedenjak"}}