Search in sources :

Example 1 with ManageBucketMessage

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");
}
Also used : ManageBucketMessage(org.apache.geode.internal.cache.partitioned.ManageBucketMessage) RMIException(org.apache.geode.test.dunit.RMIException) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

DistributionManager (org.apache.geode.distributed.internal.DistributionManager)1 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)1 DistributionMessageObserver (org.apache.geode.distributed.internal.DistributionMessageObserver)1 ManageBucketMessage (org.apache.geode.internal.cache.partitioned.ManageBucketMessage)1 Host (org.apache.geode.test.dunit.Host)1 RMIException (org.apache.geode.test.dunit.RMIException)1 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)1 VM (org.apache.geode.test.dunit.VM)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1