Search in sources :

Example 41 with EntryNotFoundException

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

the class ParallelGatewaySenderQueue method destroyEventFromQueue.

private void destroyEventFromQueue(PartitionedRegion prQ, int bucketId, Object key) {
    boolean isPrimary = prQ.getRegionAdvisor().getBucketAdvisor(bucketId).isPrimary();
    BucketRegionQueue brq = getBucketRegionQueueByBucketId(prQ, bucketId);
    // before destroying a key from it
    try {
        if (brq != null) {
            brq.destroyKey(key);
        }
        stats.decQueueSize();
    } catch (EntryNotFoundException e) {
        if (!this.sender.isBatchConflationEnabled() && logger.isDebugEnabled()) {
            logger.debug("ParallelGatewaySenderQueue#remove: Got EntryNotFoundException while removing key {} for {} for bucket = {} for GatewaySender {}", key, this, bucketId, this.sender);
        }
    } catch (ForceReattemptException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Bucket :{} moved to other member", bucketId);
        }
    } catch (PrimaryBucketException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Primary bucket :{} moved to other member", bucketId);
        }
    } catch (RegionDestroyedException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Caught RegionDestroyedException attempting to remove key {} from bucket {} in {}", key, bucketId, prQ.getFullPath());
        }
    }
    addRemovedEvent(prQ, bucketId, key);
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException)

Example 42 with EntryNotFoundException

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

the class DeleteCommand method processBinaryCommand.

private ByteBuffer processBinaryCommand(RequestReader request, Cache cache) {
    ByteBuffer buffer = request.getRequest();
    ByteBuffer response = request.getResponse();
    KeyWrapper key = getKey(buffer, HEADER_LENGTH);
    Region<Object, ValueWrapper> r = getMemcachedRegion(cache);
    try {
        r.destroy(key);
        if (isQuiet()) {
            return null;
        }
        response.putShort(POSITION_RESPONSE_STATUS, ResponseStatus.NO_ERROR.asShort());
    } catch (EntryNotFoundException e) {
        response.putShort(POSITION_RESPONSE_STATUS, ResponseStatus.KEY_NOT_FOUND.asShort());
    } catch (Exception e) {
        response = handleBinaryException(key, request, response, "delete", e);
    }
    if (getLogger().fineEnabled()) {
        getLogger().fine("delete:key:" + key);
    }
    return response;
}
Also used : KeyWrapper(org.apache.geode.internal.memcached.KeyWrapper) ValueWrapper(org.apache.geode.internal.memcached.ValueWrapper) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) ByteBuffer(java.nio.ByteBuffer) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException)

Example 43 with EntryNotFoundException

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

the class TXJUnitTest method testTxAlgebra.

