public boolean truncateSuffix(final long lastIndexKept, final int pos) {
        if (getLastLogIndex() <= lastIndexKept) {
            return true;
        }
        this.readLock.lock();
        final List<AbstractFile> willRemoveFiles = new ArrayList<>();
        try {
            long retainPosition = 0;
            for (final AbstractFile abstractFile : this.files) {
                final long firstLogIndex = abstractFile.getFirstLogIndex();
                final long lastLogIndex = abstractFile.getLastLogIndex();
                if (lastLogIndex > lastIndexKept) {
                    if (lastIndexKept >= firstLogIndex) {
                        // Truncate
                        final int lastPosition = abstractFile.truncate(lastIndexKept + 1, pos);
                        retainPosition += lastPosition;
                    } else {
                        // Remove
                        willRemoveFiles.add(abstractFile);
                    }
                } else {
                    retainPosition += this.fileSize;
                }
            }
            // Update flush position
            if (retainPosition < getFlushedPosition())
                setFlushedPosition(retainPosition);
            return true;
        } finally {
            this.readLock.unlock();
            for (final AbstractFile file : willRemoveFiles) {
                if (file != null) {
                    file.shutdown(1000, true);
                }
            }
            deleteFiles(willRemoveFiles);
        }
    }
@Test
    public void testTruncateSuffix() {
        // Current flush position = 212
        testFlush();
        // Test truncate to logIndex = 10 , that means update flush position to 126 + 26 + 10 = 162
        this.fileManager.truncateSuffix(10, 0);
        assertEquals(this.fileManager.getFlushedPosition(), 162);
        assertEquals(this.fileManager.getLastLogIndex(), 10);
    }