Search in sources :

Example 6 with EntryExistsException

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

the class LocalRegion method basicBridgeCreate.

public boolean basicBridgeCreate(final Object key, final byte[] value, boolean isObject, Object callbackArg, final ClientProxyMembershipID client, boolean fromClient, EntryEventImpl clientEvent, boolean throwEntryExists) throws TimeoutException, EntryExistsException, CacheWriterException {
    EventID eventId = clientEvent.getEventId();
    Object theCallbackArg = callbackArg;
    long startPut = CachePerfStats.getStatTime();
    if (fromClient) {
        // GatewayEventCallbackArgument to store the event id.
        if (isGatewaySenderEnabled()) {
            theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
        }
    }
    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.CREATE, key, value, theCallbackArg, false, /* origin remote */
    client.getDistributedMember(), true, /* generateCallbacks */
    eventId);
    try {
        event.setContext(client);
        // if this is a replayed operation or WAN event we may already have a version tag
        event.setVersionTag(clientEvent.getVersionTag());
        // carry over the possibleDuplicate flag from clientEvent
        event.setPossibleDuplicate(clientEvent.isPossibleDuplicate());
        // normal regions. Otherwise, it will become a distributed invalidate.
        if (getDataPolicy() == DataPolicy.NORMAL) {
            event.setLocalInvalid(true);
        }
        // Set the new value to the input byte[] if it isn't null
        if (value != null) {
            // in a CachedDeserializable; otherwise store it directly as a byte[]
            if (isObject) {
                // The value represents an object
                event.setSerializedNewValue(value);
            } else {
                // The value does not represent an object
                event.setNewValue(value);
            }
        }
        // cannot overwrite an existing key
        boolean ifNew = true;
        // can create a new key
        boolean ifOld = false;
        // use now
        long lastModified = 0L;
        // not okay to overwrite the DESTROYED token
        boolean overwriteDestroyed = false;
        boolean success = basicUpdate(event, ifNew, ifOld, lastModified, overwriteDestroyed);
        clientEvent.isConcurrencyConflict(event.isConcurrencyConflict());
        if (success) {
            clientEvent.setVersionTag(event.getVersionTag());
            getCachePerfStats().endPut(startPut, event.isOriginRemote());
        } else {
            this.stopper.checkCancelInProgress(null);
            if (throwEntryExists) {
                throw new EntryExistsException("" + key, event.getOldValue());
            }
        }
        return success;
    } finally {
        event.release();
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) StoredObject(org.apache.geode.internal.offheap.StoredObject) EntryExistsException(org.apache.geode.cache.EntryExistsException) GatewaySenderEventCallbackArgument(org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument)

Example 7 with EntryExistsException

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

the class TXJUnitTest method testStats.

