devabhishekpal commented on code in PR #9584: URL: https://github.com/apache/ozone/pull/9584#discussion_r2678424004
########## 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: I agree with the shorter refresh interval until data is loaded i.e the status is `FINISHED` However we should not persist old data while background refresh is going on. This would be against general UI guidelines, any loading should be indicated in the UI as well since the users won't know otherwise if anything goes wrong (say the loading failed in the background, or some error occurred - but since the UI is showing the old data and not indicating any loading process users might not even be aware something failed until they see the logs. Hence even if the loading takes time for a very large cluster (which it shouldn't as you said it is a fast enough process) we should show it as loading in the UI as well so that the user is aware of a task going on. -- 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]
