priyeshkaratha commented on code in PR #9584:
URL: https://github.com/apache/ozone/pull/9584#discussion_r2670886881


##########
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 = () => {
+    dnPendingDeletes.refetch();

Review Comment:
   Currently, the UI shows loading because data is cleared during the 30-second 
refresh interval. To fix this, we should persist the existing data in the UI 
while the background update is in progress, only replacing it once the new 
value is available. Additionally, for the initial load, we should poll at a 
faster 2-second interval until the first value is retrieved to avoid a long 
initial loading state. Whenever use do refresh of the page call API which will 
give in progress state and that time also do a polling with some small 
interval. So that it can be more UI friendly. 
   
   API results will be fast for even 100 node cluster so it usually takes less 
time for normal clusters.



-- 
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]

Reply via email to