public static SlotManagerConfiguration fromConfiguration(
            Configuration configuration, WorkerResourceSpec defaultWorkerResourceSpec)
            throws ConfigurationException {

        final Time rpcTimeout =
                Time.fromDuration(configuration.get(RpcOptions.ASK_TIMEOUT_DURATION));

        final Time taskManagerTimeout =
                Time.fromDuration(configuration.get(ResourceManagerOptions.TASK_MANAGER_TIMEOUT));

        final Duration requirementCheckDelay =
                configuration.get(ResourceManagerOptions.REQUIREMENTS_CHECK_DELAY);

        final Duration declareNeededResourceDelay =
                configuration.get(ResourceManagerOptions.DECLARE_NEEDED_RESOURCE_DELAY);

        boolean waitResultConsumedBeforeRelease =
                configuration.get(ResourceManagerOptions.TASK_MANAGER_RELEASE_WHEN_RESULT_CONSUMED);

        TaskManagerLoadBalanceMode taskManagerLoadBalanceMode =
                TaskManagerLoadBalanceMode.loadFromConfiguration(configuration);

        int numSlotsPerWorker = configuration.get(TaskManagerOptions.NUM_TASK_SLOTS);

        int minSlotNum = configuration.get(ResourceManagerOptions.MIN_SLOT_NUM);
        int maxSlotNum = configuration.get(ResourceManagerOptions.MAX_SLOT_NUM);

        int redundantTaskManagerNum =
                configuration.get(ResourceManagerOptions.REDUNDANT_TASK_MANAGER_NUM);

        return new SlotManagerConfiguration(
                rpcTimeout,
                taskManagerTimeout,
                requirementCheckDelay,
                declareNeededResourceDelay,
                waitResultConsumedBeforeRelease,
                taskManagerLoadBalanceMode,
                defaultWorkerResourceSpec,
                numSlotsPerWorker,
                minSlotNum,
                maxSlotNum,
                getMinTotalCpu(configuration, defaultWorkerResourceSpec, minSlotNum),
                getMaxTotalCpu(configuration, defaultWorkerResourceSpec, maxSlotNum),
                getMinTotalMem(configuration, defaultWorkerResourceSpec, minSlotNum),
                getMaxTotalMem(configuration, defaultWorkerResourceSpec, maxSlotNum),
                redundantTaskManagerNum);
    }
@Test
    void testComputeMinMaxCpuIsInvalid() {
        final Configuration configuration = new Configuration();
        final double minTotalCpu = 10.0;
        final double maxTotalCpu = 11.0;
        final int numSlots = 3;
        final double cpuCores = 3;
        configuration.set(ResourceManagerOptions.MIN_TOTAL_CPU, minTotalCpu);
        configuration.set(ResourceManagerOptions.MAX_TOTAL_CPU, maxTotalCpu);

        assertThatIllegalStateException()
                .isThrownBy(
                        () ->
                                SlotManagerConfiguration.fromConfiguration(
                                        configuration,
                                        new WorkerResourceSpec.Builder()
                                                .setNumSlots(numSlots)
                                                .setCpuCores(cpuCores)
                                                .build()));
    }