@Override
    public Map<ExecutionAttemptID, ExecutionSlotAssignment> allocateSlotsFor(
            List<ExecutionAttemptID> executionAttemptIds) {

        final Map<ExecutionVertexID, ExecutionAttemptID> vertexIdToExecutionId = new HashMap<>();
        executionAttemptIds.forEach(
                executionId ->
                        vertexIdToExecutionId.put(executionId.getExecutionVertexId(), executionId));

        checkState(
                vertexIdToExecutionId.size() == executionAttemptIds.size(),
                "SlotSharingExecutionSlotAllocator does not support one execution vertex to have multiple concurrent executions");

        final List<ExecutionVertexID> vertexIds =
                executionAttemptIds.stream()
                        .map(ExecutionAttemptID::getExecutionVertexId)
                        .collect(Collectors.toList());

        return allocateSlotsForVertices(vertexIds).stream()
                .collect(
                        Collectors.toMap(
                                vertexAssignment ->
                                        vertexIdToExecutionId.get(
                                                vertexAssignment.getExecutionVertexId()),
                                vertexAssignment ->
                                        new ExecutionSlotAssignment(
                                                vertexIdToExecutionId.get(
                                                        vertexAssignment.getExecutionVertexId()),
                                                vertexAssignment.getLogicalSlotFuture())));
    }
@Test
    void testFailedPhysicalSlotRequestFailsLogicalSlotFuturesAndRemovesSharedSlot() {
        AllocationContext context =
                AllocationContext.newBuilder()
                        .addGroup(EV1)
                        .withPhysicalSlotProvider(
                                TestingPhysicalSlotProvider
                                        .createWithoutImmediatePhysicalSlotCreation())
                        .build();
        CompletableFuture<LogicalSlot> logicalSlotFuture =
                getAssignmentByExecutionVertexId(context.allocateSlotsFor(EV1), EV1)
                        .getLogicalSlotFuture();
        SlotRequestId slotRequestId =
                context.getSlotProvider().getFirstRequestOrFail().getSlotRequestId();

        assertThat(logicalSlotFuture).isNotDone();
        context.getSlotProvider()
                .getResponses()
                .get(slotRequestId)
                .completeExceptionally(new Throwable());
        assertThat(logicalSlotFuture).isCompletedExceptionally();

        // next allocation allocates new shared slot
        context.allocateSlotsFor(EV1);
        assertThat(context.getSlotProvider().getRequests()).hasSize(2);
    }