@Override
    public boolean tryStartNewSegment(
            TieredStorageSubpartitionId subpartitionId, int segmentId, int minNumBuffers) {
        File filePath = dataFilePath.toFile();
        boolean canStartNewSegment =
                filePath.getUsableSpace()
                                - (long) Math.max(numBuffersPerSegment, minNumBuffers)
                                        * bufferSizeBytes
                        > (long) (filePath.getTotalSpace() * minReservedDiskSpaceFraction);
        if (canStartNewSegment) {
            firstBufferIndexInSegment
                    .get(subpartitionId.getSubpartitionId())
                    .put(
                            diskCacheManager.getBufferIndex(subpartitionId.getSubpartitionId()),
                            segmentId);
            diskCacheManager.startSegment(subpartitionId.getSubpartitionId(), segmentId);
        }
        return canStartNewSegment;
    }
@Test
    void testStartNewSegmentFailed() {
        try (DiskTierProducerAgent diskTierProducerAgent =
                createDiskTierProducerAgent(
                        false,
                        NUM_BYTES_PER_SEGMENT,
                        1,
                        tempFolder.toString(),
                        new TestingPartitionFileWriter.Builder().build(),
                        new TieredStorageResourceRegistry())) {
            assertThat(diskTierProducerAgent.tryStartNewSegment(SUBPARTITION_ID, 0, 0)).isFalse();
        }
    }