Search in sources :

Example 16 with TransactionId

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

the class DiscardExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    CacheTransactionManager txm = context.getCacheTransactionManager();
    if (context.hasTransaction()) {
        TransactionId transactionId = context.getTransactionID();
        txm.resume(transactionId);
        txm.rollback();
        context.clearTransaction();
    }
    command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));
}
Also used : CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionId(org.apache.geode.cache.TransactionId)

Example 17 with TransactionId

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

the class ExecExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    CacheTransactionManager txm = context.getCacheTransactionManager();
    if (!context.hasTransaction()) {
        command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
        return;
    }
    TransactionId transactionId = context.getTransactionID();
    txm.resume(transactionId);
    boolean hasError = hasError(context.getTransactionQueue());
    if (hasError)
        txm.rollback();
    else {
        try {
            txm.commit();
        } catch (CommitConflictException e) {
            command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_COMMIT_CONFLICT));
            context.clearTransaction();
            return;
        }
    }
    ByteBuf response = constructResponseExec(context);
    command.setResponse(response);
    context.clearTransaction();
}
Also used : CommitConflictException(org.apache.geode.cache.CommitConflictException) ByteBuf(io.netty.buffer.ByteBuf) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionId(org.apache.geode.cache.TransactionId)

Example 18 with TransactionId

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

the class MultiExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    CacheTransactionManager txm = context.getCacheTransactionManager();
    command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));
    if (context.hasTransaction()) {
        throw new IllegalStateException(RedisConstants.ERROR_NESTED_MULTI);
    }
    txm.begin();
    TransactionId id = txm.suspend();
    context.setTransactionID(id);
}
Also used : CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionId(org.apache.geode.cache.TransactionId)

Example 19 with TransactionId

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

the class MultiVMRegionTestCase method testTXAlgebra.

