use of org.apache.geode.internal.cache.DestroyRegionOperation.DestroyRegionMessage in project geode by apache.
the class PersistentRecoveryOrderDUnitTest method testGIIDuringDestroy.
/**
* Test to make sure we don't leak any persistent ids if a member does GII while a distributed
* destroy is in progress
*/
@Test
public void testGIIDuringDestroy() throws Exception {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
final VM vm1 = host.getVM(1);
final VM vm2 = host.getVM(2);
LogWriterUtils.getLogWriter().info("Creating region in VM0");
createPersistentRegion(vm0);
// Add a hook which will disconnect from the distributed
// system when the initial image message shows up.
vm1.invoke(new SerializableRunnable() {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof DestroyRegionMessage) {
createPersistentRegionAsync(vm2);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DistributionMessageObserver.setInstance(null);
}
}
}
@Override
public void afterProcessMessage(DistributionManager dm, DistributionMessage message) {
}
@Override
public void beforeSendMessage(DistributionManager dm, DistributionMessage msg) {
}
});
}
});
createPersistentRegion(vm1);
vm0.invoke(new SerializableRunnable("Destroy region") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion(REGION_NAME);
region.destroyRegion();
}
});
vm1.invoke(new SerializableRunnable("check destroyed") {
public void run() {
Cache cache = getCache();
assertNull(cache.getRegion(REGION_NAME));
}
});
vm2.invoke(new SerializableRunnable("Wait for region creation") {
public void run() {
final Cache cache = getCache();
Wait.waitForCriterion(new WaitCriterion() {
public String description() {
return "Waiting for creation of region " + REGION_NAME;
}
public boolean done() {
Region region = cache.getRegion(REGION_NAME);
return region != null;
}
}, MAX_WAIT, 100, true);
}
});
vm2.invoke(new SerializableRunnable("Check offline members") {
public void run() {
final Cache cache = getCache();
DistributedRegion region = (DistributedRegion) cache.getRegion(REGION_NAME);
PersistenceAdvisor persistAdvisor = region.getPersistenceAdvisor();
assertEquals(Collections.emptySet(), persistAdvisor.getMembershipView().getOfflineMembers());
}
});
}
Aggregations