Search in sources :

Example 31 with MiniYARNCluster

use of org.apache.hadoop.yarn.server.MiniYARNCluster in project hadoop by apache.

the class TestYarnClient method testUpdateReservation.

@Test
public void testUpdateReservation() throws Exception {
    MiniYARNCluster cluster = setupMiniYARNCluster();
    YarnClient client = setupYarnClient(cluster);
    try {
        Clock clock = new UTCClock();
        long arrival = clock.getTime();
        long duration = 60000;
        long deadline = (long) (arrival + 1.05 * duration);
        ReservationSubmissionRequest sRequest = submitReservationTestHelper(client, arrival, deadline, duration);
        ReservationDefinition rDef = sRequest.getReservationDefinition();
        ReservationRequest rr = rDef.getReservationRequests().getReservationResources().get(0);
        ReservationId reservationID = sRequest.getReservationId();
        rr.setNumContainers(5);
        arrival = clock.getTime();
        duration = 30000;
        deadline = (long) (arrival + 1.05 * duration);
        rr.setDuration(duration);
        rDef.setArrival(arrival);
        rDef.setDeadline(deadline);
        ReservationUpdateRequest uRequest = ReservationUpdateRequest.newInstance(rDef, reservationID);
        ReservationUpdateResponse uResponse = client.updateReservation(uRequest);
        Assert.assertNotNull(uResponse);
        System.out.println("Update reservation response: " + uResponse);
    } finally {
        // clean-up
        if (client != null) {
            client.stop();
        }
        cluster.stop();
    }
}
Also used : ReservationUpdateRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ReservationRequest(org.apache.hadoop.yarn.api.records.ReservationRequest) ReservationUpdateResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse) ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) UTCClock(org.apache.hadoop.yarn.util.UTCClock) Clock(org.apache.hadoop.yarn.util.Clock) UTCClock(org.apache.hadoop.yarn.util.UTCClock) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 32 with MiniYARNCluster

use of org.apache.hadoop.yarn.server.MiniYARNCluster in project hadoop by apache.

the class TestYarnClient method setupMiniYARNCluster.

private MiniYARNCluster setupMiniYARNCluster() throws Exception {
    CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
    ReservationSystemTestUtil.setupQueueConfiguration(conf);
    conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class);
    conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true);
    MiniYARNCluster cluster = new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
    cluster.init(conf);
    cluster.start();
    GenericTestUtils.waitFor(new Supplier<Boolean>() {

        @Override
        public Boolean get() {
            return cluster.getResourceManager().getRMContext().getReservationSystem().getPlan(ReservationSystemTestUtil.reservationQ).getTotalCapacity().getMemorySize() > 6000;
        }
    }, 10, 10000);
    return cluster;
}
Also used : MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)

Example 33 with MiniYARNCluster

use of org.apache.hadoop.yarn.server.MiniYARNCluster in project hadoop by apache.

the class TestYarnClient method testAMMRTokens.

@Test(timeout = 30000)
public void testAMMRTokens() throws Exception {
    MiniYARNCluster cluster = new MiniYARNCluster("testMRAMTokens", 1, 1, 1);
    YarnClient rmClient = null;
    try {
        cluster.init(new YarnConfiguration());
        cluster.start();
        final Configuration yarnConf = cluster.getConfig();
        rmClient = YarnClient.createYarnClient();
        rmClient.init(yarnConf);
        rmClient.start();
        ApplicationId appId = createApp(rmClient, false);
        waitTillAccepted(rmClient, appId, false);
        //managed AMs don't return AMRM token
        Assert.assertNull(rmClient.getAMRMToken(appId));
        appId = createApp(rmClient, true);
        waitTillAccepted(rmClient, appId, true);
        long start = System.currentTimeMillis();
        while (rmClient.getAMRMToken(appId) == null) {
            if (System.currentTimeMillis() - start > 20 * 1000) {
                Assert.fail("AMRM token is null");
            }
            Thread.sleep(100);
        }
        //unmanaged AMs do return AMRM token
        Assert.assertNotNull(rmClient.getAMRMToken(appId));
        UserGroupInformation other = UserGroupInformation.createUserForTesting("foo", new String[] {});
        appId = other.doAs(new PrivilegedExceptionAction<ApplicationId>() {

            @Override
            public ApplicationId run() throws Exception {
                YarnClient rmClient = YarnClient.createYarnClient();
                rmClient.init(yarnConf);
                rmClient.start();
                ApplicationId appId = createApp(rmClient, true);
                waitTillAccepted(rmClient, appId, true);
                long start = System.currentTimeMillis();
                while (rmClient.getAMRMToken(appId) == null) {
                    if (System.currentTimeMillis() - start > 20 * 1000) {
                        Assert.fail("AMRM token is null");
                    }
                    Thread.sleep(100);
                }
                //unmanaged AMs do return AMRM token
                Assert.assertNotNull(rmClient.getAMRMToken(appId));
                return appId;
            }
        });
        //other users don't get AMRM token
        Assert.assertNull(rmClient.getAMRMToken(appId));
    } finally {
        if (rmClient != null) {
            rmClient.stop();
        }
        cluster.stop();
    }
}
Also used : CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 34 with MiniYARNCluster

use of org.apache.hadoop.yarn.server.MiniYARNCluster in project cdap by caskdata.

the class YarnRMHAOperationalStatsTest method createYarnCluster.

@Override
protected MiniYARNCluster createYarnCluster() throws IOException, InterruptedException, YarnException {
    Configuration hConf = new Configuration();
    hConf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
    String hostname = MiniYARNCluster.getHostname();
    for (String confKey : YarnConfiguration.RM_SERVICES_ADDRESS_CONF_KEYS) {
        hConf.set(HAUtil.addSuffix(confKey, "rm0"), hostname + ":" + Networks.getRandomPort());
        hConf.set(HAUtil.addSuffix(confKey, "rm1"), hostname + ":" + Networks.getRandomPort());
    }
    MiniYARNCluster yarnCluster = new MiniYARNCluster(getClass().getName(), 2, 2, 2, 2);
    yarnCluster.init(hConf);
    yarnCluster.start();
    yarnCluster.getResourceManager(0).getRMContext().getRMAdminService().transitionToActive(new HAServiceProtocol.StateChangeRequestInfo(HAServiceProtocol.RequestSource.REQUEST_BY_USER));
    return yarnCluster;
}
Also used : HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster)

Example 35 with MiniYARNCluster

use of org.apache.hadoop.yarn.server.MiniYARNCluster in project cdap by caskdata.

the class YarnOperationalStatsTest method createYarnCluster.

@Override
protected MiniYARNCluster createYarnCluster() throws IOException, InterruptedException, YarnException {
    MiniYARNCluster yarnCluster = new MiniYARNCluster(getClass().getName(), 1, 1, 1);
    yarnCluster.init(new Configuration());
    yarnCluster.start();
    return yarnCluster;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster)

Aggregations

MiniYARNCluster (org.apache.hadoop.yarn.server.MiniYARNCluster)35 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)20 Test (org.junit.Test)19 Configuration (org.apache.hadoop.conf.Configuration)17 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)15 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)7 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)7 Clock (org.apache.hadoop.yarn.util.Clock)7 UTCClock (org.apache.hadoop.yarn.util.UTCClock)7 ReservationListRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest)5 ReservationListResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse)5 CapacitySchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)5 BeforeClass (org.junit.BeforeClass)5 File (java.io.File)4 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)4 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 URL (java.net.URL)3 Path (org.apache.hadoop.fs.Path)3