/** * A container has been allocated on a node -update the data structures * @param container container * @param desiredCount desired #of instances * @param actualCount current count of instances * @return The allocation outcome */ public synchronized ContainerAllocationResults onContainerAllocated(Container container, long desiredCount, long actualCount) { int role = ContainerPriority.extractRole(container); String hostname = RoleHistoryUtils.hostnameOf(container); List<NodeInstance> nodeInstances = listRecentNodesForRoleId(role); ContainerAllocationResults outcome = outstandingRequests.onContainerAllocated(role, hostname, container); if (desiredCount <= actualCount) { // all outstanding requests have been satisfied // clear all the lists, so returning nodes to the available set List<NodeInstance> hosts = outstandingRequests.resetOutstandingRequests(role); if (!hosts.isEmpty()) { //add the list log.info("Adding {} hosts for role {}", hosts.size(), role); nodeInstances.addAll(hosts); sortRecentNodeList(role); } } return outcome; }
/** * A container has been allocated on a node -update the data structures * @param container container * @param desiredCount desired #of instances * @param actualCount current count of instances * @return The allocation outcome */ public synchronized ContainerAllocationResults onContainerAllocated(Container container, long desiredCount, long actualCount) { int role = ContainerPriority.extractRole(container); String hostname = RoleHistoryUtils.hostnameOf(container); List<NodeInstance> nodeInstances = listRecentNodesForRoleId(role); ContainerAllocationResults outcome = outstandingRequests.onContainerAllocated(role, hostname, container); if (desiredCount <= actualCount) { // all outstanding requests have been satisfied // clear all the lists, so returning nodes to the available set List<NodeInstance> hosts = outstandingRequests.resetOutstandingRequests(role); if (!hosts.isEmpty()) { //add the list log.info("Adding {} hosts for role {}", hosts.size(), role); nodeInstances.addAll(hosts); sortRecentNodeList(role); } } return outcome; }