Search in sources :

Example 11 with ResourceRequestEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent in project hadoop by apache.

the class TestLocalResourcesTrackerImpl method testReleaseWhileDownloading.

@Test
@SuppressWarnings("unchecked")
public void testReleaseWhileDownloading() throws Exception {
    String user = "testuser";
    DrainDispatcher dispatcher = null;
    try {
        Configuration conf = new Configuration();
        dispatcher = createDispatcher(conf);
        EventHandler<LocalizerEvent> localizerEventHandler = mock(EventHandler.class);
        EventHandler<LocalizerEvent> containerEventHandler = mock(EventHandler.class);
        dispatcher.register(LocalizerEventType.class, localizerEventHandler);
        dispatcher.register(ContainerEventType.class, containerEventHandler);
        ContainerId cId = BuilderUtils.newContainerId(1, 1, 1, 1);
        LocalizerContext lc = new LocalizerContext(user, cId, null);
        LocalResourceRequest req = createLocalResourceRequest(user, 1, 1, LocalResourceVisibility.PUBLIC);
        LocalizedResource lr = createLocalizedResource(req, dispatcher);
        ConcurrentMap<LocalResourceRequest, LocalizedResource> localrsrc = new ConcurrentHashMap<LocalResourceRequest, LocalizedResource>();
        localrsrc.put(req, lr);
        LocalResourcesTracker tracker = new LocalResourcesTrackerImpl(user, null, dispatcher, localrsrc, false, conf, new NMNullStateStoreService(), null);
        // request the resource
        ResourceEvent reqEvent = new ResourceRequestEvent(req, LocalResourceVisibility.PUBLIC, lc);
        tracker.handle(reqEvent);
        // release the resource
        ResourceEvent relEvent = new ResourceReleaseEvent(req, cId);
        tracker.handle(relEvent);
        // download completing after release
        ResourceLocalizedEvent rle = new ResourceLocalizedEvent(req, new Path("file:///tmp/r1"), 1);
        tracker.handle(rle);
        dispatcher.await();
    } finally {
        if (dispatcher != null) {
            dispatcher.stop();
        }
    }
}
Also used : DrainDispatcher(org.apache.hadoop.yarn.event.DrainDispatcher) Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceLocalizedEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceLocalizedEvent) ContainerResourceLocalizedEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceLocalizedEvent) ResourceReleaseEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceReleaseEvent) NMNullStateStoreService(org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService) LocalizerEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) LocalizerResourceRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerResourceRequestEvent) ResourceRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent) ResourceEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.junit.Test)

Aggregations

Path (org.apache.hadoop.fs.Path)11 LocalizerResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerResourceRequestEvent)11 ResourceRequestEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceRequestEvent)11 Configuration (org.apache.hadoop.conf.Configuration)10 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)10 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)10 LocalizerEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizerEvent)10 Test (org.junit.Test)10 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)9 ResourceEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceEvent)9 ResourceLocalizedEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceLocalizedEvent)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 ContainerResourceLocalizedEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceLocalizedEvent)7 ResourceReleaseEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceReleaseEvent)7 NMNullStateStoreService (org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService)6 IOException (java.io.IOException)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)3 DeletionService (org.apache.hadoop.yarn.server.nodemanager.DeletionService)3 ResourceFailedLocalizationEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ResourceFailedLocalizationEvent)3 NMStateStoreService (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService)3