use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.
the class DefaultCacheContainerTestCase method getCoordinator.
@Test
public void getCoordinator() {
Address expected = mock(Address.class);
when(this.manager.getCoordinator()).thenReturn(expected);
Address result = this.subject.getCoordinator();
assertSame(expected, result);
}
use of org.infinispan.remoting.transport.Address 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.remoting.transport.Address in project wildfly by wildfly.
the class InfinispanBeanManagerFactory method createBeanManager.
@Override
public BeanManager<I, T, TransactionBatch> createBeanManager(IdentifierFactory<I> identifierFactory, PassivationListener<T> passivationListener, RemoveListener<T> removeListener) {
MarshallingContext context = new SimpleMarshallingContextFactory().createMarshallingContext(this.configuration.getMarshallingConfigurationRepository(), this.configuration.getBeanContext().getClassLoader());
MarshalledValueFactory<MarshallingContext> factory = new SimpleMarshalledValueFactory(context);
Cache<BeanKey<I>, BeanEntry<I>> beanCache = this.configuration.getCache();
Cache<BeanGroupKey<I>, BeanGroupEntry<I, T>> groupCache = this.configuration.getCache();
final CacheProperties properties = new InfinispanCacheProperties(groupCache.getCacheConfiguration());
final String beanName = this.configuration.getBeanContext().getBeanName();
BeanGroupFactory<I, T> groupFactory = new InfinispanBeanGroupFactory<>(groupCache, beanCache, factory, context, properties);
Configuration<BeanGroupKey<I>, BeanGroupEntry<I, T>, BeanGroupFactory<I, T>> groupConfiguration = new SimpleConfiguration<>(groupCache, groupFactory);
BeanFactory<I, T> beanFactory = new InfinispanBeanFactory<>(beanName, groupFactory, beanCache, properties, this.configuration.getBeanContext().getTimeout(), properties.isPersistent() ? passivationListener : null);
Configuration<BeanKey<I>, BeanEntry<I>, BeanFactory<I, T>> beanConfiguration = new SimpleConfiguration<>(beanCache, beanFactory);
final NodeFactory<Address> nodeFactory = this.configuration.getNodeFactory();
final Registry<String, ?> registry = this.configuration.getRegistry();
final KeyAffinityServiceFactory affinityFactory = this.configuration.getKeyAffinityServiceFactory();
final CommandDispatcherFactory dispatcherFactory = this.configuration.getCommandDispatcherFactory();
final Time timeout = this.configuration.getBeanContext().getTimeout();
final ScheduledExecutorService scheduler = this.configuration.getScheduler();
final ExpirationConfiguration<T> expiration = new ExpirationConfiguration<T>() {
@Override
public Time getTimeout() {
return timeout;
}
@Override
public RemoveListener<T> getRemoveListener() {
return removeListener;
}
@Override
public ScheduledExecutorService getExecutor() {
return scheduler;
}
};
final Executor executor = this.configuration.getExecutor();
final BeanPassivationConfiguration passivationConfig = this.configuration.getPassivationConfiguration();
final PassivationConfiguration<T> passivation = new PassivationConfiguration<T>() {
@Override
public PassivationListener<T> getPassivationListener() {
return passivationListener;
}
@Override
public BeanPassivationConfiguration getConfiguration() {
return passivationConfig;
}
@Override
public Executor getExecutor() {
return executor;
}
};
InfinispanBeanManagerConfiguration<T> configuration = new InfinispanBeanManagerConfiguration<T>() {
@Override
public String getBeanName() {
return beanName;
}
@Override
public KeyAffinityServiceFactory getAffinityFactory() {
return affinityFactory;
}
@Override
public Registry<String, ?> getRegistry() {
return registry;
}
@Override
public NodeFactory<Address> getNodeFactory() {
return nodeFactory;
}
@Override
public CommandDispatcherFactory getCommandDispatcherFactory() {
return dispatcherFactory;
}
@Override
public ExpirationConfiguration<T> getExpirationConfiguration() {
return expiration;
}
@Override
public PassivationConfiguration<T> getPassivationConfiguration() {
return passivation;
}
@Override
public CacheProperties getProperties() {
return properties;
}
};
return new InfinispanBeanManager<>(configuration, identifierFactory, beanConfiguration, groupConfiguration);
}
use of org.infinispan.remoting.transport.Address 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
}
}
}
use of org.infinispan.remoting.transport.Address in project wildfly by wildfly.
the class InfinispanSessionManager method locatePrimaryOwner.
private Node locatePrimaryOwner(String sessionId) {
DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
Address address = (dist != null) ? dist.getPrimaryLocation(new Key<>(sessionId)) : null;
return (address != null) ? this.nodeFactory.createNode(address) : this.dispatcherFactory.getGroup().getLocalNode();
}
Aggregations