Search in sources :

Example 6 with LocalResourceProto

use of org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto in project hadoop by apache.

the class ResourceLocalizationService method recoverTrackerResources.

private void recoverTrackerResources(LocalResourcesTracker tracker, LocalResourceTrackerState state) throws URISyntaxException {
    for (LocalizedResourceProto proto : state.getLocalizedResources()) {
        LocalResource rsrc = new LocalResourcePBImpl(proto.getResource());
        LocalResourceRequest req = new LocalResourceRequest(rsrc);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Recovering localized resource " + req + " at " + proto.getLocalPath());
        }
        tracker.handle(new ResourceRecoveredEvent(req, new Path(proto.getLocalPath()), proto.getSize()));
    }
    for (Map.Entry<LocalResourceProto, Path> entry : state.getInProgressResources().entrySet()) {
        LocalResource rsrc = new LocalResourcePBImpl(entry.getKey());
        LocalResourceRequest req = new LocalResourceRequest(rsrc);
        Path localPath = entry.getValue();
        tracker.handle(new ResourceRecoveredEvent(req, localPath, 0));
        // delete any in-progress localizations, containers will request again
        LOG.info("Deleting in-progress localization for " + req + " at " + localPath);
        tracker.remove(tracker.getLocalizedResource(req), delService);
    }
// TODO: remove untracked directories in local filesystem
}
Also used : Path(org.apache.hadoop.fs.Path) ResourceRecoveredEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRecoveredEvent) LocalizedResourceProto(org.apache.hadoop.yarn.proto.YarnServerNodemanagerRecoveryProtos.LocalizedResourceProto) LocalResourcePBImpl(org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LocalResourceProto(org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource)

Example 7 with LocalResourceProto

use of org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto in project hadoop by apache.

the class NMLeveldbStateStoreService method loadStartedResources.

private Map<LocalResourceProto, Path> loadStartedResources(LeveldbIterator iter, String keyPrefix) throws IOException {
    Map<LocalResourceProto, Path> rsrcs = new HashMap<LocalResourceProto, Path>();
    while (iter.hasNext()) {
        Entry<byte[], byte[]> entry = iter.peekNext();
        String key = asString(entry.getKey());
        if (!key.startsWith(keyPrefix)) {
            break;
        }
        Path localPath = new Path(key.substring(keyPrefix.length()));
        if (LOG.isDebugEnabled()) {
            LOG.debug("Loading in-progress resource at " + localPath);
        }
        rsrcs.put(LocalResourceProto.parseFrom(entry.getValue()), localPath);
        iter.next();
    }
    return rsrcs;
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) LocalResourceProto(org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto)

Aggregations

Path (org.apache.hadoop.fs.Path)7 LocalResourceProto (org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto)7 LocalResourcePBImpl (org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl)6 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)5 Test (org.junit.Test)5 LocalizedResourceProto (org.apache.hadoop.yarn.proto.YarnServerNodemanagerRecoveryProtos.LocalizedResourceProto)4 LocalResourceTrackerState (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService.LocalResourceTrackerState)3 RecoveredLocalizationState (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService.RecoveredLocalizationState)3 RecoveredUserResources (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService.RecoveredUserResources)3 HashMap (java.util.HashMap)2 Configuration (org.apache.hadoop.conf.Configuration)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)2 LocalizerEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerEvent)2 LocalizerResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerResourceRequestEvent)2 ResourceEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceEvent)2 ResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent)2 NMStateStoreService (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService)2 IOException (java.io.IOException)1