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

@param consensusGroupType DataRegion or SchemaRegion
@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