devabhishekpal commented on code in PR #9584: URL: https://github.com/apache/ozone/pull/9584#discussion_r2707428093
########## hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/capacity/capacity.tsx: ########## @@ -0,0 +1,342 @@ +/* + * 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 { Popover, Tag, Tooltip, Typography } from 'antd'; +import React from 'react'; +import AutoReloadPanel from '@/components/autoReloadPanel/autoReloadPanel'; + +import './capacity.less'; +import { showDataFetchError } from '@/utils/common' +import moment from 'moment'; +import CapacityBreakdown from '@/v2/pages/capacity/components/CapacityBreakdown'; +import CapacityDetail from '@/v2/pages/capacity/components/CapacityDetail'; +import { + datanodesPendingDeletionDesc, + otherUsedSpaceDesc, + ozoneUsedSpaceDesc, + totalCapacityDesc +} from '@/v2/pages/capacity/constants/descriptions.constants'; +import WrappedInfoIcon from '@/v2/pages/capacity/components/WrappedInfoIcon'; +import filesize from 'filesize'; +import { InfoCircleOutlined, WarningFilled, CheckCircleFilled } from '@ant-design/icons'; +import { useApiData } from '@/v2/hooks/useAPIData.hook'; +import * as CONSTANTS from '@/v2/constants/capacity.constants'; +import { UtilizationResponse, SCMPendingDeletion, OMPendingDeletion, DNPendingDeletion, DataNodeUsage } from '@/v2/types/capacity.types'; +import { useAutoReload } from '@/v2/hooks/useAutoReload.hook'; + +type CapacityState = { + isDNPending: boolean; + lastUpdated: number; +}; + +const Capacity: React.FC<object> = () => { + + const [state, setState] = React.useState<CapacityState>({ + isDNPending: true, + lastUpdated: 0 + }); + + const storageDistribution = useApiData<UtilizationResponse>( + '/api/v1/storageDistribution', + CONSTANTS.DEFAULT_CAPACITY_UTILIZATION, + { + retryAttempts: 2, + onError: (error) => showDataFetchError(error) + } + ); + + const scmPendingDeletes = useApiData<SCMPendingDeletion>( + '/api/v1/pendingDeletion?component=scm', + CONSTANTS.DEFAULT_SCM_PENDING_DELETION, + { + retryAttempts: 2, + onError: (error) => showDataFetchError(error) + } + ); + + const omPendingDeletes = useApiData<OMPendingDeletion>( + '/api/v1/pendingDeletion?component=om', + CONSTANTS.DEFAULT_OM_PENDING_DELETION, + { + retryAttempts: 2, + onError: (error) => showDataFetchError(error) + } + ); + + const dnPendingDeletes = useApiData<DNPendingDeletion>( + '/api/v1/pendingDeletion?component=dn', + CONSTANTS.DEFAULT_DN_PENDING_DELETION, + { + retryAttempts: 2, + initialFetch: false, + onError: (error) => showDataFetchError(error) + } + ); + + const [selectedDatanode, setSelectedDatanode] = React.useState<string>(storageDistribution.data.dataNodeUsage[0]?.hostName ?? ""); + + // Seed selected datanode once data loads so dependent calculations work + React.useEffect(() => { + const firstHost = storageDistribution.data.dataNodeUsage[0]?.hostName; + if (!selectedDatanode && firstHost) { + setSelectedDatanode(firstHost); + } + }, [selectedDatanode, storageDistribution.data.dataNodeUsage]); + + const loadDNData = () => { Review Comment: This has been addressed in the latest patch. We are loading the data initially by polling every 5s till status is FINISHED. Then onwards we are keeping the data and depending on the user to re-fetch the latest data as discussed earlier. -- 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]
