@Override public Object get(String column) { return atomicMap.get( column ); }
@Override public boolean isEmpty() { return atomicMap.isEmpty(); }
@Override public Set<String> getColumnNames() { return atomicMap.keySet(); }
public void testFineGrainedAtomicMapWithoutBatchSet() { ConfigurationBuilder builder = buildConfiguration(); builder.invocationBatching().disable(); cacheManager.defineConfiguration("fgahm_without_batch", builder.build()); Cache<String, String> fgahmCache = cacheManager.getCache("fgahm_without_batch"); FineGrainedAtomicMap<String, String> map = AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key").get("a").equals("b"); }
/** * Verifies we can create a new AtomicMap, use it and then remove it while in the same transaction * See also ISPN-2075. */ public void testDontFailOnImmediateRemovalOfAtomicMaps() throws Exception { final String key = "key1"; final String subKey = "subK"; TestingUtil.withTx(tm, () -> { FineGrainedAtomicMap<String, String> fineGrainedAtomicMap = AtomicMapLookup.getFineGrainedAtomicMap(cache, key); fineGrainedAtomicMap.put(subKey, "some value"); fineGrainedAtomicMap = AtomicMapLookup.getFineGrainedAtomicMap(cache, key); fineGrainedAtomicMap.get(subKey); fineGrainedAtomicMap.put(subKey, "v"); fineGrainedAtomicMap.put(subKey + 2, "v2"); fineGrainedAtomicMap = AtomicMapLookup.getFineGrainedAtomicMap(cache, key); Object object = fineGrainedAtomicMap.get(subKey); assertEquals("Wrong FGAM sub-key value.", "v", object); AtomicMapLookup.removeAtomicMap(cache, key); return null; }); }
map.put("key" + keyIndex, VALUE);
public void testFineGrainedAtomicMapWithoutTransactionManagerLookupSet() { ConfigurationBuilder builder = buildConfiguration(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(null); cacheManager.defineConfiguration("fgahm_without_tmlookup", builder.build()); Cache<String, String> fgahmCache = cacheManager.getCache("fgahm_without_tmlookup"); FineGrainedAtomicMap<String, String> map = AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key").get("a").equals("b"); }
@Test(expectedExceptions = IllegalStateException.class) public void testFineGrainedAtomicMapNonTransactionWithoutBatchSet() { ConfigurationBuilder builder = buildConfiguration(); builder.invocationBatching().disable(); builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); cacheManager.defineConfiguration("fgahm_no_tx_without_batch", builder.build()); Cache<String, String> fgahmCache = cacheManager.getCache("fgahm_no_tx_without_batch"); FineGrainedAtomicMap<String, String> map = AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key").get("a").equals("b"); }
@Override public Object get(String column) { return atomicMap.get( column ); }
@Override public boolean isEmpty() { return atomicMap.isEmpty(); }
@Override public Set<String> getColumnNames() { return atomicMap.keySet(); }