Search in sources :

Example 71 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.

the class ControlPointUtils method doWrap.

public static <T> Callable<T> doWrap(Callable<T> callable, ControlPoint controlPoint) {
    if (controlPoint == null || callable == null) {
        return callable;
    }
    try {
        controlPoint.forceBeginRequest();
        final ControlledCallable controlledCallable = new ControlledCallable(callable, controlPoint);
        return callable instanceof ManagedTask ? new ControlledManagedCallable(controlledCallable, (ManagedTask) callable) : controlledCallable;
    } catch (Exception e) {
        throw new RejectedExecutionException(e);
    }
}
Also used : RejectedExecutionException(java.util.concurrent.RejectedExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ManagedTask(javax.enterprise.concurrent.ManagedTask)

Example 72 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.

the class InfinispanBeanManager method dataRehashed.

@DataRehashed
public void dataRehashed(DataRehashedEvent<BeanKey<I>, BeanEntry<I>> event) {
    Address localAddress = this.cache.getCacheManager().getAddress();
    Locality newLocality = new ConsistentHashLocality(localAddress, event.getConsistentHashAtEnd());
    if (event.isPre()) {
        Future<?> future = this.rehashFuture.getAndSet(null);
        if (future != null) {
            future.cancel(true);
        }
        try {
            this.executor.submit(() -> {
                this.schedulerContext.getBeanScheduler().cancel(newLocality);
                this.schedulerContext.getBeanGroupScheduler().cancel(newLocality);
            });
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    } else {
        Locality oldLocality = new ConsistentHashLocality(localAddress, event.getConsistentHashAtStart());
        try {
            this.rehashFuture.set(this.executor.submit(() -> this.schedule(oldLocality, newLocality)));
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) Locality(org.wildfly.clustering.infinispan.spi.distribution.Locality) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) DataRehashed(org.infinispan.notifications.cachelistener.annotation.DataRehashed)

Example 73 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.

the class InfinispanSessionManager method dataRehashed.

@DataRehashed
public void dataRehashed(DataRehashedEvent<SessionCreationMetaDataKey, ?> event) {
    Cache<SessionCreationMetaDataKey, ?> cache = event.getCache();
    Address localAddress = cache.getCacheManager().getAddress();
    Locality newLocality = new ConsistentHashLocality(localAddress, event.getConsistentHashAtEnd());
    if (event.isPre()) {
        Future<?> future = this.rehashFuture.getAndSet(null);
        if (future != null) {
            future.cancel(true);
        }
        try {
            this.executor.submit(() -> this.scheduler.cancel(newLocality));
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    } else {
        Locality oldLocality = new ConsistentHashLocality(localAddress, event.getConsistentHashAtStart());
        try {
            this.rehashFuture.set(this.executor.submit(() -> this.schedule(oldLocality, newLocality)));
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) Locality(org.wildfly.clustering.infinispan.spi.distribution.Locality) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) DataRehashed(org.infinispan.notifications.cachelistener.annotation.DataRehashed)

Example 74 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.

the class CacheRegistry method notifyListeners.

private void notifyListeners(Event.Type type, Map<K, V> entries) {
    for (Map.Entry<Listener<K, V>, ExecutorService> entry : this.listeners.entrySet()) {
        Listener<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().globalJmxStatistics().cacheManagerName(), this.cache.getName(), type, entries);
                }
            });
        } catch (RejectedExecutionException e) {
        // Executor was shutdown
        }
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AbstractMap(java.util.AbstractMap) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 75 with RejectedExecutionException

use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.

the class CacheRegistry method topologyChanged.

@TopologyChanged
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();
    // Determine which nodes have left the cache view
    Set<Address> addresses = new HashSet<>(previousMembers);
    addresses.removeAll(members);
    try {
        this.topologyChangeExecutor.submit(() -> {
            if (!addresses.isEmpty()) {
                // We're only interested in the entries for which we are the primary owner
                List<Node> nodes = addresses.stream().filter(address -> hash.locatePrimaryOwner(address).equals(localAddress)).map(address -> this.factory.createNode(address)).collect(Collectors.toList());
                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);
                    }
                    // Invoke listeners outside above tx context
                    if (!removed.isEmpty()) {
                        this.notifyListeners(Event.Type.CACHE_ENTRY_REMOVED, removed);
                    }
                }
            } else {
                // This is a merge after cluster split: re-populate the cache registry with lost registry entries
                if (!previousMembers.contains(localAddress)) {
                    // If this node is not a member at merge start, its mapping is lost and needs to be recreated and listeners notified
                    try {
                        this.populateRegistry();
                        // Local cache events do not trigger notifications
                        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) {
    // Executor was shutdown
    }
}
Also used : CacheEntryRemoved(org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved) TopologyChanged(org.infinispan.notifications.cachelistener.annotation.TopologyChanged) ClusteringLogger(org.jboss.as.clustering.logging.ClusteringLogger) HashMap(java.util.HashMap) Cache(org.infinispan.Cache) HashSet(java.util.HashSet) ClassLoaderThreadFactory(org.wildfly.clustering.service.concurrent.ClassLoaderThreadFactory) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Map(java.util.Map) CacheEntryModified(org.infinispan.notifications.cachelistener.annotation.CacheEntryModified) CacheEntryRemovedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent) ThreadFactory(java.util.concurrent.ThreadFactory) NodeFactory(org.wildfly.clustering.group.NodeFactory) ExecutorService(java.util.concurrent.ExecutorService) Address(org.infinispan.remoting.transport.Address) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) CacheException(org.infinispan.commons.CacheException) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) Batcher(org.wildfly.clustering.ee.Batcher) Registry(org.wildfly.clustering.registry.Registry) Group(org.wildfly.clustering.group.Group) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PrivilegedAction(java.security.PrivilegedAction) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) TopologyChangedEvent(org.infinispan.notifications.cachelistener.event.TopologyChangedEvent) TimeUnit(java.util.concurrent.TimeUnit) CacheEntryCreated(org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated) AbstractMap(java.util.AbstractMap) List(java.util.List) WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) Flag(org.infinispan.context.Flag) KeyFilter(org.infinispan.filter.KeyFilter) CacheEntryEvent(org.infinispan.notifications.cachelistener.event.CacheEntryEvent) Batch(org.wildfly.clustering.ee.Batch) Event(org.infinispan.notifications.cachelistener.event.Event) Node(org.wildfly.clustering.group.Node) ClusteringServerLogger(org.wildfly.clustering.server.logging.ClusteringServerLogger) Collections(java.util.Collections) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) Address(org.infinispan.remoting.transport.Address) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CacheException(org.infinispan.commons.CacheException) Node(org.wildfly.clustering.group.Node) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Batch(org.wildfly.clustering.ee.Batch) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AbstractMap(java.util.AbstractMap) HashSet(java.util.HashSet) TopologyChanged(org.infinispan.notifications.cachelistener.annotation.TopologyChanged)

Aggregations

RejectedExecutionException (java.util.concurrent.RejectedExecutionException)246 ExecutorService (java.util.concurrent.ExecutorService)42 IOException (java.io.IOException)34 Test (org.junit.Test)34 Future (java.util.concurrent.Future)19 ArrayList (java.util.ArrayList)18 Executor (java.util.concurrent.Executor)18 ExecutionException (java.util.concurrent.ExecutionException)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)15 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)14 List (java.util.List)11 TaskRejectedException (org.springframework.core.task.TaskRejectedException)11 BitmapDrawable (android.graphics.drawable.BitmapDrawable)10 Animation (android.view.animation.Animation)10 Map (java.util.Map)10 CancellationException (java.util.concurrent.CancellationException)10 CacheableBitmapDrawable (uk.co.senab.bitmapcache.CacheableBitmapDrawable)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9