protected void doTestIgnoreReturnValueAndRead(boolean executeOnPrimaryOwner) throws Exception { final Object key = new MagicKey("ignore-previous-value", cache(0)); final AdvancedCache<Object, Object> c = executeOnPrimaryOwner ? advancedCache(0) : advancedCache(1); final TransactionManager tm = executeOnPrimaryOwner ? tm(0) : tm(1); for (Cache cache : caches()) { assertNull("wrong initial value for " + address(cache) + ".", cache.get(key)); } c.put("k", "init"); tm.begin(); c.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).put("k", "v1"); assertEquals("v1", c.put("k", "v2")); Transaction tx = tm.suspend(); assertEquals("init", c.put("k", "other")); tm.resume(tx); tm.commit(); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = defaultConfigurationBuilder(); decorate(builder); createCluster(builder, clusterSize()); waitForClusterToForm(); builder = defaultConfigurationBuilder(); builder.persistence().passivation(true).addStore(DummyInMemoryStoreConfigurationBuilder.class); builder.memory().size(MAX_ENTRIES); decorate(builder); defineConfigurationOnAllManagers(PASSIVATION_CACHE, builder); waitForClusterToForm(PASSIVATION_CACHE); }
private void doTestWriteSkewWithPassivation(boolean executeOnPrimaryOwner, Operation operation, boolean fail) throws Exception { final AdvancedCache<Object, Object> primaryOwner = advancedCache(0, PASSIVATION_CACHE); final Object key = new MagicKey("ignore-return-value", primaryOwner); final AdvancedCache<Object, Object> executeOnCache = executeOnPrimaryOwner ? advancedCache(0, PASSIVATION_CACHE) : advancedCache(1, PASSIVATION_CACHE); final TransactionManager tm = executeOnPrimaryOwner ? tm(0, PASSIVATION_CACHE) : tm(1, PASSIVATION_CACHE); for (Cache cache : caches(PASSIVATION_CACHE)) { assertNull("wrong initial value for " + address(cache) + ".", cache.get(key)); assertNoTransactions(); for (Cache cache : caches(PASSIVATION_CACHE)) { assertEquals("wrong final value for " + address(cache) + ".", finalValue, cache.get(key));
private void doIgnoreReturnValueTest(boolean executeOnPrimaryOwner, Operation operation, boolean initKey) throws Exception { final Object key = new MagicKey("ignore-return-value", cache(0)); final AdvancedCache<Object, Object> c = executeOnPrimaryOwner ? advancedCache(0) : advancedCache(1); final TransactionManager tm = executeOnPrimaryOwner ? tm(0) : tm(1); for (Cache cache : caches()) { assertNull("wrong initial value for " + address(cache) + ".", cache.get(key)); cache(0).put(key, "init"); for (Cache cache : caches()) { assertEquals("wrong intermediate value for " + address(cache) + ".", "v2", cache.get(key)); assertNoTransactions(); for (Cache cache : caches()) { assertEquals("wrong final value for " + address(cache) + ".", finalValue, cache.get(key));