public Map<TConsensusGroupId, Integer> getRegionLeaderMap() {
    Map<TConsensusGroupId, Integer> regionLeaderMap = new ConcurrentHashMap<>();
    consensusGroupCacheMap.forEach(
        (regionGroupId, consensusGroupCache) ->
            regionLeaderMap.put(regionGroupId, consensusGroupCache.getLeaderId()));
    return regionLeaderMap;
  }
Safely get the latest RegionLeaderMap.

@return Map<RegionGroupId, leaderId>, leaderId will be -1 if the RegionGroup has no leader yet.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java