Skip to content

Commit

Permalink
GEODE-9870: Avoid Radish MOVED error during flushAll in AuthWhileServ…
Browse files Browse the repository at this point in the history
…ersRestartDUnitTest (apache#7171)

- Since servers have been stopped and restarted, as part of the test,
  buckets may be moving. Occasionally this may still be the case when
  the test is done and flushAll is cleaning up. To avoid that, make sure
  that everything is rebalanced before flushAll is called.
  • Loading branch information
jdeppe-pivotal authored Dec 9, 2021
1 parent 20c4177 commit d02d95a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import redis.clients.jedis.Jedis;

import org.apache.geode.cache.Region;
import org.apache.geode.cache.control.RebalanceFactory;
import org.apache.geode.cache.control.ResourceManager;
import org.apache.geode.cache.partition.PartitionRegionHelper;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.logging.internal.log4j.api.FastLogger;
Expand Down Expand Up @@ -253,4 +255,19 @@ public String getKeyOnServer(String keyPrefix, int vmId) {
});
}

/**
* Rebalance all regions for the cluster. This implicitly uses VM1.
*/
public void rebalanceAllRegions() {
getMember(1).invoke("Running rebalance", () -> {
ResourceManager manager = ClusterStartupRule.getCache().getResourceManager();
RebalanceFactory factory = manager.createRebalanceFactory();
try {
factory.start().getResults();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public static void classSetup() {

@After
public void after() {
// Make sure that no buckets are moving before calling flushAll, otherwise we might get
// a MOVED exception.
clusterStartUp.rebalanceAllRegions();
clusterStartUp.flushAll("data", "data");
}

Expand Down

0 comments on commit d02d95a

Please sign in to comment.