@Test
  public void testScatterWidth() {
    final int dataRegionGroupNum =
        DATA_REGION_PER_DATA_NODE * TEST_DATA_NODE_NUM / DATA_REPLICATION_FACTOR;

    /* Allocate DataRegionGroups */
    long startTime = System.currentTimeMillis();
    List<TRegionReplicaSet> allocateResult = new ArrayList<>();
    for (int index = 0; index < dataRegionGroupNum; index++) {
      allocateResult.add(
          ALLOCATOR.generateOptimalRegionReplicasDistribution(
              AVAILABLE_DATA_NODE_MAP,
              FREE_SPACE_MAP,
              allocateResult,
              allocateResult,
              DATA_REPLICATION_FACTOR,
              new TConsensusGroupId(TConsensusGroupType.DataRegion, index)));
    }
    long endTime = System.currentTimeMillis();

    /* Statistics result */
    // Map<DataNodeId, RegionGroup Count>
    Map<Integer, Integer> regionCounter = new HashMap<>();
    allocateResult.forEach(
        regionReplicaSet ->
            regionReplicaSet
                .getDataNodeLocations()
                .forEach(
                    dataNodeLocation ->
                        regionCounter.merge(dataNodeLocation.getDataNodeId(), 1, Integer::sum)));
    // Map<DataNodeId, ScatterWidth>
    // where a true in the bitset denotes the corresponding DataNode can help the DataNode in
    // Map-Key to share the RegionGroup-leader and restore data when restarting.
    // The more true in the bitset, the more safety the cluster DataNode in Map-Key is.
    Map<Integer, BitSet> scatterWidthMap = new HashMap<>();
    for (TRegionReplicaSet replicaSet : allocateResult) {
      for (int i = 0; i < DATA_REPLICATION_FACTOR; i++) {
        for (int j = i + 1; j < DATA_REPLICATION_FACTOR; j++) {
          int dataNodeId1 = replicaSet.getDataNodeLocations().get(i).getDataNodeId();
          int dataNodeId2 = replicaSet.getDataNodeLocations().get(j).getDataNodeId();
          scatterWidthMap.computeIfAbsent(dataNodeId1, empty -> new BitSet()).set(dataNodeId2);
          scatterWidthMap.computeIfAbsent(dataNodeId2, empty -> new BitSet()).set(dataNodeId1);
        }
      }
    }
    int scatterWidthSum = 0;
    int minScatterWidth = Integer.MAX_VALUE;
    int maxScatterWidth = Integer.MIN_VALUE;
    for (int i = 1; i <= TEST_DATA_NODE_NUM; i++) {
      Assert.assertTrue(regionCounter.get(i) <= DATA_REGION_PER_DATA_NODE);
      int scatterWidth = scatterWidthMap.get(i).cardinality();
      scatterWidthSum += scatterWidth;
      minScatterWidth = Math.min(minScatterWidth, scatterWidth);
      maxScatterWidth = Math.max(maxScatterWidth, scatterWidth);
    }

    LOGGER.info("Test {}:", ALLOCATOR.getClass().getSimpleName());
    LOGGER.info(
        "Allocate {} DataRegionGroups for {} DataNodes in {}ms",
        dataRegionGroupNum,
        TEST_DATA_NODE_NUM,
        endTime - startTime);
    LOGGER.info(
        "Scatter width avg: {}, min: {}, max: {}",
        (double) scatterWidthSum / TEST_DATA_NODE_NUM,
        minScatterWidth,
        maxScatterWidth);
  }
Assign an allocator than run this test manually. This test will show the scatter width
distribution of the specified allocator
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/region/AllocatorScatterWidthManualTest.java