Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liketic committed May 26, 2018
1 parent b330f0f commit d155b59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
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 @@ -55,8 +52,6 @@
* 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 @@ -114,9 +109,8 @@ 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);
Property.IndexScope, Property.Dynamic, Property.Deprecated);

private final TranslogConfig translogConfig;
private final OpenMode openMode;
Expand All @@ -137,11 +131,6 @@ 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
Expand Up @@ -20,6 +20,7 @@

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.ESTestCase;
Expand All @@ -28,42 +29,21 @@

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);
public void testOptimizeAutoGeneratedIdsSettingDeprecation() {
boolean optimizeAutoGeneratedIds = randomBoolean();
Settings.Builder builder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, version)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.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());
EngineConfig config = 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);

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());
assertSettingDeprecationsAndWarnings(new Setting<?>[]{EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS});
}

}

0 comments on commit d155b59

Please sign in to comment.