CompletableFuture<?> registerSlotRequestFuture = resourceManager.runInMainThread(() -> { rmServices.slotManager.registerSlotRequest( new SlotRequest(new JobID(), new AllocationID(), resourceProfile1, taskHost)); return null; });
protected TaskManagerSlot findMatchingSlotSpreading(SlotRequest slotRequest) { List<TaskManagerSlot> slots = new ArrayList<>(freeSlots.values()); Collections.sort(slots, Preconditions.checkNotNull(slotComparator)); for (TaskManagerSlot slot : slots) { if (hasEnoughResource(slot.getSlotId().getResourceID(), slotRequest.getResourceProfile()) && placementConstraintManager.check( slotRequest.getJobId(), allocationIdTags.get(slotRequest.getAllocationId()), getTaskExecutorSlotTags(slot.getSlotId()))) { recordAllocatedSlotAndResource(slot.getSlotId(), slotRequest.getResourceProfile()); freeSlots.remove(slot.getSlotId()); return slot; } } return null; }
public AllocationID getAllocationId() { return slotRequest.getAllocationId(); }
public String getTargetAddress() { return slotRequest.getTargetAddress(); }
public ResourceProfile getResourceProfile() { return slotRequest.getResourceProfile(); }
public JobID getJobId() { return slotRequest.getJobId(); }
/** * Requests a slot with the respective resource profile. * * @param slotRequest specifying the requested slot specs * @return true if the slot request was registered; false if the request is a duplicate * @throws SlotManagerException if the slot request failed (e.g. not enough resources left) */ public boolean registerSlotRequest(SlotRequest slotRequest) throws SlotManagerException { checkInit(); if (checkDuplicateRequest(slotRequest.getAllocationId())) { LOG.debug("Ignoring a duplicate slot request with allocation id {}.", slotRequest.getAllocationId()); return false; } else { PendingSlotRequest pendingSlotRequest = new PendingSlotRequest(slotRequest); pendingSlotRequests.put(slotRequest.getAllocationId(), pendingSlotRequest); allocationIdTags.put(slotRequest.getAllocationId(), slotRequest.getTags()); try { internalRequestSlot(pendingSlotRequest); } catch (ResourceManagerException e) { // requesting the slot failed --> remove pending slot request pendingSlotRequests.remove(slotRequest.getAllocationId()); allocationIdTags.remove(slotRequest.getAllocationId()); throw new SlotManagerException("Could not fulfill slot request " + slotRequest.getAllocationId() + '.', e); } return true; } }
pendingSlotRequest.getResourceProfile(), pendingSlotRequest.getTargetAddress(), pendingSlotRequest.getSlotRequest().getTags(), resourceManagerId, taskManagerSlot.getVersion(),
@Override protected TaskManagerSlot findMatchingSlot(SlotRequest slotRequest) { Iterator<Map.Entry<SlotID, TaskManagerSlot>> iterator = freeSlots.entrySet().iterator(); while (iterator.hasNext()) { TaskManagerSlot taskManagerSlot = iterator.next().getValue(); // sanity check Preconditions.checkState(taskManagerSlot.getState() == TaskManagerSlot.State.FREE, String.format("Slot %s is in state %s", taskManagerSlot.getSlotId(), taskManagerSlot.getState())); if (taskManagerSlot.getResourceProfile().equals(slotRequest.getResourceProfile()) && placementConstraintManager.check( slotRequest.getJobId(), allocationIdTags.get(slotRequest.getAllocationId()), getTaskExecutorSlotTags(taskManagerSlot.getSlotId()))) { freeSlots.remove(taskManagerSlot.getSlotId()); return taskManagerSlot; } } return null; }
public AllocationID getAllocationId() { return slotRequest.getAllocationId(); }
public String getTargetAddress() { return slotRequest.getTargetAddress(); }
public ResourceProfile getResourceProfile() { return slotRequest.getResourceProfile(); }
public JobID getJobId() { return slotRequest.getJobId(); }
int index = random.nextInt(freeSlots.size()); TaskManagerSlot slot = resourceSlots.get(index); if (hasEnoughResource(slot.getSlotId().getResourceID(), slotRequest.getResourceProfile()) && placementConstraintManager.check( slotRequest.getJobId(), allocationIdTags.get(slotRequest.getAllocationId()), getTaskExecutorSlotTags(slot.getSlotId()))) { recordAllocatedSlotAndResource(slot.getSlotId(), slotRequest.getResourceProfile()); freeSlots.remove(slot.getSlotId()); return slot; while (iterator.hasNext()) { TaskManagerSlot slot = iterator.next().getValue(); if (hasEnoughResource(slot.getSlotId().getResourceID(), slotRequest.getResourceProfile()) && placementConstraintManager.check( slotRequest.getJobId(), allocationIdTags.get(slotRequest.getAllocationId()), getTaskExecutorSlotTags(slot.getSlotId()))) { recordAllocatedSlotAndResource(slot.getSlotId(), slotRequest.getResourceProfile()); freeSlots.remove(slot.getSlotId()); return slot;
new SlotRequest(new JobID(), new AllocationID(), resourceProfile1, taskHost)); return null; });
public AllocationID getAllocationId() { return slotRequest.getAllocationId(); }
public String getTargetAddress() { return slotRequest.getTargetAddress(); }
public ResourceProfile getResourceProfile() { return slotRequest.getResourceProfile(); }
public JobID getJobId() { return slotRequest.getJobId(); }
@Override public CompletableFuture<Acknowledge> requestSlot( JobMasterId jobMasterId, SlotRequest slotRequest, final Time timeout) { JobID jobId = slotRequest.getJobId(); JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId); if (null != jobManagerRegistration) { if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) { log.info("Request slot with profile {} for job {} with allocation id {}.", slotRequest.getResourceProfile(), slotRequest.getJobId(), slotRequest.getAllocationId()); try { slotManager.registerSlotRequest(slotRequest); } catch (SlotManagerException e) { return FutureUtils.completedExceptionally(e); } return CompletableFuture.completedFuture(Acknowledge.get()); } else { return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " + jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.')); } } else { return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.')); } }