@Ignore("TODO: test is disabled")
@Test
public void testTXAlgebra() throws Exception {
    assumeFalse(getRegionAttributes().getScope().isGlobal());
    assumeFalse(getRegionAttributes().getDataPolicy().withPersistence());
    assertTrue(getRegionAttributes().getScope().isDistributed());
    CacheTransactionManager txMgr = this.getCache().getCacheTransactionManager();
    MyTransactionListener localTl = new MyTransactionListener();
    TransactionId myTXId;
    txMgr.addListener(localTl);
    assertEquals(null, localTl.lastEvent);
    localTl.assertCounts(0, 0, 0, 0);
    final String rgnName = getUniqueName();
    SerializableRunnable create = new SerializableRunnable("testTXAlgebra: Create Region") {

        @Override
        public void run() {
            CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
            MyTransactionListener tl = new MyTransactionListener();
            txMgr2.addListener(tl);
            assertEquals(null, tl.lastEvent);
            tl.assertCounts(0, 0, 0, 0);
            try {
                Region rgn = createRegion(rgnName);
                if (!getRegionAttributes().getDataPolicy().withReplication()) {
                    rgn.create("key", null);
                    getSystem().getLogWriter().info("testTXAlgebra: Created Key");
                }
            } catch (CacheException e) {
                fail("While creating region", e);
            }
        }
    };
    Invoke.invokeInEveryVM(create);
    // check C + P -> C
    try {
        AttributesFactory rgnAtts = new AttributesFactory(getRegionAttributes());
        rgnAtts.setDataPolicy(DataPolicy.NORMAL);
        Region rgn = createRegion(rgnName, rgnAtts.create());
        //// callbackVal.reset();
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.create("key", "value1");
        //// callbackVal.assertCreateCnt(1);
        try {
            rgn.create("key", "value2");
            fail("expected EntryExistsException");
        } catch (EntryExistsException ok) {
        }
        //// callbackVal.assertCreateCnt(1, /*remember*/ false);
        rgn.put("key", "value2");
        //// callbackVal.assertUpdateCnt(1);
        assertEquals("value2", rgn.getEntry("key").getValue());
        txMgr.commit();
        // Make sure commit did not trigger callbacks
        //// callbackVal.reAssert();
        Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: C+P->C") {

            @Override
            public void run2() {
                Region rgn1 = getRootRegion().getSubregion(rgnName);
                CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                assertEquals("value2", rgn1.getEntry("key").getValue());
                tl.assertCounts(1, 0, 0, 0);
                {
                    Collection events;
                    RegionAttributes attr = getRegionAttributes();
                    if (!attr.getDataPolicy().withReplication() || attr.getConcurrencyChecksEnabled()) {
                        events = tl.lastEvent.getPutEvents();
                    } else {
                        events = tl.lastEvent.getCreateEvents();
                    }
                    assertEquals(1, events.size());
                    EntryEvent ev = (EntryEvent) events.iterator().next();
                    // assertIndexDetailsEquals(tl.expectedTxId, ev.getTransactionId());
                    assertTrue(ev.getRegion() == rgn1);
                    assertEquals("key", ev.getKey());
                    assertEquals("value2", ev.getNewValue());
                    assertNull(ev.getOldValue());
                    assertTrue(!ev.getOperation().isLocalLoad());
                    assertTrue(!ev.getOperation().isNetLoad());
                    assertTrue(!ev.getOperation().isLoad());
                    assertTrue(!ev.getOperation().isNetSearch());
                    assertTrue(!ev.getOperation().isExpiration());
                    assertEquals(null, ev.getCallbackArgument());
                    assertEquals(true, ev.isCallbackArgumentAvailable());
                    assertTrue(ev.isOriginRemote());
                    assertTrue(ev.getOperation().isDistributed());
                }
            }
        });
        assertEquals("value2", rgn.getEntry("key").getValue());
        {
            localTl.assertCounts(1, 0, 0, 0);
            Collection events = localTl.lastEvent.getCreateEvents();
            assertEquals(myTXId, localTl.lastEvent.getTransactionId());
            assertEquals(1, events.size());
            EntryEvent ev = (EntryEvent) events.iterator().next();
            assertEquals(myTXId, ev.getTransactionId());
            assertTrue(ev.getRegion() == rgn);
            assertEquals("key", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertNull(ev.getOldValue());
            assertTrue(!ev.getOperation().isLocalLoad());
            assertTrue(!ev.getOperation().isNetLoad());
            assertTrue(!ev.getOperation().isLoad());
            assertTrue(!ev.getOperation().isNetSearch());
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
        if (!getRegionAttributes().getDataPolicy().withReplication()) {
            rgn.invalidate("key");
            rgn.localDestroy("key");
        } else {
            rgn.destroy("key");
        }
        // Check C + DI -> C (invalid value)
        //// callbackVal.reset();
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.create("key", "value1");
        //// callbackVal.assertCreateCnt(1);
        rgn.invalidate("key");
        //// callbackVal.assertInvalidateCnt(1);
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        txMgr.commit();
        //// callbackVal.reAssert();
        Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: C+DI->C (invalid value)") {

            @Override
            public void run2() {
                Region rgn1 = getRootRegion().getSubregion(rgnName);
                CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                assertTrue(rgn1.containsKey("key"));
                assertTrue(!rgn1.containsValueForKey("key"));
                tl.assertCounts(2, 0, 0, 0);
                {
                    Collection events;
                    RegionAttributes attr = getRegionAttributes();
                    if (!attr.getDataPolicy().withReplication() || attr.getConcurrencyChecksEnabled()) {
                        events = tl.lastEvent.getPutEvents();
                    } else {
                        events = tl.lastEvent.getCreateEvents();
                    }
                    assertEquals(1, events.size());
                    EntryEvent ev = (EntryEvent) events.iterator().next();
                    // assertIndexDetailsEquals(tl.expectedTxId, ev.getTransactionId());
                    assertTrue(ev.getRegion() == rgn1);
                    assertEquals("key", ev.getKey());
                    assertNull(ev.getNewValue());
                    assertNull(ev.getOldValue());
                    assertTrue(!ev.getOperation().isLocalLoad());
                    assertTrue(!ev.getOperation().isNetLoad());
                    assertTrue(!ev.getOperation().isLoad());
                    assertTrue(!ev.getOperation().isNetSearch());
                    assertTrue(!ev.getOperation().isExpiration());
                    assertEquals(null, ev.getCallbackArgument());
                    assertEquals(true, ev.isCallbackArgumentAvailable());
                    assertTrue(ev.isOriginRemote());
                    assertTrue(ev.getOperation().isDistributed());
                }
            }
        });
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        localTl.assertCounts(2, 0, 0, 0);
        {
            Collection events = localTl.lastEvent.getCreateEvents();
            assertEquals(myTXId, localTl.lastEvent.getTransactionId());
            assertEquals(1, events.size());
            EntryEvent ev = (EntryEvent) events.iterator().next();
            assertEquals(myTXId, ev.getTransactionId());
            assertTrue(ev.getRegion() == rgn);
            assertEquals("key", ev.getKey());
            assertNull(ev.getNewValue());
            assertNull(ev.getOldValue());
            assertTrue(!ev.getOperation().isLocalLoad());
            assertTrue(!ev.getOperation().isNetLoad());
            assertTrue(!ev.getOperation().isLoad());
            assertTrue(!ev.getOperation().isNetSearch());
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
        // check (commited) LI + DI -> NOOP
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.invalidate("key");
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        txMgr.commit();
        Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: committed LI + TX DI-> NOOP") {

            @Override
            public void run2() {
                Region rgn1 = getRootRegion().getSubregion(rgnName);
                CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                assertEquals("value1", rgn1.getEntry("key").getValue());
                // There should be no change in counts
                tl.assertCounts(2, 0, 0, 0);
            }
        });
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        // There should be no change in counts
        localTl.assertCounts(2, 0, 0, 0);
        if (!getRegionAttributes().getDataPolicy().withReplication()) {
            // check (exists commited) LI + DI -> LI
            rgn.put("key", "value1");
            assertTrue(rgn.containsKey("key"));
            assertEquals("value1", rgn.getEntry("key").getValue());
            txMgr.begin();
            myTXId = txMgr.getTransactionId();
            rgn.localInvalidate("key");
            rgn.invalidate("key");
            assertTrue(rgn.containsKey("key"));
            assertTrue(!rgn.containsValueForKey("key"));
            txMgr.commit();
            Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: TX LI + TX DI -> LI") {

                @Override
                public void run2() {
                    Region rgn1 = getRootRegion().getSubregion(rgnName);
                    CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                    MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                    assertTrue(rgn1.containsKey("key"));
                    assertTrue(rgn1.containsValueForKey("key"));
                    assertEquals("value1", rgn1.getEntry("key").getValue());
                    // nothing happened remotely
                    tl.assertCounts(2, 0, 0, 0);
                }
            });
            assertTrue(rgn.containsKey("key"));
            assertTrue(!rgn.containsValueForKey("key"));
            assertNull(rgn.getEntry("key").getValue());
            localTl.assertCounts(3, 0, 0, 0);
            {
                Collection events = localTl.lastEvent.getInvalidateEvents();
                assertEquals(1, events.size());
                EntryEvent ev = (EntryEvent) events.iterator().next();
                assertEquals(myTXId, ev.getTransactionId());
                assertTrue(ev.getRegion() == rgn);
                assertEquals("key", ev.getKey());
                assertNull(ev.getNewValue());
                assertEquals("value1", ev.getOldValue());
                assertTrue(!ev.getOperation().isLocalLoad());
                assertTrue(!ev.getOperation().isNetLoad());
                assertTrue(!ev.getOperation().isLoad());
                assertTrue(!ev.getOperation().isNetSearch());
                assertEquals(null, ev.getCallbackArgument());
                assertEquals(true, ev.isCallbackArgumentAvailable());
                assertTrue(!ev.isOriginRemote());
                assertTrue(!ev.getOperation().isExpiration());
                assertTrue(ev.getOperation().isDistributed());
            }
            rgn.invalidate("key");
            rgn.localDestroy("key");
        } else {
            rgn.destroy("key");
        }
        // check C + DD -> DD
        //// callbackVal.reset();
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.create("key", "value0");
        //// callbackVal.assertCreateCnt(1);
        rgn.destroy("key");
        //// callbackVal.assertDestroyCnt(1);
        assertTrue(!rgn.containsKey("key"));
        txMgr.commit();
        //// callbackVal.reAssert();
        Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: C+DD->DD") {

            @Override
            public void run2() {
                Region rgn1 = getRootRegion().getSubregion(rgnName);
                CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                assertTrue(!rgn1.containsKey("key"));
                assertTrue(!rgn1.containsValueForKey("key"));
                tl.assertCounts(3, 0, 0, 0);
                {
                    Collection events = tl.lastEvent.getDestroyEvents();
                    assertEquals(1, events.size());
                    EntryEvent ev = (EntryEvent) events.iterator().next();
                    // assertIndexDetailsEquals(tl.expectedTxId, ev.getTransactionId());
                    assertTrue(ev.getRegion() == rgn1);
                    assertNull(ev.getKey());
                    assertNull(ev.getNewValue());
                    assertNull(ev.getOldValue());
                    assertTrue(!ev.getOperation().isLocalLoad());
                    assertTrue(!ev.getOperation().isNetLoad());
                    assertTrue(!ev.getOperation().isLoad());
                    assertTrue(!ev.getOperation().isNetSearch());
                    assertTrue(!ev.getOperation().isExpiration());
                    assertEquals(null, ev.getCallbackArgument());
                    assertEquals(true, ev.isCallbackArgumentAvailable());
                    assertTrue(ev.isOriginRemote());
                    assertTrue(ev.getOperation().isDistributed());
                }
            }
        });
        assertTrue(!rgn.containsKey("key"));
        // no change
        localTl.assertCounts(3, 0, 0, 0);
        // Check C + LI -> C
        if (!getRegionAttributes().getDataPolicy().withReplication()) {
            // assume that remote regions have same mirror type as local
            Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: C+LI-> entry creation") {

                @Override
                public void run2() {
                    Region rgn1 = getRootRegion().getSubregion(rgnName);
                    try {
                        rgn1.create("key", null);
                    } catch (CacheException e) {
                        fail("While creating key", e);
                    }
                }
            });
        }
        assertTrue(!rgn.containsKey("key"));
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.create("key", "value1");
        //// callbackVal.assertCreateCnt(1);
        rgn.localInvalidate("key");
        //// callbackVal.assertInvalidateCnt(1);
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        txMgr.commit();
        //// callbackVal.reAssert();
        Invoke.invokeInEveryVM(new CacheSerializableRunnable("testTXAlgebra: check: C+LI->C (with value)") {

            @Override
            public void run2() {
                Region rgn1 = getRootRegion().getSubregion(rgnName);
                CacheTransactionManager txMgr2 = getCache().getCacheTransactionManager();
                MyTransactionListener tl = (MyTransactionListener) txMgr2.getListeners()[0];
                tl.assertCounts(4, 0, 0, 0);
                assertTrue(rgn1.containsKey("key"));
                assertEquals("value1", rgn1.getEntry("key").getValue());
                {
                    Collection events;
                    RegionAttributes attr = getRegionAttributes();
                    if (!attr.getDataPolicy().withReplication() || attr.getConcurrencyChecksEnabled()) {
                        events = tl.lastEvent.getPutEvents();
                    } else {
                        events = tl.lastEvent.getCreateEvents();
                    }
                    assertEquals(1, events.size());
                    EntryEvent ev = (EntryEvent) events.iterator().next();
                    // assertIndexDetailsEquals(tl.expectedTxId, ev.getTransactionId());
                    assertTrue(ev.getRegion() == rgn1);
                    assertEquals("key", ev.getKey());
                    assertEquals("value1", ev.getNewValue());
                    assertNull(ev.getOldValue());
                    assertTrue(!ev.getOperation().isLocalLoad());
                    assertTrue(!ev.getOperation().isNetLoad());
                    assertTrue(!ev.getOperation().isLoad());
                    assertTrue(!ev.getOperation().isNetSearch());
                    assertTrue(!ev.getOperation().isExpiration());
                    assertEquals(null, ev.getCallbackArgument());
                    assertEquals(true, ev.isCallbackArgumentAvailable());
                    assertTrue(ev.isOriginRemote());
                    assertTrue(ev.getOperation().isDistributed());
                }
            }
        });
        assertTrue(rgn.containsKey("key"));
        assertTrue(!rgn.containsValueForKey("key"));
        localTl.assertCounts(4, 0, 0, 0);
        {
            Collection events = localTl.lastEvent.getCreateEvents();
            assertEquals(myTXId, localTl.lastEvent.getTransactionId());
            assertEquals(1, events.size());
            EntryEvent ev = (EntryEvent) events.iterator().next();
            assertEquals(myTXId, ev.getTransactionId());
            assertTrue(ev.getRegion() == rgn);
            assertEquals("key", ev.getKey());
            assertNull(ev.getNewValue());
            assertNull(ev.getOldValue());
            assertTrue(!ev.getOperation().isLocalLoad());
            assertTrue(!ev.getOperation().isNetLoad());
            assertTrue(!ev.getOperation().isLoad());
            assertTrue(!ev.getOperation().isNetSearch());
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
        rgn.destroy("key");
        // Check P + LI + C -> EX
        // Check C + LI + P -> C
        //// callbackVal.reset();
        txMgr.begin();
        myTXId = txMgr.getTransactionId();
        rgn.create("key", "value1");
        //// callbackVal.assertCreateCnt(1);
        rgn.localInvalidate("key");
        //// callbackVal.assertInvalidateCnt(1);
        try {
            rgn.create("key", "ex");
            fail("expected EntryExistsException");
        } catch (EntryExistsException ok) {
        }
        //// callbackVal.assertCreateCnt(1, /*remember*/ false);
        rgn.put("key", "value2");
        //// callbackVal.assertUpdateCnt(1);
        assertTrue(rgn.containsKey("key"));
        assertEquals("value2", rgn.getEntry("key").getValue());
        txMgr.commit();
        //// callbackVal.reAssert();
        assertTrue(rgn.containsKey("key"));
        assertEquals("value2", rgn.getEntry("key").getValue());
        localTl.assertCounts(5, 0, 0, 0);
        {
            Collection events = localTl.lastEvent.getCreateEvents();
            assertEquals(myTXId, localTl.lastEvent.getTransactionId());
            assertEquals(1, events.size());
            EntryEvent ev = (EntryEvent) events.iterator().next();
            assertEquals(myTXId, ev.getTransactionId());
            assertTrue(ev.getRegion() == rgn);
            assertEquals("key", ev.getKey());
            assertEquals("value2", ev.getNewValue());
            assertNull(ev.getOldValue());
            assertTrue(!ev.getOperation().isLocalLoad());
            assertTrue(!ev.getOperation().isNetLoad());
            assertTrue(!ev.getOperation().isLoad());
            assertTrue(!ev.getOperation().isNetSearch());
            assertEquals(null, ev.getCallbackArgument());
            assertEquals(true, ev.isCallbackArgumentAvailable());
            assertTrue(!ev.isOriginRemote());
            assertTrue(!ev.getOperation().isExpiration());
            assertTrue(ev.getOperation().isDistributed());
        }
        rgn.localDestroy("key");
    } catch (Exception e) {
        CacheFactory.getInstance(getSystem()).close();
        getSystem().getLogWriter().fine("testTXAlgebra: Caused exception in createRegion");
        throw e;
    }
}
Also used : CacheException(org.apache.geode.cache.CacheException) RegionAttributes(org.apache.geode.cache.RegionAttributes) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) EntryExistsException(org.apache.geode.cache.EntryExistsException) TimeoutException(org.apache.geode.cache.TimeoutException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) EntryExistsException(org.apache.geode.cache.EntryExistsException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionId(org.apache.geode.cache.TransactionId) AttributesFactory(org.apache.geode.cache.AttributesFactory) EntryEvent(org.apache.geode.cache.EntryEvent) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) Collection(java.util.Collection) Ignore(org.junit.Ignore) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 20 with TransactionId

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

