public static BufferDebloatConfiguration fromConfiguration(ReadableConfig config) {
        Duration targetTotalBufferSize = config.get(BUFFER_DEBLOAT_TARGET);
        int maxBufferSize =
                Math.toIntExact(config.get(TaskManagerOptions.MEMORY_SEGMENT_SIZE).getBytes());
        int minBufferSize =
                Math.toIntExact(config.get(TaskManagerOptions.MIN_MEMORY_SEGMENT_SIZE).getBytes());

        int bufferDebloatThresholdPercentages = config.get(BUFFER_DEBLOAT_THRESHOLD_PERCENTAGES);
        final int numberOfSamples = config.get(BUFFER_DEBLOAT_SAMPLES);

        // Right now the buffer size can not be grater than integer max value according to
        // MemorySegment and buffer implementation.
        checkArgument(maxBufferSize > 0);
        checkArgument(minBufferSize > 0);
        checkArgument(numberOfSamples > 0);
        checkArgument(maxBufferSize >= minBufferSize);
        checkArgument(targetTotalBufferSize.toMillis() > 0.0);
        return new BufferDebloatConfiguration(
                config.get(TaskManagerOptions.BUFFER_DEBLOAT_ENABLED),
                targetTotalBufferSize,
                maxBufferSize,
                minBufferSize,
                bufferDebloatThresholdPercentages,
                numberOfSamples);
    }
@Test
    public void testMinGreaterThanMaxBufferSize() {
        final Configuration config = new Configuration();
        config.set(TaskManagerOptions.MIN_MEMORY_SEGMENT_SIZE, new MemorySize(50));
        config.set(TaskManagerOptions.MEMORY_SEGMENT_SIZE, new MemorySize(49));
        assertThrows(
                IllegalArgumentException.class,
                () -> BufferDebloatConfiguration.fromConfiguration(config));
    }