Search in sources :

Example 1 with TXRegionStub

use of org.apache.geode.internal.cache.tx.TXRegionStub in project geode by apache.

the class TXStateStub method destroyExistingEntry.

/*
   * (non-Javadoc)
   * 
   * @see
   * org.apache.geode.internal.cache.TXStateInterface#destroyExistingEntry(org.apache.geode.internal
   * .cache.EntryEventImpl, boolean, java.lang.Object)
   */
public void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) throws EntryNotFoundException {
    if (event.getOperation().isLocal()) {
        throw new UnsupportedOperationInTransactionException(LocalizedStrings.TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString());
    }
    TXRegionStub rs = getTXRegionStub(event.getRegion());
    rs.destroyExistingEntry(event, cacheWrite, expectedOldValue);
}
Also used : TXRegionStub(org.apache.geode.internal.cache.tx.TXRegionStub) UnsupportedOperationInTransactionException(org.apache.geode.cache.UnsupportedOperationInTransactionException)

Example 2 with TXRegionStub

use of org.apache.geode.internal.cache.tx.TXRegionStub in project geode by apache.

the class TXStateStub method getTXRegionStub.

/**
   * Get or create a TXRegionStub for the given region. For regions that are new to the tx, we
   * validate their eligibility.
   * 
   * @param region The region to involve in the tx.
   * @return existing or new stub for region
   */
protected TXRegionStub getTXRegionStub(LocalRegion region) {
    TXRegionStub stub = regionStubs.get(region);
    if (stub == null) {
        /*
       * validate whether this region is legit or not
       */
        validateRegionCanJoinTransaction(region);
        stub = generateRegionStub(region);
        regionStubs.put(region, stub);
    }
    return stub;
}
Also used : TXRegionStub(org.apache.geode.internal.cache.tx.TXRegionStub)

Example 3 with TXRegionStub

use of org.apache.geode.internal.cache.tx.TXRegionStub in project geode by apache.

the class TXStateStubTest method shouldBeMockable.

@Test
public void shouldBeMockable() throws Exception {
    TXStateStub mockTXStateStub = mock(TXStateStub.class);
    TXRegionStub mockTXRegionStub = mock(TXRegionStub.class);
    LocalRegion mockLocalRegion = mock(LocalRegion.class);
    when(mockTXStateStub.getTXRegionStub(eq(mockLocalRegion))).thenReturn(mockTXRegionStub);
    assertThat(mockTXStateStub.getTXRegionStub(mockLocalRegion)).isSameAs(mockTXRegionStub);
}
Also used : TXRegionStub(org.apache.geode.internal.cache.tx.TXRegionStub) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

TXRegionStub (org.apache.geode.internal.cache.tx.TXRegionStub)3 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1 Test (org.junit.Test)1