the class PRTransactionDUnitTest method basicPRTXWithOpOnMovedBucket.

/**
   * This method executes a transaction with operation on a key in a moved bucket, and expects
   * transaction to fail with TransactionDataRebalancedException.
   * 
   * @param op which entry op to be executed
   * @param bucketRedundancy redundancy for the colocated PRs
   */
@SuppressWarnings("unchecked")
protected void basicPRTXWithOpOnMovedBucket(Op op, int bucketRedundancy, DistributedMember dm1, DistributedMember dm2) {
    // First transaction.
    TransactionId txId = (TransactionId) dataStore1.invoke(beginTx());
    dataStore1.invoke(resumeTx(op, txId, dm1, dm2));
    // Second one. Will go through different path (using TXState or TXStateStub)
    txId = (TransactionId) dataStore1.invoke(beginTx());
    dataStore1.invoke(resumeTx(op, txId, dm1, dm2));
}
Also used : TransactionId(org.apache.geode.cache.TransactionId)

Aggregations

TransactionId (org.apache.geode.cache.TransactionId)22 Test (org.junit.Test)12 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)11 EntryEvent (org.apache.geode.cache.EntryEvent)7 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)7 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)6 CacheWriterException (org.apache.geode.cache.CacheWriterException)6 Region (org.apache.geode.cache.Region)6 IgnoredException (org.apache.geode.test.dunit.IgnoredException)6 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)6 CommitConflictException (org.apache.geode.cache.CommitConflictException)5 VM (org.apache.geode.test.dunit.VM)5 IOException (java.io.IOException)4 Collection (java.util.Collection)4 EntryExistsException (org.apache.geode.cache.EntryExistsException)4 TransactionEvent (org.apache.geode.cache.TransactionEvent)4 Host (org.apache.geode.test.dunit.Host)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 NamingException (javax.naming.NamingException)3