Search in sources :

Example 1 with SchedulerResourceTypes

use of org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes in project hadoop by apache.

the class TestApplicationMasterService method testResourceTypes.

@Test(timeout = 3000000)
public void testResourceTypes() throws Exception {
    HashMap<YarnConfiguration, EnumSet<SchedulerResourceTypes>> driver = new HashMap<YarnConfiguration, EnumSet<SchedulerResourceTypes>>();
    CapacitySchedulerConfiguration csconf = new CapacitySchedulerConfiguration();
    csconf.setResourceComparator(DominantResourceCalculator.class);
    YarnConfiguration testCapacityDRConf = new YarnConfiguration(csconf);
    testCapacityDRConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class);
    YarnConfiguration testCapacityDefConf = new YarnConfiguration();
    testCapacityDefConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class);
    YarnConfiguration testFairDefConf = new YarnConfiguration();
    testFairDefConf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class, ResourceScheduler.class);
    driver.put(conf, EnumSet.of(SchedulerResourceTypes.MEMORY));
    driver.put(testCapacityDRConf, EnumSet.of(SchedulerResourceTypes.CPU, SchedulerResourceTypes.MEMORY));
    driver.put(testCapacityDefConf, EnumSet.of(SchedulerResourceTypes.MEMORY));
    driver.put(testFairDefConf, EnumSet.of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU));
    for (Map.Entry<YarnConfiguration, EnumSet<SchedulerResourceTypes>> entry : driver.entrySet()) {
        EnumSet<SchedulerResourceTypes> expectedValue = entry.getValue();
        MockRM rm = new MockRM(entry.getKey());
        rm.start();
        MockNM nm1 = rm.registerNode("127.0.0.1:1234", 6 * GB);
        RMApp app1 = rm.submitApp(2048);
        //Wait to make sure the attempt has the right state
        //TODO explore a better way than sleeping for a while (YARN-4929)
        Thread.sleep(1000);
        nm1.nodeHeartbeat(true);
        RMAppAttempt attempt1 = app1.getCurrentAppAttempt();
        MockAM am1 = rm.sendAMLaunched(attempt1.getAppAttemptId());
        RegisterApplicationMasterResponse resp = am1.registerAppAttempt();
        EnumSet<SchedulerResourceTypes> types = resp.getSchedulerResourceTypes();
        LOG.info("types = " + types.toString());
        Assert.assertEquals(expectedValue, types);
        rm.stop();
    }
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) HashMap(java.util.HashMap) EnumSet(java.util.EnumSet) SchedulerResourceTypes(org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) RegisterApplicationMasterResponse(org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse) HashMap(java.util.HashMap) Map(java.util.Map) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration) Test(org.junit.Test)

Example 2 with SchedulerResourceTypes

use of org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes in project hadoop by apache.

the class RegisterApplicationMasterResponsePBImpl method initSchedulerResourceTypes.

private void initSchedulerResourceTypes() {
    if (this.schedulerResourceTypes != null) {
        return;
    }
    RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder;
    List<SchedulerResourceTypes> list = p.getSchedulerResourceTypesList();
    if (list.isEmpty()) {
        this.schedulerResourceTypes = EnumSet.noneOf(SchedulerResourceTypes.class);
    } else {
        this.schedulerResourceTypes = EnumSet.copyOf(list);
    }
}
Also used : SchedulerResourceTypes(org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes) RegisterApplicationMasterResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder)

Aggregations

SchedulerResourceTypes (org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes)2 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 RegisterApplicationMasterResponse (org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 RegisterApplicationMasterResponseProtoOrBuilder (org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)1 CapacitySchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)1 Test (org.junit.Test)1