public long setCommitIndex(long commitIndex) {
    checkArgument(commitIndex >= 0, "commitIndex must be positive");
    long previousCommitIndex = this.commitIndex;
    if (commitIndex > previousCommitIndex) {
      this.commitIndex = commitIndex;
      logWriter.commit(Math.min(commitIndex, logWriter.getLastIndex()));
      long configurationIndex = cluster.getConfiguration().index();
      if (configurationIndex > previousCommitIndex && configurationIndex <= commitIndex) {
        cluster.commit();
      }
      setFirstCommitIndex(commitIndex);
    }
    return previousCommitIndex;
  }
public long setCommitIndex ( long commitIndex ) { checkArgument ( commitIndex >= 0 , "commitIndex must be positive" ) ; long previousCommitIndex = this . commitIndex ; if ( commitIndex > previousCommitIndex ) { this . commitIndex = commitIndex ; logWriter . commit ( Math . min ( commitIndex , logWriter . getLastIndex ( ) ) ) ; long configurationIndex = cluster . getConfiguration ( ) . index ( ) ; if ( configurationIndex > previousCommitIndex && configurationIndex <= commitIndex ) { cluster . commit ( ) ; } setFirstCommitIndex ( commitIndex ) ; } return previousCommitIndex ; }
Sets the commit index.

@param commitIndex The commit index.
@return the previous commit index