@Override
    public void freeSlot(AllocationID allocationId) {
        Preconditions.checkNotNull(allocationId);
        checkStarted();
        LOG.info("Freeing slot {}.", allocationId);

        final Optional<TaskManagerSlotInformation> slotOptional =
                taskManagerTracker.getAllocatedOrPendingSlot(allocationId);
        if (!slotOptional.isPresent()) {
            LOG.warn("Try to free unknown slot {}.", allocationId);
            return;
        }

        final TaskManagerSlotInformation slot = slotOptional.get();
        if (slot.getState() == SlotState.PENDING) {
            pendingSlotAllocations.remove(allocationId);
        }
        resourceTracker.notifyLostResource(slot.getJobId(), slot.getResourceProfile());
        taskManagerTracker.notifySlotStatus(
                allocationId,
                slot.getJobId(),
                slot.getInstanceId(),
                slot.getResourceProfile(),
                SlotState.FREE);
    }
@Test
    void testAllocationUpdatesIgnoredIfSlotFreed() throws Exception {
        testSlotAllocation(
                (slotStatusSyncer, taskManagerTracker, ignored, allocationId) -> {
                    slotStatusSyncer.freeSlot(allocationId);
                    assertThat(taskManagerTracker.getAllocatedOrPendingSlot(allocationId))
                            .isEmpty();
                });
    }