Source:
public void topologyChanged(TopologyChangedEvent<Node, Map.Entry<K, V>> event) { if (event.isPre()) return; ConsistentHash previousHash = event.getConsistentHashAtStart(); List<Address> previousMembers = previousHash.getMembers(); ConsistentHash hash = event.getConsistentHashAtEnd(); List<Address> members = hash.getMembers(); Address localAddress = event.getCache().getCacheManager().getAddress(); Set<Address> addresses = new HashSet<>(previousMembers); addresses.removeAll(members); try { this.topologyChangeExecutor.submit(() -> { if (!addresses.isEmpty()) { List<Node> nodes = new ArrayList<>(); for (Address address : addresses) { if (hash.locatePrimaryOwner(address).equals(localAddress)) { nodes.add(this.group.createNode(address)); } } if (!nodes.isEmpty()) { Cache<Node, Map.Entry<K, V>> cache = this.cache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS); Map<K, V> removed = new HashMap<>(); try (Batch batch = this.batcher.createBatch()) { for (Node node: nodes) { Map.Entry<K, V> old = cache.remove(node); if (old != null) { removed.put(old.getKey(), old.getValue()); } } } catch (CacheException e) { ClusteringServerLogger.ROOT_LOGGER.registryPurgeFailed(e, this.cache.getCacheManager().toString(), this.cache.getName(), nodes); } if (!removed.isEmpty()) { this.notifyListeners(Event.Type.CACHE_ENTRY_REMOVED, removed); } } } else { if (!previousMembers.contains(localAddress)) { try { this.populateRegistry(); this.notifyListeners(Event.Type.CACHE_ENTRY_CREATED, this.entry); } catch (CacheException e) { ClusteringServerLogger.ROOT_LOGGER.failedToRestoreLocalRegistryEntry(e, this.cache.getCacheManager().toString(), this.cache.getName()); } } } }); } catch (RejectedExecutionException e) { } }

Target:
public void topologyChanged(TopologyChangedEvent<Node, Map.Entry<K, V>> event) { if (event.isPre()) return; ConsistentHash previousHash = event.getConsistentHashAtStart(); List<Address> previousMembers = previousHash.getMembers(); ConsistentHash hash = event.getConsistentHashAtEnd(); List<Address> members = hash.getMembers(); Address localAddress = event.getCache().getCacheManager().getAddress(); Set<Address> addresses = new HashSet<>(previousMembers); addresses.removeAll(members); try { this.topologyChangeExecutor.submit(() -> { if (!addresses.isEmpty()) { List<Node> nodes = new ArrayList<>(addresses.size()); for (Address address : addresses) { if (hash.locatePrimaryOwner(address).equals(localAddress)) { nodes.add(this.group.createNode(address)); } } if (!nodes.isEmpty()) { Cache<Node, Map.Entry<K, V>> cache = this.cache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS); Map<K, V> removed = new HashMap<>(); try (Batch batch = this.batcher.createBatch()) { for (Node node: nodes) { Map.Entry<K, V> old = cache.remove(node); if (old != null) { removed.put(old.getKey(), old.getValue()); } } } catch (CacheException e) { ClusteringServerLogger.ROOT_LOGGER.registryPurgeFailed(e, this.cache.getCacheManager().toString(), this.cache.getName(), nodes); } if (!removed.isEmpty()) { this.notifyListeners(Event.Type.CACHE_ENTRY_REMOVED, removed); } } } else { if (!previousMembers.contains(localAddress)) { try { this.populateRegistry(); this.notifyListeners(Event.Type.CACHE_ENTRY_CREATED, this.entry); } catch (CacheException e) { ClusteringServerLogger.ROOT_LOGGER.failedToRestoreLocalRegistryEntry(e, this.cache.getCacheManager().toString(), this.cache.getName()); } } } }); } catch (RejectedExecutionException e) { } }