public void freeSlot(AllocationID allocationId) {
        Preconditions.checkNotNull(allocationId);
        FineGrainedTaskManagerSlot taskManagerSlot =
                Preconditions.checkNotNull(slots.remove(allocationId));

        if (taskManagerSlot.getState() == SlotState.PENDING) {
            pendingResource = pendingResource.subtract(taskManagerSlot.getResourceProfile());
        } else {
            unusedResource = unusedResource.merge(taskManagerSlot.getResourceProfile());
        }

        if (slots.isEmpty()) {
            idleSince = System.currentTimeMillis();
        }
    }
@Test
    void testFreeSlot() {
        final ResourceProfile totalResource = ResourceProfile.fromResources(10, 1000);
        final FineGrainedTaskManagerRegistration taskManager =
                new FineGrainedTaskManagerRegistration(
                        TASK_EXECUTOR_CONNECTION, totalResource, totalResource);
        final AllocationID allocationId = new AllocationID();
        final JobID jobId = new JobID();
        final FineGrainedTaskManagerSlot slot =
                new FineGrainedTaskManagerSlot(
                        allocationId,
                        jobId,
                        ResourceProfile.fromResources(2, 100),
                        TASK_EXECUTOR_CONNECTION,
                        SlotState.ALLOCATED);
        taskManager.notifyAllocation(allocationId, slot);

        taskManager.freeSlot(allocationId);
        assertThat(taskManager.getAvailableResource()).isEqualTo(totalResource);
        assertThat(taskManager.getIdleSince()).isNotEqualTo(Long.MAX_VALUE);
        assertThat(taskManager.getAllocatedSlots()).isEmpty();
    }