{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/77725664","id":77725664,"diff_hunk":"@@ -128,97 +129,104 @@ public void processExistingRecoveries(RoutingAllocation allocation) {\n         }\n     }\n \n-    public void allocateUnassigned(RoutingAllocation allocation) {\n-        final RoutingNodes routingNodes = allocation.routingNodes();\n-        final RoutingNodes.UnassignedShards.UnassignedIterator unassignedIterator = routingNodes.unassigned().iterator();\n-        while (unassignedIterator.hasNext()) {\n-            ShardRouting shard = unassignedIterator.next();\n-            if (shard.primary()) {\n-                continue;\n-            }\n+    /**\n+     * Is the allocator responsible for allocating the given {@link ShardRouting}?\n+     */\n+    private static boolean isResponsibleFor(final ShardRouting shard) {\n+        return shard.primary() == false // must be a replica\n+                   && shard.unassigned() // must be unassigned\n+                   // if we are allocating a replica because of index creation, no need to go and find a copy, there isn't one...\n+                   && shard.unassignedInfo().getReason() != UnassignedInfo.Reason.INDEX_CREATED;\n+    }\n \n-            // if we are allocating a replica because of index creation, no need to go and find a copy, there isn't one...\n-            if (shard.unassignedInfo().getReason() == UnassignedInfo.Reason.INDEX_CREATED) {\n-                continue;\n-            }\n+    @Override\n+    public UnassignedShardDecision makeAllocationDecision(final ShardRouting unassignedShard,\n+                                                          final RoutingAllocation allocation,\n+                                                          final boolean explain,\n+                                                          final Logger logger) {\n+        if (isResponsibleFor(unassignedShard) == false) {\n+            // this allocator is not responsible for deciding on this shard\n+            return UnassignedShardDecision.DECISION_NOT_TAKEN;\n+        }\n \n-            // pre-check if it can be allocated to any node that currently exists, so we won't list the store for it for nothing\n-            Decision decision = canBeAllocatedToAtLeastOneNode(shard, allocation);\n-            if (decision.type() != Decision.Type.YES) {\n-                logger.trace(\"{}: ignoring allocation, can't be allocated on any node\", shard);\n-                unassignedIterator.removeAndIgnore(UnassignedInfo.AllocationStatus.fromDecision(decision), allocation.changes());\n-                continue;\n-            }\n+        final RoutingNodes routingNodes = allocation.routingNodes();\n+        // pre-check if it can be allocated to any node that currently exists, so we won't list the store for it for nothing\n+        Tuple<Decision, Map<String, Decision>> allocateDecision = canBeAllocatedToAtLeastOneNode(unassignedShard, allocation, explain);\n+        if (allocateDecision.v1().type() != Decision.Type.YES) {\n+            logger.trace(\"{}: ignoring allocation, can't be allocated on any node\", unassignedShard);\n+            return UnassignedShardDecision.noDecision(UnassignedInfo.AllocationStatus.fromDecision(allocateDecision.v1()),\n+                \"all nodes received a NO decision for allocating the replica shard\", allocateDecision.v2());","path":"core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java","position":96,"original_position":96,"commit_id":"f127ae13428bf616443c9e2c5c97da78ae04d7e3","original_commit_id":"f127ae13428bf616443c9e2c5c97da78ae04d7e3","user":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"body":"This explanation doesn't include nodes returning THROTTLE","created_at":"2016-09-06T21:52:24Z","updated_at":"2016-09-06T21:52:24Z","html_url":"https://github.com/elastic/elasticsearch/pull/20347#discussion_r77725664","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/77725664"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20347#discussion_r77725664"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347","id":84184053,"html_url":"https://github.com/elastic/elasticsearch/pull/20347","diff_url":"https://github.com/elastic/elasticsearch/pull/20347.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/20347.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20347","number":20347,"state":"open","locked":false,"title":"Split allocator decision making from decision application ","user":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"body":"Splits the PrimaryShardAllocator and ReplicaShardAllocator's decision \r\nmaking for a shard from the implementation of that decision on the\r\nrouting table. This is a step toward making it easier to use the same\r\nlogic for the cluster allocation explain APIs.\r\n\r\nA subsequent PR will split the decision making and decision application\r\nfor the BalancedShardsAllocator.","created_at":"2016-09-06T19:45:48Z","updated_at":"2016-09-06T21:52:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51cebf08850819e33932b9c8ec6eec3a2e15bd5b","assignee":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"assignees":[{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20347/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/f127ae13428bf616443c9e2c5c97da78ae04d7e3","head":{"label":"abeyad:allocators-decision-refactor","ref":"allocators-decision-refactor","sha":"f127ae13428bf616443c9e2c5c97da78ae04d7e3","user":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"repo":{"id":48216890,"name":"elasticsearch","full_name":"abeyad/elasticsearch","owner":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abeyad/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/abeyad/elasticsearch","forks_url":"https://api.github.com/repos/abeyad/elasticsearch/forks","keys_url":"https://api.github.com/repos/abeyad/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abeyad/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abeyad/elasticsearch/teams","hooks_url":"https://api.github.com/repos/abeyad/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/abeyad/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/abeyad/elasticsearch/events","assignees_url":"https://api.github.com/repos/abeyad/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/abeyad/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/abeyad/elasticsearch/tags","blobs_url":"https://api.github.com/repos/abeyad/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abeyad/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abeyad/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/abeyad/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abeyad/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/abeyad/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/abeyad/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/abeyad/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/abeyad/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/abeyad/elasticsearch/subscription","commits_url":"https://api.github.com/repos/abeyad/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/abeyad/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/abeyad/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/abeyad/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/abeyad/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/abeyad/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abeyad/elasticsearch/merges","archive_url":"https://api.github.com/repos/abeyad/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abeyad/elasticsearch/downloads","issues_url":"https://api.github.com/repos/abeyad/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/abeyad/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/abeyad/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/abeyad/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abeyad/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/abeyad/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/abeyad/elasticsearch/deployments","created_at":"2015-12-18T05:46:26Z","updated_at":"2016-07-06T05:16:50Z","pushed_at":"2016-09-06T19:42:39Z","git_url":"git://github.com/abeyad/elasticsearch.git","ssh_url":"git@github.com:abeyad/elasticsearch.git","clone_url":"https://github.com/abeyad/elasticsearch.git","svn_url":"https://github.com/abeyad/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":238220,"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":"elastic:master","ref":"master","sha":"eb9d2b66591db01f4e5c7016971c18ba0f5315d3","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-09-06T17:50:45Z","pushed_at":"2016-09-06T21:14:35Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":345602,"stargazers_count":18288,"watchers_count":18288,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6219,"mirror_url":null,"open_issues_count":1143,"forks":6219,"open_issues":1143,"watchers":18288,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20347"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20347"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20347/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20347/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/f127ae13428bf616443c9e2c5c97da78ae04d7e3"}}}}
{"actor":{"display_login":"dakrone"}}