-
Notifications
You must be signed in to change notification settings - Fork 588
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 6 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<>(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
|
|
@@ -79,38 +84,28 @@ private boolean isContainerReplicatingOrDeleting(ContainerID containerID) { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Gets containers that are suitable for moving based on the following | ||||||||||||||||||
| * required criteria: | ||||||||||||||||||
| * 1. Container must not be undergoing replication. | ||||||||||||||||||
| * 2. Container must not already be selected for balancing. | ||||||||||||||||||
| * 3. Container size should be closer to 5GB. | ||||||||||||||||||
| * 4. Container must not be in the configured exclude containers list. | ||||||||||||||||||
| * 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. | ||||||||||||||||||
| * Get ContainerID Set for the Datanode, it will be returned as NavigableSet | ||||||||||||||||||
| * Since sorting will be time-consuming, the Set will be cached. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param node source datanode | ||||||||||||||||||
| * @return cached Navigable ContainerID Set | ||||||||||||||||||
| */ | ||||||||||||||||||
| public NavigableSet<ContainerID> getCandidateContainers( | ||||||||||||||||||
| DatanodeDetails node, long sizeMovedAlready) { | ||||||||||||||||||
| NavigableSet<ContainerID> containerIDSet = | ||||||||||||||||||
| new TreeSet<>(orderContainersByUsedBytes().reversed()); | ||||||||||||||||||
| public Set<ContainerID> getContainerIDSet(DatanodeDetails node) { | ||||||||||||||||||
| try { | ||||||||||||||||||
| containerIDSet.addAll(nodeManager.getContainers(node)); | ||||||||||||||||||
| // Initialize containerSet for node | ||||||||||||||||||
| if (!setMap.containsKey(node)) { | ||||||||||||||||||
| addNodeToSetMap(node); | ||||||||||||||||||
sumitagrawl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||
| } | ||||||||||||||||||
| // In case the node is removed | ||||||||||||||||||
| nodeManager.getContainers(node); | ||||||||||||||||||
|
||||||||||||||||||
| @Override | |
| public Boolean isNodeRegistered(DatanodeDetails datanodeDetails) { | |
| try { | |
| nodeStateManager.getNode(datanodeDetails); | |
| return true; | |
| } catch (NodeNotFoundException e) { | |
| return false; | |
| } |
sumitagrawl marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
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.
Points 1 and 2 duplicate points 6 and 4, respectively.
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.
@siddhantsangwan Thanks for the detailed review. Updated, PTAL.
Outdated
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.
@return should be updated.
Uh oh!
There was an error while loading. Please reload this page.