org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes Java Examples

The following examples show how to use org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DagAwareYarnTaskScheduler.java    From tez with Apache License 2.0 6 votes vote down vote up
@Override
public void start() throws Exception {
  super.start();
  client.start();
  if (shouldReuseContainers) {
    reuseExecutor = createExecutor();
  }
  TaskSchedulerContext ctx = getContext();
  RegisterApplicationMasterResponse response = client.registerApplicationMaster(
      ctx.getAppHostName(), ctx.getAppClientPort(), ctx.getAppTrackingUrl());
  ctx.setApplicationRegistrationData(response.getMaximumResourceCapability(),
      response.getApplicationACLs(), response.getClientToAMTokenMasterKey(),
      response.getQueue());
  if (response.getSchedulerResourceTypes().contains(SchedulerResourceTypes.CPU)) {
    resourceCalculator = new MemCpuResourceCalculator();
  } else {
    resourceCalculator = new MemResourceCalculator();
  }
}
 
Example #2
Source File: RegisterApplicationMasterResponsePBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void addSchedulerResourceTypes() {
  maybeInitBuilder();
  builder.clearSchedulerResourceTypes();
  if (schedulerResourceTypes == null) {
    return;
  }
  Iterable<? extends SchedulerResourceTypes> values =
      new Iterable<SchedulerResourceTypes>() {

        @Override
        public Iterator<SchedulerResourceTypes> iterator() {
          return new Iterator<SchedulerResourceTypes>() {
            Iterator<SchedulerResourceTypes> settingsIterator =
                schedulerResourceTypes.iterator();

            @Override
            public boolean hasNext() {
              return settingsIterator.hasNext();
            }

            @Override
            public SchedulerResourceTypes next() {
              return settingsIterator.next();
            }

            @Override
            public void remove() {
              throw new UnsupportedOperationException();
            }
          };
        }
      };
  this.builder.addAllSchedulerResourceTypes(values);
}
 
Example #3
Source File: TestDagAwareYarnTaskScheduler.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public RegisterApplicationMasterResponse registerApplicationMaster(String appHostName, int appHostPort,
    String appTrackingUrl) {
  mockRegResponse = mock(RegisterApplicationMasterResponse.class);
  Resource mockMaxResource = Resources.createResource(1024*1024, 1024);
  Map<ApplicationAccessType, String> mockAcls = Collections.emptyMap();
  when(mockRegResponse.getMaximumResourceCapability()).thenReturn(
      mockMaxResource);
  when(mockRegResponse.getApplicationACLs()).thenReturn(mockAcls);
  when(mockRegResponse.getSchedulerResourceTypes()).thenReturn(
      EnumSet.of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU));
  return mockRegResponse;
}
 
Example #4
Source File: HadoopShim28.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getSupportedResourceTypes(RegisterApplicationMasterResponse response) {
  EnumSet<SchedulerResourceTypes> supportedResourceTypes = response.getSchedulerResourceTypes();
  Set<String> supportedTypes = new HashSet<String>();
  for (SchedulerResourceTypes resourceType : supportedResourceTypes) {
    supportedTypes.add(resourceType.name());
  }
  return supportedTypes;
}
 
Example #5
Source File: HadoopShim27.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getSupportedResourceTypes(RegisterApplicationMasterResponse response) {
  EnumSet<SchedulerResourceTypes> supportedResourceTypes = response.getSchedulerResourceTypes();
  Set<String> supportedTypes = new HashSet<String>();
  for (SchedulerResourceTypes resourceType : supportedResourceTypes) {
    supportedTypes.add(resourceType.name());
  }
  return supportedTypes;
}
 
Example #6
Source File: RMCommunicator.java    From big-c with Apache License 2.0 5 votes vote down vote up
public RMCommunicator(ClientService clientService, AppContext context) {
  super("RMCommunicator");
  this.clientService = clientService;
  this.context = context;
  this.eventHandler = context.getEventHandler();
  this.applicationId = context.getApplicationID();
  this.stopped = new AtomicBoolean(false);
  this.heartbeatCallbacks = new ConcurrentLinkedQueue<Runnable>();
  this.schedulerResourceTypes = EnumSet.of(SchedulerResourceTypes.MEMORY);
}
 
