-
Notifications
You must be signed in to change notification settings - Fork 621
HDDS-10042. Show IDs of under-replicated and unclosed containers for decommissioning nodes #5929
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
Changes from 10 commits
8c5fe3e
3675e80
743390b
98f6e65
0ffc941
42b4aa4
a8afded
01accb4
8edd010
53c54a7
4d5d2da
fadf3c4
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.hadoop.hdds.scm.node; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.collect.ImmutableList; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
|
|
@@ -96,8 +97,8 @@ public class DatanodeAdminMonitorImpl implements DatanodeAdminMonitor { | |
| public static final class TrackedNode { | ||
|
|
||
| private DatanodeDetails datanodeDetails; | ||
|
|
||
| private long startTime = 0L; | ||
| private Map<String, List<ContainerID>> containersReplicatedOnNode = new HashMap<>(); | ||
|
|
||
| public TrackedNode(DatanodeDetails datanodeDetails, long startTime) { | ||
| this.datanodeDetails = datanodeDetails; | ||
|
|
@@ -122,6 +123,15 @@ public DatanodeDetails getDatanodeDetails() { | |
| public long getStartTime() { | ||
| return startTime; | ||
| } | ||
|
|
||
| public Map<String, List<ContainerID>> getContainersReplicatedOnNode() { | ||
| return containersReplicatedOnNode; | ||
| } | ||
|
|
||
| public void setContainersReplicatedOnNode(List<ContainerID> underReplicated, List<ContainerID> unClosed) { | ||
| this.containersReplicatedOnNode.put("UnderReplicated", ImmutableList.copyOf(underReplicated)); | ||
|
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 don't think we need to make a copy of the lists here. The list are local variable so nothing can change them after we exit the method, so making a copy just adds expense. It would be find to wrap them in an Immutable list however.
Contributor
Author
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. Thank you for the review! I have changed this to Collections.unmodifiableList(containerList) |
||
| this.containersReplicatedOnNode.put("UnClosed", ImmutableList.copyOf(unClosed)); | ||
| } | ||
| } | ||
|
|
||
| private Map<String, ContainerStateInWorkflow> containerStateByHost; | ||
|
|
@@ -423,9 +433,7 @@ private boolean checkContainersReplicatedOnNode(TrackedNode dn) | |
|
|
||
| boolean isHealthy = replicaSet.isHealthyEnoughForOffline(); | ||
| if (!isHealthy) { | ||
| if (LOG.isDebugEnabled()) { | ||
| unClosedIDs.add(cid); | ||
| } | ||
| unClosedIDs.add(cid); | ||
| if (unclosed < containerDetailsLoggingLimit | ||
| || LOG.isDebugEnabled()) { | ||
| LOG.info("Unclosed Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplicas())); | ||
|
|
@@ -448,20 +456,18 @@ private boolean checkContainersReplicatedOnNode(TrackedNode dn) | |
| replicationManager.checkContainerStatus(replicaSet.getContainer(), report); | ||
| replicatedOK = report.getStat(ReplicationManagerReport.HealthState.UNDER_REPLICATED) == 0; | ||
| } | ||
|
|
||
| if (replicatedOK) { | ||
| sufficientlyReplicated++; | ||
| } else { | ||
| if (LOG.isDebugEnabled()) { | ||
| underReplicatedIDs.add(cid); | ||
| } | ||
| underReplicatedIDs.add(cid); | ||
| if (underReplicated < containerDetailsLoggingLimit || LOG.isDebugEnabled()) { | ||
| LOG.info("Under Replicated Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplicas())); | ||
| } | ||
| underReplicated++; | ||
| } | ||
| } catch (ContainerNotFoundException e) { | ||
| LOG.warn("ContainerID {} present in node list for {} but not found in containerManager", cid, dn); | ||
| LOG.warn("ContainerID {} present in node list for {} but not found in containerManager", cid, | ||
| dn.getDatanodeDetails()); | ||
| } | ||
| } | ||
| LOG.info("{} has {} sufficientlyReplicated, {} deleting, {} " + | ||
|
|
@@ -485,9 +491,21 @@ private boolean checkContainersReplicatedOnNode(TrackedNode dn) | |
| unclosed, unClosedIDs.stream().map( | ||
| Object::toString).collect(Collectors.joining(", "))); | ||
| } | ||
| dn.setContainersReplicatedOnNode(underReplicatedIDs, unClosedIDs); | ||
| return underReplicated == 0 && unclosed == 0; | ||
| } | ||
|
|
||
| public Map<String, List<ContainerID>> getContainersReplicatedOnNode(TrackedNode dn) { | ||
| Iterator<TrackedNode> iterator = trackedNodes.iterator(); | ||
|
sodonnel marked this conversation as resolved.
|
||
| while (iterator.hasNext()) { | ||
| TrackedNode trackedNode = iterator.next(); | ||
| if (trackedNode.equals(dn)) { | ||
| return trackedNode.getContainersReplicatedOnNode(); | ||
| } | ||
| } | ||
| return new HashMap<>(); | ||
| } | ||
|
|
||
| private String replicaDetails(Collection<ContainerReplica> replicas) { | ||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("Replicas{"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ | |
| import org.apache.hadoop.hdds.scm.ha.SCMHAUtils; | ||
| import org.apache.hadoop.hdds.scm.ha.SCMRatisServer; | ||
| import org.apache.hadoop.hdds.scm.ha.SCMRatisServerImpl; | ||
| import org.apache.hadoop.hdds.scm.node.DatanodeAdminMonitorImpl; | ||
| import org.apache.hadoop.hdds.scm.node.DatanodeUsageInfo; | ||
| import org.apache.hadoop.hdds.scm.node.NodeStatus; | ||
| import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException; | ||
|
|
@@ -588,6 +589,16 @@ public void deleteContainer(long containerID) throws IOException { | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, List<ContainerID>> getContainersOnDecomNode(DatanodeDetails dn) throws IOException { | ||
| try { | ||
| return scm.getScmDecommissionManager().getContainersReplicatedOnNode( | ||
| new DatanodeAdminMonitorImpl.TrackedNode(dn, 0L)); | ||
|
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. What do you think about changing this method's definition in
Contributor
Author
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 have changed it now to use DatanodeDetails instead. Only inside DatanodeAdminMonitor it uses TrackedNode to find the required node |
||
| } catch (NodeNotFoundException e) { | ||
| throw new IOException("Failed to get containers list. Unable to find required node", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public List<HddsProtos.Node> queryNode( | ||
| HddsProtos.NodeOperationalState opState, HddsProtos.NodeState state, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.