-
Notifications
You must be signed in to change notification settings - Fork 25.7k
IndexMetaData: Introduce internal format index setting #25292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5991ae6
8f9b2e4
b8d51fa
ef1fd65
bbffd94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
| import com.carrotsearch.hppc.cursors.IntObjectCursor; | ||
| import com.carrotsearch.hppc.cursors.ObjectCursor; | ||
| import com.carrotsearch.hppc.cursors.ObjectObjectCursor; | ||
|
|
||
| import org.elasticsearch.Version; | ||
| import org.elasticsearch.action.support.ActiveShardCount; | ||
| import org.elasticsearch.cluster.Diff; | ||
|
|
@@ -259,6 +258,14 @@ static Setting<Integer> buildNumberOfShardsSetting() { | |
| Setting.Property.Dynamic, | ||
| Setting.Property.IndexScope); | ||
|
|
||
| /** | ||
| * an internal index format description, allowing us to find out if this index is upgraded or needs upgrading | ||
| */ | ||
| private static final String INDEX_INTERNAL_FORMAT = "index.internal.format"; | ||
| public static final Setting<Integer> INDEX_INTERNAL_FORMAT_SETTING = | ||
| Setting.intSetting(INDEX_INTERNAL_FORMAT, 0, Setting.Property.IndexScope); | ||
| static final int INTERNAL_INDEX_FORMAT_CURRENT = 6; | ||
|
||
|
|
||
| public static final String KEY_IN_SYNC_ALLOCATIONS = "in_sync_allocations"; | ||
| static final String KEY_VERSION = "version"; | ||
| static final String KEY_ROUTING_NUM_SHARDS = "routing_num_shards"; | ||
|
|
@@ -279,6 +286,7 @@ static Setting<Integer> buildNumberOfShardsSetting() { | |
| private final Index index; | ||
| private final long version; | ||
| private final long[] primaryTerms; | ||
| private final int internalIndexFormat; | ||
|
||
|
|
||
| private final State state; | ||
|
|
||
|
|
@@ -309,7 +317,7 @@ private IndexMetaData(Index index, long version, long[] primaryTerms, State stat | |
| ImmutableOpenMap<String, Custom> customs, ImmutableOpenIntMap<Set<String>> inSyncAllocationIds, | ||
| DiscoveryNodeFilters requireFilters, DiscoveryNodeFilters initialRecoveryFilters, DiscoveryNodeFilters includeFilters, DiscoveryNodeFilters excludeFilters, | ||
| Version indexCreatedVersion, Version indexUpgradedVersion, | ||
| int routingNumShards, int routingPartitionSize, ActiveShardCount waitForActiveShards) { | ||
| int routingNumShards, int routingPartitionSize, ActiveShardCount waitForActiveShards, int internalIndexFormat) { | ||
|
||
|
|
||
| this.index = index; | ||
| this.version = version; | ||
|
|
@@ -335,6 +343,7 @@ private IndexMetaData(Index index, long version, long[] primaryTerms, State stat | |
| this.routingPartitionSize = routingPartitionSize; | ||
| this.waitForActiveShards = waitForActiveShards; | ||
| assert numberOfShards * routingFactor == routingNumShards : routingNumShards + " must be a multiple of " + numberOfShards; | ||
| this.internalIndexFormat = internalIndexFormat; | ||
| } | ||
|
|
||
| public Index getIndex() { | ||
|
|
@@ -506,6 +515,16 @@ public DiscoveryNodeFilters excludeFilters() { | |
| return excludeFilters; | ||
| } | ||
|
|
||
| /** | ||
| * Check that the 'index.internal.format' setting is set correctly for this index. | ||
| * This setting eases for upgrades | ||
| * | ||
| * @return true if the index format is configured to be {@link #INTERNAL_INDEX_FORMAT_CURRENT} | ||
| */ | ||
| public boolean isIndexInternalFormat() { | ||
| return internalIndexFormat == INTERNAL_INDEX_FORMAT_CURRENT; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) { | ||
|
|
@@ -551,6 +570,9 @@ public boolean equals(Object o) { | |
| if (!inSyncAllocationIds.equals(that.inSyncAllocationIds)) { | ||
| return false; | ||
| } | ||
| if (internalIndexFormat != that.internalIndexFormat) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -567,6 +589,7 @@ public int hashCode() { | |
| result = 31 * result + Long.hashCode(routingNumShards); | ||
| result = 31 * result + Arrays.hashCode(primaryTerms); | ||
| result = 31 * result + inSyncAllocationIds.hashCode(); | ||
| result = 31 * result + Integer.hashCode(internalIndexFormat); | ||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -1051,9 +1074,11 @@ public IndexMetaData build() { | |
| } | ||
|
|
||
| final String uuid = settings.get(SETTING_INDEX_UUID, INDEX_UUID_NA_VALUE); | ||
|
|
||
| int internalIndexFormat = INDEX_INTERNAL_FORMAT_SETTING.get(settings); | ||
| return new IndexMetaData(new Index(index, uuid), version, primaryTerms, state, numberOfShards, numberOfReplicas, tmpSettings, mappings.build(), | ||
| tmpAliases.build(), customs.build(), filledInSyncAllocationIds.build(), requireFilters, initialRecoveryFilters, includeFilters, excludeFilters, | ||
| indexCreatedVersion, indexUpgradedVersion, getRoutingNumShards(), routingPartitionSize, waitForActiveShards); | ||
| indexCreatedVersion, indexUpgradedVersion, getRoutingNumShards(), routingPartitionSize, waitForActiveShards, internalIndexFormat); | ||
|
||
| } | ||
|
|
||
| public static void toXContent(IndexMetaData indexMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also make this setting
Setting.Property.FinalThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh, wasnt aware of that. great!