use of org.apache.geode.internal.cache.partitioned.ManageBucketMessage.ManageBucketReplyMessage in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testCrashDuringBucketCreation.
/**
* Test for bug 41336
*/
// GEODE-1738
@Category(FlakyTest.class)
@Test
public void testCrashDuringBucketCreation() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
vm0.invoke(new SerializableRunnable("Install observer") {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeSendMessage(DistributionManager dm, DistributionMessage msg) {
if (msg instanceof ManageBucketReplyMessage) {
Cache cache = getCache();
disconnectFromDS();
await().atMost(30, SECONDS).until(() -> {
return (cache == null || cache.isClosed());
});
LogWriterUtils.getLogWriter().info("Cache is confirmed closed");
}
}
});
}
});
createPR(vm0, 0);
createPR(vm1, 0);
createData(vm1, 0, 4, "a");
Set<Integer> vm1Buckets = getBucketList(vm1);
// Make sure the test hook ran
vm0.invoke(new SerializableRunnable("Check for no distributed system") {
public void run() {
assertEquals(null, GemFireCacheImpl.getInstance());
}
});
checkData(vm1, 0, 4, "a");
assertEquals(4, vm1Buckets.size());
createPR(vm0, 0);
checkData(vm0, 0, 4, "a");
assertEquals(vm1Buckets, getBucketList(vm1));
assertEquals(Collections.emptySet(), getBucketList(vm0));
closeCache(vm0);
closeCache(vm1);
AsyncInvocation async0 = createPRAsync(vm0, 0);
AsyncInvocation async1 = createPRAsync(vm1, 0);
async0.getResult();
async1.getResult();
checkData(vm0, 0, 4, "a");
assertEquals(vm1Buckets, getBucketList(vm1));
assertEquals(Collections.emptySet(), getBucketList(vm0));
}
use of org.apache.geode.internal.cache.partitioned.ManageBucketMessage.ManageBucketReplyMessage in project geode by apache.
the class Bug41733DUnitTest method testCrashAfterBucketCreation.
/**
* Test the we can handle a member departing after creating a bucket on the remote node but before
* we choose a primary
*/
@Test
public void testCrashAfterBucketCreation() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
vm0.invoke(new SerializableRunnable("Install observer") {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof ManageBucketReplyMessage) {
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