Search in sources :

Example 1 with DataRehashed

use of org.infinispan.notifications.cachelistener.annotation.DataRehashed 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 2 with DataRehashed

use of org.infinispan.notifications.cachelistener.annotation.DataRehashed 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)

Aggregations

RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 DataRehashed (org.infinispan.notifications.cachelistener.annotation.DataRehashed)2 Address (org.infinispan.remoting.transport.Address)2 ConsistentHashLocality (org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality)2 Locality (org.wildfly.clustering.infinispan.spi.distribution.Locality)2 SimpleLocality (org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality)2