use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.
the class SlotSharingSlotAllocator method determineParallelism.
@Override
public Optional<VertexParallelismWithSlotSharing> determineParallelism(JobInformation jobInformation, Collection<? extends SlotInfo> freeSlots) {
// TODO: This can waste slots if the max parallelism for slot sharing groups is not equal
final int slotsPerSlotSharingGroup = freeSlots.size() / jobInformation.getSlotSharingGroups().size();
if (slotsPerSlotSharingGroup == 0) {
// => less slots than slot-sharing groups
return Optional.empty();
}
final Iterator<? extends SlotInfo> slotIterator = freeSlots.iterator();
final Collection<ExecutionSlotSharingGroupAndSlot> assignments = new ArrayList<>();
final Map<JobVertexID, Integer> allVertexParallelism = new HashMap<>();
for (SlotSharingGroup slotSharingGroup : jobInformation.getSlotSharingGroups()) {
final List<JobInformation.VertexInformation> containedJobVertices = slotSharingGroup.getJobVertexIds().stream().map(jobInformation::getVertexInformation).collect(Collectors.toList());
final Map<JobVertexID, Integer> vertexParallelism = determineParallelism(containedJobVertices, slotsPerSlotSharingGroup);
final Iterable<ExecutionSlotSharingGroup> sharedSlotToVertexAssignment = createExecutionSlotSharingGroups(vertexParallelism);
for (ExecutionSlotSharingGroup executionSlotSharingGroup : sharedSlotToVertexAssignment) {
final SlotInfo slotInfo = slotIterator.next();
assignments.add(new ExecutionSlotSharingGroupAndSlot(executionSlotSharingGroup, slotInfo));
}
allVertexParallelism.putAll(vertexParallelism);
}
return Optional.of(new VertexParallelismWithSlotSharing(allVertexParallelism, assignments));
}
use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.
the class AdaptiveScheduler method hasDesiredResources.
// ----------------------------------------------------------------
@Override
public boolean hasDesiredResources(ResourceCounter desiredResources) {
final Collection<? extends SlotInfo> allSlots = declarativeSlotPool.getFreeSlotsInformation();
ResourceCounter outstandingResources = desiredResources;
final Iterator<? extends SlotInfo> slotIterator = allSlots.iterator();
while (!outstandingResources.isEmpty() && slotIterator.hasNext()) {
final SlotInfo slotInfo = slotIterator.next();
final ResourceProfile resourceProfile = slotInfo.getResourceProfile();
if (outstandingResources.containsResource(resourceProfile)) {
outstandingResources = outstandingResources.subtract(resourceProfile, 1);
} else {
outstandingResources = outstandingResources.subtract(ResourceProfile.UNKNOWN, 1);
}
}
return outstandingResources.isEmpty();
}
use of org.apache.flink.runtime.jobmaster.SlotInfo in project flink by apache.
the class DefaultAllocatedSlotPoolTest method assertSlotPoolContainsSlots.
private void assertSlotPoolContainsSlots(DefaultAllocatedSlotPool slotPool, Collection<AllocatedSlot> slots) {
assertThat(slotPool.getAllSlotsInformation(), hasSize(slots.size()));
final Map<AllocationID, AllocatedSlot> slotsPerAllocationId = slots.stream().collect(Collectors.toMap(AllocatedSlot::getAllocationId, Function.identity()));
for (SlotInfo slotInfo : slotPool.getAllSlotsInformation()) {
assertTrue(slotsPerAllocationId.containsKey(slotInfo.getAllocationId()));
final AllocatedSlot allocatedSlot = slotsPerAllocationId.get(slotInfo.getAllocationId());
assertThat(slotInfo, matchesPhysicalSlot(allocatedSlot));
}
}
Aggregations