@Test
public void testStats() throws CacheException {
    final int SLEEP_MS = 250;
    // final int OP_TIME = 0; // ns // changed form 10 to 0 because on fater platforms
    // and low resolution clocks this test will fail.
    final CachePerfStats stats = this.cache.getCachePerfStats();
    class statsValidator {

        private long txSuccessLifeTime;

        private long txFailedLifeTime;

        private long txRollbackLifeTime;

        private int txCommits;

        private int txFailures;

        private int txRollbacks;

        private long txCommitTime;

        private long txFailureTime;

        private long txRollbackTime;

        private int txCommitChanges;

        private int txFailureChanges;

        private int txRollbackChanges;

        private CachePerfStats stats;

        private statsValidator(CachePerfStats stats) {
            this.stats = stats;
        }

        private void reset() {
            this.txSuccessLifeTime = this.stats.getTxSuccessLifeTime();
            this.txFailedLifeTime = this.stats.getTxFailedLifeTime();
            this.txRollbackLifeTime = this.stats.getTxRollbackLifeTime();
            this.txCommits = this.stats.getTxCommits();
            this.txFailures = this.stats.getTxFailures();
            this.txRollbacks = this.stats.getTxRollbacks();
            this.txCommitTime = this.stats.getTxCommitTime();
            this.txFailureTime = this.stats.getTxFailureTime();
            this.txRollbackTime = this.stats.getTxRollbackTime();
            this.txCommitChanges = this.stats.getTxCommitChanges();
            this.txFailureChanges = this.stats.getTxFailureChanges();
            this.txRollbackChanges = this.stats.getTxRollbackChanges();
        }

        private void setTxSuccessLifeTime(long txSuccessLifeTime) {
            this.txSuccessLifeTime = txSuccessLifeTime;
        }

        private void setTxFailedLifeTime(long txFailedLifeTime) {
            this.txFailedLifeTime = txFailedLifeTime;
        }

        private void setTxRollbackLifeTime(long txRollbackLifeTime) {
            this.txRollbackLifeTime = txRollbackLifeTime;
        }

        private void setTxCommits(int txCommits) {
            this.txCommits = txCommits;
        }

        private void setTxFailures(int txFailures) {
            this.txFailures = txFailures;
        }

        private void setTxRollbacks(int txRollbacks) {
            this.txRollbacks = txRollbacks;
        }

        private void setTxCommitTime(long txCommitTime) {
            this.txCommitTime = txCommitTime;
        }

        private void setTxFailureTime(long txFailureTime) {
            this.txFailureTime = txFailureTime;
        }

        private void setTxRollbackTime(long txRollbackTime) {
            this.txRollbackTime = txRollbackTime;
        }

        private void setTxCommitChanges(int txCommitChanges) {
            this.txCommitChanges = txCommitChanges;
        }

        private void setTxFailureChanges(int txFailureChanges) {
            this.txFailureChanges = txFailureChanges;
        }

        private void setTxRollbackChanges(int txRollbackChanges) {
            this.txRollbackChanges = txRollbackChanges;
        }

        private void assertValid() {
            assertEquals(this.txRollbacks, this.stats.getTxRollbacks());
            assertEquals(this.txRollbackChanges, this.stats.getTxRollbackChanges());
            if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "cache.enable-time-statistics")) {
                assertTrue(this.txRollbackTime <= this.stats.getTxRollbackTime());
                // assertTrue(this.txRollbackLifeTime+((SLEEP_MS-10)*1000000) <=
                // this.stats.getTxRollbackLifeTime());
                assertTrue("RollbackLifeTime " + this.txRollbackLifeTime + " is not <= " + this.stats.getTxRollbackLifeTime(), this.txRollbackLifeTime <= this.stats.getTxRollbackLifeTime());
                assertTrue(this.txCommitTime <= this.stats.getTxCommitTime());
                assertTrue(this.txSuccessLifeTime <= this.stats.getTxSuccessLifeTime());
                assertTrue(this.txFailureTime <= this.stats.getTxFailureTime());
                assertTrue("FailedLifeTime " + this.txFailedLifeTime + " is not <= " + this.stats.getTxFailedLifeTime(), this.txFailedLifeTime <= this.stats.getTxFailedLifeTime());
            }
            assertEquals(this.txCommits, this.stats.getTxCommits());
            assertEquals(this.txCommitChanges, this.stats.getTxCommitChanges());
            assertEquals(this.txFailures, this.stats.getTxFailures());
            assertEquals(this.txFailureChanges, this.stats.getTxFailureChanges());
        }
    }
    statsValidator statsVal = new statsValidator(stats);
    // Zero and non-zero rollback stats test
    int i;
    long testRollbackLifeTime = 0, testTotalTx = 0;
    for (i = 0; i < 2; ++i) {
        statsVal.reset();
        statsVal.setTxRollbacks(stats.getTxRollbacks() + 1);
        statsVal.setTxRollbackLifeTime(stats.getTxRollbackLifeTime() + ((SLEEP_MS - 20) * 1000000));
        final long beforeBegin = NanoTimer.getTime();
        this.txMgr.begin();
        final long afterBegin = NanoTimer.getTime();
        pause(SLEEP_MS);
        if (i > 0) {
            statsVal.setTxRollbackChanges(stats.getTxRollbackChanges() + 2);
            this.region.put("stats1", "stats rollback1");
            this.region.put("stats2", "stats rollback2");
        }
        statsVal.setTxRollbackTime(stats.getTxRollbackTime());
        final long beforeRollback = NanoTimer.getTime();
        this.txMgr.rollback();
        final long afterRollback = NanoTimer.getTime();
        final long statsRollbackLifeTime = stats.getTxRollbackLifeTime();
        testRollbackLifeTime += beforeRollback - afterBegin;
        // bruce - time based stats are disabled by default
        String p = (String) cache.getDistributedSystem().getProperties().get(DistributionConfig.GEMFIRE_PREFIX + "enable-time-statistics");
        if (p != null && Boolean.getBoolean(p)) {
            assertTrue("Local RollbackLifeTime assertion:  " + testRollbackLifeTime + " is not <= " + statsRollbackLifeTime, testRollbackLifeTime <= statsRollbackLifeTime);
        }
        testTotalTx += afterRollback - beforeBegin;
        final long totalTXMinusRollback = testTotalTx - stats.getTxRollbackTime();
        if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "cache.enable-time-statistics")) {
            assertTrue("Total Tx Minus Rollback assertion:  " + totalTXMinusRollback + " is not >= " + statsRollbackLifeTime, totalTXMinusRollback >= statsRollbackLifeTime);
        }
        statsVal.assertValid();
    }
    // Zero and non-zero commit stats test
    for (i = 0; i < 2; ++i) {
        statsVal.reset();
        statsVal.setTxCommits(stats.getTxCommits() + 1);
        statsVal.setTxSuccessLifeTime(stats.getTxSuccessLifeTime() + ((SLEEP_MS - 10) * 1000000));
        this.txMgr.begin();
        pause(SLEEP_MS);
        if (i > 0) {
            statsVal.setTxCommitChanges(stats.getTxCommitChanges() + 2);
            this.region.put("stats1", "commit1");
            this.region.put("stats2", "commit2");
        }
        try {
            statsVal.setTxCommitTime(stats.getTxCommitTime());
            this.txMgr.commit();
        } catch (CommitConflictException ex) {
            fail("unexpected " + ex);
        }
        statsVal.assertValid();
    }
    // Non-zero failed commit stats
    TXManagerImpl txMgrImpl = (TXManagerImpl) this.txMgr;
    statsVal.reset();
    statsVal.setTxFailures(stats.getTxFailures() + 1);
    statsVal.setTxFailureChanges(stats.getTxFailureChanges() + 2);
    statsVal.setTxFailedLifeTime(stats.getTxFailedLifeTime() + ((SLEEP_MS - 20) * 1000000));
    this.region.put("stats3", "stats fail3");
    this.txMgr.begin();
    this.region.put("stats1", "stats fail1");
    this.region.put("stats2", "stats fail2");
    try {
        this.region.create("stats3", "try stats3");
        fail("expected EntryExistsException");
    } catch (EntryExistsException ok) {
    }
    // begin other tx simulation
    TXStateProxy tx = txMgrImpl.internalSuspend();
    this.region.put("stats1", "stats success1");
    this.region.put("stats2", "stats success2");
    txMgrImpl.internalResume(tx);
    // end other tx simulation
    pause(SLEEP_MS);
    try {
        statsVal.setTxFailureTime(stats.getTxFailureTime());
        this.txMgr.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    // expected failure
    }
    statsVal.assertValid();
}
Also used : CommitConflictException(org.apache.geode.cache.CommitConflictException) TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) EntryExistsException(org.apache.geode.cache.EntryExistsException) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 8 with EntryExistsException

