Search in sources :

Example 21 with RegionEvent

use of org.apache.geode.cache.RegionEvent in project geode by apache.

the class TXJUnitTest method testCacheCallbacks.

/**
   * Test to make sure CacheListener callbacks are called in place with the CacheEvents properly
   * constructed
   */
@Test
public void testCacheCallbacks() throws CacheException {
    final String key1 = "Key1";
    final String value1 = "value1";
    final String value2 = "value2";
    final String callBackArg = "call back arg";
    // install listeners
    AttributesMutator<String, String> mutator = this.region.getAttributesMutator();
    TXCallBackValidator cbv = new TXCallBackValidator();
    // Cache Listener
    ValidatableCacheListener vCl = new ValidatableCacheListener() {

        TXCallBackValidator v;

        int callCount;

        int prevCallCount;

        EntryEvent lastEvent;

        @Override
        public void validate() {
            this.v.validate(this.lastEvent, this.callCount);
        }

        void validate(EntryEvent event) {
            this.v.validate(event, ++this.callCount);
        }

        @Override
        public void setValidator(TXCallBackValidator v) {
            this.v = v;
        }

        @Override
        public void close() {
        }

        @Override
        public void afterCreate(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            this.validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsCreate Assertion!", this.v.isCreate());
            assertTrue(event.getRegion().containsKey(this.v.getKey()));
            assertTrue(event.getRegion().containsValueForKey(this.v.getKey()));
            assertNotNull(event.getRegion().getEntry(event.getKey()).getValue());
            this.v.setPassedValidation(true);
        }

        @Override
        public void afterUpdate(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsUpdate Assertion!", this.v.isUpdate());
            assertTrue(event.getRegion().containsKey(this.v.getKey()));
            assertTrue(event.getRegion().containsValueForKey(this.v.getKey()));
            assertNotNull(event.getRegion().getEntry(event.getKey()).getValue());
            this.v.setPassedValidation(true);
        }

        @Override
        public void afterInvalidate(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsInvalidate Assertion!", this.v.isInvalidate());
            assertTrue(event.getRegion().containsKey(this.v.getKey()));
            assertTrue(!event.getRegion().containsValueForKey(this.v.getKey()));
            assertNull(event.getRegion().getEntry(event.getKey()).getValue());
            this.v.setPassedValidation(true);
        }

        @Override
        public void afterDestroy(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsDestroy Assertion!", this.v.isDestroy());
            assertTrue(!event.getRegion().containsKey(this.v.getKey()));
            assertTrue(!event.getRegion().containsValueForKey(this.v.getKey()));
            assertNull(event.getRegion().getEntry(event.getKey()));
            this.v.setPassedValidation(true);
        }

        @Override
        public void afterRegionInvalidate(RegionEvent event) {
            fail("Unexpected invocation of afterRegionInvalidate");
        }

        @Override
        public void afterRegionDestroy(RegionEvent event) {
            if (!event.getOperation().isClose()) {
                fail("Unexpected invocation of afterRegionDestroy");
            }
        }

        @Override
        public void afterRegionClear(RegionEvent event) {
        }

        @Override
        public void afterRegionCreate(RegionEvent event) {
        }

        @Override
        public void afterRegionLive(RegionEvent event) {
        }

        @Override
        public void reset() {
            lastEvent = null;
            prevCallCount = callCount;
        }

        @Override
        public void validateNoEvents() {
            assertNull("Did not expect listener callback", lastEvent);
            assertEquals(prevCallCount, callCount);
        }

        @Override
        public void setExpectedCount(int count) {
            callCount = count;
        }

        @Override
        public int getCallCount() {
            return callCount;
        }
    };
    vCl.setValidator(cbv);
    mutator.setCacheListener(vCl);
    // CacheWriter
    ValidatableCacheWriter vCw = new ValidatableCacheWriter() {

        TXCallBackValidator v;

        int callCount;

        int prevCallCount;

        EntryEvent lastEvent;

        @Override
        public int getCallCount() {
            return this.callCount;
        }

        @Override
        public void localDestroyMakeup(int count) {
            this.callCount += count;
        }

        @Override
        public void validate() {
            this.v.validate(this.lastEvent, this.callCount);
        }

        void validate(EntryEvent event) {
            this.v.validate(event, ++this.callCount);
        }

        @Override
        public void setValidator(TXCallBackValidator v) {
            this.v = v;
        }

        @Override
        public void close() {
        }

        @Override
        public void beforeCreate(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsCreate Assertion!", this.v.isCreate());
            assertTrue(!event.getRegion().containsKey(this.v.getKey()));
            assertTrue(!event.getRegion().containsValueForKey(this.v.getKey()));
            assertNull(event.getRegion().getEntry(event.getKey()));
            this.v.setPassedValidation(true);
        }

        @Override
        public void beforeUpdate(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsUpdate Assertion!", this.v.isUpdate());
            assertTrue(event.getRegion().containsKey(this.v.getKey()));
            // Can not assert the following line, as the value being update may be invalid
            // assertTrue(event.getRegion().containsValueForKey(this.v.getKey()));
            this.v.setPassedValidation(true);
        }

        @Override
        public void beforeDestroy(EntryEvent event) {
            lastEvent = event;
            if (this.v.isSuspendValidation()) {
                return;
            }
            validate(event);
            this.v.setPassedValidation(false);
            assertTrue("IsDestroy Assertion!", this.v.isDestroy());
            assertTrue(event.getRegion().containsKey(this.v.getKey()));
            this.v.setPassedValidation(true);
        }

        @Override
        public void beforeRegionDestroy(RegionEvent event) {
            fail("Unexpected invocation of beforeRegionDestroy");
        }

        @Override
        public void beforeRegionClear(RegionEvent event) {
            fail("Unexpected invocation of beforeRegionClear");
        }

        @Override
        public void reset() {
            lastEvent = null;
            prevCallCount = callCount;
        }

        @Override
        public void validateNoEvents() {
            assertNull("Did not expect a writer event", lastEvent);
            assertEquals(prevCallCount, callCount);
        }
    };
    vCw.setValidator(cbv);
    mutator.setCacheWriter(vCw);
    // Cache Loader
    mutator.setCacheLoader(new CacheLoader() {

        int count = 0;

        @Override
        public Object load(LoaderHelper helper) throws CacheLoaderException {
            return count++;
        }

        @Override
        public void close() {
        }
    });
    // Use this to track the number of callout method invocations
    int appCallCount = 1;
    // Create => beforeCreate/afterCreate tests
    cbv.setKey(key1);
    cbv.setCallBackArg(callBackArg);
    cbv.setNewValue(value1, false);
    cbv.setOldValue(null, true);
    cbv.setIsDistributed(true);
    cbv.setIsLoad(false);
    cbv.setIsCreate(true);
    cbv.setIsUpdate(false);
    // Test non-transactional create expecting beforeCreate/afterCreate call
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.create(key1, value1, callBackArg);
    assertTrue("Non-TX Create Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    cbv.suspendValidation(false);
    // Test transactional create expecting afterCreate call
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.create(key1, value1, callBackArg);
    this.txMgr.commit();
    assertTrue("TX Create Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    // Put => afterCreate tests
    cbv.suspendValidation(false);
    cbv.setNewValue(value2, false);
    cbv.setOldValue(null, true);
    cbv.setIsDistributed(true);
    cbv.setIsLoad(false);
    cbv.setIsCreate(true);
    cbv.setIsUpdate(false);
    // Test non-transactional put expecting afterCreate call due to no
    // previous Entry
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.put(key1, value2, callBackArg);
    assertTrue("Non-TX Put->Create Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    cbv.suspendValidation(false);
    // Test transactional put expecting afterCreate call due to no
    // previous Entry
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.put(key1, value2, callBackArg);
    this.txMgr.commit();
    assertTrue("TX Put->Create Validation Assertion", cbv.passedValidation());
    // Put => afterUpdate tests
    cbv.setNewValue(value1, false);
    cbv.setOldValue(value2, false);
    cbv.setIsDistributed(true);
    cbv.setIsLoad(false);
    cbv.setIsCreate(false);
    cbv.setIsUpdate(true);
    // Test non-transactional put expecting afterUpdate call due to
    // previous Entry
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.put(key1, value1, callBackArg);
    assertTrue("Non-TX Put->Update Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    this.region.put(key1, value2);
    cbv.suspendValidation(false);
    // Test transactional put expecting afterUpdate call due to
    // previous Entry
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.put(key1, value1, callBackArg);
    this.txMgr.commit();
    assertTrue("TX Put->Update Validation Assertion", cbv.passedValidation());
    // LocalDestroy => afterDestroy, non-distributed tests
    cbv.setNewValue(null, true);
    cbv.setOldValue(value1, false);
    cbv.setIsDistributed(false);
    cbv.setIsLoad(false);
    cbv.setIsDestroy(true);
    cbv.setIsUpdate(false);
    // Test non-transactional localDestroy, expecting afterDestroy,
    // non-distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.localDestroy(key1, callBackArg);
    if (!isPR())
        // Account for cacheWriter not begin called
        vCw.localDestroyMakeup(1);
    assertTrue("Non-TX LocalDestroy Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.create(key1, value1);
    cbv.suspendValidation(false);
    // Test transactional localDestroy expecting afterDestroy,
    // non-distributed
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.localDestroy(key1, callBackArg);
    if (!isPR())
        // Account for cacheWriter not begin called
        vCw.localDestroyMakeup(1);
    this.txMgr.commit();
    assertTrue("TX LocalDestroy Validation Assertion", cbv.passedValidation());
    // Destroy => afterDestroy, distributed tests
    cbv.setNewValue(null, true);
    cbv.setOldValue(value1, false);
    cbv.setIsDistributed(true);
    cbv.setIsLoad(false);
    cbv.setIsDestroy(true);
    cbv.suspendValidation(true);
    this.region.create(key1, value1);
    cbv.suspendValidation(false);
    // Test non-transactional Destroy, expecting afterDestroy,
    // distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.destroy(key1, callBackArg);
    assertTrue("Non-TX Destroy Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.create(key1, value1);
    cbv.suspendValidation(false);
    // Test transactional Destroy, expecting afterDestroy,
    // distributed
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.destroy(key1, callBackArg);
    this.txMgr.commit();
    assertTrue("TX Destroy Validation Assertion", cbv.passedValidation());
    // localInvalidate => afterInvalidate, non-distributed tests
    cbv.setNewValue(null, true);
    cbv.setOldValue(value1, false);
    cbv.setIsDistributed(false);
    cbv.setIsLoad(false);
    cbv.setIsInvalidate(true);
    cbv.setIsDestroy(false);
    cbv.suspendValidation(true);
    this.region.create(key1, value1);
    cbv.suspendValidation(false);
    // Test non-transactional localInvalidate, expecting afterInvalidate
    // non-distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.localInvalidate(key1, callBackArg);
    assertTrue("Non-TX LocalInvalidate Validation Assertion", cbv.passedValidation());
    // Account for cacheWriter not begin called
    vCw.localDestroyMakeup(1);
    cbv.suspendValidation(true);
    this.region.put(key1, value1);
    cbv.suspendValidation(false);
    // Test transactional localInvalidate, expecting afterInvalidate
    // non-distributed
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.localInvalidate(key1, callBackArg);
    this.txMgr.commit();
    assertTrue("TX LocalInvalidate Validation Assertion", cbv.passedValidation());
    // Account for cacheWriter not begin called
    vCw.localDestroyMakeup(1);
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    // Invalidate => afterInvalidate, distributed tests
    cbv.setNewValue(null, true);
    cbv.setOldValue(value1, false);
    cbv.setIsDistributed(true);
    cbv.setIsLoad(false);
    cbv.suspendValidation(true);
    this.region.create(key1, value1);
    cbv.suspendValidation(false);
    // Test non-transactional Invalidate, expecting afterInvalidate
    // distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.invalidate(key1, callBackArg);
    // Account for cacheWriter not begin called
    vCw.localDestroyMakeup(1);
    assertTrue("Non-TX Invalidate Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.put(key1, value1);
    cbv.suspendValidation(false);
    // Test transactional Invalidate, expecting afterInvalidate
    // distributed
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.invalidate(key1, callBackArg);
    this.txMgr.commit();
    // Account for cacheWriter not begin called
    vCw.localDestroyMakeup(1);
    assertTrue("TX Invalidate Validation Assertion", cbv.passedValidation());
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    cbv.suspendValidation(false);
    // Create load Event tests
    int loaderValCheck = 0;
    cbv.setNewValue(loaderValCheck++, false);
    cbv.setCallBackArg(null);
    cbv.setOldValue(null, false);
    cbv.setIsDistributed(true);
    cbv.setIsCreate(true);
    cbv.setIsUpdate(false);
    cbv.setIsLoad(true);
    // Test non-transactional load, expecting afterCreate distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.get(key1);
    assertTrue("Non-TX Invalidate Validation Assertion", cbv.passedValidation());
    vCl.validate();
    vCw.validate();
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    cbv.suspendValidation(false);
    // Test transactional load, expecting afterCreate distributed
    vCl.reset();
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setNewValue(loaderValCheck++, false);
    cbv.setExpectedCount(appCallCount++);
    this.region.get(key1);
    this.txMgr.rollback();
    assertTrue("TX Invalidate Validation Assertion", cbv.passedValidation());
    vCw.validate();
    vCl.validateNoEvents();
    vCl.setExpectedCount(vCl.getCallCount() + 1);
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setNewValue(loaderValCheck++, false);
    cbv.setExpectedCount(appCallCount++);
    this.region.get(key1);
    vCw.validate();
    vCw.reset();
    this.txMgr.commit();
    vCw.validateNoEvents();
    assertTrue("TX Invalidate Validation Assertion", cbv.passedValidation());
    vCl.validate();
    cbv.suspendValidation(true);
    this.region.localDestroy(key1);
    cbv.suspendValidation(false);
    // Update load Event tests
    cbv.suspendValidation(true);
    this.region.create(key1, null);
    cbv.suspendValidation(false);
    assertTrue(this.region.containsKey(key1));
    assertTrue(!this.region.containsValueForKey(key1));
    cbv.setNewValue(loaderValCheck++, false);
    cbv.setOldValue(null, false);
    cbv.setIsDistributed(true);
    cbv.setCallBackArg(null);
    cbv.setIsCreate(false);
    cbv.setIsUpdate(true);
    cbv.setIsLoad(true);
    // Test non-transactional load, expecting afterUpdate distributed
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    this.region.get(key1);
    assertTrue("Non-TX Invalidate Validation Assertion", cbv.passedValidation());
    vCw.validate();
    vCl.validate();
    cbv.suspendValidation(true);
    this.region.invalidate(key1);
    cbv.suspendValidation(false);
    assertTrue(this.region.containsKey(key1));
    assertTrue(!this.region.containsValueForKey(key1));
    // Test transactional load, expecting afterUpdate distributed
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    cbv.setNewValue(loaderValCheck++, false);
    this.region.get(key1);
    vCw.validate();
    vCw.reset();
    this.txMgr.commit();
    vCw.validateNoEvents();
    vCl.validate();
    cbv.suspendValidation(true);
    this.region.invalidate(key1);
    cbv.suspendValidation(false);
    vCl.reset();
    this.txMgr.begin();
    cbv.setTXId(txMgr.getTransactionId());
    cbv.setExpectedCount(appCallCount++);
    cbv.setNewValue(loaderValCheck++, false);
    this.region.get(key1);
    this.txMgr.rollback();
    assertTrue("TX Invalidate Validation Assertion", cbv.passedValidation());
    vCw.validate();
    vCl.validateNoEvents();
}
Also used : RegionEvent(org.apache.geode.cache.RegionEvent) LoaderHelper(org.apache.geode.cache.LoaderHelper) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) EntryEvent(org.apache.geode.cache.EntryEvent) CacheLoader(org.apache.geode.cache.CacheLoader) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 22 with RegionEvent

use of org.apache.geode.cache.RegionEvent in project geode by apache.

the class QueueMsgDUnitTest method testQueueWhenRoleMissing.

/**
   * Make sure that cache operations are queued when a required role is missing
   */
@Ignore("TODO: test is disabled")
@Test
public void testQueueWhenRoleMissing() throws Exception {
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    DistributedRegion r = (DistributedRegion) createRootRegion(factory.create());
    final CachePerfStats stats = r.getCachePerfStats();
    int queuedOps = stats.getReliableQueuedOps();
    r.create("createKey", "createValue", "createCBArg");
    r.invalidate("createKey", "invalidateCBArg");
    r.put("createKey", "putValue", "putCBArg");
    r.destroy("createKey", "destroyCBArg");
    assertEquals(queuedOps + 4, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    {
        Map m = new TreeMap();
        m.put("aKey", "aValue");
        m.put("bKey", "bValue");
        r.putAll(m);
    }
    assertEquals(queuedOps + 2, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    r.invalidateRegion("invalidateRegionCBArg");
    assertEquals(queuedOps + 1, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    r.clear();
    assertEquals(queuedOps + 1, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    // @todo darrel: try some other ops
    VM vm = Host.getHost(0).getVM(0);
    // now create a system that fills this role since it does not create the
    // region our queue should not be flushed
    vm.invoke(new SerializableRunnable() {

        public void run() {
            Properties config = new Properties();
            config.setProperty(ROLES, "missing");
            getSystem(config);
        }
    });
    // we still should have everything queued since the region is not created
    assertEquals(queuedOps, stats.getReliableQueuedOps());
    // now create the region
    vm.invoke(new CacheSerializableRunnable("create root") {

        public void run2() throws CacheException {
            AttributesFactory factory = new AttributesFactory();
            factory.setScope(Scope.DISTRIBUTED_ACK);
            factory.setDataPolicy(DataPolicy.NORMAL);
            factory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
            TestCacheListener cl = new TestCacheListener() {

                public void afterCreate2(EntryEvent event) {
                }

                public void afterUpdate2(EntryEvent event) {
                }

                public void afterInvalidate2(EntryEvent event) {
                }

                public void afterDestroy2(EntryEvent event) {
                }
            };
            cl.enableEventHistory();
            factory.addCacheListener(cl);
            createRootRegion(factory.create());
        }
    });
    // after some amount of time we should see the queuedOps flushed
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return stats.getReliableQueuedOps() == 0;
        }

        public String description() {
            return "waiting for reliableQueuedOps to become 0";
        }
    };
    Wait.waitForCriterion(ev, 5 * 1000, 200, true);
    // now check that the queued op was delivered
    vm.invoke(new CacheSerializableRunnable("check") {

        public void run2() throws CacheException {
            Region r = getRootRegion();
            assertEquals(null, r.getEntry("createKey"));
            // assertIndexDetailsEquals("putValue", r.getEntry("createKey").getValue());
            {
                int evIdx = 0;
                TestCacheListener cl = (TestCacheListener) r.getAttributes().getCacheListener();
                List events = cl.getEventHistory();
                {
                    CacheEvent ce = (CacheEvent) events.get(evIdx++);
                    assertEquals(Operation.REGION_CREATE, ce.getOperation());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.CREATE, ee.getOperation());
                    assertEquals("createKey", ee.getKey());
                    assertEquals("createValue", ee.getNewValue());
                    assertEquals(null, ee.getOldValue());
                    assertEquals("createCBArg", ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.INVALIDATE, ee.getOperation());
                    assertEquals("createKey", ee.getKey());
                    assertEquals(null, ee.getNewValue());
                    assertEquals("createValue", ee.getOldValue());
                    assertEquals("invalidateCBArg", ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.UPDATE, ee.getOperation());
                    assertEquals("createKey", ee.getKey());
                    assertEquals("putValue", ee.getNewValue());
                    assertEquals(null, ee.getOldValue());
                    assertEquals("putCBArg", ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.DESTROY, ee.getOperation());
                    assertEquals("createKey", ee.getKey());
                    assertEquals(null, ee.getNewValue());
                    assertEquals("putValue", ee.getOldValue());
                    assertEquals("destroyCBArg", ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.PUTALL_CREATE, ee.getOperation());
                    assertEquals("aKey", ee.getKey());
                    assertEquals("aValue", ee.getNewValue());
                    assertEquals(null, ee.getOldValue());
                    assertEquals(null, ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    EntryEvent ee = (EntryEvent) events.get(evIdx++);
                    assertEquals(Operation.PUTALL_CREATE, ee.getOperation());
                    assertEquals("bKey", ee.getKey());
                    assertEquals("bValue", ee.getNewValue());
                    assertEquals(null, ee.getOldValue());
                    assertEquals(null, ee.getCallbackArgument());
                    assertEquals(true, ee.isOriginRemote());
                }
                {
                    RegionEvent re = (RegionEvent) events.get(evIdx++);
                    assertEquals(Operation.REGION_INVALIDATE, re.getOperation());
                    assertEquals("invalidateRegionCBArg", re.getCallbackArgument());
                    assertEquals(true, re.isOriginRemote());
                }
                {
                    RegionEvent re = (RegionEvent) events.get(evIdx++);
                    assertEquals(Operation.REGION_CLEAR, re.getOperation());
                    assertEquals(null, re.getCallbackArgument());
                    assertEquals(true, re.isOriginRemote());
                }
                assertEquals(evIdx, events.size());
            }
        }
    });
}
Also used : CacheException(org.apache.geode.cache.CacheException) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) TreeMap(java.util.TreeMap) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) RegionEvent(org.apache.geode.cache.RegionEvent) AttributesFactory(org.apache.geode.cache.AttributesFactory) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) VM(org.apache.geode.test.dunit.VM) EntryEvent(org.apache.geode.cache.EntryEvent) CacheEvent(org.apache.geode.cache.CacheEvent) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) List(java.util.List) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Map(java.util.Map) TreeMap(java.util.TreeMap) SubscriptionAttributes(org.apache.geode.cache.SubscriptionAttributes) Ignore(org.junit.Ignore) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 23 with RegionEvent

use of org.apache.geode.cache.RegionEvent in project geode by apache.

the class ProxyDUnitTest method remoteOriginOps.

/**
   * check remote ops done in a normal vm are correctly distributed to PROXY regions
   */
private void remoteOriginOps(DataPolicy dp, InterestPolicy ip) throws CacheException {
    initOtherId();
    AttributesFactory af = new AttributesFactory();
    af.setDataPolicy(dp);
    af.setSubscriptionAttributes(new SubscriptionAttributes(ip));
    af.setScope(Scope.DISTRIBUTED_ACK);
    CacheListener cl1 = new CacheListener() {

        public void afterUpdate(EntryEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterCreate(EntryEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterInvalidate(EntryEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterDestroy(EntryEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterRegionInvalidate(RegionEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterRegionDestroy(RegionEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterRegionClear(RegionEvent e) {
            clLastEvent = e;
            clInvokeCount++;
        }

        public void afterRegionCreate(RegionEvent e) {
        }

        public void afterRegionLive(RegionEvent e) {
        }

        public void close() {
        }
    };
    af.addCacheListener(cl1);
    Region r = createRootRegion("ProxyDUnitTest", af.create());
    this.clInvokeCount = 0;
    doCreateOtherVm();
    DMStats stats = getDMStats();
    long receivedMsgs = stats.getReceivedMessages();
    if (ip.isAll()) {
        getOtherVm().invoke(new CacheSerializableRunnable("do put") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.put("p", "v");
            }
        });
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.CREATE, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        // failure
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        assertEquals("v", ((EntryEvent) this.clLastEvent).getNewValue());
        assertEquals("p", ((EntryEvent) this.clLastEvent).getKey());
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do create") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.create("c", "v");
            }
        });
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.CREATE, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        assertEquals("v", ((EntryEvent) this.clLastEvent).getNewValue());
        assertEquals("c", ((EntryEvent) this.clLastEvent).getKey());
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do update") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.put("c", "v2");
            }
        });
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.UPDATE, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        assertEquals("v2", ((EntryEvent) this.clLastEvent).getNewValue());
        assertEquals("c", ((EntryEvent) this.clLastEvent).getKey());
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do invalidate") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.invalidate("c");
            }
        });
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.INVALIDATE, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getNewValue());
        assertEquals("c", ((EntryEvent) this.clLastEvent).getKey());
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do destroy") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.destroy("c");
            }
        });
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.DESTROY, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getNewValue());
        assertEquals("c", ((EntryEvent) this.clLastEvent).getKey());
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do putAll") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                Map m = new HashMap();
                m.put("putAllKey1", "putAllValue1");
                m.put("putAllKey2", "putAllValue2");
                r.putAll(m);
            }
        });
        assertEquals(2, this.clInvokeCount);
        // @todo darrel; check putAll events
        this.clInvokeCount = 0;
        getOtherVm().invoke(new CacheSerializableRunnable("do netsearch") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                // total miss
                assertEquals(null, r.get("loadkey"));
            }
        });
        assertEquals(0, this.clInvokeCount);
    } else {
        getOtherVm().invoke(new CacheSerializableRunnable("do entry ops") {

            public void run2() throws CacheException {
                Region r = getRootRegion("ProxyDUnitTest");
                r.put("p", "v");
                r.create("c", "v");
                // update
                r.put("c", "v");
                r.invalidate("c");
                r.destroy("c");
                {
                    Map m = new HashMap();
                    m.put("putAllKey1", "putAllValue1");
                    m.put("putAllKey2", "putAllValue2");
                    r.putAll(m);
                }
                // total miss
                assertEquals(null, r.get("loadkey"));
            }
        });
        assertEquals(0, this.clInvokeCount);
        assertEquals(0, r.size());
        // check the stats to make sure none of the above sent up messages
        assertEquals(receivedMsgs, stats.getReceivedMessages());
    }
    {
        AttributesMutator am = r.getAttributesMutator();
        CacheLoader cl = new CacheLoader() {

            public Object load(LoaderHelper helper) throws CacheLoaderException {
                if (helper.getKey().equals("loadkey")) {
                    return "loadvalue";
                } else if (helper.getKey().equals("loadexception")) {
                    throw new CacheLoaderException("expected");
                } else {
                    return null;
                }
            }

            public void close() {
            }
        };
        am.setCacheLoader(cl);
    }
    receivedMsgs = stats.getReceivedMessages();
    getOtherVm().invoke(new CacheSerializableRunnable("check net loader") {

        public void run2() throws CacheException {
            Region r = getRootRegion("ProxyDUnitTest");
            // net load
            assertEquals("loadvalue", r.get("loadkey"));
            // total miss
            assertEquals(null, r.get("foobar"));
            try {
                r.get("loadexception");
                fail("expected CacheLoaderException");
            } catch (CacheLoaderException expected) {
            }
        }
    });
    assertTrue(stats.getReceivedMessages() > receivedMsgs);
    if (ip.isAll()) {
        assertEquals(1, this.clInvokeCount);
        assertEquals(Operation.NET_LOAD_CREATE, this.clLastEvent.getOperation());
        assertEquals(true, this.clLastEvent.isOriginRemote());
        assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
        assertEquals(null, ((EntryEvent) this.clLastEvent).getOldValue());
        assertEquals(false, ((EntryEvent) this.clLastEvent).isOldValueAvailable());
        this.clInvokeCount = 0;
    } else {
        assertEquals(0, this.clInvokeCount);
    }
    {
        AttributesMutator am = r.getAttributesMutator();
        am.setCacheLoader(null);
        CacheWriter cw = new CacheWriterAdapter() {

            public void beforeCreate(EntryEvent event) throws CacheWriterException {
                throw new CacheWriterException("expected");
            }
        };
        am.setCacheWriter(cw);
    }
    receivedMsgs = stats.getReceivedMessages();
    getOtherVm().invoke(new CacheSerializableRunnable("check net write") {

        public void run2() throws CacheException {
            Region r = getRootRegion("ProxyDUnitTest");
            try {
                r.put("putkey", "putvalue");
                fail("expected CacheWriterException");
            } catch (CacheWriterException expected) {
            }
        }
    });
    assertTrue(stats.getReceivedMessages() > receivedMsgs);
    {
        AttributesMutator am = r.getAttributesMutator();
        am.setCacheWriter(null);
    }
    assertEquals(0, this.clInvokeCount);
    this.clLastEvent = null;
    getOtherVm().invoke(new CacheSerializableRunnable("check region invalidate") {

        public void run2() throws CacheException {
            Region r = getRootRegion("ProxyDUnitTest");
            r.invalidateRegion();
        }
    });
    assertEquals(1, this.clInvokeCount);
    assertEquals(Operation.REGION_INVALIDATE, this.clLastEvent.getOperation());
    assertEquals(true, this.clLastEvent.isOriginRemote());
    assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
    this.clLastEvent = null;
    getOtherVm().invoke(new CacheSerializableRunnable("check region clear") {

        public void run2() throws CacheException {
            Region r = getRootRegion("ProxyDUnitTest");
            r.clear();
        }
    });
    assertEquals(2, this.clInvokeCount);
    assertEquals(Operation.REGION_CLEAR, this.clLastEvent.getOperation());
    assertEquals(true, this.clLastEvent.isOriginRemote());
    assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
    this.clLastEvent = null;
    getOtherVm().invoke(new CacheSerializableRunnable("check region destroy") {

        public void run2() throws CacheException {
            Region r = getRootRegion("ProxyDUnitTest");
            r.destroyRegion();
        }
    });
    assertEquals(3, this.clInvokeCount);
    assertEquals(Operation.REGION_DESTROY, this.clLastEvent.getOperation());
    assertEquals(true, this.clLastEvent.isOriginRemote());
    assertEquals(this.otherId, this.clLastEvent.getDistributedMember());
    assertTrue(r.isDestroyed());
}
Also used : CacheWriterAdapter(org.apache.geode.cache.util.CacheWriterAdapter) DMStats(org.apache.geode.distributed.internal.DMStats) CacheException(org.apache.geode.cache.CacheException) HashMap(java.util.HashMap) RegionEvent(org.apache.geode.cache.RegionEvent) CacheListener(org.apache.geode.cache.CacheListener) LoaderHelper(org.apache.geode.cache.LoaderHelper) AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) EntryEvent(org.apache.geode.cache.EntryEvent) CacheWriter(org.apache.geode.cache.CacheWriter) Region(org.apache.geode.cache.Region) CacheLoader(org.apache.geode.cache.CacheLoader) HashMap(java.util.HashMap) Map(java.util.Map) SubscriptionAttributes(org.apache.geode.cache.SubscriptionAttributes) AttributesMutator(org.apache.geode.cache.AttributesMutator) CacheWriterException(org.apache.geode.cache.CacheWriterException)

