public void testWriteSkewOnPrimaryOwner() throws Exception { doWriteSkewTest(cache(0, "atomic"), new MagicKey(cache(0, "atomic"), cache(1, "atomic")), caches("atomic")); }
@Override protected void createCacheManagers() throws Throwable { createClusteredCaches(3, "atomic", configuration()); }
private void doWriteSkewTest(final Cache<Object, Object> cache, final Object mapKey, final List<Cache<Object, Object>> caches) throws Exception { final TransactionManager tm = tm(cache); Map<Object, Object> atomicMap = getAtomicMap(cache, mapKey, true); //let's put some values atomicMap.put("k1", "v1"); tm.begin(); AssertJUnit.assertEquals("v1", atomicMap.get("k1")); final Transaction tx1 = tm.suspend(); tm.begin(); AssertJUnit.assertEquals("v1", atomicMap.get("k1")); final Transaction tx2 = tm.suspend(); tm.resume(tx1); atomicMap.put("k1", "v2"); tm.commit(); tm.resume(tx2); AssertJUnit.assertEquals("v1", atomicMap.get("k1")); atomicMap.put("k1", "v3"); try { tm.commit(); fail(); } catch (RollbackException e) { //expected safeRollback(tm); } for (Cache<Object, Object> cache1 : caches) { AssertJUnit.assertEquals("v2", getAtomicMap(cache1, mapKey).get("k1")); } }
private ConfigurationBuilder configuration() { ConfigurationBuilder configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); configurationBuilder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .lockingMode(LockingMode.OPTIMISTIC) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()) .isolationLevel(IsolationLevel.REPEATABLE_READ) .clustering().hash().numOwners(2).groups().enabled() .stateTransfer().fetchInMemoryState(false); return configurationBuilder; }
public void testWriteSkewOnBackupOwner() throws Exception { doWriteSkewTest(cache(1, "atomic"), new MagicKey(cache(0, "atomic"), cache(1, "atomic")), caches("atomic")); }
public void testWriteSkewOnNonOwner() throws Exception { doWriteSkewTest(cache(2, "atomic"), new MagicKey(cache(0, "atomic"), cache(1, "atomic")), caches("atomic")); }