use of org.apache.geode.cache.EntryExistsException 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 9 with EntryExistsException

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

the class PartitionedRegionAPIDUnitTest method partitionedRegionTestAfterDestroyRegion.

/**
   * Test the Region operations after the PartitionedRegion has been destroyed
   * 
   * @param prName
   */
public void partitionedRegionTestAfterDestroyRegion(final String prName) {
    /*
     * do some put(), create(), invalidate() operations for PR with accessor + Datastore and
     * validate.
     */
    vm0.invoke(new CacheSerializableRunnable("doPutCreateInvalidateOperations1") {

        public void run2() throws CacheException {
            Cache cache = getCache();
            String exceptionStr = "";
            Region pr = cache.getRegion(prName);
            if (pr == null) {
                fail("PR not created");
            }
            for (int i = putRange_1Start; i <= putRange_1End; i++) {
                // System.out.println("Putting entry for key = " + i);
                pr.put("" + i, "" + i);
            }
            // Create Operation
            for (int i = createRange_1Start; i <= createRange_1End; i++) {
                Object val = null;
                Object key = "" + i;
                if (i % 2 == 0) {
                    val = "" + i;
                }
                pr.create(key, val);
            }
            for (int i = createRange_1Start; i <= createRange_1End; i++) {
                Object val = null;
                Object key = "" + i;
                if (i % 2 == 0) {
                    val = "" + i;
                }
                final String expectedExceptions = EntryExistsException.class.getName();
                getCache().getLogger().info("<ExpectedException action=add>" + expectedExceptions + "</ExpectedException>");
                exceptionStr = ReplyException.class.getName() + ":" + expectedExceptions;
                vm1.invoke(addExceptionTag1(exceptionStr));
                vm2.invoke(addExceptionTag1(exceptionStr));
                vm3.invoke(addExceptionTag1(exceptionStr));
                addExceptionTag1(exceptionStr);
                try {
                    pr.create(key, val);
                    fail("EntryExistsException is not thrown");
                } catch (EntryExistsException expected) {
                // getLogWriter().fine("EntryExistsException is properly thrown");
                }
                vm1.invoke(removeExceptionTag1(exceptionStr));
                vm2.invoke(removeExceptionTag1(exceptionStr));
                vm3.invoke(removeExceptionTag1(exceptionStr));
                removeExceptionTag1(exceptionStr);
                getCache().getLogger().info("<ExpectedException action=remove>" + expectedExceptions + "</ExpectedException>");
            }
            for (int i = invalidateRange_1Start; i <= invalidateRange_1End; i++) {
                // Check that before creating an entry it throws
                // EntryNotFoundException
                final Object val = Integer.toString(i);
                final Object key = Integer.toString(i);
                final String entryNotFoundException = EntryNotFoundException.class.getName();
                getCache().getLogger().info("<ExpectedException action=add>" + entryNotFoundException + "</ExpectedException>");
                exceptionStr = ReplyException.class.getName() + "||" + entryNotFoundException;
                vm1.invoke(addExceptionTag1(exceptionStr));
                vm2.invoke(addExceptionTag1(exceptionStr));
                vm3.invoke(addExceptionTag1(exceptionStr));
                addExceptionTag1(exceptionStr);
                try {
                    pr.invalidate(key);
                    fail("EntryNotFoundException is not thrown for key which does not exists in the system = " + key);
                } catch (EntryNotFoundException expected) {
                }
                vm1.invoke(removeExceptionTag1(exceptionStr));
                vm2.invoke(removeExceptionTag1(exceptionStr));
                vm3.invoke(removeExceptionTag1(exceptionStr));
                removeExceptionTag1(exceptionStr);
                getCache().getLogger().info("<ExpectedException action=remove>" + entryNotFoundException + "</ExpectedException>");
                pr.create(key, val);
                assertTrue("containsValueForKey key=" + key, pr.containsValueForKey(key));
                assertEquals(val, pr.get(key));
                pr.invalidate(key);
                assertFalse(pr.containsValueForKey(key));
                assertNull(pr.get(key));
            }
            for (int i = invalidateRange_1Start; i <= invalidateRange_1End; i++) {
                final Object key = Integer.toString(i);
                pr.destroy(key);
            }
            final String entryNotFoundException = EntryNotFoundException.class.getName();
            getCache().getLogger().info("<ExpectedException action=add>" + entryNotFoundException + "</ExpectedException>");
            exceptionStr = ReplyException.class.getName() + "||" + entryNotFoundException;
            vm1.invoke(addExceptionTag1(exceptionStr));
            vm2.invoke(addExceptionTag1(exceptionStr));
            vm3.invoke(addExceptionTag1(exceptionStr));
            addExceptionTag1(exceptionStr);
            for (int i = invalidateRange_1Start; i <= invalidateRange_1End; i++) {
                // Check that after deleting an entry, invalidate for that entry
                // throws
                // EntryNotFoundException
                Object key = "" + i;
                try {
                    pr.invalidate(key);
                    fail("EntryNotFoundException is not thrown for key which does not exists in the system = " + key);
                } catch (EntryNotFoundException expected) {
                }
            }
            vm1.invoke(removeExceptionTag1(exceptionStr));
            vm2.invoke(removeExceptionTag1(exceptionStr));
            vm3.invoke(removeExceptionTag1(exceptionStr));
            removeExceptionTag1(exceptionStr);
            getCache().getLogger().info("<ExpectedException action=remove>" + entryNotFoundException + "</ExpectedException>");
            LogWriterUtils.getLogWriter().fine("Out of doPutOperations1");
            LogWriterUtils.getLogWriter().fine("All the puts done successfully for vm0.");
        }
    });
    /*
     * do some put(), create(), invalidate() operations for PR with only accessor and validate.
     */
    vm1.invoke(new CacheSerializableRunnable("doPutCreateInvalidateOperations2") {

        public void run2() throws CacheException {
            Cache cache = getCache();
            String exceptionStr = "";
            Region pr = cache.getRegion(prName);
            if (pr == null) {
                fail("PR not created");
            }
            for (int i = putRange_2Start; i <= putRange_2End; i++) {
                // System.out.println("Putting entry for key = " + i);
                pr.put("" + i, "" + i);
            }
            // Create Operation
            for (int i = createRange_2Start; i <= createRange_2End; i++) {
                Object val = null;
                Object key = "" + i;
                if (i % 2 == 0) {
                    val = "" + i;
                }
                pr.create(key, val);
            }
            final String entryExistsException = EntryExistsException.class.getName();
            getCache().getLogger().info("<ExpectedException action=add>" + entryExistsException + "</ExpectedException>");
            exceptionStr = ReplyException.class.getName() + "||" + entryExistsException;
            vm0.invoke(addExceptionTag1(exceptionStr));
            vm2.invoke(addExceptionTag1(exceptionStr));
            vm3.invoke(addExceptionTag1(exceptionStr));
            addExceptionTag1(exceptionStr);
            for (int i = createRange_2Start; i <= createRange_2End; i++) {
                Object val = null;
                Object key = "" + i;
                if (i % 2 == 0) {
                    val = "" + i;
                }
                try {
                    pr.create(key, val);
                    fail("EntryExistsException is not thrown");
                } catch (EntryExistsException expected) {
                // getLogWriter().fine("EntryExistsException is properly thrown");
                }
            }
            vm0.invoke(removeExceptionTag1(exceptionStr));
            vm2.invoke(removeExceptionTag1(exceptionStr));
            vm3.invoke(removeExceptionTag1(exceptionStr));
            removeExceptionTag1(exceptionStr);
            getCache().getLogger().info("<ExpectedException action=remove>" + entryExistsException + "</ExpectedException>");
            // Invalidate Operations
            final String entryNotFoundException = EntryNotFoundException.class.getName();
            getCache().getLogger().info("<ExpectedException action=add>" + entryNotFoundException + "</ExpectedException>");
            exceptionStr = ReplyException.class.getName() + "||" + entryNotFoundException;
            vm0.invoke(addExceptionTag1(exceptionStr));
            vm2.invoke(addExceptionTag1(exceptionStr));
            vm3.invoke(addExceptionTag1(exceptionStr));
            addExceptionTag1(exceptionStr);
            for (int i = invalidateRange_2Start; i <= invalidateRange_2End; i++) {
                // Check that before creating an entry it throws
                // EntryNotFoundException
                final Object val = Integer.toString(i);
                final Object key = Integer.toString(i);
                try {
                    pr.invalidate(key);
                    fail("EntryNotFoundException is not thrown for key which does not exists in the system = " + key);
                } catch (EntryNotFoundException expected) {
                }
                pr.create(key, val);
            }
            vm0.invoke(removeExceptionTag1(exceptionStr));
            vm2.invoke(removeExceptionTag1(exceptionStr));
            vm3.invoke(removeExceptionTag1(exceptionStr));
            removeExceptionTag1(exceptionStr);
            getCache().getLogger().info("<ExpectedException action=remove>" + entryNotFoundException + "</ExpectedException>");
            for (int i = invalidateRange_2Start; i <= invalidateRange_2End; i++) {
                // Check that before creating an entry it throws
                // EntryNotFoundException
                final Object val = Integer.toString(i);
                final Object key = Integer.toString(i);
                assertEquals(val, pr.get(key));
                assertTrue(pr.containsValueForKey(key));
                pr.invalidate(key);
            }
            for (int i = invalidateRange_2Start; i <= invalidateRange_2End; i++) {
                final Object key = Integer.toString(i);
                Object shouldBeNull = pr.get(key);
                assertNull("Key " + key + " should report val null, however it has " + shouldBeNull, shouldBeNull);
                assertFalse("Key " + key + " should report False for containsValueForKey", pr.containsValueForKey(key));
            }
            for (int i = invalidateRange_2Start; i <= invalidateRange_2End; i++) {
                final Object key = Integer.toString(i);
                pr.destroy(key);
            }
            getCache().getLogger().info("<ExpectedException action=add>" + entryNotFoundException + "</ExpectedException>");
            exceptionStr = ReplyException.class.getName() + "||" + entryNotFoundException;
            vm0.invoke(addExceptionTag1(exceptionStr));
            vm2.invoke(addExceptionTag1(exceptionStr));
            vm3.invoke(addExceptionTag1(exceptionStr));
            addExceptionTag1(exceptionStr);
            for (int i = invalidateRange_2Start; i <= invalidateRange_2End; i++) {
                // Check that after deleting an entry, invalidate for that entry
                // throws
                // EntryNotFoundException
                final Object key = Integer.toString(i);
                try {
                    pr.invalidate(key);
                    fail("EntryNotFoundException is not thrown for key which does not exists in the system = " + key);
                } catch (EntryNotFoundException expected) {
                }
            }
            vm0.invoke(removeExceptionTag1(exceptionStr));
            vm2.invoke(removeExceptionTag1(exceptionStr));
            vm3.invoke(removeExceptionTag1(exceptionStr));
            removeExceptionTag1(exceptionStr);
            getCache().getLogger().info("<ExpectedException action=remove>" + entryNotFoundException + "</ExpectedException>");
            LogWriterUtils.getLogWriter().fine("Out of doPutOperations2");
            LogWriterUtils.getLogWriter().fine("All the puts done successfully for vm1.");
        }
    });
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) EntryExistsException(org.apache.geode.cache.EntryExistsException) Cache(org.apache.geode.cache.Cache)

