public void notifyAllocationComplete(AllocationID allocationId) {
        Preconditions.checkNotNull(allocationId);
        FineGrainedTaskManagerSlot slot = Preconditions.checkNotNull(slots.get(allocationId));
        Preconditions.checkState(slot.getState() == SlotState.PENDING);
        slot.completeAllocation();
        pendingResource = pendingResource.subtract(slot.getResourceProfile());
        unusedResource = unusedResource.subtract(slot.getResourceProfile());
    }
@Test
    void testNotifyAllocationComplete() {
        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.PENDING);

        taskManager.notifyAllocation(allocationId, slot);
        assertThat(taskManager.getAvailableResource())
                .isEqualTo(ResourceProfile.fromResources(8, 900));
        assertThat(taskManager.getIdleSince()).isEqualTo(Long.MAX_VALUE);
        assertThat(taskManager.getAllocatedSlots()).containsKey(allocationId);

        taskManager.notifyAllocationComplete(allocationId);
        assertThat(taskManager.getAvailableResource())
                .isEqualTo(ResourceProfile.fromResources(8, 900));
        assertThat(taskManager.getIdleSince()).isEqualTo(Long.MAX_VALUE);
        assertThat(taskManager.getAllocatedSlots()).containsKey(allocationId);
        assertThat(taskManager.getAllocatedSlots().get(allocationId).getState())
                .isEqualTo(SlotState.ALLOCATED);
    }