@Test
  public void bigClusterTest() {
    final int regionGroupNum = 1500;
    final int dataNodeNum = 300;
    final int replicationFactor = 3;
    Map<Integer, NodeStatistics> dataNodeStatisticsMap = new TreeMap<>();
    for (int i = 0; i < dataNodeNum; i++) {
      dataNodeStatisticsMap.put(i, new NodeStatistics(NodeStatus.Running));
    }

    // The loadCost for each DataNode are the same
    int x = regionGroupNum / dataNodeNum;
    int loadCost = 2 * x * x;

    int dataNodeId = 0;
    Random random = new Random();
    Map<String, List<TConsensusGroupId>> databaseRegionGroupMap = new TreeMap<>();
    databaseRegionGroupMap.put(DATABASE, new ArrayList<>());
    Map<TConsensusGroupId, Set<Integer>> regionReplicaSetMap = new TreeMap<>();
    Map<TConsensusGroupId, Integer> regionLeaderMap = new TreeMap<>();
    Map<TConsensusGroupId, Map<Integer, RegionStatistics>> regionStatisticsMap = new TreeMap<>();
    for (int i = 0; i < regionGroupNum; i++) {
      TConsensusGroupId regionGroupId = new TConsensusGroupId(TConsensusGroupType.DataRegion, i);
      int leaderId = (dataNodeId + random.nextInt(replicationFactor)) % dataNodeNum;

      TRegionReplicaSet regionReplicaSet = new TRegionReplicaSet();
      regionReplicaSet.setRegionId(regionGroupId);
      Map<Integer, RegionStatistics> regionStatistics = new TreeMap<>();
      for (int j = 0; j < 3; j++) {
        regionReplicaSet.addToDataNodeLocations(new TDataNodeLocation().setDataNodeId(dataNodeId));
        regionStatistics.put(dataNodeId, new RegionStatistics(RegionStatus.Running));
        dataNodeId = (dataNodeId + 1) % dataNodeNum;
      }
      regionStatisticsMap.put(regionGroupId, regionStatistics);

      databaseRegionGroupMap.get(DATABASE).add(regionGroupId);
      regionReplicaSetMap.put(
          regionGroupId,
          regionReplicaSet.getDataNodeLocations().stream()
              .map(TDataNodeLocation::getDataNodeId)
              .collect(Collectors.toSet()));
      regionLeaderMap.put(regionGroupId, leaderId);
    }

    // Do balancing
    Map<TConsensusGroupId, Integer> leaderDistribution =
        BALANCER.generateOptimalLeaderDistribution(
            databaseRegionGroupMap,
            regionReplicaSetMap,
            regionLeaderMap,
            dataNodeStatisticsMap,
            regionStatisticsMap);
    // All RegionGroup got a leader
    Assert.assertEquals(regionGroupNum, leaderDistribution.size());

    Map<Integer, Integer> leaderCounter = new ConcurrentHashMap<>();
    leaderDistribution.values().forEach(leaderId -> leaderCounter.merge(leaderId, 1, Integer::sum));
    // Every DataNode has leader
    Assert.assertEquals(dataNodeNum, leaderCounter.size());
    // Every DataNode has exactly regionGroupNum / dataNodeNum leaders
    for (int i = 0; i < dataNodeNum; i++) {
      Assert.assertEquals(regionGroupNum / dataNodeNum, leaderCounter.get(i).intValue());
    }

    // MaxFlow is regionGroupNum
    Assert.assertEquals(regionGroupNum, BALANCER.getMaximumFlow());

    int minimumCost = BALANCER.getMinimumCost();
    Assert.assertTrue(minimumCost >= loadCost * dataNodeNum);
    // The number of RegionGroups who have switched leader
    int switchCost = minimumCost - loadCost * dataNodeNum;
    AtomicInteger switchCount = new AtomicInteger(0);
    regionLeaderMap.forEach(
        (regionGroupId, originLeader) -> {
          if (!Objects.equals(originLeader, leaderDistribution.get(regionGroupId))) {
            switchCount.getAndIncrement();
          }
        });
    Assert.assertEquals(switchCost, switchCount.get());

    System.out.printf(
        "MCF algorithm switch leader for %s times to construct a balanced leader distribution of 300 DataNodes and 1500 RegionGroups cluster.%n",
        switchCost);
  }
In this case shows the balance ability for big cluster.

<p>i.e. Simulate 1500 RegionGroups and 300 DataNodes
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/router/leader/CFDLeaderBalancerTest.java