@Override
  public void triggerSnapshot(ConsensusGroupId groupId, boolean force) throws ConsensusException {
    final RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(groupId);
    final RaftGroup groupInfo = getGroupInfo(raftGroupId);
    if (groupInfo == null || !groupInfo.getPeers().contains(myself)) {
      throw new ConsensusGroupNotExistException(groupId);
    }

    final SnapshotManagementRequest request =
        SnapshotManagementRequest.newCreate(
            localFakeId,
            myself.getId(),
            raftGroupId,
            localFakeCallId.incrementAndGet(),
            300000,
            force ? 1 : 0);

    synchronized (raftGroupId) {
      final RaftClientReply reply;
      try {
        reply = server.get().snapshotManagement(request);
        if (!reply.isSuccess()) {
          throw new RatisRequestFailedException(reply.getException());
        }
        logger.info(
            "{} group {}: successfully taken snapshot at index {} with force = {}",
            this,
            raftGroupId,
            reply.getLogIndex(),
            force);
      } catch (IOException ioException) {
        throw new RatisRequestFailedException(ioException);
      }
    }
  }
returns the known leader to the given group. NOTICE: if the local peer isn't a member of given
group, getLeader will return null.

@return null if local peer isn't in group, otherwise group leader.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java