Example #7
Source File: ResourceCalculatorUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static int divideAndCeilContainers(Resource required, Resource factor,
    EnumSet<SchedulerResourceTypes> resourceTypes) {
  if (resourceTypes.contains(SchedulerResourceTypes.CPU)) {
    return Math.max(divideAndCeil(required.getMemory(), factor.getMemory()),
      divideAndCeil(required.getVirtualCores(), factor.getVirtualCores()));
  }
  return divideAndCeil(required.getMemory(), factor.getMemory());
}
 
Example #8
Source File: ResourceCalculatorUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static int computeAvailableContainers(Resource available,
    Resource required, EnumSet<SchedulerResourceTypes> resourceTypes) {
  if (resourceTypes.contains(SchedulerResourceTypes.CPU)) {
    return Math.min(available.getMemory() / required.getMemory(),
      available.getVirtualCores() / required.getVirtualCores());
  }
  return available.getMemory() / required.getMemory();
}
 
Example #9
Source File: CapacityScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  if (calculator.getClass().getName()
    .equals(DefaultResourceCalculator.class.getName())) {
    return EnumSet.of(SchedulerResourceTypes.MEMORY);
  }
  return EnumSet
    .of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU);
}
 
Example #10
Source File: RegisterApplicationMasterResponsePBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void setSchedulerResourceTypes(EnumSet<SchedulerResourceTypes> types) {
  if (types == null) {
    return;
  }
  initSchedulerResourceTypes();
  this.schedulerResourceTypes.clear();
  this.schedulerResourceTypes.addAll(types);
}
 
Example #11
Source File: RegisterApplicationMasterResponsePBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #12
Source File: RMCommunicator.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public RMCommunicator(ClientService clientService, AppContext context) {
  super("RMCommunicator");
  this.clientService = clientService;
  this.context = context;
  this.eventHandler = context.getEventHandler();
  this.applicationId = context.getApplicationID();
  this.stopped = new AtomicBoolean(false);
  this.heartbeatCallbacks = new ConcurrentLinkedQueue<Runnable>();
  this.schedulerResourceTypes = EnumSet.of(SchedulerResourceTypes.MEMORY);
}
 
Example #13
Source File: ResourceCalculatorUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static int computeAvailableContainers(Resource available,
    Resource required, EnumSet<SchedulerResourceTypes> resourceTypes) {
  if (resourceTypes.contains(SchedulerResourceTypes.CPU)) {
    if (required.getGpuCores() == 0) {
      return Math.min(available.getMemory() / required.getMemory(),
              available.getVirtualCores() / required.getVirtualCores());
    }
    else {
      return Math.min(available.getMemory() / required.getMemory(),
              Math.min(available.getVirtualCores() / required.getVirtualCores(),
                      available.getGpuCores() / required.getGpuCores()));
    }
  }
  return available.getMemory() / required.getMemory();
}
 
Example #14
Source File: RegisterApplicationMasterResponsePBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #15
Source File: RegisterApplicationMasterResponsePBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void addSchedulerResourceTypes() {
  maybeInitBuilder();
  builder.clearSchedulerResourceTypes();
  if (schedulerResourceTypes == null) {
    return;
  }
  Iterable<? extends SchedulerResourceTypes> values =
      new Iterable<SchedulerResourceTypes>() {

        @Override
        public Iterator<SchedulerResourceTypes> iterator() {
          return new Iterator<SchedulerResourceTypes>() {
            Iterator<SchedulerResourceTypes> settingsIterator =
                schedulerResourceTypes.iterator();

            @Override
            public boolean hasNext() {
              return settingsIterator.hasNext();
            }

            @Override
            public SchedulerResourceTypes next() {
              return settingsIterator.next();
            }

            @Override
            public void remove() {
              throw new UnsupportedOperationException();
            }
          };
        }
      };
  this.builder.addAllSchedulerResourceTypes(values);
}
 
