use of org.apache.geode.internal.cache.TXManagerImpl in project geode by apache.
the class MyTransactionFunction method verifyRepeatableRead.
private void verifyRepeatableRead(RegionFunctionContext ctx) {
Region custPR = ctx.getDataSet();
Region orderPR = custPR.getCache().getRegion(PRColocationDUnitTest.OrderPartitionedRegionName);
ArrayList args = (ArrayList) ctx.getArguments();
CustId custId = (CustId) args.get(1);
Customer cust = (Customer) args.get(2);
Assert.assertTrue(custPR.get(custId) == null);
CacheTransactionManager mgr = custPR.getCache().getCacheTransactionManager();
TXManagerImpl mImp = (TXManagerImpl) mgr;
mImp.begin();
custPR.put(custId, cust);
Assert.assertTrue(cust.equals(custPR.get(custId)));
TXStateProxy txState = mImp.internalSuspend();
Assert.assertTrue(custPR.get(custId) == null);
mImp.internalResume(txState);
mImp.commit();
// change value
mImp.begin();
Customer oldCust = (Customer) custPR.get(custId);
Assert.assertTrue(oldCust.equals(cust));
txState = mImp.internalSuspend();
Customer newCust = new Customer("fooNew", "barNew");
custPR.put(custId, newCust);
mImp.internalResume(txState);
Assert.assertTrue(oldCust.equals(custPR.get(custId)));
mImp.commit();
}
Aggregations