Search in sources :

Example 1 with RegistryListener

use of org.wildfly.clustering.registry.RegistryListener in project wildfly by wildfly.

the class CacheRegistry method notifyListeners.

private void notifyListeners(Event.Type type, Map<K, V> entries) {
    for (Map.Entry<RegistryListener<K, V>, ExecutorService> entry : this.listeners.entrySet()) {
        RegistryListener<K, V> listener = entry.getKey();
        ExecutorService executor = entry.getValue();
        try {
            executor.submit(() -> {
                try {
                    switch(type) {
                        case CACHE_ENTRY_CREATED:
                            {
                                listener.addedEntries(entries);
                                break;
                            }
                        case CACHE_ENTRY_MODIFIED:
                            {
                                listener.updatedEntries(entries);
                                break;
                            }
                        case CACHE_ENTRY_REMOVED:
                            {
                                listener.removedEntries(entries);
                                break;
                            }
                        default:
                            {
                                throw new IllegalStateException(type.name());
                            }
                    }
                } catch (Throwable e) {
                    ClusteringServerLogger.ROOT_LOGGER.registryListenerFailed(e, this.cache.getCacheManager().getCacheManagerConfiguration().cacheManagerName(), this.cache.getName(), type, entries);
                }
            });
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    }
}
Also used : RegistryListener(org.wildfly.clustering.registry.RegistryListener) DefaultExecutorService(org.jboss.as.clustering.context.DefaultExecutorService) ExecutorService(java.util.concurrent.ExecutorService) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Aggregations

AbstractMap (java.util.AbstractMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 DefaultExecutorService (org.jboss.as.clustering.context.DefaultExecutorService)1 RegistryListener (org.wildfly.clustering.registry.RegistryListener)1