public static void assertMapEquals(final Map<?, ?> expected, final Map<?, ?> result) { // check expected entries are same for (Map.Entry<?, ?> entry : expected.entrySet()) { assertEquals(entry.getValue(), result.get(entry.getKey())); } // check null values for any remaining entries for (Map.Entry<?, ?> entry : result.entrySet()) { if (!expected.containsKey(entry.getKey())) { assertNull("expected no value for key: " + entry.getKey() + ", result: " + result, entry.getValue()); } } }
@Override public void tearDown2() throws Exception { // try { Thread.sleep(5000); } catch (InterruptedException e) { } // FOR MANUAL TESTING OF STATS - DON"T KEEP THIS invokeInEveryVM(verifyNoTxState); closeAllCache(); super.tearDown2(); }
public Object call() throws Exception { createRegion(false/*accessor*/, redundantCopies, null); populateData(); return null; } });
void verifyAfterCommit(OP op) { Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER); Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE); Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER); CustId custId = new CustId(1); OrderId orderId = new OrderId(1, custId); expectedCust = new Customer("foo", "bar"); expectedRef = expectedCust; assertNotNull(custRegion.getEntry(custId)); assertEquals(expectedCust, custRegion.getEntry(custId).getValue()); assertNotNull(refRegion.getEntry(custId)); assertEquals(expectedRef, refRegion.getEntry(custId).getValue()); orderRegion.get(orderId); expectedRef = refRegion.get(custId); validateContains(custId, Collections.singleton(orderId), true); break; case DESTROY: assertTrue(!custRegion.containsKey(custId)); assertTrue(!orderRegion.containsKey(orderId)); assertTrue(!refRegion.containsKey(custId)); validateContains(custId, Collections.singleton(orderId), false); break; case INVALIDATE: boolean validateContainsKey = true; if (!((GemFireCacheImpl)custRegion.getCache()).isClient()) { assertTrue(custRegion.containsKey(custId)); assertTrue(orderRegion.containsKey(orderId));
VM client = host.getVM(2); initAccessorAndDataStore(accessor, datastore, 0); int port = startServer(datastore); createClientRegion(client, port, false, true,false); datastore.invoke(new SerializableCallable() { public Object call() throws Exception {
void validateContains(CustId custId, Set<OrderId> ordersSet, boolean containsKey,boolean containsValue) { Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER); Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER); Region<CustId, Order> refRegion = getCache().getRegion(D_REFERENCE); boolean rContainsKC = custRegion.containsKey(custId); boolean rContainsKO = containsKey; for (OrderId o : ordersSet) { getGemfireCache().getLoggerI18n().fine("SWAP:rContainsKO:"+rContainsKO+" containsKey:"+orderRegion.containsKey(o)); rContainsKO = rContainsKO && orderRegion.containsKey(o); assertEquals(containsKey,rContainsKC); assertEquals(containsKey,rContainsKO); assertEquals(containsKey,rContainsKR); assertEquals(containsValue,rContainsVR); assertEquals(containsValue,rContainsVC); assertEquals(containsValue,rContainsVO); Region.Entry eC = custRegion.getEntry(custId); for (OrderId o : ordersSet) { assertNotNull(orderRegion.getEntry(o)); assertNotNull(eC); assertNotNull(eR); assertNull("should have had an EntryNotFoundException:"+eC,eC); assertNull("should have had an EntryNotFoundException:"+orderRegion.getEntry(o),orderRegion.getEntry(o)); assertNull("should have had an EntryNotFoundException:"+eR,eR); } catch(EntryNotFoundException enfe) {
createRegion(false, 0, null); Context ctx = getCache().getJNDIContext(); UserTransaction tx = (UserTransaction)ctx.lookup("java:/UserTransaction"); assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus()); Region pr = getCache().getRegion(CUSTOMER); Region rr = getCache().getRegion(D_REFERENCE); assertEquals(Status.STATUS_ACTIVE, tx.getStatus()); final CountDownLatch latch = new CountDownLatch(1); Thread t = new Thread(new Runnable() { pr.put(new CustId(1), new Customer("name11", "address11")); tx.commit(); fail("expected exception not thrown"); } catch (RollbackException e) {
VM datastore1 = host.getVM(1); VM datastore2 = host.getVM(2); initAccessorAndDataStore(accessor, datastore1, datastore2, 0); assertEquals(1, txOnDatastore1 + txOnDatastore2); .invoke(getNumberOfTXInProgress); assertEquals(0, txOnDatastore1_1 + txOnDatastore2_2);
VM datastore1 = host.getVM(1); VM datastore2 = host.getVM(2); initAccessorAndDataStore(accessor, datastore1, datastore2, 1); Integer txOnDatastore2 = (Integer)datastore2 .invoke(getNumberOfTXInProgress); assertEquals(2, txOnDatastore1 + txOnDatastore2); assertEquals(2, txOnDatastore1 + txOnDatastore2); final ExpectedException expected = addExpectedException( ConflictException.class.getName(), datastore1); datastore1.invoke(new SerializableCallable() { assertEquals(2, txOnDatastore1 + txOnDatastore2);
final GemFireCacheImpl cache = getGemfireCache(); final TXManagerImpl txMgr = cache.getTxManager(); txMgr.begin(); r.putAll(custMap); rr.putAll(custMap); assertMapEquals(custMap, r.getAll(custMap.keySet())); assertMapEquals(custMap, rr.getAll(custMap.keySet())); break; case GETALL: r.putAll(custGetMap); rr.putAll(custGetMap); assertMapEquals(custGetResMap, r.getAll(custMap.keySet())); assertMapEquals(custGetMap, r.getAll(custGetMap.keySet())); assertMapEquals(custGetResMap, rr.getAll(custMap.keySet())); assertMapEquals(custGetMap, rr.getAll(custGetMap.keySet())); break; default: switch (op) { case PUTALL: assertMapEquals(custOrigMap, r.getAll(custMap.keySet())); assertMapEquals(custOrigMap, rr.getAll(custMap.keySet())); break; case GETALL: assertMapEquals(custOrigGetMap, r.getAll(custGetMap.keySet())); assertMapEquals(custOrigMap, r.getAll(custMap.keySet())); assertMapEquals(custOrigGetMap, rr.getAll(custGetMap.keySet())); assertMapEquals(custOrigMap, rr.getAll(custMap.keySet()));
VM datastore2 = host.getVM(2); initAccessorAndDataStoreWithInterestPolicy(accessor, datastore1, datastore2, 1); SerializableCallable registerListener = new SerializableCallable() { public Object call() throws Exception { assertEquals(1, totalInvocation);
public Object call() throws Exception { createRegion(false/*accessor*/, redundantCopies, InterestPolicy.ALL); return null; } });
public void Bug44146_testTXCreationAndCleanupAtCommit() throws Exception { doBasicChecks(true); }
void verifyAfterRollback(OP op) { Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER); Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER); Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE); assertNotNull(custRegion); assertNotNull(orderRegion); assertNotNull(refRegion); expectedOrder = new Order("order1"); expectedRef = new Customer("customer1", "address1"); assertEquals(expectedCust, custRegion.getEntry(custId).getValue()); assertEquals(expectedOrder, orderRegion.getEntry(orderId).getValue()); getCache().getLogger().info("SWAP:verifyRollback:"+orderRegion); getCache().getLogger().info("SWAP:verifyRollback:"+orderRegion.getEntry(orderId2)); assertNull(getGemfireCache().getTxManager().getTXState()); assertNull(""+orderRegion.getEntry(orderId2),orderRegion.getEntry(orderId2)); assertNull(orderRegion.getEntry(orderId3)); assertNull(orderRegion.get(orderId2)); assertNull(orderRegion.get(orderId3)); assertEquals(expectedRef, refRegion.getEntry(custId).getValue()); validateContains(custId, Collections.singleton(orderId), true); break; case GET: expectedOrder = orderRegion.getEntry(orderId).getValue(); expectedRef = refRegion.getEntry(custId).getValue(); validateContains(custId, Collections.singleton(orderId), true); break; case DESTROY: assertTrue(!custRegion.containsKey(custId));
VM client = host.getVM(2); initAccessorAndDataStore(accessor, datastore, 0); int port = startServer(datastore); createClientRegion(client, port, false, true,false); accessor.invoke(new SerializableCallable() { public Object call() throws Exception {
VM datastore1 = host.getVM(1); VM datastore2 = host.getVM(2); initAccessorAndDataStore(accessor, datastore1, datastore2, 0); final Integer txOnDatastore2 = (Integer)datastore2 .invoke(getNumberOfTXInProgress); assertEquals(2, txOnDatastore1 + txOnDatastore2); final Integer txOnDatastore2_1 = (Integer)datastore2 .invoke(getNumberOfTXInProgress); assertEquals(2, txOnDatastore1_1 + txOnDatastore2_1); .invoke(getNumberOfTXInProgress); assertEquals(0, txOnDatastore1_2 + txOnDatastore2_2); datastore1.invoke(closeTx); .invoke(getNumberOfTXInProgress); assertEquals(0, txOnDatastore1_2 + txOnDatastore2_2); datastore2.invoke(closeTx);
public Object call() throws Exception { createRegion(true/*accessor*/, redundantCopies, null); return null; } });
public void Bug44146_testTXCreationAndCleanupAtRollback() throws Exception { doBasicChecks(false); }
VM client = host.getVM(2); initAccessorAndDataStore(accessor, datastore, 0); int port = startServer(datastore); createClientRegion(client, port, false, true,true); datastore.invoke(new SerializableCallable() { public Object call() throws Exception {
VM datastore1 = host.getVM(1); VM datastore2 = host.getVM(2); initAccessorAndDataStore(accessor, datastore1, datastore2, redundancy); if (iteratorType == OP.KEYS || !this.isRepeatableRead) { assertEquals(1 + redundancy, txOnDatastore1 + txOnDatastore2); final Integer txOnDatastore2_2 = (Integer)datastore2 .invoke(getNumberOfTXInProgress); assertEquals(0, txOnDatastore1_1 + txOnDatastore2_2);