Example usage for org.apache.hadoop.yarn.server.api.protocolrecords NodeHeartbeatResponse getNextHeartBeatInterval

List of usage examples for org.apache.hadoop.yarn.server.api.protocolrecords NodeHeartbeatResponse getNextHeartBeatInterval

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.api.protocolrecords NodeHeartbeatResponse getNextHeartBeatInterval.

Prototype

public abstract long getNextHeartBeatInterval();

Source Link

Usage

From source file:io.hops.metadata.util.TestHopYarnAPIUtilities.java

License:Apache License

@Test(timeout = 60000)
public void testAppSubmissionAndNodeUpdate() throws Exception {
    MockRM rm = new MockRM(conf);
    rm.start();/*from w w w  . jav  a  2 s.com*/

    ClientRMService rmService = rm.getClientRMService();

    GetApplicationsRequest getRequest = GetApplicationsRequest
            .newInstance(EnumSet.of(YarnApplicationState.KILLED));

    ApplicationId appId1 = getApplicationId(100);
    ApplicationId appId2 = getApplicationId(101);

    ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
    when(mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP,
            null, appId1)).thenReturn(true);

    SubmitApplicationRequest submitRequest1 = mockSubmitAppRequest(appId1, null, null);

    SubmitApplicationRequest submitRequest2 = mockSubmitAppRequest(appId2, null, null);

    try {
        rmService.submitApplication(submitRequest1);
        rmService.submitApplication(submitRequest2);

    } catch (YarnException e) {
        Assert.fail("Exception is not expected.");
    }

    assertEquals("Incorrect number of apps in the RM", 0,
            rmService.getApplications(getRequest).getApplicationList().size());
    Thread.sleep(1000);

    //test persistance of schedulerapplication
    Map<String, SchedulerApplication> schedulerApplications = RMUtilities.getSchedulerApplications();
    assertEquals("db does not contain good number of schedulerApplications", 2, schedulerApplications.size());

    MockNM nm1 = rm.registerNode("host1:1234", 5120);
    MockNM nm2 = rm.registerNode("host2:5678", 10240);

    NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true);
    Assert.assertEquals(4000, nodeHeartbeat.getNextHeartBeatInterval());

    NodeHeartbeatResponse nodeHeartbeat2 = nm2.nodeHeartbeat(true);
    Assert.assertEquals(4000, nodeHeartbeat2.getNextHeartBeatInterval());

    Thread.sleep(2000);
    rm.stop();
    Thread.sleep(2000);
}