Skip to content
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

Deprecate setting index.optimize_auto_generated_id in 6.x #28862

Merged
merged 7 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import org.apache.lucene.search.ReferenceManager;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.similarities.Similarity;
import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.unit.ByteSizeUnit;
Expand All @@ -52,6 +55,8 @@
* object will affect the {@link Engine} instance.
*/
public final class EngineConfig {
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(EngineConfig.class));

private final ShardId shardId;
private final String allocationId;
private final IndexSettings indexSettings;
Expand Down Expand Up @@ -109,6 +114,7 @@ public final class EngineConfig {
* this setting won't be reflected re-enabled optimization until the engine is restarted or the index is closed and reopened.
* The default is <code>true</code>
*/
@Deprecated
public static final Setting<Boolean> INDEX_OPTIMIZE_AUTO_GENERATED_IDS = Setting.boolSetting("index.optimize_auto_generated_id", true,
Property.IndexScope, Property.Dynamic);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to deprecate this in Java, but we should deprecate this with Property.Deprecated. Can you add that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jasontedor , please review again.


Expand All @@ -131,6 +137,11 @@ public EngineConfig(OpenMode openMode, ShardId shardId, String allocationId, Thr
if (openMode == null) {
throw new IllegalArgumentException("openMode must not be null");
}
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_0_0_rc1)
&& INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(indexSettings.getSettings())) {
DEPRECATION_LOGGER.deprecated(
"Setting [" + INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] has been deprecated in favor of the auto-ID optimization");
}
this.shardId = shardId;
this.allocationId = allocationId;
this.indexSettings = indexSettings;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.index.engine;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;


public class EngineConfigTests extends ESTestCase {


private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) {
return new EngineConfig(EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, null, null, null,
indexSettings, null, null, null, null,
null, null, null, null, null,
true, null, null, null, null, null,
null, null, null);
}

public void testOptimizeAutoGeneratedIdsSettingDeprecation() throws Exception {
Version version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0);
boolean optimizeAutoGeneratedIds = randomBoolean();
Settings.Builder builder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, version)
.put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds);
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build());

EngineConfig config = createEngineConfigWithSettings(indexSettings);
assertWarnings("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey()
+ "] has been deprecated in favor of the auto-ID optimization");
assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled());

version = randomFrom(Version.V_5_0_0, Version.V_5_0_0_alpha1, Version.V_5_6_9);
optimizeAutoGeneratedIds = randomBoolean();
builder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, version)
.put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds);
indexSettings = IndexSettingsModule.newIndexSettings("index2", builder.build());
config = createEngineConfigWithSettings(indexSettings);
assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled());

version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0);
builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version);
indexSettings = IndexSettingsModule.newIndexSettings("index3", builder.build());
config = createEngineConfigWithSettings(indexSettings);
assertTrue(config.isAutoGeneratedIDsOptimizationEnabled());
}

}