{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/34557302","id":34557302,"diff_hunk":"@@ -0,0 +1,383 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * 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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.elasticsearch.action.admin.indices.shards;\n+\n+import com.carrotsearch.hppc.cursors.IntObjectCursor;\n+import com.carrotsearch.hppc.cursors.ObjectObjectCursor;\n+import com.google.common.collect.ImmutableList;\n+import org.elasticsearch.ElasticsearchException;\n+import org.elasticsearch.action.ActionResponse;\n+import org.elasticsearch.action.ShardOperationFailedException;\n+import org.elasticsearch.action.support.DefaultShardOperationFailedException;\n+import org.elasticsearch.cluster.node.DiscoveryNode;\n+import org.elasticsearch.common.collect.ImmutableOpenIntMap;\n+import org.elasticsearch.common.collect.ImmutableOpenMap;\n+import org.elasticsearch.common.io.stream.StreamInput;\n+import org.elasticsearch.common.io.stream.StreamOutput;\n+import org.elasticsearch.common.io.stream.Streamable;\n+import org.elasticsearch.common.xcontent.ToXContent;\n+import org.elasticsearch.common.xcontent.XContentBuilder;\n+import org.elasticsearch.common.xcontent.XContentBuilderString;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import static org.elasticsearch.ExceptionsHelper.detailedMessage;\n+import static org.elasticsearch.action.admin.indices.shards.IndicesShardsStoresResponse.StoreStatus.*;\n+\n+/**\n+ * Response for {@link IndicesShardsStoresAction}\n+ *\n+ * Consists of {@link StoreStatus}s for requested indices grouped by\n+ * indices and shard ids and a list of encountered node {@link Failure}s\n+ */\n+public class IndicesShardsStoresResponse extends ActionResponse implements ToXContent {\n+\n+    /**\n+     * Shard store information from a node\n+     */\n+    public static class StoreStatus implements Streamable, ToXContent, Comparable<StoreStatus> {\n+        private DiscoveryNode node;\n+        private long version;\n+        private Throwable storeException;\n+        private Allocation allocation;\n+\n+        /**\n+         * The status of the shard store with respect to the cluster\n+         */\n+        public enum Allocation {\n+\n+            /**\n+             * Allocated as primary\n+             */\n+            PRIMARY((byte) 0),\n+\n+            /**\n+             * Allocated as a replica\n+             */\n+            REPLICA((byte) 1),\n+\n+            /**\n+             * Not allocated\n+             */\n+            UNUSED((byte) 2);\n+\n+            private final byte id;\n+\n+            Allocation(byte id) {\n+                this.id = id;\n+            }\n+\n+            private static Allocation fromId(byte id) {\n+                switch (id) {\n+                    case 0: return PRIMARY;\n+                    case 1: return REPLICA;\n+                    case 2: return UNUSED;\n+                    default: throw new IllegalArgumentException(\"unknown id for allocation [\" + id + \"]\");\n+                }\n+            }\n+\n+            public String value() {\n+                switch (id) {\n+                    case 0: return \"primary\";\n+                    case 1: return \"replica\";\n+                    case 2: return \"unused\";\n+                    default: throw new IllegalArgumentException(\"unknown id for allocation [\" + id + \"]\");\n+                }\n+            }\n+\n+            private static Allocation readFrom(StreamInput in) throws IOException {\n+                return fromId(in.readByte());\n+            }\n+\n+            private void writeTo(StreamOutput out) throws IOException {\n+                out.writeByte(id);\n+            }\n+        }\n+\n+        private StoreStatus() {\n+        }\n+\n+        public StoreStatus(DiscoveryNode node, long version, Allocation allocation, Throwable storeException) {\n+            this.node = node;\n+            this.version = version;\n+            this.allocation = allocation;\n+            this.storeException = storeException;\n+        }\n+\n+        /**\n+         * Node the shard belongs to\n+         */\n+        public DiscoveryNode getNode() {\n+            return node;\n+        }\n+\n+        /**\n+         * Version of the shard, used to select the store that will be","path":"core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardsStoresResponse.java","position":134,"original_position":134,"commit_id":"792ade6ca1e7323583e58607a7be337c566b63d2","original_commit_id":"792ade6ca1e7323583e58607a7be337c566b63d2","user":{"login":"bleskes","id":1006375,"avatar_url":"https://avatars.githubusercontent.com/u/1006375?v=3","gravatar_id":"","url":"https://api.github.com/users/bleskes","html_url":"https://github.com/bleskes","followers_url":"https://api.github.com/users/bleskes/followers","following_url":"https://api.github.com/users/bleskes/following{/other_user}","gists_url":"https://api.github.com/users/bleskes/gists{/gist_id}","starred_url":"https://api.github.com/users/bleskes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleskes/subscriptions","organizations_url":"https://api.github.com/users/bleskes/orgs","repos_url":"https://api.github.com/users/bleskes/repos","events_url":"https://api.github.com/users/bleskes/events{/privacy}","received_events_url":"https://api.github.com/users/bleskes/received_events","type":"User","site_admin":false},"body":"shard -> store","created_at":"2015-07-14T11:08:53Z","updated_at":"2015-07-14T11:08:53Z","html_url":"https://github.com/elastic/elasticsearch/pull/11545#discussion_r34557302","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/34557302"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/11545#discussion_r34557302"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545","id":37203622,"html_url":"https://github.com/elastic/elasticsearch/pull/11545","diff_url":"https://github.com/elastic/elasticsearch/pull/11545.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/11545.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11545","number":11545,"state":"open","locked":false,"title":"Add an API to locate unrecovered shards and their state","user":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"body":"This API provides store information for shard copies of indices.\r\nStore information reports on which nodes shard copies exist, the shard\r\ncopy version, indicating how recent they are, and any exceptions\r\nencountered while opening the shard index or from earlier engine failure.\r\n\r\nBy default, only lists store information for shards that have at least one\r\nunallocated copy. When the cluster `status` is yellow, this will list store\r\ninformation for shards that have at least one unassigned replica. When the\r\ncluster `status` is red, this will list store information for shards, which\r\nhas unassigned primaries.\r\n\r\nEndpoints include shard stores information for a specific index, several\r\nindices, or all:\r\n\r\n```bash\r\ncurl -XGET 'http://localhost:9200/test/_shard_stores'\r\ncurl -XGET 'http://localhost:9200/test1,test2/_shard_stores'\r\ncurl -XGET 'http://localhost:9200/_shard_stores'\r\n```\r\n\r\nThe default scope of shards to list store information can be changed through\r\n`status` param. Defaults to 'yellow' and 'red'. 'yellow' lists store information of \r\nshards with at least one unassigned replica and 'red' for shards with unassigned\r\nprimary shard.\r\nUse 'green' to list store information for shards with all assigned copies and 'all' for\r\nstore information on all shards.\r\n\r\n```bash\r\ncurl -XGET 'http://localhost:9200/_shard_stores?status=all'\r\n```\r\n\r\nResponse:\r\n\r\nThe shard stores information is grouped by indices and shard ids.\r\n\r\n```bash\r\n{\r\n    ...\r\n   \"0\": { <1>\r\n        \"stores\": [ <2>\r\n            {\r\n                \"sPa3OgxLSYGvQ4oPs-Tajw\": { <3>\r\n                    \"name\": \"node_t0\",\r\n                    \"transport_address\": \"local[1]\",\r\n                    \"attributes\": {\r\n                        \"enable_custom_paths\": \"true\",\r\n                        \"mode\": \"local\"\r\n                    }\r\n                },\r\n                \"version\": 4, <4>\r\n                \"allocation\" : \"primary\" | \"replica\" | \"unused\", <6>\r\n                \"store_exception\": ... <5>\r\n            },\r\n            ...\r\n        ]\r\n   },\r\n    ...\r\n}\r\n```\r\n<1> The key is the corresponding shard id for the store information\r\n<2> A list of store information for all copies of the shard\r\n<3> The node information that hosts a copy of the shard, the key\r\n    is the unique node id.\r\n<4> The version of the shard copy\r\n<5> The status of the shard copy, whether it is used as a\r\n    primary, replica or not used at all\r\n<6> Any exception encountered while opening the shard index or\r\n    from earlier engine failure\r\n\r\ncloses #10952","created_at":"2015-06-08T22:41:20Z","updated_at":"2015-07-14T11:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d57ba5d319be425be4d621cfe3081da56273a0c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11545/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/792ade6ca1e7323583e58607a7be337c566b63d2","head":{"label":"areek:enhancement/10952","ref":"enhancement/10952","sha":"792ade6ca1e7323583e58607a7be337c566b63d2","user":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"repo":{"id":16661385,"name":"elasticsearch","full_name":"areek/elasticsearch","owner":{"login":"areek","id":753679,"avatar_url":"https://avatars.githubusercontent.com/u/753679?v=3","gravatar_id":"","url":"https://api.github.com/users/areek","html_url":"https://github.com/areek","followers_url":"https://api.github.com/users/areek/followers","following_url":"https://api.github.com/users/areek/following{/other_user}","gists_url":"https://api.github.com/users/areek/gists{/gist_id}","starred_url":"https://api.github.com/users/areek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areek/subscriptions","organizations_url":"https://api.github.com/users/areek/orgs","repos_url":"https://api.github.com/users/areek/repos","events_url":"https://api.github.com/users/areek/events{/privacy}","received_events_url":"https://api.github.com/users/areek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/areek/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/areek/elasticsearch","forks_url":"https://api.github.com/repos/areek/elasticsearch/forks","keys_url":"https://api.github.com/repos/areek/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/areek/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/areek/elasticsearch/teams","hooks_url":"https://api.github.com/repos/areek/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/areek/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/areek/elasticsearch/events","assignees_url":"https://api.github.com/repos/areek/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/areek/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/areek/elasticsearch/tags","blobs_url":"https://api.github.com/repos/areek/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/areek/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/areek/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/areek/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/areek/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/areek/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/areek/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/areek/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/areek/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/areek/elasticsearch/subscription","commits_url":"https://api.github.com/repos/areek/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/areek/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/areek/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/areek/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/areek/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/areek/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/areek/elasticsearch/merges","archive_url":"https://api.github.com/repos/areek/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/areek/elasticsearch/downloads","issues_url":"https://api.github.com/repos/areek/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/areek/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/areek/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/areek/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/areek/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/areek/elasticsearch/releases{/id}","created_at":"2014-02-09T06:24:53Z","updated_at":"2015-05-01T17:04:19Z","pushed_at":"2015-07-14T03:43:51Z","git_url":"git://github.com/areek/elasticsearch.git","ssh_url":"git@github.com:areek/elasticsearch.git","clone_url":"https://github.com/areek/elasticsearch.git","svn_url":"https://github.com/areek/elasticsearch","homepage":"http://elasticsearch.org","size":137679,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"1504b3d97d0ee073e1164abf16726b8fbbde777d","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}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-07-14T10:52:28Z","pushed_at":"2015-07-14T11:08:46Z","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":1902575,"stargazers_count":11980,"watchers_count":11980,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3821,"mirror_url":null,"open_issues_count":1114,"forks":3821,"open_issues":1114,"watchers":11980,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/11545"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/11545"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/11545/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11545/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/792ade6ca1e7323583e58607a7be337c566b63d2"}}}}