SimpleReplicatedExoCache extends ConcurrentFIFOExoCache<K, V> { @Override public void putMap(Map<? extends K, ? extends V> objs) { super.putMap(objs); try { rpcService.executeCommandOnAllNodes(command, false, id, "m", new HashMap<K, V>(objs)); } catch (Exception e) { LOG.warn("Could not put entries on other cluster nodes", e); } } SimpleReplicatedExoCache();   SimpleReplicatedExoCache(ExoContainerContext ctx, RPCService rpcService); @Override void setName(String s); @Override V remove(Serializable name); @Override void clearCache(); @Override void put(K name, V obj); @Override void putMap(Map<? extends K, ? extends V> objs);  }
@Test public void testPutMap() throws Exception { Assert.assertEquals(0, cache1.getCacheSize()); Assert.assertEquals(0, cache2.getCacheSize()); cache1.putMap(Collections.singletonMap("a", "value")); Assert.assertEquals(1, cache1.getCacheSize()); Assert.assertEquals("value", cache1.get("a")); for (int i = 0; i < 5; i++) { if (cache2.getCacheSize() > 0) break; Thread.sleep(200); } Assert.assertEquals(1, cache2.getCacheSize()); Assert.assertEquals("value", cache2.get("a")); String value1 = new String("value"); Object value2 = cache2.get("a"); cache1.putMap(Collections.singletonMap("a", value1)); Assert.assertEquals(1, cache1.getCacheSize()); Assert.assertEquals("value", cache1.get("a")); Assert.assertTrue(value1 == cache1.get("a")); for (int i = 0; i < 5; i++) { Assert.assertEquals("value", cache2.get("a")); Assert.assertTrue(value2 == cache2.get("a")); Thread.sleep(200); } Assert.assertEquals("value", cache2.get("a")); Assert.assertTrue(value2 == cache2.get("a")); cache1.putMap(Collections.singletonMap("a", "value2")); Assert.assertEquals(1, cache1.getCacheSize()); Assert.assertEquals("value2", cache1.get("a")); for (int i = 0; i < 5; i++) { if (cache2.get("a").equals("value2")) break; Thread.sleep(200); } Assert.assertEquals(1, cache2.getCacheSize()); Assert.assertEquals("value2", cache2.get("a")); }