@Override public TieredMergePolicy newMergePolicy() { CustomTieredMergePolicyProvider mergePolicy; if (asyncMerge) { mergePolicy = new EnableMergeTieredMergePolicyProvider(this); } else { mergePolicy = new CustomTieredMergePolicyProvider(this); } mergePolicy.setUseCompoundFile(compoundFormat); mergePolicy.setForceMergeDeletesPctAllowed(forceMergeDeletesPctAllowed); mergePolicy.setFloorSegmentMB(floorSegment.mbFrac()); mergePolicy.setMaxMergeAtOnce(maxMergeAtOnce); mergePolicy.setMaxMergeAtOnceExplicit(maxMergeAtOnceExplicit); mergePolicy.setMaxMergedSegmentMB(maxMergedSegment.mbFrac()); mergePolicy.setSegmentsPerTier(segmentsPerTier); mergePolicy.setReclaimDeletesWeight(reclaimDeletesWeight); return mergePolicy; }
@Override public void onRefreshSettings(Settings settings) { double expungeDeletesPctAllowed = settings.getAsDouble( "index.merge.policy.expunge_deletes_allowed", TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed); if (expungeDeletesPctAllowed != TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed) { logger.info( "updating [expunge_deletes_allowed] from [{}] to [{}]", TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed, expungeDeletesPctAllowed); TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed = expungeDeletesPctAllowed; for (CustomTieredMergePolicyProvider policy : policies) { policy.setForceMergeDeletesPctAllowed(expungeDeletesPctAllowed); } } ByteSizeValue floorSegment = settings.getAsBytesSize( "index.merge.policy.floor_segment", TieredMergePolicyProvider.this.floorSegment); if (!floorSegment.equals(TieredMergePolicyProvider.this.floorSegment)) { logger.info( "updating [floor_segment] from [{}] to [{}]", TieredMergePolicyProvider.this.floorSegment, floorSegment); TieredMergePolicyProvider.this.floorSegment = floorSegment; for (CustomTieredMergePolicyProvider policy : policies) { policy.setFloorSegmentMB(floorSegment.mbFrac()); } } int maxMergeAtOnce = settings.getAsInt( "index.merge.policy.max_merge_at_once", TieredMergePolicyProvider.this.maxMergeAtOnce); if (maxMergeAtOnce != TieredMergePolicyProvider.this.maxMergeAtOnce) { logger.info( "updating [max_merge_at_once] from [{}] to [{}]", TieredMergePolicyProvider.this.maxMergeAtOnce, maxMergeAtOnce); TieredMergePolicyProvider.this.maxMergeAtOnce = maxMergeAtOnce; for (CustomTieredMergePolicyProvider policy : policies) { policy.setMaxMergeAtOnce(maxMergeAtOnce); } } int maxMergeAtOnceExplicit = settings.getAsInt( "index.merge.policy.max_merge_at_once_explicit", TieredMergePolicyProvider.this.maxMergeAtOnceExplicit); if (maxMergeAtOnceExplicit != TieredMergePolicyProvider.this.maxMergeAtOnceExplicit) { logger.info( "updating [max_merge_at_once_explicit] from [{}] to [{}]", TieredMergePolicyProvider.this.maxMergeAtOnceExplicit, maxMergeAtOnceExplicit); TieredMergePolicyProvider.this.maxMergeAtOnceExplicit = maxMergeAtOnceExplicit; for (CustomTieredMergePolicyProvider policy : policies) { policy.setMaxMergeAtOnceExplicit(maxMergeAtOnceExplicit); } } ByteSizeValue maxMergedSegment = settings.getAsBytesSize( "index.merge.policy.max_merged_segment", TieredMergePolicyProvider.this.maxMergedSegment); if (!maxMergedSegment.equals(TieredMergePolicyProvider.this.maxMergedSegment)) { logger.info( "updating [max_merged_segment] from [{}] to [{}]", TieredMergePolicyProvider.this.maxMergedSegment, maxMergedSegment); TieredMergePolicyProvider.this.maxMergedSegment = maxMergedSegment; for (CustomTieredMergePolicyProvider policy : policies) { policy.setFloorSegmentMB(maxMergedSegment.mbFrac()); } } double segmentsPerTier = settings.getAsDouble( "index.merge.policy.segments_per_tier", TieredMergePolicyProvider.this.segmentsPerTier); if (segmentsPerTier != TieredMergePolicyProvider.this.segmentsPerTier) { logger.info( "updating [segments_per_tier] from [{}] to [{}]", TieredMergePolicyProvider.this.segmentsPerTier, segmentsPerTier); TieredMergePolicyProvider.this.segmentsPerTier = segmentsPerTier; for (CustomTieredMergePolicyProvider policy : policies) { policy.setSegmentsPerTier(segmentsPerTier); } } double reclaimDeletesWeight = settings.getAsDouble( "index.merge.policy.reclaim_deletes_weight", TieredMergePolicyProvider.this.reclaimDeletesWeight); if (reclaimDeletesWeight != TieredMergePolicyProvider.this.reclaimDeletesWeight) { logger.info( "updating [reclaim_deletes_weight] from [{}] to [{}]", TieredMergePolicyProvider.this.reclaimDeletesWeight, reclaimDeletesWeight); TieredMergePolicyProvider.this.reclaimDeletesWeight = reclaimDeletesWeight; for (CustomTieredMergePolicyProvider policy : policies) { policy.setReclaimDeletesWeight(reclaimDeletesWeight); } } boolean compoundFormat = settings.getAsBoolean( "index.compound_format", TieredMergePolicyProvider.this.compoundFormat); if (compoundFormat != TieredMergePolicyProvider.this.compoundFormat) { logger.info( "updating index.compound_format from [{}] to [{}]", TieredMergePolicyProvider.this.compoundFormat, compoundFormat); TieredMergePolicyProvider.this.compoundFormat = compoundFormat; for (CustomTieredMergePolicyProvider policy : policies) { policy.setUseCompoundFile(compoundFormat); } } fixSettingsIfNeeded(); }