public Status insert(String table, String key, Map<String, ByteIterator> values) { try { if (clustered) { AtomicMap<String, String> row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key); row.clear(); StringByteIterator.putAllAsStrings(row, values); } else { infinispanManager.getCache(table).put(key, values); } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public Status delete(String table, String key) { try { if (clustered) { AtomicMapLookup.removeAtomicMap(infinispanManager.getCache(table), key); } else { infinispanManager.getCache(table).remove(key); } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } } }
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { Map<String, String> row; if (clustered) { row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key, false); } else { Cache<String, Map<String, String>> cache = infinispanManager.getCache(table); row = cache.get(key); } if (row != null) { result.clear(); if (fields == null || fields.isEmpty()) { StringByteIterator.putAllAsByteIterators(result, row); } else { for (String field : fields) { result.put(field, new StringByteIterator(row.get(field))); } } } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
@Override public Void call() throws Exception { // Modify atomic map from first node AtomicMap<String, String> map = AtomicMapLookup .getAtomicMap(cache1, "map"); map.put("key1", "new_value1"); assertTrue(map.containsKey("key2")); assertEquals("value2", map.get("key2")); return null; } });
@SuppressWarnings({ "rawtypes", "unchecked" }) private void removeEntry(final org.infinispan.Cache cache, final Object o) { final CompoundKey key = (CompoundKey) o; final AtomicMap map = AtomicMapLookup.getAtomicMap(cache, key.getName(), false); map.remove(key); }
@Override public Void call() throws Exception { // Add atomic map in first node AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap( cache1, "map"); map.put("key1", "value1"); map.put("key2", "value2"); return null; } });
public static <K> void assertIsEmptyMap(Cache<K, ?> cache, K key) { assertIsEmpty(AtomicMapLookup.getAtomicMap(cache, key)); } }
@Override public Object call() throws Exception { Object obj1 = daa.getObject(cache(nodeThatWrites), KEY1); daa.setFirstComponent(obj1, "** UPDATED** first component of object with key=key1"); daa.putObject(cache(nodeThatWrites), KEY1, obj1); Object obj2 = daa.getObject(cache(nodeThatWrites), KEY2); daa.setFirstComponent(obj2, "** UPDATED** first component of object with key=key2"); daa.putObject(cache(nodeThatWrites), KEY2, obj2); return null; } });
public void setFirstComponent(String firstComponent) { getDelta().registerComponentChange("firstComponent", firstComponent); this.firstComponent = firstComponent; }
@Override public void testDeltaAware() throws Exception { test(createDeltaAwareAccessor(), 0, 1); }
protected void createCacheManagers() throws Throwable { ConfigurationBuilder c = getConfigurationBuilder(); createClusteredCaches(1, CACHE_NAME, c); }
@Override public Delta delta() { Delta toReturn = getDelta(); delta = null; return toReturn; }
@Override public void setFirstComponent(TestDeltaAware da, String value) { da.setFirstComponent(value); }
@Override public Object call() { daa.createObject(cache(nodeThatWrites), KEY1); daa.createObject(cache(nodeThatWrites), KEY2); return null; } });
private TestDelta getDelta() { if (delta == null) delta = new TestDelta(); return delta; }
@Override public void setSecondComponent(TestDeltaAware da, String value) { da.setSecondComponent(value); }
public Status update(String table, String key, Map<String, ByteIterator> values) { try { if (clustered) { AtomicMap<String, String> row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key); StringByteIterator.putAllAsStrings(row, values); } else { Cache<String, Map<String, String>> cache = infinispanManager.getCache(table); Map<String, String> row = cache.get(key); if (row == null) { row = StringByteIterator.getStringMap(values); cache.put(key, row); } else { StringByteIterator.putAllAsStrings(row, values); } } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public void setSecondComponent(String secondComponent) { getDelta().registerComponentChange("secondComponent", secondComponent); this.secondComponent = secondComponent; }
private AtomicMap<Serializable, Void> getKeysPerCategoryCollection(String category) { return AtomicMapLookup.getAtomicMap(this.cache, category, true); } }
@Override protected <CK, K, V> Map<K, V> createAtomicMap(Cache<CK, Object> cache, CK key, boolean createIfAbsent) { return getAtomicMap(cache, key, createIfAbsent); } }