devmadhuu commented on code in PR #10198:
URL: https://github.com/apache/ozone/pull/10198#discussion_r3217648609
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/containers/containers.tsx:
##########
@@ -272,20 +276,86 @@ const Containers: React.FC<{}> = () => {
};
// ── Container data fetching ───────────────────────────────────────────────
+
+ // Fetches the quasi-closed count independently to populate Highlights on
page load.
+ const fetchQuasiClosedCount = async () => {
+ try {
+ const response = await fetchData<QuasiClosedContainersResponse>(
+ '/api/v1/containers/quasiClosed',
+ 'GET',
+ { limit: 1, minContainerId: 0 }
+ );
+ setState(prev => ({
+ ...prev,
+ quasiClosedCount: response.quasiClosedCount ?? prev.quasiClosedCount,
+ }));
+ } catch (_) {
+ // Non-critical: count stays 0 until the tab is opened.
+ }
+ };
+
const fetchTabData = async (
tabKey: string,
minContainerId: number,
currentPageSize: number
) => {
const containerStateName = TAB_STATE_MAP[tabKey];
- if (!containerStateName) return; // skip Export tab (key='6') or unknown
keys
+ if (!containerStateName) return; // skip Export tab (key='7') or unknown
keys
const fetchSize = currentPageSize + 1;
setTabStates(prev => ({
...prev,
[tabKey]: { ...prev[tabKey], loading: true },
}));
+ if (tabKey === '6') {
+ // Quasi-closed tab uses its own dedicated in-memory endpoint.
+ try {
+ const response = await fetchData<QuasiClosedContainersResponse>(
+ '/api/v1/containers/quasiClosed',
+ 'GET',
+ { limit: fetchSize, minContainerId }
+ );
+ const allContainers = response.containers ?? [];
+ const hasNextPage = allContainers.length > currentPageSize;
+ const pageContainers = allContainers.slice(0, currentPageSize);
+ // Map stateEnterTime → unhealthySince so the shared ContainerTable
renders correctly.
+ const mapped = pageContainers.map(c => ({
+ ...c,
+ containerState: 'QUASI_CLOSED',
+ unhealthySince: c.stateEnterTime,
Review Comment:
Instead of doing like this, better define a mapper function, so in future it
can catch any type safety issues. If tomorrow someone renames `containerID` to
id in `QuasiClosedContainer`, TypeScript won't warn you that `c.containerID` is
now undefined
```
function toContainer(qc: QuasiClosedContainer): Container {
return {
containerID: qc.containerID,
pipelineID: qc.pipelineID,
keys: qc.keys,
containerState: 'QUASI_CLOSED',
unhealthySince: qc.stateEnterTime, // clear rename
expectedReplicaCount: qc.expectedReplicaCount,
actualReplicaCount: qc.actualReplicaCount,
replicaDeltaCount: qc.actualReplicaCount - qc.expectedReplicaCount,
reason: '',
replicas: qc.replicas,
};
}
const mapped: Container[] = pageContainers.map(toContainer); // fully
typed, no 'any'
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/container.types.ts:
##########
@@ -84,6 +101,16 @@ export type TabPaginationState = {
hasNextPage: boolean;
}
+export type QuasiClosedTabState = {
+ data: QuasiClosedContainer[];
Review Comment:
This is not used because `TabPaginationState` has data: `Container[]`, not
data: `QuasiClosedContainer[]`.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -976,4 +978,55 @@ public Response getOmContainersDeletedInSCM(
response.put("containerDiscrepancyInfo", containerDiscrepancyInfoList);
return Response.ok(response).build();
}
+
+ /**
+ * Return all containers in QUASI_CLOSED state.
+ *
+ * @param limit max no. of containers to get.
+ * @param minContainerId cursor — return containers with ID >
minContainerId.
+ * @return {@link Response}
+ */
+ @GET
+ @Path("/quasiClosed")
+ public Response getQuasiClosedContainers(
+ @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int
limit,
+ @DefaultValue(PREV_CONTAINER_ID_DEFAULT_VALUE)
+ @QueryParam(RECON_QUERY_MIN_CONTAINER_ID) long minContainerId) {
+
+ List<ContainerInfo> containers = containerManager.getContainers(
+ ContainerID.valueOf(minContainerId + 1), limit,
HddsProtos.LifeCycleState.QUASI_CLOSED);
+
+ List<QuasiClosedContainerMetadata> metaList = containers.stream()
+ .map(this::toQuasiClosedMetadata)
+ .collect(Collectors.toList());
+
+ long firstKey = metaList.isEmpty() ? minContainerId :
metaList.get(0).getContainerID();
+ long lastKey = metaList.isEmpty() ? minContainerId :
metaList.get(metaList.size() - 1).getContainerID();
+ long total =
containerManager.getContainerStateCount(HddsProtos.LifeCycleState.QUASI_CLOSED);
Review Comment:
Keep the return type same as underlying API return type.
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/containers/containers.tsx:
##########
@@ -64,6 +65,7 @@ const TAB_STATE_MAP: Record<string, string> = {
'3': 'OVER_REPLICATED',
'4': 'MIS_REPLICATED',
'5': 'REPLICA_MISMATCH',
+ '6': 'QUASI_CLOSED',
Review Comment:
Why this entry needs to be added. We are not using it anyways and deciding
the URL to call. Because for other tabs, its "`/api/v1/containers/unhealthy`",
but for tab 6, we have different URL `/quasiClosed.` Better to remove from this
map and explicitly handle using `6` as key something like:
```
if (tabKey === '6') { /* quasi-closed path */ return; }
if (!containerStateName) return; // skips tab '7' (Export)
```
##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/containers/containers.tsx:
##########
@@ -272,20 +276,86 @@ const Containers: React.FC<{}> = () => {
};
// ── Container data fetching ───────────────────────────────────────────────
+
+ // Fetches the quasi-closed count independently to populate Highlights on
page load.
+ const fetchQuasiClosedCount = async () => {
+ try {
+ const response = await fetchData<QuasiClosedContainersResponse>(
+ '/api/v1/containers/quasiClosed',
+ 'GET',
+ { limit: 1, minContainerId: 0 }
Review Comment:
Here, we are fetching full `QuasiClosedContainerMetadata` object, but we
just need count. Frontend throws away everything except `quasiClosedCount`. Can
we check if we pass limit as 0, the backend should return an empty container
list but still compute and return `quasiClosedCount`
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -976,4 +978,55 @@ public Response getOmContainersDeletedInSCM(
response.put("containerDiscrepancyInfo", containerDiscrepancyInfoList);
return Response.ok(response).build();
}
+
+ /**
+ * Return all containers in QUASI_CLOSED state.
+ *
+ * @param limit max no. of containers to get.
+ * @param minContainerId cursor — return containers with ID >
minContainerId.
+ * @return {@link Response}
+ */
+ @GET
+ @Path("/quasiClosed")
+ public Response getQuasiClosedContainers(
+ @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int
limit,
+ @DefaultValue(PREV_CONTAINER_ID_DEFAULT_VALUE)
+ @QueryParam(RECON_QUERY_MIN_CONTAINER_ID) long minContainerId) {
+
+ List<ContainerInfo> containers = containerManager.getContainers(
Review Comment:
Have some validation check here before using on `minContainerId` and `limit`.
--
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]