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);
}
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;
}
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);
}
Aggregations