@Override public void run() { txMgrImpl.begin(); try { exprReg.put("key0", putVal); txMgrImpl.commit(); fail("Expected ConflictException!"); } catch (ConflictException expected) { txMgrImpl.rollback(); } } };
public Object call() throws Exception { getGemfireCache().getTxManager().begin(); Region r = getCache().getRegion(CUSTOMER); r.put(new CustId(8), new Customer("name8", "address8")); try { getGemfireCache().getTxManager().commit(); fail("Expected exception not thrown"); } catch (Exception e) { assertEquals("TestException", e.getCause().getMessage()); } return null; } });
public Object call() throws Exception { Region custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); assertEquals(5, custRegion.size()); assertNotNull(mgr.getTXState()); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); Region<CustId, Customer> cust = getCache().getRegion(CUSTOMER); mgr.begin(); // TODO: TX: also check for non-TX put once conflict detection for // non-TX + TX mix is done // create conflict try { cust.put(conflictCust, new Customer("foo", "bar")); fail("expected exception not thrown"); } catch (ConflictException ce) { // expected } mgr.commit(); return null; } });
public void testSuspendTimeout() throws Exception { cache.close(); System.setProperty("gemfire.suspendedTxTimeout", "1"); createCache(); TXManagerImpl mgr = (TXManagerImpl) cache.getCacheTransactionManager(); assertEquals(1, mgr.getSuspendedTransactionTimeout()); mgr.begin(); region.put("key", "value"); final TransactionId txId = mgr.suspend(); Thread.sleep(70*1000); try { mgr.resume(txId); fail("An expected exception was not thrown"); } catch (IllegalStateException expected) { } assertNull(region.get("key")); System.setProperty("gemfire.suspendedTxTimeout", ""); } }
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(CUSTOMER); mgr.begin(); Set filter = new HashSet(); filter.add(expectedCustId); FunctionService.onRegion(pr).withFilter(filter).execute(new NestedTxFunction()).getResult(); assertNotNull(getGemfireCache().getTxManager().getTXState()); mgr.commit(); assertEquals(expectedCustomer, pr.get(expectedCustId)); return null; } });
public Object call() throws Exception { Region cust = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); cust.put(new CustId(6), new Customer("customer6", "address6")); return null; } });
public Object call() throws Exception { Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER); Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); put10Entries(custRegion, orderRegion); return mgr.getTransactionId(); } });
public Object call() throws Exception { Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER); Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); put10Entries(custRegion, orderRegion); return mgr.getTransactionId(); } });
public Object call() throws Exception { Region custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); try { FunctionService.onRegion(custRegion).execute(TXFunction.id).getResult(); fail("Expected exception not thrown"); } catch (TransactionException expected) { } Set filter = new HashSet(); filter.add(expectedCustId); FunctionService.onRegion(custRegion).withFilter(filter).execute(TXFunction.id).getResult(); assertEquals(expectedCustomer, custRegion.get(expectedCustId)); TXStateInterface tx = mgr.internalSuspend(); assertNull(custRegion.get(expectedCustId)); mgr.resume(tx); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); Region r = getCache().getRegion(regionName); Customer cust = new Customer(1, "cust1"); r.put(key, cust); mgr.begin(); cust.setName(""); try { r.put(key, cust); fail("exception not thrown"); } catch (UnsupportedOperationInTransactionException expected) { } mgr.rollback(); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(CUSTOMER); CustId keyOnDs = getKeyOnMember(pr.getMyId(), pr); mgr.begin(); pr.get(keyOnDs); Set filter = new HashSet(); filter.add(keyOnDs); FunctionService.onRegion(pr).withFilter(filter).execute(TXFunction.id).getResult(); assertEquals(expectedCustomer, pr.get(expectedCustId)); TXStateInterface tx = mgr.internalSuspend(); assertNull(pr.get(expectedCustId)); mgr.resume(tx); return null; } };
public Object call() throws Exception { Region<CustId, Customer> cust = getCache().getRegion(CUSTOMER); Region<CustId, Customer> ref = getCache().getRegion(D_REFERENCE); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); Customer customer = new Customer("customer1", "address1"); Customer fakeCust = new Customer("foo", "bar"); assertFalse(cust.replace(custId, fakeCust, updatedCust)); assertTrue(cust.replace(custId, customer, updatedCust)); assertFalse(ref.replace(custId, fakeCust, updatedCust)); assertTrue(ref.replace(custId, customer, updatedCust)); TXStateInterface tx = mgr.internalSuspend(); assertEquals(cust.get(custId), customer); assertEquals(ref.get(custId), customer); mgr.resume(tx); return mgr.getTransactionId(); } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); Region cust = getCache().getRegion(CUSTOMER); Customer s = (Customer)cust.get(new CustId(8)); assertTrue(cust.containsKey(new CustId(8))); TXStateInterface tx = mgr.internalSuspend(); assertFalse(cust.containsKey(new CustId(8))); mgr.resume(tx); mgr.commit(); Customer s2 = (Customer)cust.get(new CustId(8)); Customer ex = new Customer("sup dawg", "add"); assertEquals(ex,s); assertEquals(ex,s2); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.commit(); Region<CustId, Customer> cust = getCache().getRegion(CUSTOMER); Region<CustId, Customer> rr = getCache().getRegion(D_REFERENCE); assertEquals(updateCust, cust.get(newCustId)); assertEquals(updateCust, rr.get(newCustId)); //test conflict mgr.begin(); CustId conflictCust = new CustId(11); cust.putIfAbsent(conflictCust, new Customer("name11", "address11")); TXStateInterface tx = mgr.internalSuspend(); cust.put(conflictCust, new Customer("foo", "bar")); mgr.resume(tx); try { mgr.commit(); fail("expected exception not thrown"); } catch (ConflictException cce) { } return null; } });
public Object call() throws Exception { Region ref = getCache().getRegion(D_REFERENCE); Region empty = getCache().getRegion(EMPTY_REGION); getGemfireCache().getCacheTransactionManager().begin(); ref.put("one", "value1"); empty.put("eone", "valueOne"); getCache().getLogger().info("SWAP:callingCommit"); getGemfireCache().getCacheTransactionManager().commit(); assertTrue(ref.containsKey("one")); assertEquals("value1", ref.get("one")); assertFalse(empty.containsKey("eone")); assertNull(empty.get("eone")); return null; } });
public Object call() throws Exception { TXManagerImpl mgr = getGemfireCache().getTxManager(); Region<String, CustomerNoDelta> r = getCache().getRegion(regionName); CustomerNoDelta cnd = new CustomerNoDelta(1, "cust1NoDelta"); Customer cust = new Customer(1, "cust1"); r.put(keynd, cnd); r.put(key, cust); mgr.begin(); cnd.setName("cust11NoDelta"); cust.setName("cust11"); r.put(keynd, cnd); r.put(key, cust); return null; } });
public Object call() throws Exception { Region<CustId, Customer> cust = getCache().getRegion(CUSTOMER); Region<CustId, Customer> ref = getCache().getRegion(D_REFERENCE); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); Customer customer = new Customer("customer1", "address1"); Customer fakeCust = new Customer("foo", "bar"); assertFalse(cust.remove(custId, fakeCust)); assertTrue(cust.remove(custId, customer)); assertFalse(ref.remove(custId, fakeCust)); assertTrue(ref.remove(custId, customer)); TXStateInterface tx = mgr.internalSuspend(); assertNotNull(cust.get(custId)); assertNotNull(ref.get(custId)); mgr.resume(tx); return mgr.getTransactionId(); } });
public Object call() throws Exception { Region custRegion = getCache().getRegion(CUSTOMER); TXManagerImpl mgr = getGemfireCache().getTxManager(); mgr.begin(); FunctionService.onRegion(custRegion).execute(TXFunction.id).getResult(); assertNotNull(mgr.getTXState()); TXStateInterface tx= mgr.internalSuspend(); assertNull(mgr.getTXState()); getGemfireCache().getLogger().fine("SWAP:callingget"); assertNull("expected null but was:" + custRegion.get(expectedCustId), custRegion.get(expectedCustId)); mgr.resume(tx); mgr.commit(); assertEquals(expectedCustomer, custRegion.get(expectedCustId)); return null; } });
public void run2() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_ACK); Region r1 = createRootRegion("r1", af.create()); Region r2 = r1.createSubregion("r2", af.create()); Region r3 = r2.createSubregion("r3", af.create()); final TXManagerImpl ctm = (TXManagerImpl)getCache() .getCacheTransactionManager(); ctm.begin(); r2.put("b", "value1"); r3.put("c", "value2"); r1.put("a", "value3"); r1.put("a2", "value4"); r3.put("c2", "value5"); r2.put("b2", "value6"); ctm.commit(); TXManagerImpl.waitForPendingCommitForTest(); } });