-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ILM] Add index_codec to forcemerge action in hot and warm phases #78175
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
5d40489
01493fc
944b286
c43fdff
233012b
1d7295b
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; | |
| import { | ||
| EuiDescribedFormGroup, | ||
| EuiFieldNumber, | ||
| EuiFormRow, | ||
| EuiSpacer, | ||
| EuiSwitch, | ||
| EuiTextColor, | ||
|
|
@@ -19,17 +20,25 @@ import { ErrableFormRow } from './form_errors'; | |
| import { Phases, PhaseWithForcemergeAction } from '../../../../../common/types'; | ||
| import { PhaseValidationErrors } from '../../../services/policies/policy_validation'; | ||
|
|
||
| const forcemergeLabel = i18n.translate('xpack.indexLifecycleMgmt.warmPhase.forceMergeDataLabel', { | ||
| const forcemergeLabel = i18n.translate('xpack.indexLifecycleMgmt.forcemerge.enableLabel', { | ||
| defaultMessage: 'Force merge data', | ||
| }); | ||
|
|
||
| const bestCompressionLabel = i18n.translate( | ||
| 'xpack.indexLifecycleMgmt.forcemerge.bestCompressionLabel', | ||
| { | ||
| defaultMessage: 'Enable higher compression ratio codec', | ||
| } | ||
| ); | ||
|
|
||
| interface Props { | ||
| errors?: PhaseValidationErrors<PhaseWithForcemergeAction>; | ||
| phase: keyof Phases & string; | ||
| phaseData: PhaseWithForcemergeAction; | ||
| setPhaseData: (dataKey: keyof PhaseWithForcemergeAction, value: boolean | string) => void; | ||
| isShowingErrors: boolean; | ||
| } | ||
|
|
||
| export const Forcemerge: React.FunctionComponent<Props> = ({ | ||
| errors, | ||
| phaseData, | ||
|
|
@@ -42,15 +51,15 @@ export const Forcemerge: React.FunctionComponent<Props> = ({ | |
| title={ | ||
| <h3> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.warmPhase.forceMergeDataText" | ||
| id="xpack.indexLifecycleMgmt.editPolicy.forceMerge.enableText" | ||
| defaultMessage="Force merge" | ||
| /> | ||
| </h3> | ||
| } | ||
| description={ | ||
| <EuiTextColor color="subdued"> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.warmPhase.forceMergeDataExplanationText" | ||
| id="xpack.indexLifecycleMgmt.editPolicy.forceMerge.enableExplanationText" | ||
| defaultMessage="Reduce the number of segments in your shard by merging smaller files and clearing deleted ones." | ||
| />{' '} | ||
| <LearnMoreLink docPath="indices-forcemerge.html" /> | ||
|
|
@@ -73,23 +82,44 @@ export const Forcemerge: React.FunctionComponent<Props> = ({ | |
| <EuiSpacer /> | ||
| <div id="forcemergeContent" aria-live="polite" role="region"> | ||
| {phaseData.forceMergeEnabled ? ( | ||
| <ErrableFormRow | ||
| id={`${phase}-selectedForceMergeSegments`} | ||
| label={i18n.translate('xpack.indexLifecycleMgmt.warmPhase.numberOfSegmentsLabel', { | ||
| defaultMessage: 'Number of segments', | ||
| })} | ||
| isShowingErrors={isShowingErrors} | ||
| errors={errors?.selectedForceMergeSegments} | ||
| > | ||
| <EuiFieldNumber | ||
| data-test-subj={`${phase}-selectedForceMergeSegments`} | ||
| value={phaseData.selectedForceMergeSegments} | ||
| onChange={(e) => { | ||
| setPhaseData('selectedForceMergeSegments', e.target.value); | ||
| }} | ||
| min={1} | ||
| /> | ||
| </ErrableFormRow> | ||
| <> | ||
| <ErrableFormRow | ||
| id={`${phase}-selectedForceMergeSegments`} | ||
| label={i18n.translate('xpack.indexLifecycleMgmt.forceMerge.numberOfSegmentsLabel', { | ||
| defaultMessage: 'Number of segments', | ||
| })} | ||
| isShowingErrors={isShowingErrors} | ||
| errors={errors?.selectedForceMergeSegments} | ||
| > | ||
| <EuiFieldNumber | ||
| data-test-subj={`${phase}-selectedForceMergeSegments`} | ||
| value={phaseData.selectedForceMergeSegments} | ||
| onChange={(e) => { | ||
| setPhaseData('selectedForceMergeSegments', e.target.value); | ||
| }} | ||
| min={1} | ||
| /> | ||
| </ErrableFormRow> | ||
| <EuiFormRow | ||
| hasEmptyLabelSpace | ||
| helpText={ | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.forceMerge.bestCompressionText" | ||
| defaultMessage="Uses DEFLATE for a higher compression ratio but slower stored fields performance | ||
| than the default LZ4 codec." | ||
|
||
| /> | ||
| } | ||
| > | ||
| <EuiSwitch | ||
| data-test-subj={`${phase}-bestCompression`} | ||
| label={bestCompressionLabel} | ||
| checked={phaseData.bestCompressionEnabled} | ||
| onChange={(e) => { | ||
| setPhaseData('bestCompressionEnabled', e.target.checked); | ||
| }} | ||
| /> | ||
| </EuiFormRow> | ||
| </> | ||
| ) : null} | ||
| </div> | ||
| </EuiDescribedFormGroup> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,14 +4,15 @@ | |
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import cloneDeep from 'lodash/cloneDeep'; | ||
| import { serializePolicy } from './policy_serialization'; | ||
| import { deserializePolicy, serializePolicy } from './policy_serialization'; | ||
| import { | ||
| defaultNewColdPhase, | ||
| defaultNewDeletePhase, | ||
| defaultNewHotPhase, | ||
| defaultNewWarmPhase, | ||
| } from '../../constants'; | ||
| import { DataTierAllocationType } from '../../../../common/types'; | ||
| import { coldPhaseInitialization } from './cold_phase'; | ||
|
|
||
| describe('Policy serialization', () => { | ||
| test('serialize a policy using "default" data allocation', () => { | ||
|
|
@@ -367,4 +368,135 @@ describe('Policy serialization', () => { | |
| serializePolicy(deserializedPolicy, originalPolicy); | ||
| expect(originalPolicy).toEqual(originalClone); | ||
| }); | ||
|
|
||
| test('serialize a policy using "best_compression" codec for forcemerge', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is worth adding a test that asserts our serialisation will remove the "best_compression" setting from a policy that originally has it specified. This will ensure that we do not have a dangling "best_compression" setting. |
||
| expect( | ||
| serializePolicy( | ||
| { | ||
| name: 'test', | ||
| phases: { | ||
| hot: { | ||
| ...defaultNewHotPhase, | ||
| forceMergeEnabled: true, | ||
| selectedForceMergeSegments: '1', | ||
| bestCompressionEnabled: true, | ||
| }, | ||
| warm: { | ||
| ...defaultNewWarmPhase, | ||
| phaseEnabled: true, | ||
| forceMergeEnabled: true, | ||
| selectedForceMergeSegments: '1', | ||
| bestCompressionEnabled: true, | ||
| }, | ||
| cold: { | ||
| ...defaultNewColdPhase, | ||
| }, | ||
| delete: { ...defaultNewDeletePhase }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'test', | ||
| phases: { | ||
| hot: { actions: {} }, | ||
| warm: { | ||
| actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, | ||
| }, | ||
| }, | ||
| } | ||
| ) | ||
| ).toEqual({ | ||
| name: 'test', | ||
| phases: { | ||
| hot: { | ||
| actions: { | ||
| rollover: { | ||
| max_age: '30d', | ||
| max_size: '50gb', | ||
| }, | ||
| forcemerge: { | ||
| max_num_segments: 1, | ||
| index_codec: 'best_compression', | ||
| }, | ||
| set_priority: { | ||
| priority: 100, | ||
| }, | ||
| }, | ||
| }, | ||
| warm: { | ||
| actions: { | ||
| forcemerge: { | ||
| max_num_segments: 1, | ||
| index_codec: 'best_compression', | ||
| }, | ||
| set_priority: { | ||
| priority: 50, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| test('de-serialize a policy using "best_compression" codec for forcemerge', () => { | ||
| expect( | ||
| deserializePolicy({ | ||
| modified_date: Date.now().toString(), | ||
| name: 'test', | ||
| version: 1, | ||
| policy: { | ||
| name: 'test', | ||
| phases: { | ||
| hot: { | ||
| actions: { | ||
| rollover: { | ||
| max_age: '30d', | ||
| max_size: '50gb', | ||
| }, | ||
| forcemerge: { | ||
| max_num_segments: 1, | ||
| index_codec: 'best_compression', | ||
| }, | ||
| set_priority: { | ||
| priority: 100, | ||
| }, | ||
| }, | ||
| }, | ||
| warm: { | ||
| actions: { | ||
| forcemerge: { | ||
| max_num_segments: 1, | ||
| index_codec: 'best_compression', | ||
| }, | ||
| set_priority: { | ||
| priority: 50, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| ).toEqual({ | ||
| name: 'test', | ||
| phases: { | ||
| hot: { | ||
| ...defaultNewHotPhase, | ||
| forceMergeEnabled: true, | ||
| selectedForceMergeSegments: '1', | ||
| bestCompressionEnabled: true, | ||
| }, | ||
| warm: { | ||
| ...defaultNewWarmPhase, | ||
| warmPhaseOnRollover: false, | ||
| phaseEnabled: true, | ||
| forceMergeEnabled: true, | ||
| selectedForceMergeSegments: '1', | ||
| bestCompressionEnabled: true, | ||
| }, | ||
| cold: { | ||
| ...coldPhaseInitialization, | ||
| }, | ||
| delete: { ...defaultNewDeletePhase }, | ||
| }, | ||
| }); | ||
| }); | ||
| }); | ||
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.
Some alternate suggestions in order of preference:
Compress stored fieldsUse higher compression