Search in sources :

Example 11 with Address

use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.

the class DefaultCacheContainerTestCase method getAddress.

@Test
public void getAddress() {
    Address expected = mock(Address.class);
    when(this.manager.getAddress()).thenReturn(expected);
    Address result = this.subject.getAddress();
    assertSame(expected, result);
}
Also used : Address(org.infinispan.remoting.transport.Address) Test(org.junit.Test)

Example 12 with Address

use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.

the class InfinispanSessionManagerFactory method createSessionManager.

@Override
public <L> SessionManager<L, TransactionBatch> createSessionManager(final SessionManagerConfiguration<L> configuration) {
    final Batcher<TransactionBatch> batcher = new InfinispanBatcher(this.config.getCache());
    final Cache<Key<String>, ?> cache = this.config.getCache();
    final CacheProperties properties = new InfinispanCacheProperties(cache.getCacheConfiguration());
    final IdentifierFactory<String> factory = new AffinityIdentifierFactory<>(configuration.getIdentifierFactory(), cache, this.config.getKeyAffinityServiceFactory());
    final CommandDispatcherFactory dispatcherFactory = this.config.getCommandDispatcherFactory();
    final NodeFactory<Address> nodeFactory = this.config.getNodeFactory();
    final int maxActiveSessions = this.config.getSessionManagerFactoryConfiguration().getMaxActiveSessions();
    InfinispanSessionManagerConfiguration config = new InfinispanSessionManagerConfiguration() {

        @Override
        public SessionExpirationListener getExpirationListener() {
            return configuration.getExpirationListener();
        }

        @Override
        public ServletContext getServletContext() {
            return configuration.getServletContext();
        }

        @Override
        public Cache<Key<String>, ?> getCache() {
            return cache;
        }

        @Override
        public CacheProperties getProperties() {
            return properties;
        }

        @Override
        public IdentifierFactory<String> getIdentifierFactory() {
            return factory;
        }

        @Override
        public Batcher<TransactionBatch> getBatcher() {
            return batcher;
        }

        @Override
        public CommandDispatcherFactory getCommandDispatcherFactory() {
            return dispatcherFactory;
        }

        @Override
        public NodeFactory<Address> getNodeFactory() {
            return nodeFactory;
        }

        @Override
        public int getMaxActiveSessions() {
            return maxActiveSessions;
        }

        @Override
        public Recordable<ImmutableSession> getInactiveSessionRecorder() {
            return configuration.getInactiveSessionRecorder();
        }
    };
    return new InfinispanSessionManager<>(this.createSessionFactory(properties, configuration.getLocalContextFactory()), config);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) Address(org.infinispan.remoting.transport.Address) TransactionBatch(org.wildfly.clustering.ee.infinispan.TransactionBatch) InfinispanBatcher(org.wildfly.clustering.ee.infinispan.InfinispanBatcher) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties) CacheProperties(org.wildfly.clustering.ee.infinispan.CacheProperties) AffinityIdentifierFactory(org.wildfly.clustering.web.infinispan.AffinityIdentifierFactory) CommandDispatcherFactory(org.wildfly.clustering.dispatcher.CommandDispatcherFactory) Key(org.wildfly.clustering.infinispan.spi.distribution.Key) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties)

Example 13 with Address

use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.

the class InfinispanRouteLocator method locate.

@Override
public String locate(String sessionId) {
    Map.Entry<String, Void> entry = null;
    Address location = this.locatePrimaryOwner(sessionId);
    if (location != null) {
        Node node = this.factory.createNode(location);
        entry = this.registry.getEntry(node);
    }
    return (entry != null) ? entry.getKey() : null;
}
Also used : Address(org.infinispan.remoting.transport.Address) Node(org.wildfly.clustering.group.Node) Map(java.util.Map)

Example 14 with Address

use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.

the class CacheGroup method getNodes.

@Override
public List<Node> getNodes() {
    List<Address> addresses = this.getAddresses();
    List<Node> nodes = new ArrayList<>(addresses.size());
    for (Address address : addresses) {
        nodes.add(this.factory.createNode(address));
    }
    return nodes;
}
Also used : Address(org.infinispan.remoting.transport.Address) Node(org.wildfly.clustering.group.Node) ArrayList(java.util.ArrayList)

Example 15 with Address

use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.

the class InfinispanBeanManager method locatePrimaryOwner.

Node locatePrimaryOwner(I id) {
    DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
    Address address = (dist != null) ? dist.getPrimaryLocation(id) : null;
    return (address != null) ? this.nodeFactory.createNode(address) : this.registry.getGroup().getLocalNode();
}
Also used : Address(org.infinispan.remoting.transport.Address) DistributionManager(org.infinispan.distribution.DistributionManager)

Aggregations

Address (org.infinispan.remoting.transport.Address)15 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 Test (org.junit.Test)3 Map (java.util.Map)2 EndInvalidationCommand (org.hibernate.cache.infinispan.util.EndInvalidationCommand)2 DistributionManager (org.infinispan.distribution.DistributionManager)2 ConsistentHash (org.infinispan.distribution.ch.ConsistentHash)2 DataRehashed (org.infinispan.notifications.cachelistener.annotation.DataRehashed)2 CommandDispatcherFactory (org.wildfly.clustering.dispatcher.CommandDispatcherFactory)2 Node (org.wildfly.clustering.group.Node)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 PrivilegedAction (java.security.PrivilegedAction)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1