Search in sources :

Example 6 with ContainersLauncherEvent

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent in project hadoop by apache.

the class TestContainer method testServiceData.

/**
   * Verify serviceData correctly sent.
   */
@Test
public void testServiceData() throws Exception {
    WrappedContainer wc = null;
    try {
        wc = new WrappedContainer(9, 314159265358979L, 4344, "yak", false, true);
        assertEquals(ContainerState.NEW, wc.c.getContainerState());
        wc.initContainer();
        for (final Map.Entry<String, ByteBuffer> e : wc.serviceData.entrySet()) {
            ArgumentMatcher<AuxServicesEvent> matchesServiceReq = new ArgumentMatcher<AuxServicesEvent>() {

                @Override
                public boolean matches(Object o) {
                    AuxServicesEvent evt = (AuxServicesEvent) o;
                    return e.getKey().equals(evt.getServiceID()) && 0 == e.getValue().compareTo(evt.getServiceData());
                }
            };
            verify(wc.auxBus).handle(argThat(matchesServiceReq));
        }
        final WrappedContainer wcf = wc;
        // verify launch on empty resource request
        ArgumentMatcher<ContainersLauncherEvent> matchesLaunchReq = new ArgumentMatcher<ContainersLauncherEvent>() {

            @Override
            public boolean matches(Object o) {
                ContainersLauncherEvent evt = (ContainersLauncherEvent) o;
                return evt.getType() == ContainersLauncherEventType.LAUNCH_CONTAINER && wcf.cId.equals(evt.getContainer().getContainerId());
            }
        };
        verify(wc.launcherBus).handle(argThat(matchesLaunchReq));
    } finally {
        if (wc != null) {
            wc.finished();
        }
    }
}
Also used : ArgumentMatcher(org.mockito.ArgumentMatcher) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) AuxServicesEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServicesEvent) ContainersLauncherEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent) Test(org.junit.Test)

Aggregations

ContainersLauncherEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent)6 ContainersLauncher (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncher)2 ContainersLauncherEventType (org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEventType)2 Test (org.junit.Test)2 ArgumentMatcher (org.mockito.ArgumentMatcher)2 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileContext (org.apache.hadoop.fs.FileContext)1 Path (org.apache.hadoop.fs.Path)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)1 LogAggregationContext (org.apache.hadoop.yarn.api.records.LogAggregationContext)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 ContainerExecutor (org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor)1 Context (org.apache.hadoop.yarn.server.nodemanager.Context)1 DeletionService (org.apache.hadoop.yarn.server.nodemanager.DeletionService)1