diff --git a/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java index 8af8e022012..9fa5bbb1e39 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java @@ -41,8 +41,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractMergePolicyProvider< private final ApplySettings applySettings = new ApplySettings(); private final LogByteSizeMergePolicy mergePolicy = new LogByteSizeMergePolicy(); - private static final ByteSizeValue DEFAULT_MIN_MERGE_SIZE = new ByteSizeValue((long) (LogByteSizeMergePolicy.DEFAULT_MIN_MERGE_MB * 1024 * 1024), ByteSizeUnit.BYTES); - private static final ByteSizeValue DEFAULT_MAX_MERGE_SIZE = new ByteSizeValue((long) LogByteSizeMergePolicy.DEFAULT_MAX_MERGE_MB, ByteSizeUnit.MB); + public static final ByteSizeValue DEFAULT_MIN_MERGE_SIZE = new ByteSizeValue((long) (LogByteSizeMergePolicy.DEFAULT_MIN_MERGE_MB * 1024 * 1024), ByteSizeUnit.BYTES); + public static final ByteSizeValue DEFAULT_MAX_MERGE_SIZE = new ByteSizeValue((long) LogByteSizeMergePolicy.DEFAULT_MAX_MERGE_MB, ByteSizeUnit.MB); @Inject public LogByteSizeMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { @@ -88,35 +88,35 @@ public class LogByteSizeMergePolicyProvider extends AbstractMergePolicyProvider< @Override public void onRefreshSettings(Settings settings) { double oldMinMergeSizeMB = mergePolicy.getMinMergeMB(); - ByteSizeValue minMergeSize = settings.getAsBytesSize(INDEX_MERGE_POLICY_MIN_MERGE_SIZE, DEFAULT_MIN_MERGE_SIZE); - if (minMergeSize.mbFrac() != oldMinMergeSizeMB) { + ByteSizeValue minMergeSize = settings.getAsBytesSize(INDEX_MERGE_POLICY_MIN_MERGE_SIZE, null); + if (minMergeSize != null && minMergeSize.mbFrac() != oldMinMergeSizeMB) { logger.info("updating min_merge_size from [{}mb] to [{}]", oldMinMergeSizeMB, minMergeSize); mergePolicy.setMinMergeMB(minMergeSize.mbFrac()); } double oldMaxMergeSizeMB = mergePolicy.getMaxMergeMB(); - ByteSizeValue maxMergeSize = settings.getAsBytesSize(INDEX_MERGE_POLICY_MAX_MERGE_SIZE, DEFAULT_MAX_MERGE_SIZE); - if (maxMergeSize.mbFrac() != oldMaxMergeSizeMB) { + ByteSizeValue maxMergeSize = settings.getAsBytesSize(INDEX_MERGE_POLICY_MAX_MERGE_SIZE, null); + if (maxMergeSize != null && maxMergeSize.mbFrac() != oldMaxMergeSizeMB) { logger.info("updating max_merge_size from [{}mb] to [{}]", oldMaxMergeSizeMB, maxMergeSize); mergePolicy.setMaxMergeMB(maxMergeSize.mbFrac()); } int oldMaxMergeDocs = mergePolicy.getMaxMergeDocs(); - int maxMergeDocs = settings.getAsInt(INDEX_MERGE_POLICY_MAX_MERGE_DOCS, LogByteSizeMergePolicy.DEFAULT_MAX_MERGE_DOCS); + int maxMergeDocs = settings.getAsInt(INDEX_MERGE_POLICY_MAX_MERGE_DOCS, oldMaxMergeDocs); if (maxMergeDocs != oldMaxMergeDocs) { logger.info("updating max_merge_docs from [{}] to [{}]", oldMaxMergeDocs, maxMergeDocs); mergePolicy.setMaxMergeDocs(maxMergeDocs); } int oldMergeFactor = mergePolicy.getMergeFactor(); - int mergeFactor = settings.getAsInt(INDEX_MERGE_POLICY_MERGE_FACTOR, LogByteSizeMergePolicy.DEFAULT_MERGE_FACTOR); + int mergeFactor = settings.getAsInt(INDEX_MERGE_POLICY_MERGE_FACTOR, oldMergeFactor); if (mergeFactor != oldMergeFactor) { logger.info("updating merge_factor from [{}] to [{}]", oldMergeFactor, mergeFactor); mergePolicy.setMergeFactor(mergeFactor); } boolean oldCalibrateSizeByDeletes = mergePolicy.getCalibrateSizeByDeletes(); - boolean calibrateSizeByDeletes = settings.getAsBoolean(INDEX_MERGE_POLICY_CALIBRATE_SIZE_BY_DELETES, true); + boolean calibrateSizeByDeletes = settings.getAsBoolean(INDEX_MERGE_POLICY_CALIBRATE_SIZE_BY_DELETES, oldCalibrateSizeByDeletes); if (calibrateSizeByDeletes != oldCalibrateSizeByDeletes) { logger.info("updating calibrate_size_by_deletes from [{}] to [{}]", oldCalibrateSizeByDeletes, calibrateSizeByDeletes); mergePolicy.setCalibrateSizeByDeletes(calibrateSizeByDeletes); diff --git a/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java index f34649ce420..3c0c6cf4576 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java @@ -85,28 +85,28 @@ public class LogDocMergePolicyProvider extends AbstractMergePolicyProvider