private boolean shouldUploadLogs(ContainerId containerId, boolean wasContainerSuccessful) { // All containers if (this.retentionPolicy.equals(ContainerLogsRetentionPolicy.ALL_CONTAINERS)) { return true; } // AM Container only if (this.retentionPolicy.equals(ContainerLogsRetentionPolicy.APPLICATION_MASTER_ONLY)) { if (containerId.getId() == 1) { return true; } return false; } // AM + Failing containers if (this.retentionPolicy.equals(ContainerLogsRetentionPolicy.AM_AND_FAILED_CONTAINERS_ONLY)) { if (containerId.getId() == 1) { return true; } else if (!wasContainerSuccessful) { return true; } return false; } return false; }
/** * Changed the return type to AllocateResponse which use to hold a reference to AMResponse. * * <p>AMResponse seems to have disappeared in CDH 4.6 * * @param requestedContainers * @param releasedContainers * @return * @throws YarnRemoteException */ public AllocateResponse allocateRequest( List<ResourceRequest> requestedContainers, List<ContainerId> releasedContainers) throws YarnRemoteException { if (amResourceManager == null) throw new IllegalStateException( "Cannot send allocation request before connecting to the resource manager!"); LOG.info( "Sending allocation request" + ", requestedSize=" + requestedContainers.size() + ", releasedSize=" + releasedContainers.size()); for (ResourceRequest req : requestedContainers) LOG.info( "Requesting container, host=" + req.getHostName() + ", amount=" + req.getNumContainers() + ", memory=" + req.getCapability().getMemory() + ", priority=" + req.getPriority().getPriority()); for (ContainerId rel : releasedContainers) LOG.info("Releasing container: " + rel.getId()); AllocateRequest request = Records.newRecord(AllocateRequest.class); request.setResponseId(rmRequestId.incrementAndGet()); request.setApplicationAttemptId(appAttemptId); request.addAllAsks(requestedContainers); request.addAllReleases(releasedContainers); AllocateResponse response = amResourceManager.allocate(request); // response.getAllocatedContainers() LOG.debug( "Got an allocation response, " + ", responseId=" + response.getResponseId() + ", numClusterNodes=" + response.getNumClusterNodes() + ", headroom=" + response.getAvailableResources().getMemory() + ", allocatedSize=" + response.getAllocatedContainers().size() + ", updatedNodes=" + response.getUpdatedNodes().size() + ", reboot=" + response.getReboot() + ", completedSize=" + response.getCompletedContainersStatuses().size()); return response; }