public void notifyAllocation(
            AllocationID allocationId, FineGrainedTaskManagerSlot taskManagerSlot) {
        Preconditions.checkNotNull(allocationId);
        Preconditions.checkNotNull(taskManagerSlot);
        switch (taskManagerSlot.getState()) {
            case PENDING:
                ResourceProfile newPendingResource =
                        pendingResource.merge(taskManagerSlot.getResourceProfile());
                Preconditions.checkState(totalResource.allFieldsNoLessThan(newPendingResource));
                pendingResource = newPendingResource;
                break;
            case ALLOCATED:
                unusedResource = unusedResource.subtract(taskManagerSlot.getResourceProfile());
                break;
            default:
                throw new IllegalStateException(
                        "The slot stat should not be FREE under fine-grained resource management.");
        }
        slots.put(allocationId, taskManagerSlot);
        idleSince = Long.MAX_VALUE;
    }
@Test
    void testNotifyAllocation() {
        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);
        assertThat(taskManager.getAvailableResource())
                .isEqualTo(ResourceProfile.fromResources(8, 900));
        assertThat(taskManager.getIdleSince()).isEqualTo(Long.MAX_VALUE);
        assertThat(taskManager.getAllocatedSlots()).containsKey(allocationId);
    }