Example 24 with RegionEvent

use of org.apache.geode.cache.RegionEvent in project geode by apache.

the class SearchAndLoadDUnitTest method testOneHopNetWrite.

@Test
public void testOneHopNetWrite() throws CacheException, InterruptedException {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    final String name = this.getUniqueName() + "Region";
    final String objectName = "Object7";
    final Integer value = new Integer(483);
    final Integer updateValue = new Integer(484);
    vm0.invoke(new SerializableRunnable("Create replicated region with cacheWriter") {

        public void run() {
            netWriteInvoked = false;
            operationWasCreate = false;
            originWasRemote = false;
            writerInvocationCount = 0;
            try {
                AttributesFactory factory = new AttributesFactory();
                factory.setScope(Scope.DISTRIBUTED_ACK);
                factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
                factory.setCacheWriter(new CacheWriter() {

                    public void beforeCreate(EntryEvent e) throws CacheWriterException {
                        e.getRegion().getCache().getLogger().info("cache writer beforeCreate invoked for " + e);
                        netWriteInvoked = true;
                        operationWasCreate = true;
                        originWasRemote = e.isOriginRemote();
                        writerInvocationCount++;
                        return;
                    }

                    public void beforeUpdate(EntryEvent e) throws CacheWriterException {
                        e.getRegion().getCache().getLogger().info("cache writer beforeUpdate invoked for " + e);
                        netWriteInvoked = true;
                        operationWasCreate = false;
                        originWasRemote = e.isOriginRemote();
                        writerInvocationCount++;
                        return;
                    }

                    public void beforeDestroy(EntryEvent e) throws CacheWriterException {
                    }

                    public void beforeRegionDestroy(RegionEvent e) throws CacheWriterException {
                    }

                    public void beforeRegionClear(RegionEvent e) throws CacheWriterException {
                    }

                    public void close() {
                    }
                });
                createRegion(name, factory.create());
            } catch (CacheException ex) {
                Assert.fail("While creating replicated region", ex);
            }
        }
    });
    vm1.invoke(new SerializableRunnable("Create empty Region") {

        public void run() {
            try {
                AttributesFactory factory = new AttributesFactory();
                factory.setScope(Scope.DISTRIBUTED_ACK);
                factory.setDataPolicy(DataPolicy.EMPTY);
                createRegion(name, factory.create());
            } catch (CacheException ex) {
                Assert.fail("While creating empty region", ex);
            }
        }
    });
    vm1.invoke(new SerializableRunnable("do a put that should be proxied in the other vm and invoke its cache writer") {

        public void run() {
            try {
                getRootRegion().getSubregion(name).put(objectName, value);
            } catch (CacheWriterException cwe) {
            } catch (TimeoutException te) {
            }
        }
    });
    vm0.invoke(new SerializableRunnable("ensure that cache writer was invoked with correct settings in event") {

        public void run() {
            assertTrue("expected cache writer to be invoked", netWriteInvoked);
            assertTrue("expected originRemote to be true", originWasRemote);
            assertTrue("expected event to be create", operationWasCreate);
            assertEquals("expected only one cache writer invocation", 1, writerInvocationCount);
            // set flags for the next test - updating the same key
            netWriteInvoked = false;
            writerInvocationCount = 0;
        }
    });
    vm1.invoke(new SerializableRunnable("do an update that should be proxied in the other vm and invoke its cache writer") {

        public void run() {
            try {
                getRootRegion().getSubregion(name).put(objectName, updateValue);
            } catch (CacheWriterException cwe) {
            } catch (TimeoutException te) {
            }
        }
    });
    vm0.invoke(new SerializableRunnable("ensure that cache writer was invoked with correct settings in event") {

        public void run() {
            assertTrue("expected cache writer to be invoked", netWriteInvoked);
            assertTrue("expected originRemote to be true", originWasRemote);
            assertTrue("expected event to be create", operationWasCreate);
            assertEquals("expected only one cache writer invocation", 1, writerInvocationCount);
        }
    });
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheException(org.apache.geode.cache.CacheException) VM(org.apache.geode.test.dunit.VM) CacheWriter(org.apache.geode.cache.CacheWriter) EntryEvent(org.apache.geode.cache.EntryEvent) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) RegionEvent(org.apache.geode.cache.RegionEvent) CacheWriterException(org.apache.geode.cache.CacheWriterException) TimeoutException(org.apache.geode.cache.TimeoutException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 25 with RegionEvent

use of org.apache.geode.cache.RegionEvent in project geode by apache.

the class SearchAndLoadDUnitTest method testNetWrite.

@Test
public void testNetWrite() throws CacheException, InterruptedException {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    final String name = this.getUniqueName() + "-ACK";
    final String objectName = "Gemfire7";
    final Integer value = new Integer(483);
    vm0.invoke(new SerializableRunnable("Create ACK Region with cacheWriter") {

        public void run() {
            netWriteInvoked = false;
            try {
                AttributesFactory factory = new AttributesFactory();
                factory.setScope(Scope.DISTRIBUTED_ACK);
                factory.setCacheWriter(new CacheWriter() {

                    public void beforeCreate(EntryEvent e) throws CacheWriterException {
                        netWriteInvoked = true;
                        return;
                    }

                    public void beforeUpdate(EntryEvent e) throws CacheWriterException {
                        netWriteInvoked = true;
                        return;
                    }

                    public void beforeDestroy(EntryEvent e) throws CacheWriterException {
                        return;
                    }

                    public void beforeRegionDestroy(RegionEvent e) throws CacheWriterException {
                        return;
                    }

                    public void beforeRegionClear(RegionEvent e) throws CacheWriterException {
                        return;
                    }

                    public void close() {
                    }
                });
                createRegion(name, factory.create());
            } catch (CacheException ex) {
                Assert.fail("While creating ACK region", ex);
            }
        }
    });
    vm1.invoke(new SerializableRunnable("Create ACK Region") {

        public void run() {
            loaderInvoked = false;
            remoteLoaderInvoked = false;
            netWriteInvoked = false;
            try {
                AttributesFactory factory = new AttributesFactory();
                factory.setScope(Scope.DISTRIBUTED_ACK);
                createRegion(name, factory.create());
            } catch (CacheException ex) {
                Assert.fail("While creating ACK region", ex);
            }
        }
    });
    vm1.invoke(new SerializableRunnable("Do a put operation resulting in cache writer notification in other vm") {

        public void run() {
            try {
                getRootRegion().getSubregion(name).put(objectName, value);
                try {
                    Object result = getRootRegion().getSubregion(name).get(objectName);
                    assertEquals(result, value);
                } catch (CacheLoaderException cle) {
                } catch (TimeoutException te) {
                }
            } catch (CacheWriterException cwe) {
            } catch (TimeoutException te) {
            }
        }
    });
    vm0.invoke(new SerializableRunnable("ensure that cache writer was invoked") {

        public void run() {
            assertTrue("expected cache writer to be invoked", netWriteInvoked);
        }
    });
}
Also used : CacheException(org.apache.geode.cache.CacheException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) RegionEvent(org.apache.geode.cache.RegionEvent) AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) VM(org.apache.geode.test.dunit.VM) CacheWriter(org.apache.geode.cache.CacheWriter) EntryEvent(org.apache.geode.cache.EntryEvent) TimeoutException(org.apache.geode.cache.TimeoutException) CacheWriterException(org.apache.geode.cache.CacheWriterException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

RegionEvent (org.apache.geode.cache.RegionEvent)29 Test (org.junit.Test)21 Region (org.apache.geode.cache.Region)20 AttributesFactory (org.apache.geode.cache.AttributesFactory)19 EntryEvent (org.apache.geode.cache.EntryEvent)18 CacheException (org.apache.geode.cache.CacheException)12 RegionAttributes (org.apache.geode.cache.RegionAttributes)12 LocalRegion (org.apache.geode.internal.cache.LocalRegion)11 Properties (java.util.Properties)10 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)10 VM (org.apache.geode.test.dunit.VM)9 CacheWriterException (org.apache.geode.cache.CacheWriterException)8 CacheListenerAdapter (org.apache.geode.cache.util.CacheListenerAdapter)8 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)8 Host (org.apache.geode.test.dunit.Host)8 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)7 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)7 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)6 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)6 CacheWriter (org.apache.geode.cache.CacheWriter)5