Example 10 with EntryExistsException

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

the class TXJUnitTest method testRepeatableRead.

@Test
public void testRepeatableRead() throws CacheException {
    final TXManagerImpl txMgrImpl = (TXManagerImpl) this.txMgr;
    TXStateProxy tx;
    // try repeating a get and make sure it doesn't cause a conflict
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals("value1", this.region.get("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals("value1", this.region.get("key1"));
    txMgrImpl.commit();
    // try repeating a get and modify the entry and make sure it causes a conflict
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals("value1", this.region.get("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals("value1", this.region.get("key1"));
    this.region.put("key1", "value3");
    assertEquals("value3", this.region.get("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try repeating a getEntry and make sure it doesn't cause a conflict
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    this.region.getEntry("key1");
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals("value1", this.region.get("key1"));
    txMgrImpl.commit();
    // try repeating a getEntry and modify the entry and make sure it causes a conflict
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    this.region.getEntry("key1");
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    this.region.put("key1", "value3");
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try RR when entry fetched using entrySet
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    // bootstrap the tx, entrySet does not
    this.region.get("key1");
    this.region.entrySet(false).iterator().next();
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals("value1", this.region.get("key1"));
    txMgrImpl.commit();
    // try RRW->CONFLICT when entry fetched using entrySet
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    // bootstrap the tx, entrySet does not
    this.region.get("key1");
    this.region.entrySet(false).iterator().next();
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals("value1", this.region.get("key1"));
    this.region.put("key1", "value3");
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try containsKey
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals(true, this.region.containsKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsKey("key1"));
    txMgrImpl.commit();
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals(true, this.region.containsKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsKey("key1"));
    this.region.put("key1", "value3");
    assertEquals(true, this.region.containsKey("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try containsValueForKey
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals(true, this.region.containsValueForKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsValueForKey("key1"));
    txMgrImpl.commit();
    // non-tx
    this.region.put("key1", "value1");
    txMgrImpl.begin();
    assertEquals(true, this.region.containsValueForKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsValueForKey("key1"));
    this.region.put("key1", "value3");
    assertEquals(true, this.region.containsValueForKey("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // now try the same things but with no entry in committed state at
    // the time of the first read
    // try repeating a get and make sure it doesn't cause a conflict
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(null, this.region.get("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(null, this.region.get("key1"));
    txMgrImpl.commit();
    // try repeating a get and modify the entry and make sure it causes a conflict
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(null, this.region.get("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(null, this.region.get("key1"));
    this.region.put("key1", "value3");
    assertEquals("value3", this.region.get("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try repeating a getEntry and make sure it doesn't cause a conflict
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(null, this.region.getEntry("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(null, this.region.getEntry("key1"));
    txMgrImpl.commit();
    // try repeating a getEntry and modify the entry and make sure it causes a conflict
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(null, this.region.getEntry("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(null, this.region.getEntry("key1"));
    this.region.put("key1", "value3");
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try containsKey
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(false, this.region.containsKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(false, this.region.containsKey("key1"));
    txMgrImpl.commit();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(false, this.region.containsKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(false, this.region.containsKey("key1"));
    this.region.put("key1", "value3");
    assertEquals(true, this.region.containsKey("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try containsValueForKey
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(false, this.region.containsValueForKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(false, this.region.containsValueForKey("key1"));
    txMgrImpl.commit();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    assertEquals(false, this.region.containsValueForKey("key1"));
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.put("key1", "value2");
    txMgrImpl.internalResume(tx);
    assertEquals(false, this.region.containsValueForKey("key1"));
    this.region.put("key1", "value3");
    assertEquals(true, this.region.containsValueForKey("key1"));
    try {
        txMgrImpl.commit();
        fail("expected CommitConflictException");
    } catch (CommitConflictException ex) {
    }
    // try an invalidate of an already invalid entry
    // non-tx
    this.region.remove("key1");
    // non-tx
    this.region.create("key1", null);
    txMgrImpl.begin();
    this.region.get("key1");
    // should be a noop since it is already invalid
    this.region.localInvalidate("key1");
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    txMgrImpl.commit();
    assertEquals(false, this.region.containsKey("key1"));
    // make sure a noop invalidate is repeatable read
    // non-tx
    this.region.remove("key1");
    // non-tx
    this.region.create("key1", null);
    txMgrImpl.begin();
    // should be a noop since it is already invalid
    this.region.localInvalidate("key1");
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsKey("key1"));
    assertEquals(false, this.region.containsValueForKey("key1"));
    txMgrImpl.commit();
    assertEquals(false, this.region.containsKey("key1"));
    // make sure a destroy that throws entryNotFound is repeatable read
    // non-tx
    this.region.remove("key1");
    txMgrImpl.begin();
    try {
        this.region.localDestroy("key1");
        fail("expected EntryNotFoundException");
    } catch (EntryNotFoundException expected) {
    }
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.create("key1", "value1");
    txMgrImpl.internalResume(tx);
    assertEquals(false, this.region.containsKey("key1"));
    txMgrImpl.commit();
    assertEquals(true, this.region.containsKey("key1"));
    // non-tx
    this.region.remove("key1");
    // make sure a create that throws entryExists is repeatable read
    // non-tx
    this.region.create("key1", "non-tx-value1");
    txMgrImpl.begin();
    try {
        this.region.create("key1", "value1");
        fail("expected EntryExistsException");
    } catch (EntryExistsException expected) {
    }
    tx = txMgrImpl.internalSuspend();
    // non-tx
    this.region.remove("key1");
    txMgrImpl.internalResume(tx);
    assertEquals(true, this.region.containsKey("key1"));
    txMgrImpl.commit();
    assertEquals(false, this.region.containsKey("key1"));
}
Also used : CommitConflictException(org.apache.geode.cache.CommitConflictException) TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) EntryExistsException(org.apache.geode.cache.EntryExistsException) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

EntryExistsException (org.apache.geode.cache.EntryExistsException)11 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)6 Region (org.apache.geode.cache.Region)6 CacheException (org.apache.geode.cache.CacheException)5 Test (org.junit.Test)5 LocalRegion (org.apache.geode.internal.cache.LocalRegion)4 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)4 Cache (org.apache.geode.cache.Cache)3 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)3 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)3 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Random (java.util.Random)2 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)2 CommitConflictException (org.apache.geode.cache.CommitConflictException)2 EntryEvent (org.apache.geode.cache.EntryEvent)2 TransactionId (org.apache.geode.cache.TransactionId)2 TXManagerImpl (org.apache.geode.internal.cache.TXManagerImpl)2 TXStateProxy (org.apache.geode.internal.cache.TXStateProxy)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1