Skip to content

Commit b7501de

Browse files
authored
[CCR] Integrate new follower index info ES API (#29153)
* Integrate new follower index info ES API * Collate data from follower stats and info apis when retrieving all followers and single follower * Add follower settings info to detail panel * Add paused/active UI state * Surface follower default settings to UI * Adjust tests * Address PR feedback
1 parent 3a489ce commit b7501de

File tree

21 files changed

+645
-132
lines changed

21 files changed

+645
-132
lines changed

x-pack/plugins/cross_cluster_replication/fixtures/follower_index.js

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const Chance = require('chance'); // eslint-disable-line import/no-extraneous-dependencies
88
const chance = new Chance();
99

10-
export const getFollowerIndexMock = (
10+
export const getFollowerIndexStatsMock = (
1111
name = chance.string(),
1212
shards = [{
1313
id: chance.string(),
@@ -100,16 +100,59 @@ export const getFollowerIndexMock = (
100100
};
101101
};
102102

103-
export const getFollowerIndexListMock = (total = 3) => {
103+
export const getFollowerIndexListStatsMock = (total = 3, names) => {
104104
const list = {
105105
follow_stats: {
106106
indices: [],
107107
},
108108
};
109109

110-
let i = total;
111-
while(i--) {
112-
list.follow_stats.indices.push(getFollowerIndexMock());
110+
for(let i = 0; i < total; i++) {
111+
list.follow_stats.indices.push(getFollowerIndexStatsMock(names[i]));
112+
}
113+
114+
return list;
115+
};
116+
117+
export const getFollowerIndexInfoMock = (
118+
name = chance.string(),
119+
status = chance.string(),
120+
parameters = {
121+
maxReadRequestOperationCount: chance.string(),
122+
maxOutstandingReadRequests: chance.string(),
123+
maxReadRequestSize: chance.string(),
124+
maxWriteRequestOperationCount: chance.string(),
125+
maxWriteRequestSize: chance.string(),
126+
maxOutstandingWriteRequests: chance.string(),
127+
maxWriteBufferCount: chance.string(),
128+
maxWriteBufferSize: chance.string(),
129+
maxRetryDelay: chance.string(),
130+
readPollTimeout: chance.string(),
131+
}
132+
) => {
133+
return {
134+
follower_index: name,
135+
status,
136+
max_read_request_operation_count: parameters.maxReadRequestOperationCount,
137+
max_outstanding_read_requests: parameters.maxOutstandingReadRequests,
138+
max_read_request_size: parameters.maxReadRequestSize,
139+
max_write_request_operation_count: parameters.maxWriteRequestOperationCount,
140+
max_write_request_size: parameters.maxWriteRequestSize,
141+
max_outstanding_write_requests: parameters.maxOutstandingWriteRequests,
142+
max_write_buffer_count: parameters.maxWriteBufferCount,
143+
max_write_buffer_size: parameters.maxWriteBufferSize,
144+
max_retry_delay: parameters.maxRetryDelay,
145+
read_poll_timeout: parameters.readPollTimeout,
146+
};
147+
};
148+
149+
export const getFollowerIndexListInfoMock = (total = 3) => {
150+
const list = {
151+
follower_indices: [],
152+
};
153+
154+
for(let i = 0; i < total; i++) {
155+
list.follower_indices.push(getFollowerIndexInfoMock());
113156
}
114157

115158
return list;

x-pack/plugins/cross_cluster_replication/fixtures/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export {
1212
export { esErrors } from './es_errors';
1313

1414
export {
15-
getFollowerIndexMock,
16-
getFollowerIndexListMock,
15+
getFollowerIndexStatsMock,
16+
getFollowerIndexListStatsMock,
17+
getFollowerIndexInfoMock,
18+
getFollowerIndexListInfoMock,
1719
} from './follower_index';

x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_form/advanced_settings_fields.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React from 'react';
88
import { FormattedMessage } from '@kbn/i18n/react';
99
import { i18n } from '@kbn/i18n';
1010
import { byteUnitsUrl, timeUnitsUrl } from '../../services/documentation_links';
11+
import { getSettingDefault } from '../../services/follower_index_default_settings';
1112

1213
const byteUnitsHelpText = (
1314
<FormattedMessage
@@ -57,6 +58,7 @@ export const advancedSettingsFields = [
5758
defaultMessage: 'Max read request operation count (optional)'
5859
}
5960
),
61+
defaultValue: getSettingDefault('maxReadRequestOperationCount'),
6062
type: 'number',
6163
}, {
6264
field: 'maxOutstandingReadRequests',
@@ -73,6 +75,7 @@ export const advancedSettingsFields = [
7375
defaultMessage: 'Max outstanding read requests (optional)'
7476
}
7577
),
78+
defaultValue: getSettingDefault('maxOutstandingReadRequests'),
7679
type: 'number',
7780
}, {
7881
field: 'maxReadRequestSize',
@@ -89,6 +92,7 @@ export const advancedSettingsFields = [
8992
defaultMessage: 'Max read request size (optional)'
9093
}
9194
),
95+
defaultValue: getSettingDefault('maxReadRequestSize'),
9296
helpText: byteUnitsHelpText,
9397
}, {
9498
field: 'maxWriteRequestOperationCount',
@@ -107,6 +111,7 @@ export const advancedSettingsFields = [
107111
defaultMessage: 'Max write request operation count (optional)'
108112
}
109113
),
114+
defaultValue: getSettingDefault('maxWriteRequestOperationCount'),
110115
type: 'number',
111116
}, {
112117
field: 'maxWriteRequestSize',
@@ -125,6 +130,7 @@ export const advancedSettingsFields = [
125130
defaultMessage: 'Max write request size (optional)'
126131
}
127132
),
133+
defaultValue: getSettingDefault('maxWriteRequestSize'),
128134
helpText: byteUnitsHelpText,
129135
}, {
130136
field: 'maxOutstandingWriteRequests',
@@ -143,6 +149,7 @@ export const advancedSettingsFields = [
143149
defaultMessage: 'Max outstanding write requests (optional)'
144150
}
145151
),
152+
defaultValue: getSettingDefault('maxOutstandingWriteRequests'),
146153
type: 'number',
147154
}, {
148155
field: 'maxWriteBufferCount',
@@ -163,6 +170,7 @@ export const advancedSettingsFields = [
163170
defaultMessage: 'Max write buffer count (optional)'
164171
}
165172
),
173+
defaultValue: getSettingDefault('maxWriteBufferCount'),
166174
type: 'number',
167175
}, {
168176
field: 'maxWriteBufferSize',
@@ -183,6 +191,7 @@ export const advancedSettingsFields = [
183191
defaultMessage: 'Max write buffer size (optional)'
184192
}
185193
),
194+
defaultValue: getSettingDefault('maxWriteBufferSize'),
186195
helpText: byteUnitsHelpText,
187196
}, {
188197
field: 'maxRetryDelay',
@@ -202,6 +211,7 @@ export const advancedSettingsFields = [
202211
defaultMessage: 'Max retry delay (optional)'
203212
}
204213
),
214+
defaultValue: getSettingDefault('maxRetryDelay'),
205215
helpText: timeUnitsHelpText,
206216
}, {
207217
field: 'readPollTimeout',
@@ -223,6 +233,7 @@ export const advancedSettingsFields = [
223233
defaultMessage: 'Read poll timeout (optional)'
224234
}
225235
),
236+
defaultValue: getSettingDefault('readPollTimeout'),
226237
helpText: timeUnitsHelpText,
227238
},
228239
];

