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
}
}
}
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
}
}
}
Aggregations