Search in sources :

Example 1 with ContainerState

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState in project hadoop by apache.

the class ResourceLocalizationService method handleInitContainerResources.

/**
   * For each of the requested resources for a container, determines the
   * appropriate {@link LocalResourcesTracker} and forwards a 
   * {@link LocalResourceRequest} to that tracker.
   */
private void handleInitContainerResources(ContainerLocalizationRequestEvent rsrcReqs) {
    Container c = rsrcReqs.getContainer();
    EnumSet<ContainerState> set = EnumSet.of(ContainerState.LOCALIZING, ContainerState.RUNNING, ContainerState.REINITIALIZING);
    if (!set.contains(c.getContainerState())) {
        LOG.warn(c.getContainerId() + " is at " + c.getContainerState() + " state, do not localize resources.");
        return;
    }
    // create a loading cache for the file statuses
    LoadingCache<Path, Future<FileStatus>> statCache = CacheBuilder.newBuilder().build(FSDownload.createStatusCacheLoader(getConfig()));
    LocalizerContext ctxt = new LocalizerContext(c.getUser(), c.getContainerId(), c.getCredentials(), statCache);
    Map<LocalResourceVisibility, Collection<LocalResourceRequest>> rsrcs = rsrcReqs.getRequestedResources();
    for (Map.Entry<LocalResourceVisibility, Collection<LocalResourceRequest>> e : rsrcs.entrySet()) {
        LocalResourcesTracker tracker = getLocalResourcesTracker(e.getKey(), c.getUser(), c.getContainerId().getApplicationAttemptId().getApplicationId());
        for (LocalResourceRequest req : e.getValue()) {
            tracker.handle(new ResourceRequestEvent(req, e.getKey(), ctxt));
            if (LOG.isDebugEnabled()) {
                LOG.debug("Localizing " + req.getPath() + " for container " + c.getContainerId());
            }
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ContainerState(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState) LocalResourceVisibility(org.apache.hadoop.yarn.api.records.LocalResourceVisibility) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) LocalizerResourceRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerResourceRequestEvent) ResourceRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent) Future(java.util.concurrent.Future) Collection(java.util.Collection) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Future (java.util.concurrent.Future)1 Path (org.apache.hadoop.fs.Path)1 LocalResourceVisibility (org.apache.hadoop.yarn.api.records.LocalResourceVisibility)1 Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)1 ContainerState (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState)1 LocalizerResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerResourceRequestEvent)1 ResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent)1