x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_form/follower_index_form.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
EuiButton,
1717
EuiButtonEmpty,
1818
EuiCallOut,
19+
EuiCode,
1920
EuiDescribedFormGroup,
2021
EuiFlexGroup,
2122
EuiFlexItem,
@@ -511,7 +512,7 @@ export const FollowerIndexForm = injectI18n(
511512
<Fragment>
512513
<EuiSpacer size="s"/>
513514
{advancedSettingsFields.map((advancedSetting) => {
514-
const { field, title, description, label, helpText } = advancedSetting;
515+
const { field, title, description, label, helpText, defaultValue } = advancedSetting;
515516
return (
516517
<FormEntryRow
517518
key={field}
@@ -523,7 +524,19 @@ export const FollowerIndexForm = injectI18n(
523524
<h3>{title}</h3>
524525
</EuiTitle>
525526
)}
526-
description={description}
527+
description={(
528+
<Fragment>
529+
{description}
530+
<EuiSpacer size="s" />
531+
<EuiText size="xs">
532+
<FormattedMessage
533+
id="xpack.crossClusterReplication.followerIndexForm.advancedSettingsDefaultLabel"
534+
defaultMessage="Default:"
535+
/>{' '}
536+
<EuiCode>{defaultValue}</EuiCode>
537+
</EuiText>
538+
</Fragment>
539+
)}
527540
label={label}
528541
helpText={helpText}
529542
areErrorsVisible={areErrorsVisible}

x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_pause_provider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import React, { PureComponent, Fragment } from 'react';
8+
import PropTypes from 'prop-types';
89
import { connect } from 'react-redux';
910
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
1011
import {
@@ -16,6 +17,10 @@ import { pauseFollowerIndex } from '../store/actions';
1617
import { arrify } from '../../../common/services/utils';
1718

1819
class Provider extends PureComponent {
20+
static propTypes = {
21+
onConfirm: PropTypes.func,
22+
}
23+
1924
state = {
2025
isModalOpen: false,
2126
ids: null
@@ -34,6 +39,7 @@ class Provider extends PureComponent {
3439
onConfirm = () => {
3540
this.props.pauseFollowerIndex(this.state.ids);
3641
this.setState({ isModalOpen: false, ids: null });
42+
this.props.onConfirm && this.props.onConfirm();
3743
}
3844

3945
closeConfirmModal = () => {

x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_resume_provider.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import React, { PureComponent, Fragment } from 'react';
8+
import PropTypes from 'prop-types';
89
import { connect } from 'react-redux';
910
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
1011
import {
@@ -16,6 +17,10 @@ import { resumeFollowerIndex } from '../store/actions';
1617
import { arrify } from '../../../common/services/utils';
1718

1819
class Provider extends PureComponent {
20+
static propTypes = {
21+
onConfirm: PropTypes.func,
22+
}
23+
1924
state = {
2025
isModalOpen: false,
2126
ids: null
@@ -34,6 +39,7 @@ class Provider extends PureComponent {
3439
onConfirm = () => {
3540
this.props.resumeFollowerIndex(this.state.ids);
3641
this.setState({ isModalOpen: false, ids: null });
42+
this.props.onConfirm && this.props.onConfirm();
3743
}
3844

3945
closeConfirmModal = () => {
@@ -78,12 +84,21 @@ class Provider extends PureComponent {
7884
}
7985
onMouseOver={this.onMouseOverModal}
8086
>
81-
{!isSingle && (
87+
{isSingle ? (
88+
<p>
89+
<FormattedMessage
90+
id="xpack.crossClusterReplication.resumeFollowerIndex.confirmModal.singleResumeDescription"
91+
defaultMessage="This follower index will be resumed using default settings. To resume using
92+
different settings, edit this follower index instead."
93+
/>
94+
</p>
95+
) : (
8296
<Fragment>
8397
<p>
8498
<FormattedMessage
8599
id="xpack.crossClusterReplication.resumeFollowerIndex.confirmModal.multipleResumeDescription"
86-
defaultMessage="These follower indices will be resumed:"
100+
defaultMessage="These follower indices will be resumed using default settings. To resume using
101+
different settings, edit each follower index instead:"
87102
/>
88103
</p>
89104
<ul>{ids.map(id => <li key={id}>{id}</li>)}</ul>

x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_unfollow_provider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import React, { PureComponent, Fragment } from 'react';
8+
import PropTypes from 'prop-types';
89
import { connect } from 'react-redux';
910
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
1011
import {
@@ -16,6 +17,10 @@ import { unfollowLeaderIndex } from '../store/actions';
1617
import { arrify } from '../../../common/services/utils';
1718

1819
class Provider extends PureComponent {
20+
static propTypes = {
21+
onConfirm: PropTypes.func,
22+
}
23+
1924
state = {
2025
isModalOpen: false,
2126
ids: null
@@ -34,6 +39,7 @@ class Provider extends PureComponent {
3439
onConfirm = () => {
3540
this.props.unfollowLeaderIndex(this.state.ids);
3641
this.setState({ isModalOpen: false, ids: null });
42+
this.props.onConfirm && this.props.onConfirm();
3743
}
3844

3945
closeConfirmModal = () => {

x-pack/plugins/cross_cluster_replication/public/app/sections/follower_index_edit/follower_index_edit.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const FollowerIndexEdit = injectI18n(
148148
}
149149

150150
renderConfirmModal = () => {
151-
const { followerIndexId, intl } = this.props;
151+
const { followerIndexId, intl, followerIndex: { isPaused } } = this.props;
152152
const title = intl.formatMessage({
153153
id: 'xpack.crossClusterReplication.followerIndexEditForm.confirmModal.title',
154154
defaultMessage: 'Update follower index \'{id}\'?',
@@ -166,19 +166,31 @@ export const FollowerIndexEdit = injectI18n(
166166
defaultMessage: 'Cancel',
167167
})
168168
}
169-
confirmButtonText={
170-
intl.formatMessage({
171-
id: 'xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmButtonText',
172-
defaultMessage: 'Update',
173-
})
174-
}
169+
confirmButtonText={isPaused ? (
170+
<FormattedMessage
171+
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmAndResumeButtonText"
172+
defaultMessage="Update and resume"
173+
/>
174+
) : (
175+
<FormattedMessage
176+
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmButtonText"
177+
defaultMessage="Update"
178+
/>
179+
)}
175180
>
176181
<p>
177-
<FormattedMessage
178-
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.description"
179-
defaultMessage="To update the follower index, it will first be paused and then resumed.
182+
{isPaused ? (
183+
<FormattedMessage
184+
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.resumeDescription"
185+
defaultMessage="This follower index will also be resumed."
186+
/>
187+
) : (
188+
<FormattedMessage
189+
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.description"
190+
defaultMessage="To update the follower index, it will first be paused and then resumed.
180191
If the update fails, you may need to manually resume the follower index."
181-
/>
192+
/>
193+
)}
182194
</p>
183195
</EuiConfirmModal>
184196
</EuiOverlayMask>

0 commit comments

Comments
 (0)