@Override public Collection<Serializable> getAllKeys(String category) { try { AtomicMap<Serializable, Void> m = getKeysPerCategoryCollection(category); return m.keySet(); // the keyset are the DS keys } catch (CacheException ce) { return null; } }
private Set<Object> getChildrenNames(AdvancedCache<?, ?> cache) { return Immutables.immutableSetCopy(getStructure(cache).keySet()); }
/** * Remove all children of this node. Method is useful only for path nodes */ public void removeChildren() { AtomicMap atomicMap = treeCache.getStructure(nodeFqn); for (Object o : Immutables.immutableSetCopy(atomicMap.keySet())) { removeChild(o); } }
public void testConcurrentPut() throws Exception { final CountDownLatch readLatch = new CountDownLatch(1); final CountDownLatch commitLatch = new CountDownLatch(1); AtomicMap<Integer, String> atomicMap = AtomicMapLookup.getAtomicMap(cache, KEY); tm().begin(); atomicMap.put(1, "value1"); Future<Object> future = fork(() -> { try { tm().begin(); AtomicMap<Integer, String> otMap = AtomicMapLookup.getAtomicMap(cache, KEY); assertEquals(0, otMap.size()); readLatch.countDown(); otMap.put(2, "value2"); commitLatch.await(10, TimeUnit.SECONDS); tm().commit(); } catch (Exception e) { tm().rollback(); throw e; } return null; }); readLatch.await(10, TimeUnit.SECONDS); tm().commit(); commitLatch.countDown(); future.get(10, TimeUnit.SECONDS); assertEquals(new HashSet<>(Arrays.asList(1, 2)), atomicMap.keySet()); }
assertEquals(new HashSet<>(Arrays.asList(3)), atomicMap.keySet());
Set<Object> structureCopy = Immutables.immutableSetCopy(structure.keySet());
assertEquals(new HashSet<>(Arrays.asList("key1", "key2")), atomicMap2.keySet());