Skip to content

Commit

Permalink
[CCR] Integrate new follower index info ES API (#29153)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jen-huang committed Jan 24, 2019
1 parent 3a489ce commit b7501de
Show file tree
Hide file tree
Showing 21 changed files with 645 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const Chance = require('chance'); // eslint-disable-line import/no-extraneous-dependencies
const chance = new Chance();

export const getFollowerIndexMock = (
export const getFollowerIndexStatsMock = (
name = chance.string(),
shards = [{
id: chance.string(),
Expand Down Expand Up @@ -100,16 +100,59 @@ export const getFollowerIndexMock = (
};
};

export const getFollowerIndexListMock = (total = 3) => {
export const getFollowerIndexListStatsMock = (total = 3, names) => {
const list = {
follow_stats: {
indices: [],
},
};

let i = total;
while(i--) {
list.follow_stats.indices.push(getFollowerIndexMock());
for(let i = 0; i < total; i++) {
list.follow_stats.indices.push(getFollowerIndexStatsMock(names[i]));
}

return list;
};

export const getFollowerIndexInfoMock = (
name = chance.string(),
status = chance.string(),
parameters = {
maxReadRequestOperationCount: chance.string(),
maxOutstandingReadRequests: chance.string(),
maxReadRequestSize: chance.string(),
maxWriteRequestOperationCount: chance.string(),
maxWriteRequestSize: chance.string(),
maxOutstandingWriteRequests: chance.string(),
maxWriteBufferCount: chance.string(),
maxWriteBufferSize: chance.string(),
maxRetryDelay: chance.string(),
readPollTimeout: chance.string(),
}
) => {
return {
follower_index: name,
status,
max_read_request_operation_count: parameters.maxReadRequestOperationCount,
max_outstanding_read_requests: parameters.maxOutstandingReadRequests,
max_read_request_size: parameters.maxReadRequestSize,
max_write_request_operation_count: parameters.maxWriteRequestOperationCount,
max_write_request_size: parameters.maxWriteRequestSize,
max_outstanding_write_requests: parameters.maxOutstandingWriteRequests,
max_write_buffer_count: parameters.maxWriteBufferCount,
max_write_buffer_size: parameters.maxWriteBufferSize,
max_retry_delay: parameters.maxRetryDelay,
read_poll_timeout: parameters.readPollTimeout,
};
};

export const getFollowerIndexListInfoMock = (total = 3) => {
const list = {
follower_indices: [],
};

for(let i = 0; i < total; i++) {
list.follower_indices.push(getFollowerIndexInfoMock());
}

return list;
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/cross_cluster_replication/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export {
export { esErrors } from './es_errors';

export {
getFollowerIndexMock,
getFollowerIndexListMock,
getFollowerIndexStatsMock,
getFollowerIndexListStatsMock,
getFollowerIndexInfoMock,
getFollowerIndexListInfoMock,
} from './follower_index';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { byteUnitsUrl, timeUnitsUrl } from '../../services/documentation_links';
import { getSettingDefault } from '../../services/follower_index_default_settings';

const byteUnitsHelpText = (
<FormattedMessage
Expand Down Expand Up @@ -57,6 +58,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max read request operation count (optional)'
}
),
defaultValue: getSettingDefault('maxReadRequestOperationCount'),
type: 'number',
}, {
field: 'maxOutstandingReadRequests',
Expand All @@ -73,6 +75,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max outstanding read requests (optional)'
}
),
defaultValue: getSettingDefault('maxOutstandingReadRequests'),
type: 'number',
}, {
field: 'maxReadRequestSize',
Expand All @@ -89,6 +92,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max read request size (optional)'
}
),
defaultValue: getSettingDefault('maxReadRequestSize'),
helpText: byteUnitsHelpText,
}, {
field: 'maxWriteRequestOperationCount',
Expand All @@ -107,6 +111,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max write request operation count (optional)'
}
),
defaultValue: getSettingDefault('maxWriteRequestOperationCount'),
type: 'number',
}, {
field: 'maxWriteRequestSize',
Expand All @@ -125,6 +130,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max write request size (optional)'
}
),
defaultValue: getSettingDefault('maxWriteRequestSize'),
helpText: byteUnitsHelpText,
}, {
field: 'maxOutstandingWriteRequests',
Expand All @@ -143,6 +149,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max outstanding write requests (optional)'
}
),
defaultValue: getSettingDefault('maxOutstandingWriteRequests'),
type: 'number',
}, {
field: 'maxWriteBufferCount',
Expand All @@ -163,6 +170,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max write buffer count (optional)'
}
),
defaultValue: getSettingDefault('maxWriteBufferCount'),
type: 'number',
}, {
field: 'maxWriteBufferSize',
Expand All @@ -183,6 +191,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max write buffer size (optional)'
}
),
defaultValue: getSettingDefault('maxWriteBufferSize'),
helpText: byteUnitsHelpText,
}, {
field: 'maxRetryDelay',
Expand All @@ -202,6 +211,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Max retry delay (optional)'
}
),
defaultValue: getSettingDefault('maxRetryDelay'),
helpText: timeUnitsHelpText,
}, {
field: 'readPollTimeout',
Expand All @@ -223,6 +233,7 @@ export const advancedSettingsFields = [
defaultMessage: 'Read poll timeout (optional)'
}
),
defaultValue: getSettingDefault('readPollTimeout'),
helpText: timeUnitsHelpText,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EuiButton,
EuiButtonEmpty,
EuiCallOut,
EuiCode,
EuiDescribedFormGroup,
EuiFlexGroup,
EuiFlexItem,
Expand Down Expand Up @@ -511,7 +512,7 @@ export const FollowerIndexForm = injectI18n(
<Fragment>
<EuiSpacer size="s"/>
{advancedSettingsFields.map((advancedSetting) => {
const { field, title, description, label, helpText } = advancedSetting;
const { field, title, description, label, helpText, defaultValue } = advancedSetting;
return (
<FormEntryRow
key={field}
Expand All @@ -523,7 +524,19 @@ export const FollowerIndexForm = injectI18n(
<h3>{title}</h3>
</EuiTitle>
)}
description={description}
description={(
<Fragment>
{description}
<EuiSpacer size="s" />
<EuiText size="xs">
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettingsDefaultLabel"
defaultMessage="Default:"
/>{' '}
<EuiCode>{defaultValue}</EuiCode>
</EuiText>
</Fragment>
)}
label={label}
helpText={helpText}
areErrorsVisible={areErrorsVisible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

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

class Provider extends PureComponent {
static propTypes = {
onConfirm: PropTypes.func,
}

state = {
isModalOpen: false,
ids: null
Expand All @@ -34,6 +39,7 @@ class Provider extends PureComponent {
onConfirm = () => {
this.props.pauseFollowerIndex(this.state.ids);
this.setState({ isModalOpen: false, ids: null });
this.props.onConfirm && this.props.onConfirm();
}

closeConfirmModal = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

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

class Provider extends PureComponent {
static propTypes = {
onConfirm: PropTypes.func,
}

state = {
isModalOpen: false,
ids: null
Expand All @@ -34,6 +39,7 @@ class Provider extends PureComponent {
onConfirm = () => {
this.props.resumeFollowerIndex(this.state.ids);
this.setState({ isModalOpen: false, ids: null });
this.props.onConfirm && this.props.onConfirm();
}

closeConfirmModal = () => {
Expand Down Expand Up @@ -78,12 +84,21 @@ class Provider extends PureComponent {
}
onMouseOver={this.onMouseOverModal}
>
{!isSingle && (
{isSingle ? (
<p>
<FormattedMessage
id="xpack.crossClusterReplication.resumeFollowerIndex.confirmModal.singleResumeDescription"
defaultMessage="This follower index will be resumed using default settings. To resume using
different settings, edit this follower index instead."
/>
</p>
) : (
<Fragment>
<p>
<FormattedMessage
id="xpack.crossClusterReplication.resumeFollowerIndex.confirmModal.multipleResumeDescription"
defaultMessage="These follower indices will be resumed:"
defaultMessage="These follower indices will be resumed using default settings. To resume using
different settings, edit each follower index instead:"
/>
</p>
<ul>{ids.map(id => <li key={id}>{id}</li>)}</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

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

class Provider extends PureComponent {
static propTypes = {
onConfirm: PropTypes.func,
}

state = {
isModalOpen: false,
ids: null
Expand All @@ -34,6 +39,7 @@ class Provider extends PureComponent {
onConfirm = () => {
this.props.unfollowLeaderIndex(this.state.ids);
this.setState({ isModalOpen: false, ids: null });
this.props.onConfirm && this.props.onConfirm();
}

closeConfirmModal = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const FollowerIndexEdit = injectI18n(
}

renderConfirmModal = () => {
const { followerIndexId, intl } = this.props;
const { followerIndexId, intl, followerIndex: { isPaused } } = this.props;
const title = intl.formatMessage({
id: 'xpack.crossClusterReplication.followerIndexEditForm.confirmModal.title',
defaultMessage: 'Update follower index \'{id}\'?',
Expand All @@ -166,19 +166,31 @@ export const FollowerIndexEdit = injectI18n(
defaultMessage: 'Cancel',
})
}
confirmButtonText={
intl.formatMessage({
id: 'xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmButtonText',
defaultMessage: 'Update',
})
}
confirmButtonText={isPaused ? (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmAndResumeButtonText"
defaultMessage="Update and resume"
/>
) : (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.confirmButtonText"
defaultMessage="Update"
/>
)}
>
<p>
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.description"
defaultMessage="To update the follower index, it will first be paused and then resumed.
{isPaused ? (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.resumeDescription"
defaultMessage="This follower index will also be resumed."
/>
) : (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexEditForm.confirmModal.description"
defaultMessage="To update the follower index, it will first be paused and then resumed.
If the update fails, you may need to manually resume the follower index."
/>
/>
)}
</p>
</EuiConfirmModal>
</EuiOverlayMask>
Expand Down
Loading

0 comments on commit b7501de

Please sign in to comment.