Search in sources :

Example 1 with SimpleLocality

use of org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality in project wildfly by wildfly.

the class InfinispanBeanManager method start.

@Override
public void start() {
    this.executor = Executors.newSingleThreadExecutor(createThreadFactory());
    this.affinity.start();
    Time timeout = this.expiration.getTimeout();
    Scheduler<I> noopScheduler = new Scheduler<I>() {

        @Override
        public void schedule(I id) {
        }

        @Override
        public void cancel(I id) {
        }

        @Override
        public void cancel(Locality locality) {
        }

        @Override
        public void close() {
        }
    };
    Scheduler<I> beanScheduler = (timeout != null) && (timeout.getValue() >= 0) ? new BeanExpirationScheduler<>(this.batcher, new ExpiredBeanRemover<>(this.beanFactory), this.expiration) : noopScheduler;
    Scheduler<I> groupScheduler = (this.passivation.getConfiguration().getMaxSize() >= 0) ? new BeanGroupEvictionScheduler<>(this.beanName + ".eviction", this.batcher, this.groupFactory, this.dispatcherFactory, this.passivation) : noopScheduler;
    this.schedulerContext = new SchedulerContext<I>() {

        @Override
        public void close() {
            groupScheduler.close();
            beanScheduler.close();
        }

        @Override
        public Scheduler<I> getBeanScheduler() {
            return beanScheduler;
        }

        @Override
        public Scheduler<I> getBeanGroupScheduler() {
            return groupScheduler;
        }
    };
    this.dispatcher = this.dispatcherFactory.createCommandDispatcher(this.beanName + ".schedulers", this.schedulerContext);
    this.cache.addListener(this, this.filter, null);
    this.schedule(new SimpleLocality(false), new ConsistentHashLocality(this.cache));
}
Also used : Locality(org.wildfly.clustering.infinispan.spi.distribution.Locality) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) Time(org.wildfly.clustering.ejb.Time) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality)

Example 2 with SimpleLocality

use of org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality in project wildfly by wildfly.

the class InfinispanSessionManager method start.

@Override
public void start() {
    this.executor = Executors.newSingleThreadExecutor(createThreadFactory());
    if (this.recorder != null) {
        this.recorder.reset();
    }
    this.identifierFactory.start();
    final List<Scheduler> schedulers = new ArrayList<>(2);
    schedulers.add(new SessionExpirationScheduler(this.batcher, new ExpiredSessionRemover<>(this.factory, this.expirationListener)));
    if (this.maxActiveSessions >= 0) {
        schedulers.add(new SessionEvictionScheduler(this.cache.getName() + ".eviction", this.factory, this.batcher, this.dispatcherFactory, this.maxActiveSessions));
    }
    this.scheduler = new Scheduler() {

        @Override
        public void schedule(String sessionId, ImmutableSessionMetaData metaData) {
            schedulers.forEach(scheduler -> scheduler.schedule(sessionId, metaData));
        }

        @Override
        public void cancel(String sessionId) {
            schedulers.forEach(scheduler -> scheduler.cancel(sessionId));
        }

        @Override
        public void cancel(Locality locality) {
            schedulers.forEach(scheduler -> scheduler.cancel(locality));
        }

        @Override
        public void close() {
            schedulers.forEach(scheduler -> scheduler.close());
        }
    };
    this.dispatcher = this.dispatcherFactory.createCommandDispatcher(this.cache.getName() + ".schedulers", this.scheduler);
    this.cache.addListener(this, this.filter);
    this.schedule(new SimpleLocality(false), this.locality);
}
Also used : Session(org.wildfly.clustering.web.session.Session) Cache(org.infinispan.Cache) CommandDispatcher(org.wildfly.clustering.dispatcher.CommandDispatcher) SessionManager(org.wildfly.clustering.web.session.SessionManager) Future(java.util.concurrent.Future) Duration(java.time.Duration) Map(java.util.Map) CacheEntryRemovedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent) SessionMetaData(org.wildfly.clustering.web.session.SessionMetaData) ThreadFactory(java.util.concurrent.ThreadFactory) HttpSession(javax.servlet.http.HttpSession) ImmutableHttpSessionAdapter(org.wildfly.clustering.web.session.ImmutableHttpSessionAdapter) InfinispanWebLogger(org.wildfly.clustering.web.infinispan.logging.InfinispanWebLogger) Listener(org.infinispan.notifications.Listener) IdentifierFactory(org.wildfly.clustering.web.IdentifierFactory) CacheEntryPassivatedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryPassivatedEvent) Key(org.wildfly.clustering.infinispan.spi.distribution.Key) ImmutableSessionMetaData(org.wildfly.clustering.web.session.ImmutableSessionMetaData) CommandDispatcherFactory(org.wildfly.clustering.dispatcher.CommandDispatcherFactory) Set(java.util.Set) PrivilegedAction(java.security.PrivilegedAction) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) List(java.util.List) WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) Stream(java.util.stream.Stream) Invoker(org.wildfly.clustering.ee.Invoker) Flag(org.infinispan.context.Flag) CacheEntryRemoved(org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved) DataRehashed(org.infinispan.notifications.cachelistener.annotation.DataRehashed) Locality(org.wildfly.clustering.infinispan.spi.distribution.Locality) CacheEntryPassivated(org.infinispan.notifications.cachelistener.annotation.CacheEntryPassivated) SessionAttributes(org.wildfly.clustering.web.session.SessionAttributes) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) HttpSessionActivationListener(javax.servlet.http.HttpSessionActivationListener) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) Command(org.wildfly.clustering.dispatcher.Command) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionEvent(javax.servlet.http.HttpSessionEvent) ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) 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) Iterator(java.util.Iterator) Batcher(org.wildfly.clustering.ee.Batcher) CacheEntryActivated(org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated) TransactionBatch(org.wildfly.clustering.ee.infinispan.TransactionBatch) SessionExpirationListener(org.wildfly.clustering.web.session.SessionExpirationListener) CacheEntryActivatedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent) TimeUnit(java.util.concurrent.TimeUnit) Recordable(org.wildfly.clustering.ee.Recordable) Batch(org.wildfly.clustering.ee.Batch) CacheProperties(org.wildfly.clustering.ee.infinispan.CacheProperties) RetryingInvoker(org.wildfly.clustering.ee.infinispan.RetryingInvoker) Node(org.wildfly.clustering.group.Node) ServletContext(javax.servlet.ServletContext) DataRehashedEvent(org.infinispan.notifications.cachelistener.event.DataRehashedEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener) DistributionManager(org.infinispan.distribution.DistributionManager) ImmutableSessionAttributes(org.wildfly.clustering.web.session.ImmutableSessionAttributes) Locality(org.wildfly.clustering.infinispan.spi.distribution.Locality) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality) ConsistentHashLocality(org.wildfly.clustering.infinispan.spi.distribution.ConsistentHashLocality) ArrayList(java.util.ArrayList) ImmutableSessionMetaData(org.wildfly.clustering.web.session.ImmutableSessionMetaData) SimpleLocality(org.wildfly.clustering.infinispan.spi.distribution.SimpleLocality)

Aggregations

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 PrivilegedAction (java.security.PrivilegedAction)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 ServletContext (javax.servlet.ServletContext)1