@Override public void initStore(final Store<?, ?> resource) { StoreConfig storeConfig = createdStores.get(resource); if (storeConfig == null) { throw new IllegalArgumentException( "Given store is not managed by this provider : " + resource); } final ClusteredStore clusteredStore = (ClusteredStore) resource; try { clusteredStore.storeProxy = clusteringService.getServerStoreProxy( storeConfig.getCacheIdentifier(), storeConfig.getStoreConfig(), storeConfig.getConsistency()); } catch (CachePersistenceException e) { throw new RuntimeException( "Unable to create server store proxy - " + storeConfig.getCacheIdentifier(), e); } clusteredStore.storeProxy.addInvalidationListener( new ServerStoreProxy.InvalidationListener() { @Override public void onInvalidateHash(long hash) { if (clusteredStore.invalidationValve != null) { try { LOGGER.debug("CLIENT: calling invalidation valve for hash {}", hash); clusteredStore.invalidationValve.invalidateAllWithHash(hash); } catch (StoreAccessException sae) { // TODO: what should be done here? delegate to resilience strategy? LOGGER.error("Error invalidating hash {}", hash, sae); } } } @Override public void onInvalidateAll() { if (clusteredStore.invalidationValve != null) { try { LOGGER.debug("CLIENT: calling invalidation valve for all"); clusteredStore.invalidationValve.invalidateAll(); } catch (StoreAccessException sae) { // TODO: what should be done here? delegate to resilience strategy? LOGGER.error("Error invalidating all", sae); } } } }); }