@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(); } }
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); } }
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); }
@Override public void setSchedulerResourceTypes(EnumSet<SchedulerResourceTypes> types) { if (types == null) { return; } initSchedulerResourceTypes(); this.schedulerResourceTypes.clear(); this.schedulerResourceTypes.addAll(types); }
/** {@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); }
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(); }
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()); }
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); }
/** {@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); }
public static int computeAvailableContainers(Resource available, Resource required, EnumSet<SchedulerResourceTypes> resourceTypes) { if (resourceTypes.contains(SchedulerResourceTypes.CPU)) { return Math.min( calculateRatioOrMaxValue(available.getMemory(), required.getMemory()), calculateRatioOrMaxValue(available.getVirtualCores(), required .getVirtualCores())); } return calculateRatioOrMaxValue( available.getMemory(), required.getMemory()); }
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()); }
/** {@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); }
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(); }
/** {@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); }
public static int computeAvailableContainers(Resource available, Resource required, EnumSet<SchedulerResourceTypes> resourceTypes) { if (resourceTypes.contains(SchedulerResourceTypes.CPU)) { return Math.min( calculateRatioOrMaxValue(available.getMemorySize(), required.getMemorySize()), calculateRatioOrMaxValue(available.getVirtualCores(), required .getVirtualCores())); } return calculateRatioOrMaxValue( available.getMemorySize(), required.getMemorySize()); }
public static int divideAndCeilContainers(Resource required, Resource factor, EnumSet<SchedulerResourceTypes> resourceTypes) { if (resourceTypes.contains(SchedulerResourceTypes.CPU)) { return Math.max(divideAndCeil(required.getMemorySize(), factor.getMemorySize()), divideAndCeil(required.getVirtualCores(), factor.getVirtualCores())); } return divideAndCeil(required.getMemorySize(), factor.getMemorySize()); }
@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; }