-
Notifications
You must be signed in to change notification settings - Fork 16
Patch to fix DONT_CARE locality enforcement flag that is ignored at the moment #3
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: cdh5-1.0.0
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -573,6 +573,11 @@ private void _reserve(Collection<RMResource> resources) | |
| resource.getRmData().put("request", request); | ||
|
|
||
| resource.getRmData().put(YARN_RM_CONNECTOR_KEY, this); | ||
|
|
||
| /*Keeping resources which relax locality in the separate map to handle them when possible*/ | ||
| if(resource.getLocalityAsk()!= com.cloudera.llama.am.api.Resource.Locality.MUST) { | ||
| anyLocationResourceIdToRequestMap.put(resource.getResourceId(), request); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -660,6 +665,9 @@ public void emptyCache() throws LlamaException { | |
| ConcurrentHashMap<ContainerId, UUID> containerToResourceMap = | ||
| new ConcurrentHashMap<ContainerId, UUID>(); | ||
|
|
||
| ConcurrentHashMap<UUID, LlamaContainerRequest> anyLocationResourceIdToRequestMap = | ||
| new ConcurrentHashMap<UUID, LlamaContainerRequest>(); | ||
|
|
||
| @Override | ||
| public void onContainersCompleted(List<ContainerStatus> containerStatuses) { | ||
| List<RMEvent> changes = new ArrayList<RMEvent>(); | ||
|
|
@@ -768,10 +776,27 @@ private RMEvent createResourceAllocation(RMResource resources, | |
| resources.getRmData()); | ||
| } | ||
|
|
||
| private void handleContainerMatchingRequest(Container container, LlamaContainerRequest req, List<RMEvent> changes) { | ||
| RMResource resource = req.getResourceAsk(); | ||
|
|
||
| LOG.debug("New allocation for '{}' container '{}', node '{}'", | ||
| resource, container.getId(), container.getNodeId()); | ||
|
|
||
| resource.getRmData().put("container", container); | ||
| containerToResourceMap.put(container.getId(), | ||
| resource.getResourceId()); | ||
| changes.add(createResourceAllocation(resource, container)); | ||
| amRmClientAsync.removeContainerRequest(req); | ||
| LOG.trace("Reservation resource '{}' removed from YARN", resource); | ||
|
|
||
| queue(new ContainerHandler(ugi, resource, container, Action.START)); | ||
| } | ||
|
|
||
| @Override | ||
| public void onContainersAllocated(List<Container> containers) { | ||
| List<RMEvent> changes = new ArrayList<RMEvent>(); | ||
| // no need to use a ugi.doAs() as this is called from within Yarn client | ||
| List<Container> unclaimedContainers = new ArrayList<Container>(); | ||
| for (Container container : containers) { | ||
| List<? extends Collection<LlamaContainerRequest>> matchingContainerReqs = | ||
| amRmClientAsync.getMatchingRequests(container.getPriority(), | ||
|
|
@@ -793,23 +818,36 @@ public void onContainersAllocated(List<Container> containers) { | |
| LOG.error("There was a match for container '{}', " + | ||
| "LlamaContainerRequest cannot be NULL", container); | ||
| } else { | ||
| RMResource resource = req.getResourceAsk(); | ||
|
|
||
| LOG.debug("New allocation for '{}' container '{}', node '{}'", | ||
| resource, container.getId(), container.getNodeId()); | ||
|
|
||
| resource.getRmData().put("container", container); | ||
| containerToResourceMap.put(container.getId(), | ||
| resource.getResourceId()); | ||
| changes.add(createResourceAllocation(resource, container)); | ||
| amRmClientAsync.removeContainerRequest(req); | ||
| LOG.trace("Reservation resource '{}' removed from YARN", resource); | ||
|
|
||
| queue(new ContainerHandler(ugi, resource, container, Action.START)); | ||
| handleContainerMatchingRequest(container, req, changes); | ||
| /*Remove the granted request from anyLocationResourceIdToRequestMap if it is there*/ | ||
| anyLocationResourceIdToRequestMap.remove(req.getResourceAsk().getResourceId()); | ||
| } | ||
| } else { | ||
| LOG.error("No matching request for {}. Releasing the container.", | ||
| LOG.debug("No strong request match for {}. Adding to the list of unclaimed containers.", | ||
| container); | ||
| unclaimedContainers.add(container); | ||
| } | ||
| } | ||
| /*Matching YARN resources against requests relaxing locality*/ | ||
|
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. In the interest of readability, would it make sense to do this in a separate private method?
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. After moving the duplicate code into the separate private method, onContainersAllocated method looks quite concise and readable. Please let me know if you still would like me to move weak match logic into separate method also. |
||
| for (Container container : unclaimedContainers) { | ||
| /*Looking for requests with 'DONT_CARE' or 'PREFERRED' locality which match with the resources we've got*/ | ||
| boolean containerIsClaimed = false; | ||
| Iterator<Map.Entry<UUID, LlamaContainerRequest>> iterator = anyLocationResourceIdToRequestMap.entrySet().iterator(); | ||
| while (iterator.hasNext()) { | ||
| Map.Entry<UUID, LlamaContainerRequest> entry = iterator.next(); | ||
| LlamaContainerRequest request = entry.getValue(); | ||
| /*Matching by the capacity only*/ | ||
| if(request.getResourceAsk().getCpuVCoresAsk() == container.getResource().getVirtualCores() && | ||
| request.getResourceAsk().getMemoryMbsAsk() == container.getResource().getMemory()) { | ||
| handleContainerMatchingRequest(container, request, changes); | ||
| iterator.remove(); | ||
| containerIsClaimed = true; | ||
| break; | ||
| } | ||
| } | ||
| if(!containerIsClaimed) { | ||
| LOG.error("No matching request for {}. Releasing the container.", | ||
| container); | ||
| containerToResourceMap.remove(container.getId()); | ||
| amRmClientAsync.releaseAssignedContainer(container.getId()); | ||
| } | ||
|
|
||
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.
Thanks for updating this. Can we also update the reference to "caching.enabled" in llama-site.xml as well?
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.
Done