-
Notifications
You must be signed in to change notification settings - Fork 601
HDDS-14927. Add Quasi-Closed Container Tracking in Recon. #10198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,7 @@ | |
| import org.apache.hadoop.ozone.recon.api.types.KeysResponse; | ||
| import org.apache.hadoop.ozone.recon.api.types.MissingContainerMetadata; | ||
| import org.apache.hadoop.ozone.recon.api.types.MissingContainersResponse; | ||
| import org.apache.hadoop.ozone.recon.api.types.QuasiClosedContainersResponse; | ||
| import org.apache.hadoop.ozone.recon.api.types.UnhealthyContainerMetadata; | ||
| import org.apache.hadoop.ozone.recon.api.types.UnhealthyContainersResponse; | ||
| import org.apache.hadoop.ozone.recon.api.types.UnhealthyContainersSummary; | ||
|
|
@@ -447,6 +448,11 @@ private Response getUnhealthyContainersFromSchema( | |
| for (UnhealthyContainersSummary s : summary) { | ||
| response.setSummaryCount(s.getContainerState(), s.getCount()); | ||
| } | ||
|
|
||
| // Also include the quasi-closed count in the summary for the frontend Highlights tab | ||
| long quasiClosedCount = containerManager.getContainerStateCount(HddsProtos.LifeCycleState.QUASI_CLOSED); | ||
| response.setQuasiClosedCount(quasiClosedCount); | ||
|
|
||
| return Response.ok(response).build(); | ||
| } | ||
|
|
||
|
|
@@ -812,4 +818,54 @@ 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 prevKey the containerID after which results are returned. | ||
| * @return {@link Response} | ||
| */ | ||
| @GET | ||
| @Path("/quasiClosed") | ||
| public Response getQuasiClosedContainers( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not use existing /unhealthy API endpoint, why need new API end point ? |
||
| @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int limit, | ||
| @DefaultValue(PREV_CONTAINER_ID_DEFAULT_VALUE) @QueryParam(RECON_QUERY_PREVKEY) long prevKey) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this new API endpoint uses |
||
|
|
||
| List<ContainerInfo> containers = containerManager.getContainers( | ||
| ContainerID.valueOf(prevKey + 1), limit, HddsProtos.LifeCycleState.QUASI_CLOSED); | ||
|
|
||
| List<UnhealthyContainerMetadata> metaList = containers.stream() | ||
| .map(ci -> { | ||
| long containerID = ci.getContainerID(); | ||
| int requiredNodes = 0; | ||
| try { | ||
| requiredNodes = ci.getReplicationConfig().getRequiredNodes(); | ||
| } catch (Exception e) { | ||
| LOG.warn("Could not get required nodes for container {}", containerID, e); | ||
| } | ||
| List<ContainerHistory> replicas = containerManager.getLatestContainerHistory(containerID, requiredNodes); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are calling this method inside a stream lambda and has no exception handling for this method when called here. If it throws a runtime exception, then entire response will fail. Better extract whole logic into a helper method (like |
||
|
|
||
| UnhealthyContainerMetadata metadata = new UnhealthyContainerMetadata( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend to create a dedicated |
||
| containerID, | ||
| "QUASI_CLOSED", | ||
| ci.getStateEnterTime() != null ? ci.getStateEnterTime().toEpochMilli() : 0L, | ||
| requiredNodes, | ||
| replicas.size(), | ||
| replicas.size() - requiredNodes, | ||
| "", | ||
| ci.getNumberOfKeys(), | ||
| ci.getPipelineID() != null ? ci.getPipelineID().getId() : null, | ||
| replicas | ||
| ); | ||
| return metadata; | ||
| }) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| long firstKey = metaList.isEmpty() ? prevKey : metaList.get(0).getContainerID(); | ||
| long lastKey = metaList.isEmpty() ? prevKey : metaList.get(metaList.size() - 1).getContainerID(); | ||
| long total = containerManager.getContainerStateCount(HddsProtos.LifeCycleState.QUASI_CLOSED); | ||
|
|
||
| return Response.ok(new QuasiClosedContainersResponse(total, firstKey, lastKey, metaList)).build(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, this |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.recon.api.types; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Class that represents the API Response structure for Quasi-Closed Containers. | ||
| */ | ||
| public class QuasiClosedContainersResponse { | ||
|
|
||
| @JsonProperty("quasiClosedCount") | ||
| private long quasiClosedCount = 0; | ||
|
|
||
| @JsonProperty("firstKey") | ||
| private long firstKey = 0; | ||
|
|
||
| @JsonProperty("lastKey") | ||
| private long lastKey = 0; | ||
|
|
||
| @JsonProperty("containers") | ||
| private List<UnhealthyContainerMetadata> containers; | ||
|
|
||
| public QuasiClosedContainersResponse() { | ||
| } | ||
|
|
||
| public QuasiClosedContainersResponse(long quasiClosedCount, long firstKey, long lastKey, | ||
| List<UnhealthyContainerMetadata> containers) { | ||
| this.quasiClosedCount = quasiClosedCount; | ||
| this.firstKey = firstKey; | ||
| this.lastKey = lastKey; | ||
| this.containers = containers; | ||
| } | ||
|
|
||
| public long getQuasiClosedCount() { | ||
| return quasiClosedCount; | ||
| } | ||
|
|
||
| public void setQuasiClosedCount(long quasiClosedCount) { | ||
| this.quasiClosedCount = quasiClosedCount; | ||
| } | ||
|
|
||
| public long getFirstKey() { | ||
| return firstKey; | ||
| } | ||
|
|
||
| public void setFirstKey(long firstKey) { | ||
| this.firstKey = firstKey; | ||
| } | ||
|
|
||
| public long getLastKey() { | ||
| return lastKey; | ||
| } | ||
|
|
||
| public void setLastKey(long lastKey) { | ||
| this.lastKey = lastKey; | ||
| } | ||
|
|
||
| public List<UnhealthyContainerMetadata> getContainers() { | ||
| return containers; | ||
| } | ||
|
|
||
| public void setContainers(List<UnhealthyContainerMetadata> containers) { | ||
| this.containers = containers; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is not good to inject here, because above all calls are fetching data from DB, so they are making DB call. But here, its a in-memory data to be retrieved and if user just wants to see QUASI CLOSED containers, we are simply making DB call also and retrieving all other unhealthy containers.