This is an automated email from the ASF dual-hosted git repository. jackie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 93bfc527e9 fix(ui): update table status to inline with new segment status (#10090) 93bfc527e9 is described below commit 93bfc527e9f4dc2b700094168a1ec07f1ffea28a Author: Jayesh Choudhary <jayeshchoudhary...@gmail.com> AuthorDate: Thu Jan 19 04:35:45 2023 +0530 fix(ui): update table status to inline with new segment status (#10090) --- .../app/components/SegmentStatusRenderer.tsx | 2 +- .../src/main/resources/app/components/Table.tsx | 6 +- .../src/main/resources/app/interfaces/types.d.ts | 2 +- .../src/main/resources/app/utils/Utils.tsx | 97 +++++++++++----------- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/pinot-controller/src/main/resources/app/components/SegmentStatusRenderer.tsx b/pinot-controller/src/main/resources/app/components/SegmentStatusRenderer.tsx index 7cd34fc1de..066bf1ccc8 100644 --- a/pinot-controller/src/main/resources/app/components/SegmentStatusRenderer.tsx +++ b/pinot-controller/src/main/resources/app/components/SegmentStatusRenderer.tsx @@ -99,7 +99,7 @@ export const SegmentStatusRenderer = ({ break; } - case DISPLAY_SEGMENT_STATUS.PARTIAL: { + case DISPLAY_SEGMENT_STATUS.UPDATING: { setStatusColor(StatusColor.Warning); setStatusTooltipTitle("External view is OFFLINE or missing for one or more servers of this segment"); diff --git a/pinot-controller/src/main/resources/app/components/Table.tsx b/pinot-controller/src/main/resources/app/components/Table.tsx index b5871d788e..acb7171493 100644 --- a/pinot-controller/src/main/resources/app/components/Table.tsx +++ b/pinot-controller/src/main/resources/app/components/Table.tsx @@ -349,7 +349,7 @@ export default function CustomizedTables({ }, [search, timeoutId, filterSearchResults]); const styleCell = (str: string) => { - if (str === 'Good' || str.toLowerCase() === 'online' || str.toLowerCase() === 'alive' || str.toLowerCase() === 'true') { + if (str.toLowerCase() === 'good' || str.toLowerCase() === 'online' || str.toLowerCase() === 'alive' || str.toLowerCase() === 'true') { return ( <StyledChip label={str} @@ -358,7 +358,7 @@ export default function CustomizedTables({ /> ); } - if (str === 'Bad' || str.toLowerCase() === 'offline' || str.toLowerCase() === 'dead' || str.toLowerCase() === 'false') { + if (str.toLocaleLowerCase() === 'bad' || str.toLowerCase() === 'offline' || str.toLowerCase() === 'dead' || str.toLowerCase() === 'false') { return ( <StyledChip label={str} @@ -367,7 +367,7 @@ export default function CustomizedTables({ /> ); } - if (str.toLowerCase() === 'consuming') { + if (str.toLowerCase() === 'consuming' || str.toLocaleLowerCase() === "partial" || str.toLocaleLowerCase() === "updating" ) { return ( <StyledChip label={str} diff --git a/pinot-controller/src/main/resources/app/interfaces/types.d.ts b/pinot-controller/src/main/resources/app/interfaces/types.d.ts index 79b28d7e16..4be7e6f76b 100644 --- a/pinot-controller/src/main/resources/app/interfaces/types.d.ts +++ b/pinot-controller/src/main/resources/app/interfaces/types.d.ts @@ -235,6 +235,6 @@ declare module 'Models' { export const enum DISPLAY_SEGMENT_STATUS { BAD = "BAD", GOOD = "GOOD", - PARTIAL = "PARTIAL", + UPDATING = "UPDATING", } } diff --git a/pinot-controller/src/main/resources/app/utils/Utils.tsx b/pinot-controller/src/main/resources/app/utils/Utils.tsx index 62f07fdd2a..2153c9175b 100644 --- a/pinot-controller/src/main/resources/app/utils/Utils.tsx +++ b/pinot-controller/src/main/resources/app/utils/Utils.tsx @@ -63,55 +63,39 @@ const tableFormat = (data) => { }; const getSegmentStatus = (idealStateObj, externalViewObj) => { - const idealSegmentKeys = Object.keys(idealStateObj); - const idealSegmentCount = idealSegmentKeys.length; - - const externalSegmentKeys = Object.keys(externalViewObj); - const externalSegmentCount = externalSegmentKeys.length; - - if (idealSegmentCount !== externalSegmentCount) { - let segmentStatusComponent = ( - <ReactDiffViewer - oldValue={JSON.stringify(idealStateObj, null, 2)} - newValue={JSON.stringify(externalViewObj, null, 2)} - splitView={true} - showDiffOnly={true} - leftTitle={"Ideal State"} - rightTitle={"External View"} - compareMethod={DiffMethod.WORDS} - /> - ) - return { - value: 'Bad', - tooltip: `Ideal Segment Count: ${idealSegmentCount} does not match external Segment Count: ${externalSegmentCount}`, - component: segmentStatusComponent, - }; + const tableStatus = getDisplayTableStatus(idealStateObj, externalViewObj); + const statusMismatchDiffComponent = ( + <ReactDiffViewer + oldValue={JSON.stringify(idealStateObj, null, 2)} + newValue={JSON.stringify(externalViewObj, null, 2)} + splitView={true} + showDiffOnly={true} + leftTitle={"Ideal State"} + rightTitle={"External View"} + compareMethod={DiffMethod.WORDS} + /> + ); + + if(tableStatus === DISPLAY_SEGMENT_STATUS.BAD) { + return ({ + value: tableStatus, + tooltip: "One or more segments in this table are in bad state. Click the status to view more details.", + component: statusMismatchDiffComponent, + }) } - let segmentStatus = {value: 'Good', tooltip: null, component: null}; - idealSegmentKeys.map((segmentKey) => { - if (segmentStatus.value === 'Good') { - if (!isEqual(idealStateObj[segmentKey], externalViewObj[segmentKey])) { - let segmentStatusComponent = ( - <ReactDiffViewer - oldValue={JSON.stringify(idealStateObj, null, 2)} - newValue={JSON.stringify(externalViewObj, null, 2)} - splitView={true} - showDiffOnly={true} - leftTitle={"Ideal State"} - rightTitle={"External View"} - compareMethod={DiffMethod.WORDS} - /> - ) - segmentStatus = { - value: 'Bad', - tooltip: "Ideal Status does not match external status", - component: segmentStatusComponent - }; - } - } + if(tableStatus === DISPLAY_SEGMENT_STATUS.UPDATING) { + return ({ + value: tableStatus, + tooltip: "One or more segments in this table are in updating state. Click the status to view more details.", + component: statusMismatchDiffComponent, + }) + } + + return ({ + value: tableStatus, + tooltip: "All segments in this table are in good state.", }); - return segmentStatus; }; const findNestedObj = (entireObj, keyToFind, valToFind) => { @@ -346,6 +330,21 @@ const splitStringByLastUnderscore = (str: string) => { return [beforeUnderscore, afterUnderscore]; } +export const getDisplayTableStatus = (idealStateObj, externalViewObj): DISPLAY_SEGMENT_STATUS => { + const segmentStatusArr = []; + Object.keys(idealStateObj).forEach((key) => { + segmentStatusArr.push(getDisplaySegmentStatus(idealStateObj[key], externalViewObj[key])) + }) + + if(segmentStatusArr.includes(DISPLAY_SEGMENT_STATUS.BAD)) { + return DISPLAY_SEGMENT_STATUS.BAD; + } + if(segmentStatusArr.includes(DISPLAY_SEGMENT_STATUS.UPDATING)) { + return DISPLAY_SEGMENT_STATUS.UPDATING; + } + return DISPLAY_SEGMENT_STATUS.GOOD; +} + export const getDisplaySegmentStatus = (idealState, externalView): DISPLAY_SEGMENT_STATUS => { const externalViewStatesArray = Object.values(externalView || {}); @@ -355,7 +354,7 @@ export const getDisplaySegmentStatus = (idealState, externalView): DISPLAY_SEGME } // if EV status is CONSUMING or ONLINE then segment is in Good state - if(externalViewStatesArray.every((status) => status === SEGMENT_STATUS.CONSUMING || status === SEGMENT_STATUS.ONLINE)) { + if(externalViewStatesArray.every((status) => status === SEGMENT_STATUS.CONSUMING || status === SEGMENT_STATUS.ONLINE) && isEqual(idealState, externalView)) { return DISPLAY_SEGMENT_STATUS.GOOD; } @@ -367,11 +366,11 @@ export const getDisplaySegmentStatus = (idealState, externalView): DISPLAY_SEGME // If EV is empty or EV state is OFFLINE and does not matches IS then segment is in Partial state. // PARTIAL state can also be interpreted as we're waiting for segments to converge if(externalViewStatesArray.length === 0 || externalViewStatesArray.includes(SEGMENT_STATUS.OFFLINE) && !isEqual(idealState, externalView)) { - return DISPLAY_SEGMENT_STATUS.PARTIAL; + return DISPLAY_SEGMENT_STATUS.UPDATING; } // does not match any condition -> assume PARTIAL state as we are waiting for segments to converge - return DISPLAY_SEGMENT_STATUS.PARTIAL; + return DISPLAY_SEGMENT_STATUS.UPDATING; } export default { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org