Example #16
Source File: RegisterApplicationMasterResponsePBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void setSchedulerResourceTypes(EnumSet<SchedulerResourceTypes> types) {
  if (types == null) {
    return;
  }
  initSchedulerResourceTypes();
  this.schedulerResourceTypes.clear();
  this.schedulerResourceTypes.addAll(types);
}
 
Example #17
Source File: CapacityScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  if (calculator.getClass().getName()
    .equals(DefaultResourceCalculator.class.getName())) {
    return EnumSet.of(SchedulerResourceTypes.MEMORY);
  }
  return EnumSet
    .of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU, SchedulerResourceTypes.GPU);
}
 
Example #18
Source File: ResourceCalculatorUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static int divideAndCeilContainers(Resource required, Resource factor,
    EnumSet<SchedulerResourceTypes> resourceTypes) {
  if (resourceTypes.contains(SchedulerResourceTypes.CPU)) {
    if (factor.getGpuCores() == 0) {
      return Math.max(divideAndCeil(required.getMemory(), factor.getMemory()),
              divideAndCeil(required.getVirtualCores(), factor.getVirtualCores()));
    }
    else {
      return Math.max(divideAndCeil(required.getMemory(), factor.getMemory()),
              Math.max(divideAndCeil(required.getVirtualCores(), factor.getVirtualCores()),
                      divideAndCeil(required.getGpuCores(), factor.getGpuCores())));
    }
  }
  return divideAndCeil(required.getMemory(), factor.getMemory());
}
 
Example #19
Source File: RMCommunicator.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public EnumSet<SchedulerResourceTypes> getSchedulerResourceTypes() {
  return schedulerResourceTypes;
}
 
Example #20
Source File: FairScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  return EnumSet
    .of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU);
}
 
Example #21
Source File: AbstractYarnScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  return EnumSet.of(SchedulerResourceTypes.MEMORY);
}
 
Example #22
Source File: TestApplicationMasterService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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, SchedulerResourceTypes.GPU));
  driver.put(testCapacityDefConf, EnumSet.of(SchedulerResourceTypes.MEMORY));
  driver.put(testFairDefConf,
    EnumSet.of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU, SchedulerResourceTypes.GPU));

  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);
    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();
  }
}
 
Example #23
Source File: TestApplicationMasterService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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);
    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();
  }
}
 
Example #24
Source File: RegisterApplicationMasterResponsePBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public EnumSet<SchedulerResourceTypes> getSchedulerResourceTypes() {
  initSchedulerResourceTypes();
  return this.schedulerResourceTypes;
}
 
Example #25
Source File: RegisterApplicationMasterResponsePBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public EnumSet<SchedulerResourceTypes> getSchedulerResourceTypes() {
  initSchedulerResourceTypes();
  return this.schedulerResourceTypes;
}
 
Example #26
Source File: AbstractYarnScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  return EnumSet.of(SchedulerResourceTypes.MEMORY);
}
 
Example #27
Source File: FairScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  return EnumSet
    .of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU, SchedulerResourceTypes.GPU);
}
 
Example #28
Source File: RMCommunicator.java    From big-c with Apache License 2.0 4 votes vote down vote up
public EnumSet<SchedulerResourceTypes> getSchedulerResourceTypes() {
  return schedulerResourceTypes;
}
 
Example #29
Source File: RegisterApplicationMasterResponse.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * Set the resource types used by the scheduler.
 *
 * @param types
 *          a set of the resource types that the scheduler considers during
 *          scheduling
 */
@Private
@Unstable
public abstract void setSchedulerResourceTypes(
    EnumSet<SchedulerResourceTypes> types);
 
Example #30
Source File: YarnScheduler.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * Return a collection of the resource types that are considered when
 * scheduling
 *
 * @return an EnumSet containing the resource types
 */
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes();