use of org.apache.geode.internal.cache.partitioned.ManageBucketMessage in project geode by apache.
the class Bug41733DUnitTest method testCrashDuringBucketCreation.
/**
* Test the we can handle a member departing while we are in the process of creating the bucket on
* the remote node.
*/
@Test
public void testCrashDuringBucketCreation() throws Throwable {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
vm1.invoke(new SerializableRunnable("Install observer") {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof ManageBucketMessage) {
vm0.invoke(() -> disconnectFromDS());
}
}
});
}
});
createPR(vm0, 0);
// Create a couple of buckets in VM0. This will make sure
// the next bucket we create will be created in VM 1.
putData(vm0, 0, 2, "a");
createPR(vm1, 0);
// Trigger a bucket creation in VM1, which should cause vm0 to close it's cache.
try {
putData(vm0, 3, 4, "a");
fail("should have received a cache closed exception");
} catch (RMIException e) {
if (!(e.getCause() instanceof DistributedSystemDisconnectedException)) {
throw e;
}
}
assertEquals(Collections.singleton(3), getBucketList(vm1));
// This shouldn't hang, because the bucket creation should finish,.
putData(vm1, 3, 4, "a");
}
Aggregations