public static void doRebalance() {
    ResourceManager resMan = cache.getResourceManager();
    boolean heapEviction = (resMan.getEvictionHeapPercentage() > 0);
    RebalanceFactory factory = resMan.createRebalanceFactory();
    try {
      RebalanceResults simulateResults = null;
      if (!heapEviction) {
        LogWriterUtils.getLogWriter().info("Calling rebalance simulate");
        RebalanceOperation simulateOp = factory.simulate();
        simulateResults = simulateOp.getResults();
      }

      LogWriterUtils.getLogWriter().info("Starting rebalancing");
      RebalanceOperation rebalanceOp = factory.start();
      RebalanceResults rebalanceResults = rebalanceOp.getResults();

    } catch (InterruptedException e) {
      Assert.fail("Interrupted", e);
    }
  }
Do a rebalance and verify balance was improved. If evictionPercentage > 0 (the default) then we
have heapLRU and this can cause simulate and rebalance results to differ if eviction kicks in
between. (See BUG 44899).
geode-dunit/src/main/java/org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase.java