devabhishekpal commented on code in PR #6724:
URL: https://github.com/apache/ozone/pull/6724#discussion_r1686231017
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/datanodes/datanodes.tsx:
##########
@@ -389,24 +398,36 @@ export class Datanodes extends
React.Component<Record<string, object>, IDatanode
return selectedColumns;
};
- _loadData = () => {
- this.setState(prevState => ({
- loading: true,
- selectedColumns: this._getSelectedColumns(prevState.selectedColumns)
- }));
-
- const { request, controller } = AxiosGetHelper('/api/v1/datanodes',
cancelSignal);
- cancelSignal = controller;
- request.then(response => {
- const datanodesResponse: IDatanodesResponse = response.data;
+ _loadData = async () => {
+ // Need to call decommission API on each interval to get updated status
before datanode API to compare UUID's
+ // update Operation State Column in table Manually before rendering
+ try {
+ let decomissionResponse = await this._loadDecommisionAPI();
+ decommissionUuids = decomissionResponse && decomissionResponse.data &&
+ decomissionResponse.data.DatanodesDecommissionInfo &&
+ decomissionResponse.data.DatanodesDecommissionInfo.map((item: {
datanodeDetails: { uuid: any; }; }) => item.datanodeDetails.uuid);
Review Comment:
Just a nit to use optional chaining
```suggestion
decommissionUuids =
decomissionResponse.data?.DatanodesDecommissionInfo?.map((item: {
datanodeDetails: { uuid: any; }; }) => item.datanodeDetails.uuid);
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/datanodes/datanodes.tsx:
##########
@@ -389,24 +398,36 @@ export class Datanodes extends
React.Component<Record<string, object>, IDatanode
return selectedColumns;
};
- _loadData = () => {
- this.setState(prevState => ({
- loading: true,
- selectedColumns: this._getSelectedColumns(prevState.selectedColumns)
- }));
-
- const { request, controller } = AxiosGetHelper('/api/v1/datanodes',
cancelSignal);
- cancelSignal = controller;
- request.then(response => {
- const datanodesResponse: IDatanodesResponse = response.data;
+ _loadData = async () => {
+ // Need to call decommission API on each interval to get updated status
before datanode API to compare UUID's
+ // update Operation State Column in table Manually before rendering
+ try {
+ let decomissionResponse = await this._loadDecommisionAPI();
+ decommissionUuids = decomissionResponse && decomissionResponse.data &&
+ decomissionResponse.data.DatanodesDecommissionInfo &&
+ decomissionResponse.data.DatanodesDecommissionInfo.map((item: {
datanodeDetails: { uuid: any; }; }) => item.datanodeDetails.uuid);
Review Comment:
Also please define a type for DatanodeDecomissionInfo as:
```
type DatanodeDetails = {
uuid: string;
}
type DatanodeDecomissionInfo = {
datanodeDetails: DatanodeDetails
}
```
```suggestion
decomissionResponse.data.DatanodesDecommissionInfo.map((item:
DatanodeDecomissionInfo) => item.datanodeDetails.uuid);
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/overview/overview.tsx:
##########
@@ -280,6 +288,13 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
openKeysError = true;
}
+ if ([
+ decommissionInfoCount].some(
+ (data) => data === undefined
+ )) {
Review Comment:
Nit:
```suggestion
if ([decommissionInfoCount].some(
(data) => data === undefined
)) {
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/datanodes/decommissionSummary.tsx:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from 'react';
+import { Descriptions, Popover, Tooltip } from 'antd';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { withRouter } from 'react-router-dom';
+import { RouteComponentProps } from 'react-router';
+import axios from 'axios';
+import { showDataFetchError } from '@/utils/common';
+
+interface IDecommissionSummaryProps extends RouteComponentProps<object> {
+ uuid: string;
+ isLoading: boolean;
+ summaryData: string[];
+ record: string[];
+}
+
+class DecommissionSummary extends React.Component<IDecommissionSummaryProps> {
+ constructor(props = {}) {
+ super(props);
+ this.state = {
+ uuid: this.props.uuid,
+ record: this.props.record,
+ isLoading: false,
+ summaryData: []
+ };
+ }
+
+ componentDidMount(): void {
+ this.setState({
+ isLoading: true
+ });
+ if (this.state.record && this.state.summaryData !== 'null' &&
this.state.summaryData !== 'undefined') {
Review Comment:
I think this can be simplified to:
```suggestion
if (this.state?.record && this.state?.summaryData) {
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/datanodes/decommissionSummary.tsx:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from 'react';
+import { Descriptions, Popover, Tooltip } from 'antd';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { withRouter } from 'react-router-dom';
+import { RouteComponentProps } from 'react-router';
+import axios from 'axios';
+import { showDataFetchError } from '@/utils/common';
+
+interface IDecommissionSummaryProps extends RouteComponentProps<object> {
+ uuid: string;
+ isLoading: boolean;
+ summaryData: string[];
+ record: string[];
+}
+
+class DecommissionSummary extends React.Component<IDecommissionSummaryProps> {
+ constructor(props = {}) {
+ super(props);
+ this.state = {
+ uuid: this.props.uuid,
+ record: this.props.record,
+ isLoading: false,
+ summaryData: []
+ };
+ }
+
+ componentDidMount(): void {
+ this.setState({
+ isLoading: true
+ });
+ if (this.state.record && this.state.summaryData !== 'null' &&
this.state.summaryData !== 'undefined') {
+ this.fetchDecommissionSummary(this.state.uuid);
+ }
+ }
+
+ fetchDecommissionSummary = async (selectedUuid: any) => {
+ try {
+ const datanodeEndpoint =
`/api/v1/datanodes/decommission/info/datanode?uuid=${selectedUuid}`;
+ let infoDatanodeResponse = await axios.get(datanodeEndpoint);
+ let DatanodesDecommissionInfo = [];
+ DatanodesDecommissionInfo = infoDatanodeResponse &&
infoDatanodeResponse.data &&
infoDatanodeResponse.data.DatanodesDecommissionInfo[0];
+ this.setState({
+ loading: false,
+ summaryData: DatanodesDecommissionInfo
+ });
+ }
+ catch (error) {
+ this.setState({
+ loading: false,
+ summaryData: []
+ });
+ showDataFetchError(error.toString());
+ }
+ };
+
+ render() {
+ const { summaryData, uuid } = this.state;
+ let content;
+
+ if ( summaryData && summaryData.length !== 0 && summaryData !== null &&
summaryData !== undefined && summaryData.datanodeDetails) {
+ const { datanodeDetails, containers, metrics } = summaryData;
+ content = (
+ <Descriptions size="small" bordered column={1} title={`Decommission
Status: DECOMMISSIONING`}>
+ <Descriptions.Item label="Datanode">
<b>{datanodeDetails.uuid}</b></Descriptions.Item>
+ <Descriptions.Item
label="Location">({datanodeDetails.networkLocation}/{datanodeDetails.ipAddress}/{datanodeDetails.hostname})</Descriptions.Item>
+ {metrics !== null && metrics !== undefined &&
Object.keys(metrics).length !== 0 &&
+ <>
+ {<Descriptions.Item label="Decommissioning Started
at">{metrics.decommissionStartTime}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Unclosed
Pipelines">{metrics.numOfUnclosedPipelines}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Unclosed
Containers">{metrics.numOfUnclosedContainers}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Under-Replicated
Containers">{metrics.numOfUnderReplicatedContainers}</Descriptions.Item>}
+ </>
+ }
+ {
+ containers !== null && containers !== undefined &&
Object.keys(containers).length !== 0 &&
+ <>
+ {containers.UnderReplicated && containers.UnderReplicated.length
> 0 && <Descriptions.Item
label="Under-Replicated">{containers.UnderReplicated}</Descriptions.Item>}
+ {containers.UnClosed && containers.UnClosed.length > 0 &&
<Descriptions.Item label="Unclosed">{containers.UnClosed}</Descriptions.Item>}
+ </>
+ }
+ </Descriptions>
+ );
+ }
+ // Need to check summarydata is not empty
+ return (
+ <>
+ { (summaryData !== 'null' && summaryData !== 'undefined' &&
summaryData && summaryData.length !== 0) ?
Review Comment:
```suggestion
{ (summaryData && summaryData.length !== 0) ?
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/datanodes/decommissionSummary.tsx:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from 'react';
+import { Descriptions, Popover, Tooltip } from 'antd';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { withRouter } from 'react-router-dom';
+import { RouteComponentProps } from 'react-router';
+import axios from 'axios';
+import { showDataFetchError } from '@/utils/common';
+
+interface IDecommissionSummaryProps extends RouteComponentProps<object> {
+ uuid: string;
+ isLoading: boolean;
+ summaryData: string[];
+ record: string[];
+}
+
+class DecommissionSummary extends React.Component<IDecommissionSummaryProps> {
+ constructor(props = {}) {
+ super(props);
+ this.state = {
+ uuid: this.props.uuid,
+ record: this.props.record,
+ isLoading: false,
+ summaryData: []
+ };
+ }
+
+ componentDidMount(): void {
+ this.setState({
+ isLoading: true
+ });
+ if (this.state.record && this.state.summaryData !== 'null' &&
this.state.summaryData !== 'undefined') {
+ this.fetchDecommissionSummary(this.state.uuid);
+ }
+ }
+
+ fetchDecommissionSummary = async (selectedUuid: any) => {
+ try {
+ const datanodeEndpoint =
`/api/v1/datanodes/decommission/info/datanode?uuid=${selectedUuid}`;
+ let infoDatanodeResponse = await axios.get(datanodeEndpoint);
+ let DatanodesDecommissionInfo = [];
+ DatanodesDecommissionInfo = infoDatanodeResponse &&
infoDatanodeResponse.data &&
infoDatanodeResponse.data.DatanodesDecommissionInfo[0];
+ this.setState({
+ loading: false,
+ summaryData: DatanodesDecommissionInfo
+ });
+ }
+ catch (error) {
+ this.setState({
+ loading: false,
+ summaryData: []
+ });
+ showDataFetchError(error.toString());
+ }
+ };
+
+ render() {
+ const { summaryData, uuid } = this.state;
+ let content;
+
+ if ( summaryData && summaryData.length !== 0 && summaryData !== null &&
summaryData !== undefined && summaryData.datanodeDetails) {
+ const { datanodeDetails, containers, metrics } = summaryData;
+ content = (
+ <Descriptions size="small" bordered column={1} title={`Decommission
Status: DECOMMISSIONING`}>
+ <Descriptions.Item label="Datanode">
<b>{datanodeDetails.uuid}</b></Descriptions.Item>
+ <Descriptions.Item
label="Location">({datanodeDetails.networkLocation}/{datanodeDetails.ipAddress}/{datanodeDetails.hostname})</Descriptions.Item>
+ {metrics !== null && metrics !== undefined &&
Object.keys(metrics).length !== 0 &&
+ <>
+ {<Descriptions.Item label="Decommissioning Started
at">{metrics.decommissionStartTime}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Unclosed
Pipelines">{metrics.numOfUnclosedPipelines}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Unclosed
Containers">{metrics.numOfUnclosedContainers}</Descriptions.Item>}
+ {<Descriptions.Item label="No. of Under-Replicated
Containers">{metrics.numOfUnderReplicatedContainers}</Descriptions.Item>}
+ </>
+ }
+ {
+ containers !== null && containers !== undefined &&
Object.keys(containers).length !== 0 &&
Review Comment:
Since containers is an object I think this can also be simplified to:
```suggestion
containers && Object.keys(containers).length !== 0 &&
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]