-
Notifications
You must be signed in to change notification settings - Fork 616
HDDS-10160. Cache sort results in ContainerBalancerSelectionCriteria #6050
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 2 commits
63b257a
e18496a
968cde7
2f4ec85
05c5a05
54d336f
7f3b085
92c7ba0
7b590d2
b2c3bcb
8c00ae7
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,8 +31,11 @@ | |||||||||||||||||
| import org.slf4j.Logger; | ||||||||||||||||||
| import org.slf4j.LoggerFactory; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.util.Collections; | ||||||||||||||||||
| import java.util.Comparator; | ||||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||||
| import java.util.HashSet; | ||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||
| import java.util.NavigableSet; | ||||||||||||||||||
| import java.util.Set; | ||||||||||||||||||
| import java.util.TreeSet; | ||||||||||||||||||
|
|
@@ -52,6 +55,7 @@ public class ContainerBalancerSelectionCriteria { | |||||||||||||||||
| private Set<ContainerID> selectedContainers; | ||||||||||||||||||
| private Set<ContainerID> excludeContainers; | ||||||||||||||||||
| private FindSourceStrategy findSourceStrategy; | ||||||||||||||||||
| private Map<DatanodeDetails, NavigableSet<ContainerID>> setMap; | ||||||||||||||||||
|
|
||||||||||||||||||
| public ContainerBalancerSelectionCriteria( | ||||||||||||||||||
| ContainerBalancerConfiguration balancerConfiguration, | ||||||||||||||||||
|
|
@@ -66,6 +70,7 @@ public ContainerBalancerSelectionCriteria( | |||||||||||||||||
| selectedContainers = new HashSet<>(); | ||||||||||||||||||
| excludeContainers = balancerConfiguration.getExcludeContainers(); | ||||||||||||||||||
| this.findSourceStrategy = findSourceStrategy; | ||||||||||||||||||
| this.setMap = new HashMap<>(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
|
|
@@ -88,19 +93,25 @@ private boolean isContainerReplicatingOrDeleting(ContainerID containerID) { | |||||||||||||||||
| * 5. Container should be closed. | ||||||||||||||||||
| * 6. If the {@link LegacyReplicationManager} is enabled, then the container should not be an EC container. | ||||||||||||||||||
| * @param node DatanodeDetails for which to find candidate containers. | ||||||||||||||||||
| * @return NavigableSet of candidate containers that satisfy the criteria. | ||||||||||||||||||
| * @return Set of candidate containers that satisfy the criteria. | ||||||||||||||||||
| */ | ||||||||||||||||||
| public NavigableSet<ContainerID> getCandidateContainers( | ||||||||||||||||||
| public Set<ContainerID> getCandidateContainers( | ||||||||||||||||||
| DatanodeDetails node, long sizeMovedAlready) { | ||||||||||||||||||
| NavigableSet<ContainerID> containerIDSet = | ||||||||||||||||||
| new TreeSet<>(orderContainersByUsedBytes().reversed()); | ||||||||||||||||||
| try { | ||||||||||||||||||
| containerIDSet.addAll(nodeManager.getContainers(node)); | ||||||||||||||||||
| // Initialize containerSet for node | ||||||||||||||||||
| if (!setMap.containsKey(node)) { | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
Outdated
|
||||||||||||||||||
| addNodeToSetMap(node); | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
Outdated
|
||||||||||||||||||
| } | ||||||||||||||||||
| // In case the node is removed | ||||||||||||||||||
| nodeManager.getContainers(node); | ||||||||||||||||||
|
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. Are we making this call just to see if an exception gets thrown? In that case this is a bit awkward and confusing. Does node manager provide an API that we can use first to check if SCM knows the node, and then get its containers (or remove them from the cache is the node isn't there anymore)?
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. Yes, since currently there is no explicit method to check if a node exists, this is used for this check.
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. Maybe
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 agree with @sodonnel. Would ozone/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java Lines 627 to 634 in ac597ad
|
||||||||||||||||||
| } catch (NodeNotFoundException e) { | ||||||||||||||||||
| LOG.warn("Could not find Datanode {} while selecting candidate " + | ||||||||||||||||||
| "containers for Container Balancer.", node.toString(), e); | ||||||||||||||||||
| return containerIDSet; | ||||||||||||||||||
| setMap.remove(node); | ||||||||||||||||||
| return Collections.emptySet(); | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
|
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| NavigableSet<ContainerID> containerIDSet = setMap.get(node); | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
Outdated
|
||||||||||||||||||
| if (excludeContainers != null) { | ||||||||||||||||||
| containerIDSet.removeAll(excludeContainers); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -242,4 +253,12 @@ public void setSelectedContainers( | |||||||||||||||||
| this.selectedContainers = selectedContainers; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| private void addNodeToSetMap(DatanodeDetails node) | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
Outdated
|
||||||||||||||||||
| throws NodeNotFoundException { | ||||||||||||||||||
| NavigableSet<ContainerID> newSet = | ||||||||||||||||||
| new TreeSet<>(orderContainersByUsedBytes().reversed()); | ||||||||||||||||||
| newSet.addAll(nodeManager.getContainers(node)); | ||||||||||||||||||
|
sumitagrawl marked this conversation as resolved.
Outdated
|
||||||||||||||||||
| setMap.put(node, newSet); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.