Search in sources :

Example 16 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class TestTimelineClient method testPostEntitiesWithError.

@Test
public void testPostEntitiesWithError() throws Exception {
    mockEntityClientResponse(spyTimelineWriter, ClientResponse.Status.OK, true, false);
    try {
        TimelinePutResponse response = client.putEntities(generateEntity());
        Assert.assertEquals(1, response.getErrors().size());
        Assert.assertEquals("test entity id", response.getErrors().get(0).getEntityId());
        Assert.assertEquals("test entity type", response.getErrors().get(0).getEntityType());
        Assert.assertEquals(TimelinePutResponse.TimelinePutError.IO_EXCEPTION, response.getErrors().get(0).getErrorCode());
    } catch (YarnException e) {
        Assert.fail("Exception is not expected");
    }
}
Also used : TimelinePutResponse(org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 17 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class TestTimelineClientV2Impl method testConfigurableNumberOfMerges.

@Test
public void testConfigurableNumberOfMerges() throws Exception {
    client.setSleepBeforeReturn(true);
    try {
        // At max 3 entities need to be merged
        client.putEntitiesAsync(generateEntity("1"));
        client.putEntitiesAsync(generateEntity("2"));
        client.putEntitiesAsync(generateEntity("3"));
        client.putEntitiesAsync(generateEntity("4"));
        client.putEntities(generateEntity("5"));
        client.putEntitiesAsync(generateEntity("6"));
        client.putEntitiesAsync(generateEntity("7"));
        client.putEntitiesAsync(generateEntity("8"));
        client.putEntitiesAsync(generateEntity("9"));
        client.putEntitiesAsync(generateEntity("10"));
    } catch (YarnException e) {
        Assert.fail("No exception expected");
    }
    // not having the same logic here as it doesn't depend on how many times
    // events are published.
    Thread.sleep(2 * TIME_TO_SLEEP);
    printReceivedEntities();
    for (TimelineEntities publishedEntities : client.publishedEntities) {
        Assert.assertTrue("Number of entities should not be greater than 3 for each publish," + " but was " + publishedEntities.getEntities().size(), publishedEntities.getEntities().size() <= 3);
    }
}
Also used : TimelineEntities(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 18 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class TestRPC method testUnknownCall.

@Test
public void testUnknownCall() {
    Configuration conf = new Configuration();
    conf.set(YarnConfiguration.IPC_RPC_IMPL, HadoopYarnProtoRPC.class.getName());
    YarnRPC rpc = YarnRPC.create(conf);
    String bindAddr = "localhost:0";
    InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
    Server server = rpc.getServer(ContainerManagementProtocol.class, new DummyContainerManager(), addr, conf, null, 1);
    server.start();
    // Any unrelated protocol would do
    ApplicationClientProtocol proxy = (ApplicationClientProtocol) rpc.getProxy(ApplicationClientProtocol.class, NetUtils.getConnectAddress(server), conf);
    try {
        proxy.getNewApplication(Records.newRecord(GetNewApplicationRequest.class));
        Assert.fail("Excepted RPC call to fail with unknown method.");
    } catch (YarnException e) {
        Assert.assertTrue(e.getMessage().matches("Unknown method getNewApplication called on.*" + "org.apache.hadoop.yarn.proto.ApplicationClientProtocol" + "\\$ApplicationClientProtocolService\\$BlockingInterface " + "protocol."));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        server.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Server(org.apache.hadoop.ipc.Server) InetSocketAddress(java.net.InetSocketAddress) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) HadoopYarnProtoRPC(org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) GetNewApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest) Test(org.junit.Test)

Example 19 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class TestRPC method testRPCOnCollectorNodeManagerProtocol.

@Test
public void testRPCOnCollectorNodeManagerProtocol() throws IOException {
    Configuration conf = new Configuration();
    conf.set(YarnConfiguration.IPC_RPC_IMPL, HadoopYarnProtoRPC.class.getName());
    YarnRPC rpc = YarnRPC.create(conf);
    String bindAddr = "localhost:0";
    InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
    Server server = rpc.getServer(CollectorNodemanagerProtocol.class, new DummyNMCollectorService(), addr, conf, null, 1);
    server.start();
    // Test unrelated protocol wouldn't get response
    ApplicationClientProtocol unknownProxy = (ApplicationClientProtocol) rpc.getProxy(ApplicationClientProtocol.class, NetUtils.getConnectAddress(server), conf);
    try {
        unknownProxy.getNewApplication(Records.newRecord(GetNewApplicationRequest.class));
        Assert.fail("Excepted RPC call to fail with unknown method.");
    } catch (YarnException e) {
        Assert.assertTrue(e.getMessage().matches("Unknown method getNewApplication called on.*" + "org.apache.hadoop.yarn.proto.ApplicationClientProtocol" + "\\$ApplicationClientProtocolService\\$BlockingInterface " + "protocol."));
    } catch (Exception e) {
        e.printStackTrace();
    }
    // Test CollectorNodemanagerProtocol get proper response
    CollectorNodemanagerProtocol proxy = (CollectorNodemanagerProtocol) rpc.getProxy(CollectorNodemanagerProtocol.class, NetUtils.getConnectAddress(server), conf);
    // normally response.
    try {
        ReportNewCollectorInfoRequest request = ReportNewCollectorInfoRequest.newInstance(DEFAULT_APP_ID, DEFAULT_COLLECTOR_ADDR);
        proxy.reportNewCollectorInfo(request);
    } catch (YarnException e) {
        Assert.fail("RPC call failured is not expected here.");
    }
    // DummyNMCollectorService)
    try {
        proxy.reportNewCollectorInfo(Records.newRecord(ReportNewCollectorInfoRequest.class));
        Assert.fail("Excepted RPC call to fail with YarnException.");
    } catch (YarnException e) {
        Assert.assertTrue(e.getMessage().contains(ILLEGAL_NUMBER_MESSAGE));
    }
    // Verify request with a valid app ID
    try {
        GetTimelineCollectorContextRequest request = GetTimelineCollectorContextRequest.newInstance(ApplicationId.newInstance(0, 1));
        GetTimelineCollectorContextResponse response = proxy.getTimelineCollectorContext(request);
        Assert.assertEquals("test_user_id", response.getUserId());
        Assert.assertEquals("test_flow_name", response.getFlowName());
        Assert.assertEquals("test_flow_version", response.getFlowVersion());
        Assert.assertEquals(12345678L, response.getFlowRunId());
    } catch (YarnException | IOException e) {
        Assert.fail("RPC call failured is not expected here.");
    }
    // Verify request with an invalid app ID
    try {
        GetTimelineCollectorContextRequest request = GetTimelineCollectorContextRequest.newInstance(ApplicationId.newInstance(0, 2));
        proxy.getTimelineCollectorContext(request);
        Assert.fail("RPC call failured is expected here.");
    } catch (YarnException | IOException e) {
        Assert.assertTrue(e instanceof YarnException);
        Assert.assertTrue(e.getMessage().contains("The application is not found."));
    }
    server.stop();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Server(org.apache.hadoop.ipc.Server) CollectorNodemanagerProtocol(org.apache.hadoop.yarn.server.api.CollectorNodemanagerProtocol) GetTimelineCollectorContextRequest(org.apache.hadoop.yarn.server.api.protocolrecords.GetTimelineCollectorContextRequest) InetSocketAddress(java.net.InetSocketAddress) ReportNewCollectorInfoRequest(org.apache.hadoop.yarn.server.api.protocolrecords.ReportNewCollectorInfoRequest) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) IOException(java.io.IOException) HadoopYarnProtoRPC(org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) GetNewApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest) GetTimelineCollectorContextResponse(org.apache.hadoop.yarn.server.api.protocolrecords.GetTimelineCollectorContextResponse) Test(org.junit.Test)

Example 20 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class TestResourceTrackerPBClientImpl method testUnRegisterNodeManager.

/**
   * Test the method unRegisterNodeManager. Method should return a not null
   * result.
   *
   */
@Test
public void testUnRegisterNodeManager() throws Exception {
    UnRegisterNodeManagerRequest request = UnRegisterNodeManagerRequest.newInstance(NodeId.newInstance("host1", 1234));
    assertNotNull(client.unRegisterNodeManager(request));
    ResourceTrackerTestImpl.exception = true;
    try {
        client.unRegisterNodeManager(request);
        fail("there  should be YarnException");
    } catch (YarnException e) {
        assertTrue(e.getMessage().startsWith("testMessage"));
    } finally {
        ResourceTrackerTestImpl.exception = false;
    }
}
Also used : UnRegisterNodeManagerRequest(org.apache.hadoop.yarn.server.api.protocolrecords.UnRegisterNodeManagerRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

YarnException (org.apache.hadoop.yarn.exceptions.YarnException)287 IOException (java.io.IOException)149 Test (org.junit.Test)107 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)61 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)44 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)31 Configuration (org.apache.hadoop.conf.Configuration)26 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)26 ArrayList (java.util.ArrayList)25 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)25 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)25 AccessControlException (org.apache.hadoop.security.AccessControlException)22 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)21 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)17 Path (org.apache.hadoop.fs.Path)17 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)15 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)15 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)14 HashMap (java.util.HashMap)13 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)13