use of org.apache.geode.internal.cache.partitioned.QueryMessage in project geode by apache.
the class PartitionedRegionQueryDUnitTest method testRebalanceDuringQueryEvaluation.
/**
* Test of bug 43102. 1. Buckets are created on several nodes 2. A query is started 3. While the
* query is executing, several buckets are moved.
*/
@Test
public void testRebalanceDuringQueryEvaluation() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
createAccessor(vm0);
createPR(vm1);
createBuckets(vm1);
createPR(vm2);
// Add a listener that will trigger a rebalance
// as soon as the query arrives on this node.
vm1.invoke(new SerializableRunnable("add listener") {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof QueryMessage) {
RebalanceOperation rebalance = getCache().getResourceManager().createRebalanceFactory().start();
// wait for the rebalance
try {
rebalanceResults.compareAndSet(null, rebalance.getResults());
} catch (CancellationException e) {
// ignore
} catch (InterruptedException e) {
// ignore
}
}
}
});
}
});
executeQuery(vm0);
vm1.invoke(new SerializableRunnable("check rebalance happened") {
public void run() {
assertNotNull(rebalanceResults.get());
assertEquals(5, rebalanceResults.get().getTotalBucketTransfersCompleted());
}
});
}
Aggregations