@Test
public void testTxAlgebra() throws CacheException {
    TransactionId myTxId;
    Region<String, String> reg1 = this.region;
    this.txMgr.setListener(new TransactionListener() {

        @Override
        public void afterCommit(TransactionEvent event) {
            listenerAfterCommit = 1;
            te = event;
        }

        @Override
        public void afterFailedCommit(TransactionEvent event) {
            listenerAfterFailedCommit = 1;
            te = event;
        }

        @Override
        public void afterRollback(TransactionEvent event) {
            listenerAfterRollback = 1;
            te = event;
        }

        @Override
        public void close() {
            listenerClose = 1;
        }
    });
    AttributesMutator<String, String> mutator = this.region.getAttributesMutator();
    CountingCacheListener cntListener = new CountingCacheListener() {

        volatile int aCreateCalls, aUpdateCalls, aInvalidateCalls, aDestroyCalls, aLocalDestroyCalls;

        @Override
        public void close() {
        }

        @Override
        public void reset() {
            this.aCreateCalls = this.aUpdateCalls = this.aInvalidateCalls = this.aDestroyCalls = this.aLocalDestroyCalls = 0;
        }

        @Override
        public void afterCreate(EntryEvent e) {
            ++this.aCreateCalls;
        }

        @Override
        public void afterUpdate(EntryEvent e) {
            ++this.aUpdateCalls;
        }

        @Override
        public void afterInvalidate(EntryEvent e) {
            ++this.aInvalidateCalls;
        }

        @Override
        public void afterDestroy(EntryEvent e) {
            if (e.getOperation().isDistributed()) {
                ++this.aDestroyCalls;
            } else {
                ++this.aLocalDestroyCalls;
            }
        }

        @Override
        public void afterRegionInvalidate(RegionEvent e) {
            fail("Unexpected afterRegionInvalidate in testTxAlgebra");
        }

        @Override
        public void afterRegionDestroy(RegionEvent e) {
            if (!e.getOperation().isClose()) {
                fail("Unexpected afterRegionDestroy in testTxAlgebra");
            }
        }

        @Override
        public void afterRegionClear(RegionEvent event) {
        }

        @Override
        public void afterRegionCreate(RegionEvent event) {
        }

        @Override
        public void afterRegionLive(RegionEvent event) {
        }

        @Override
        public int getAfterCreateCalls() {
            return this.aCreateCalls;
        }

        @Override
        public int getAfterUpdateCalls() {
            return this.aUpdateCalls;
        }

        @Override
        public int getAfterInvalidateCalls() {
            return this.aInvalidateCalls;
        }

        @Override
        public int getAfterDestroyCalls(boolean fetchLocal) {
            return fetchLocal ? this.aLocalDestroyCalls : this.aDestroyCalls;
        }
    };
    mutator.setCacheListener(cntListener);
    CountingCacheWriter cntWriter = new CountingCacheWriter() {

        int bCreateCalls, bUpdateCalls, bDestroyCalls, bLocalDestroyCalls;

        @Override
        public void close() {
        }

        @Override
        public void reset() {
            this.bCreateCalls = this.bUpdateCalls = this.bDestroyCalls = this.bLocalDestroyCalls = 0;
        }

        @Override
        public void beforeCreate(EntryEvent e) {
            ++this.bCreateCalls;
        }

        @Override
        public void beforeUpdate(EntryEvent e) {
            ++this.bUpdateCalls;
        }

        @Override
        public void beforeDestroy(EntryEvent e) {
            ++this.bDestroyCalls;
        }

        @Override
        public void beforeRegionDestroy(RegionEvent e) {
            fail("Unexpected beforeRegionDestroy in testTxAlgebra");
        }

        @Override
        public void beforeRegionClear(RegionEvent e) {
            fail("Unexpected beforeRegionClear in testTxAlgebra");
        }

        @Override
        public int getBeforeCreateCalls() {
            return this.bCreateCalls;
        }

        @Override
        public int getBeforeUpdateCalls() {
            return this.bUpdateCalls;
        }

        @Override
        public int getBeforeDestroyCalls(boolean fetchLocal) {
            return fetchLocal ? this.bLocalDestroyCalls : this.bDestroyCalls;
        }
    };
    mutator.setCacheWriter(cntWriter);
    CountingCallBackValidator callbackVal = new CountingCallBackValidator(cntListener, cntWriter);
    // make sure each op sequence has the correct affect transaction event
    // check C + C -> EX
    // check C + P -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    try {
        reg1.create("key1", "value2");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertCreateWriterCnt(1, /* remember */
    false);
    reg1.put("key1", "value2");
    callbackVal.assertUpdateWriterCnt(1);
    assertEquals("value2", reg1.getEntry("key1").getValue());
    // Make sure listener callbacks were not triggered before commit
    callbackVal.assertCreateListenerCnt(0, false);
    callbackVal.assertUpdateListenerCnt(0);
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value2", reg1.getEntry("key1").getValue());
    assertEquals(1, this.te.getEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // Check C + DI -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    callbackVal.assertCreateListenerCnt(0, false);
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    assertEquals(1, this.te.getEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // TODO: mitch implement the following
    // check LI + DI -> NOOP
    // check DI + LI -> NOOP
    // check DI + DI -> NOOP
    // check LI + LI -> NOOP
    // check C + DD -> NOOP
    callbackVal.reset();
    this.txMgr.begin();
    reg1.create("key1", "value0");
    callbackVal.assertCreateWriterCnt(1);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    callbackVal.assertDestroyListenerCnt(0);
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    // Check C + LI -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // Check C + LI + C -> EX
    // Check C + LI + P -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    try {
        reg1.create("key1", "ex");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertCreateWriterCnt(1, /* remember */
    false);
    reg1.put("key1", "value2");
    callbackVal.assertUpdateWriterCnt(1);
    assertTrue(reg1.containsKey("key1"));
    assertEquals("value2", reg1.getEntry("key1").getValue());
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0, false);
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertEquals("value2", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // Check C + LI + LD -> NOOP
    callbackVal.reset();
    this.txMgr.begin();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(0, this.te.getEvents().size());
    // Check C + LI + DD -> NOOP
    callbackVal.reset();
    this.txMgr.begin();
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(0, this.te.getEvents().size());
    // check C + LD -> NOOP
    callbackVal.reset();
    this.txMgr.begin();
    reg1.create("key1", "value0");
    callbackVal.assertCreateWriterCnt(1);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(0, this.te.getEvents().size());
    // check C + LD + D -> EX
    // check C + LD + I -> EX
    // check C + LD + C -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value0");
    callbackVal.assertCreateWriterCnt(1, /* remember */
    false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    try {
        reg1.localDestroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertLocalDestroyWriterCnt(1, /* remember */
    false);
    try {
        reg1.destroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertDestroyWriterCnt(0);
    try {
        reg1.localInvalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0);
    try {
        reg1.invalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    reg1.create("key1", "value3");
    callbackVal.assertCreateWriterCnt(2);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check C + LD + P -> C
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.create("key1", "value0");
    callbackVal.assertCreateWriterCnt(1, /* remember */
    false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.put("key1", "value3");
    callbackVal.assertCreateWriterCnt(2);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(1);
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check put of existing entry
    // check P + C -> EX
    // check P + P -> P
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1, /* remember */
    false);
    try {
        reg1.create("key1", "value2");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertUpdateWriterCnt(1, /* remember */
    false);
    callbackVal.assertCreateWriterCnt(0);
    reg1.put("key1", "value3");
    callbackVal.assertUpdateWriterCnt(2);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getPutEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check P + DI -> DI
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(1);
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getInvalidateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check P + DD -> D
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    // check P + LI -> LI
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    assertTrue(reg1.containsKey("key1"));
    assertTrue(!reg1.containsValueForKey("key1"));
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertEquals(null, reg1.getEntry("key1").getValue());
    assertTrue(!reg1.containsValueForKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getInvalidateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // Check P + LI + C -> EX
    // Check P + LI + P -> P
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1, /* remember */
    false);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    try {
        reg1.create("key1", "ex");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertCreateWriterCnt(0);
    callbackVal.assertUpdateWriterCnt(1, /* remember */
    false);
    reg1.put("key1", "value2");
    callbackVal.assertUpdateWriterCnt(2);
    assertTrue(reg1.containsKey("key1"));
    assertEquals("value2", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(reg1.containsKey("key1"));
    assertEquals("value2", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getPutEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // Check P + LI + LD -> LD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    // Check P + LI + DD -> DD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    // check P + LD -> LD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    // check P + LD + D -> EX
    // check P + LD + I -> EX
    // check P + LD + C -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    try {
        reg1.localDestroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertLocalDestroyWriterCnt(1, /* remember */
    false);
    try {
        reg1.destroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertDestroyWriterCnt(0);
    try {
        reg1.localInvalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    try {
        reg1.invalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0);
    reg1.create("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check P + LD + P -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1, /* remember */
    false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.put("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check DI + C -> EX
    // check DI + P -> P
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    try {
        reg1.create("key1", "value1");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertCreateWriterCnt(0);
    reg1.put("key1", "value2");
    callbackVal.assertUpdateWriterCnt(1);
    assertEquals("value2", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value2", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getPutEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check DI + DD -> D
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    // check DI + LD -> LD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    // check DI + LD + D -> EX
    // check DI + LD + I -> EX
    // check DI + LD + C -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    try {
        reg1.localDestroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertLocalDestroyWriterCnt(1, /* remember */
    false);
    try {
        reg1.destroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertDestroyWriterCnt(0);
    try {
        reg1.localInvalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    try {
        reg1.invalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    reg1.create("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check DI + LD + P -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.invalidate("key1", "value1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.put("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check LI + C -> EX
    // check LI + P -> P
    reg1.create("key1", "value0");
    this.txMgr.begin();
    callbackVal.reset();
    myTxId = this.txMgr.getTransactionId();
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    try {
        reg1.create("key1", "value1");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    callbackVal.assertCreateWriterCnt(0);
    reg1.put("key1", "value2");
    callbackVal.assertUpdateWriterCnt(1);
    assertEquals("value2", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.assertInvalidateCnt(0);
    callbackVal.reAssert();
    assertEquals("value2", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getPutEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check LI + DD -> DD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    // check LI + LD -> LD
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(1);
    callbackVal.reAssert();
    assertTrue(!reg1.containsKey("key1"));
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getDestroyEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals(null, ev.getNewValue());
            assertEquals("value0", ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    // check LI + LD + D -> EX
    // check LI + LD + I -> EX
    // check LI + LD + C -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    assertTrue(!reg1.containsKey("key1"));
    try {
        reg1.localDestroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertLocalDestroyWriterCnt(1, /* remember */
    false);
    try {
        reg1.destroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertDestroyWriterCnt(0);
    try {
        reg1.localInvalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    try {
        reg1.invalidate("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException ok) {
    }
    callbackVal.assertInvalidateCnt(0, /* remember */
    false);
    reg1.create("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check LI + LD + P -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localInvalidate("key1", "value1");
    callbackVal.assertInvalidateCnt(0, false);
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.put("key1", "value3");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value3", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value3", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value3", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check init state LI + P + I -> I token (bug 33073)
    reg1.create("key1", "value0");
    reg1.localInvalidate("key1");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    reg1.invalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    this.txMgr.commit();
    callbackVal.assertUpdateListenerCnt(0);
    callbackVal.assertInvalidateCnt(1);
    callbackVal.reAssert();
    assertNull(reg1.getEntry("key1").getValue());
    {
        // Special check to assert Invaldate token
        LocalRegion.NonTXEntry nonTXe = (LocalRegion.NonTXEntry) reg1.getEntry("key1");
        assertTrue(nonTXe.getRegionEntry().isInvalid());
    }
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getInvalidateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertNull(ev.getNewValue());
            assertNull(ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    // check init state I + P + LI -> LI token (bug 33073)
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.put("key1", "value1");
    callbackVal.assertUpdateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    reg1.localInvalidate("key1");
    callbackVal.assertInvalidateCnt(0, false);
    this.txMgr.commit();
    callbackVal.assertInvalidateCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.reAssert();
    assertNull(reg1.getEntry("key1").getValue());
    {
        // Special check to assert Local Invaldate token
        LocalRegion.NonTXEntry nonTXe = (LocalRegion.NonTXEntry) reg1.getEntry("key1");
        assertTrue(nonTXe.getRegionEntry().isInvalid());
    }
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(0, this.te.getCreateEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getInvalidateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertNull(ev.getNewValue());
            assertNull(ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(!ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check DD + C -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value1", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value1", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check DD + P -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.destroy("key1");
    callbackVal.assertDestroyWriterCnt(1);
    reg1.put("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value1", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value1", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check LD + C -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.create("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value1", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value1", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
    // check LD + P -> C
    reg1.create("key1", "value0");
    callbackVal.reset();
    this.txMgr.begin();
    myTxId = this.txMgr.getTransactionId();
    reg1.localDestroy("key1");
    callbackVal.assertLocalDestroyWriterCnt(1);
    reg1.put("key1", "value1");
    callbackVal.assertCreateWriterCnt(1);
    assertEquals("value1", reg1.getEntry("key1").getValue());
    this.txMgr.commit();
    callbackVal.assertLocalDestroyListenerCnt(0);
    callbackVal.assertCreateListenerCnt(0);
    callbackVal.assertUpdateListenerCnt(1);
    callbackVal.reAssert();
    assertEquals("value1", reg1.getEntry("key1").getValue());
    assertEquals(0, this.te.getPutEvents().size());
    assertEquals(0, this.te.getInvalidateEvents().size());
    assertEquals(0, this.te.getDestroyEvents().size());
    assertEquals(1, this.te.getEvents().size());
    {
        List<EntryEvent<?, ?>> events = this.te.getCreateEvents();
        assertEquals(myTxId, this.te.getTransactionId());
        assertEquals(1, events.size());
        for (EntryEvent ev : events) {
            assertEquals(myTxId, ev.getTransactionId());
            assertTrue(ev.getRegion() == reg1);
            assertEquals("key1", ev.getKey());
            assertEquals("value1", ev.getNewValue());
            assertEquals(null, ev.getOldValue());
            verifyEventProps(ev);
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
    }
    reg1.localDestroy("key1");
}
Also used : TransactionListener(org.apache.geode.cache.TransactionListener) EntryExistsException(org.apache.geode.cache.EntryExistsException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) RegionEvent(org.apache.geode.cache.RegionEvent) TransactionId(org.apache.geode.cache.TransactionId) TransactionEvent(org.apache.geode.cache.TransactionEvent) EntryEvent(org.apache.geode.cache.EntryEvent) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 44 with EntryNotFoundException

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

the class DiskRegionJUnitTest method testRemoveCorrectlyRecorded.

@Test
public void testRemoveCorrectlyRecorded() throws Exception {
    DiskRegionProperties props = new DiskRegionProperties();
    props.setOverflow(true);
    props.setOverFlowCapacity(1);
    props.setDiskDirs(dirs);
    Region region = DiskRegionHelperFactory.getSyncOverFlowAndPersistRegion(cache, props);
    region.put("1", "1");
    region.put("2", "2");
    region.put("3", "3");
    MyCL cacheListener = new MyCL();
    region.getAttributesMutator().addCacheListener(cacheListener);
    region.destroy("1");
    // Make sure we don't get an old value when doing a destroy
    // of an entry that overflowed to disk.
    // If we do then we have hit bug 40795.
    assertNotNull(cacheListener.lastEvent);
    assertEquals(null, cacheListener.lastEvent.getOldValue());
    assertTrue(region.get("1") == null);
    boolean exceptionOccurred = false;
    try {
        Object result = ((LocalRegion) region).getValueOnDisk("1");
        if (result == null || result.equals(Token.TOMBSTONE)) {
            exceptionOccurred = true;
        }
    } catch (EntryNotFoundException e) {
        exceptionOccurred = true;
    }
    if (!exceptionOccurred) {
        fail("exception did not occur although was supposed to occur");
    }
    region.close();
    region = DiskRegionHelperFactory.getSyncOverFlowAndPersistRegion(cache, props);
    assertTrue(region.get("1") == null);
    region.destroyRegion();
}
Also used : EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) Region(org.apache.geode.cache.Region) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 45 with EntryNotFoundException

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

the class MyTransactionFunction method verifyDestroyOperation.

private void verifyDestroyOperation(RegionFunctionContext ctx) {
    Region custPR = ctx.getDataSet();
    Region orderPR = custPR.getCache().getRegion(PRColocationDUnitTest.OrderPartitionedRegionName);
    CacheTransactionManager mgr = custPR.getCache().getCacheTransactionManager();
    ArrayList args = (ArrayList) ctx.getArguments();
    CustId custId = (CustId) args.get(1);
    Customer newCus = (Customer) args.get(2);
    OrderId orderId = (OrderId) args.get(3);
    Order order = (Order) args.get(4);
    Customer oldCustomer = (Customer) custPR.get(custId);
    Customer commitedCust = null;
    // test destroy rollback
    mgr.begin();
    custPR.put(custId, newCus);
    custPR.destroy(custId);
    orderPR.put(orderId, order);
    mgr.rollback();
    commitedCust = (Customer) custPR.get(custId);
    Assert.assertTrue(oldCustomer.equals(commitedCust), "Expected customer to rollback to:" + oldCustomer + " but was:" + commitedCust);
    // test destroy rollback on unmodified entry
    mgr.begin();
    custPR.destroy(custId);
    orderPR.put(orderId, order);
    mgr.rollback();
    commitedCust = (Customer) custPR.get(custId);
    Assert.assertTrue(oldCustomer.equals(commitedCust), "Expected customer to rollback to:" + oldCustomer + " but was:" + commitedCust);
    // test remote destroy
    boolean caughtEx = false;
    try {
        mgr.begin();
        Customer cust = new Customer("foo", "bar");
        custPR.put(custId, cust);
        custPR.destroy(custId);
        custPR.putIfAbsent(custId, cust);
        custPR.remove(custId, cust);
        custPR.destroy(new CustId(1));
        custPR.destroy(new CustId(3));
        custPR.destroy(new CustId(7));
        mgr.commit();
    } catch (Exception e) {
        mgr.rollback();
        if (e instanceof TransactionDataNotColocatedException) {
            caughtEx = true;
        } else if (e instanceof TransactionDataRebalancedException) {
            caughtEx = true;
        } else if (e instanceof EntryNotFoundException && e.getMessage().matches("Entry not found for key.*1")) {
            caughtEx = true;
        } else {
            throw new TestException("Expected to catch PR remote destroy exception, but caught:" + e.getMessage(), e);
        }
    }
    if (!caughtEx) {
        throw new TestException("An Expected exception was not thrown");
    }
    // test destroy on unmodified entry
    mgr.begin();
    custPR.destroy(custId);
    orderPR.put(orderId, order);
    mgr.commit();
    commitedCust = (Customer) custPR.get(custId);
    Assert.assertTrue(commitedCust == null, "Expected Customer to be null but was:" + commitedCust);
    Order commitedOrder = (Order) orderPR.get(orderId);
    Assert.assertTrue(order.equals(commitedOrder), "Expected Order to be:" + order + " but was:" + commitedOrder);
    // put the customer again for invalidate verification
    mgr.begin();
    custPR.putIfAbsent(custId, newCus);
    mgr.commit();
    // test destroy on new entry
    // TODO: This throws EntryNotFound
    OrderId newOrderId = new OrderId(5000, custId);
    mgr.begin();
    Order newOrder = new Order("New Order to be destroyed");
    orderPR.put(newOrderId, newOrder);
    orderPR.destroy(newOrderId);
    mgr.commit();
    Assert.assertTrue(orderPR.get(newOrderId) == null, "Did not expect orderId to be present");
    // test ConcurrentMap operations
    mgr.begin();
    Order order1 = new Order("New Order to be replaced");
    Order order2 = new Order("New Order to be destroyed");
    orderPR.putIfAbsent(newOrderId, order1);
    Assert.assertTrue(order1.equals(orderPR.replace(newOrderId, order2)));
    // value is order2
    mgr.commit();
    Assert.assertTrue(order2.equals(orderPR.get(newOrderId)));
    mgr.begin();
    Assert.assertTrue(orderPR.replace(newOrderId, order2, order1));
    // value is order1
    mgr.commit();
    Assert.assertTrue(orderPR.get(newOrderId).equals(order1));
    mgr.begin();
    // this should return false since the value is order1
    Assert.assertTrue(!orderPR.remove(newOrderId, new Object()));
    mgr.commit();
    Assert.assertTrue(orderPR.get(newOrderId).equals(order1));
    mgr.begin();
    Assert.assertTrue(orderPR.remove(newOrderId, order1));
    // gone now
    mgr.commit();
    Assert.assertTrue(orderPR.get(newOrderId) == null);
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) TestException(util.TestException) Customer(org.apache.geode.internal.cache.execute.data.Customer) ArrayList(java.util.ArrayList) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) TestException(util.TestException) CommitConflictException(org.apache.geode.cache.CommitConflictException) PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) CustId(org.apache.geode.internal.cache.execute.data.CustId) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Aggregations

EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)78 Region (org.apache.geode.cache.Region)27 LocalRegion (org.apache.geode.internal.cache.LocalRegion)20 Test (org.junit.Test)18 CacheException (org.apache.geode.cache.CacheException)14 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)13 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)13 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)13 Released (org.apache.geode.internal.offheap.annotations.Released)12 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)10 StoredObject (org.apache.geode.internal.offheap.StoredObject)10 AttributesFactory (org.apache.geode.cache.AttributesFactory)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 CacheWriterException (org.apache.geode.cache.CacheWriterException)8 Entry (org.apache.geode.cache.Region.Entry)8 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)8 ConcurrentCacheModificationException (org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException)8 Host (org.apache.geode.test.dunit.Host)8