{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/42805006","id":42805006,"diff_hunk":"@@ -0,0 +1,145 @@\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+package org.elasticsearch.index;\n+\n+import org.elasticsearch.Version;\n+import org.elasticsearch.cluster.metadata.IndexMetaData;\n+import org.elasticsearch.common.logging.ESLogger;\n+import org.elasticsearch.common.logging.Loggers;\n+import org.elasticsearch.common.settings.Settings;\n+import org.elasticsearch.env.NodeEnvironment;\n+\n+import java.util.ArrayList;\n+import java.util.Collection;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.function.Consumer;\n+\n+/**\n+ * This class encapsulates all index level settings and handles settings updates.\n+ * It's created per index and available to all index level classes and allows them to retrieve\n+ * the latest updated settings instance. Classes that need to listen to settings updates can register\n+ * a settings consumer at index creation via {@link IndexModule#addIndexSettingsListener(Consumer)} that will\n+ * be called for each settings update.\n+ */\n+public final class IndexSettings {\n+    private final String uuid;\n+    private volatile Settings settings;\n+    private final List<Consumer<Settings>> updateListeners;\n+    private final Index index;\n+    private final Version version;\n+    private final ESLogger logger;\n+    private final String nodeName;\n+\n+    /**\n+     * Creates a new {@link IndexSettings} instance\n+     * @param index the index this settings object is associated with\n+     * @param settings the actual settings including the node level settings\n+     * @param updateListeners a collection of listeners / consumers that should be notified if one or more settings are updated\n+     */\n+    public IndexSettings(Index index, Settings settings, Collection<Consumer<Settings>> updateListeners) {\n+        this.settings = settings;\n+        this.updateListeners = Collections.unmodifiableList(new ArrayList<>(updateListeners));\n+        this.index = index;\n+        version = Version.indexCreated(settings);\n+        uuid = settings.get(IndexMetaData.SETTING_INDEX_UUID, IndexMetaData.INDEX_UUID_NA_VALUE);\n+        logger = Loggers.getLogger(getClass(), settings, index);\n+        nodeName = settings.get(\"name\", \"\");\n+    }\n+\n+    /**\n+     * Returns the settings for this index. These settings contain the node and index level settings where\n+     * settings that are specified on both index and node level are overwritten by the index settings.\n+     */\n+    public Settings getSettings() {\n+        return settings;\n+    }\n+\n+    /**\n+     * Returns the index this settings object belongs to\n+     */\n+    public Index getIndex() {\n+        return index;\n+    }\n+\n+    /**\n+     * Returns the indexes UUID\n+     */\n+    public String getUUID() {\n+        return uuid;\n+    }\n+\n+    /**\n+     * Returns <code>true</code> if the index has a custom data path\n+     */\n+    public boolean hasCustomDataPath() {","path":"core/src/main/java/org/elasticsearch/index/IndexSettings.java","position":91,"original_position":91,"commit_id":"2245f480c93f5b8cef3b3f049213636e67850128","original_commit_id":"2245f480c93f5b8cef3b3f049213636e67850128","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"yeah I stopped to not pollute the PR\r\n","created_at":"2015-10-22T20:56:03Z","updated_at":"2015-10-22T20:56:03Z","html_url":"https://github.com/elastic/elasticsearch/pull/14251#discussion_r42805006","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/42805006"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14251#discussion_r42805006"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251","id":48456207,"html_url":"https://github.com/elastic/elasticsearch/pull/14251","diff_url":"https://github.com/elastic/elasticsearch/pull/14251.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/14251.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14251","number":14251,"state":"open","locked":false,"title":"Replace IndexSettings annotation with a full-fledged class","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"The @IndexSettings annoationat has been used to differentiate between node-level\r\nand index level settings. It was also decoupled from realtime-updates such that\r\nthe settings object that a class got injected when it was created was static and\r\nnot subject to change when an update was applied. This change removes the annoation\r\nand replaces it with a full-fledged class that adds type-safety and encapsulates additional\r\nfunctionality as well as checks on the settings.","created_at":"2015-10-22T13:21:01Z","updated_at":"2015-10-22T20:56:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"245d1e4540685acf158b21c4537ee295801669f1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14251/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/2245f480c93f5b8cef3b3f049213636e67850128","head":{"label":"s1monw:trash_index_settings","ref":"trash_index_settings","sha":"2245f480c93f5b8cef3b3f049213636e67850128","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"repo":{"id":4663744,"name":"elasticsearch","full_name":"s1monw/elasticsearch","owner":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/s1monw/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/s1monw/elasticsearch","forks_url":"https://api.github.com/repos/s1monw/elasticsearch/forks","keys_url":"https://api.github.com/repos/s1monw/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/s1monw/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/s1monw/elasticsearch/teams","hooks_url":"https://api.github.com/repos/s1monw/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/s1monw/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/s1monw/elasticsearch/events","assignees_url":"https://api.github.com/repos/s1monw/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/s1monw/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/s1monw/elasticsearch/tags","blobs_url":"https://api.github.com/repos/s1monw/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/s1monw/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/s1monw/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/s1monw/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/s1monw/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/s1monw/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/s1monw/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/s1monw/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/s1monw/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/s1monw/elasticsearch/subscription","commits_url":"https://api.github.com/repos/s1monw/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/s1monw/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/s1monw/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/s1monw/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/s1monw/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/s1monw/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/s1monw/elasticsearch/merges","archive_url":"https://api.github.com/repos/s1monw/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/s1monw/elasticsearch/downloads","issues_url":"https://api.github.com/repos/s1monw/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/s1monw/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/s1monw/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/s1monw/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/s1monw/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/s1monw/elasticsearch/releases{/id}","created_at":"2012-06-14T13:44:13Z","updated_at":"2015-05-07T08:25:29Z","pushed_at":"2015-10-22T20:27:18Z","git_url":"git://github.com/s1monw/elasticsearch.git","ssh_url":"git@github.com:s1monw/elasticsearch.git","clone_url":"https://github.com/s1monw/elasticsearch.git","svn_url":"https://github.com/s1monw/elasticsearch","homepage":"http://elasticsearch.org","size":167889,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"14aaeea25a8705d2328bc49c5fd861ebfd90d342","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-10-22T16:12:22Z","pushed_at":"2015-10-22T20:27:19Z","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":458216,"stargazers_count":13206,"watchers_count":13206,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4321,"mirror_url":null,"open_issues_count":1251,"forks":4321,"open_issues":1251,"watchers":13206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14251"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14251"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14251/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14251/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/2245f480c93f5b8cef3b3f049213636e67850128"}}}}