public boolean setLastCommittedIndex(final long lastCommittedIndex) {
        boolean doUnlock = true;
        final long stamp = this.stampedLock.writeLock();
        try {
            if (this.pendingIndex != 0 || !this.pendingMetaQueue.isEmpty()) {
                Requires.requireTrue(lastCommittedIndex < this.pendingIndex,
                    "Node changes to leader, pendingIndex=%d, param lastCommittedIndex=%d", this.pendingIndex,
                    lastCommittedIndex);
                return false;
            }
            if (!this.waiter.hasAvailableCapacity(1)) {
                LOG.warn("Node {} fsm is busy, can't set lastCommittedIndex to be {}, lastCommittedIndex={}.",
                    this.opts.getNodeId(), lastCommittedIndex, this.lastCommittedIndex);
                return false;
            }
            if (lastCommittedIndex < this.lastCommittedIndex) {
                return false;
            }
            if (lastCommittedIndex > this.lastCommittedIndex) {
                this.lastCommittedIndex = lastCommittedIndex;
                this.stampedLock.unlockWrite(stamp);
                doUnlock = false;
                this.waiter.onCommitted(lastCommittedIndex);
            }
        } finally {
            if (doUnlock) {
                this.stampedLock.unlockWrite(stamp);
            }
        }
        return true;
    }
@Test
    public void testSetLastCommittedIndex() {
        Mockito.when(this.waiter.hasAvailableCapacity(1)).thenReturn(true);
        assertEquals(0, this.box.getLastCommittedIndex());
        assertTrue(this.box.setLastCommittedIndex(1));
        assertEquals(1, this.box.getLastCommittedIndex());
        Mockito.verify(this.waiter, Mockito.times(1)).onCommitted(1);
    }