public RetryingInvoker(Cache<?, ?> cache) { super(calculateRetryIntervals(cache.getCacheConfiguration())); }
private void unregister(GroupListener listener) { ExecutorService executor = this.listeners.remove(listener); if (executor != null) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
private void shutdown(ExecutorService executor) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
@Override public Duration getStopTimeout() { return Duration.ofMillis(this.cache.getCacheConfiguration().transaction().cacheStopTimeout()); }
public CacheEntryMutator(Cache<K, V> cache, K id, V value) { this.cache = cache; this.id = id; this.value = value; this.mutated = cache.getCacheConfiguration().transaction().transactionMode().isTransactional() ? new AtomicBoolean(false) : null; }
@Override public void close() { this.cache.removeListener(this); PrivilegedAction<List<Runnable>> action = () -> this.executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { this.executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } this.dispatcher.close(); this.scheduler.close(); }
public ConsistentHashLocality(Cache<?, ?> cache, ConsistentHash hash) { this.topology = new LocalizedCacheTopology(cache.getCacheConfiguration().clustering().cacheMode(), new CacheTopology(0, 0, hash, null, CacheTopology.Phase.NO_REBALANCE, Collections.emptyList(), Collections.emptyList()), cache.getCacheConfiguration().clustering().hash().keyPartitioner(), cache.getCacheManager().getAddress(), true); }
@Override public Affinity getWeakAffinity(I id) { if (this.cache.getCacheConfiguration().clustering().cacheMode().isClustered()) { Node node = this.locatePrimaryOwner(id); Map.Entry<String, ?> entry = this.registry.getEntry(node); if (entry != null) { return new NodeAffinity(entry.getKey()); } } return Affinity.NONE; }
@Override public void stop() { this.groupFactory.close(); this.cache.removeListener(this); PrivilegedAction<List<Runnable>> action = () -> this.executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { this.executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { if (this.dispatcher != null) { this.dispatcher.close(); } this.scheduler.close(); this.affinity.stop(); } }
WildFlySecurityManager.doUnchecked(action); try { executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt();
@Override public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) { CacheMode mode = cache.getCacheConfiguration().clustering().cacheMode(); return mode.isDistributed() || mode.isReplicated() ? new KeyAffinityServiceImpl<>(executor, cache, generator, bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator); } };
@Override public void accept(XAResourceRecovery recovery) { if (this.cache.get().getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().removeXAResourceRecovery(recovery); } }
@Override public Affinity getStrictAffinity() { Group group = this.registry.getGroup(); return this.cache.getCacheConfiguration().clustering().cacheMode().isClustered() ? new ClusterAffinity(group.getName()) : new NodeAffinity(this.registry.getEntry(group.getLocalMember()).getKey()); }
public CacheServiceProviderRegistry(CacheServiceProviderRegistryConfiguration<T> config) { this.group = config.getGroup(); this.cache = config.getCache(); this.batcher = config.getBatcher(); this.dispatcher = config.getCommandDispatcherFactory().createCommandDispatcher(config.getId(), this.listeners.keySet()); this.cache.addListener(this); this.groupRegistration = this.group.register(this); this.invoker = new RetryingInvoker(this.cache); this.properties = new InfinispanCacheProperties(this.cache.getCacheConfiguration()); }
@Override public XAResourceRecovery get() { Cache<?, ?> cache = this.cache.get(); XAResourceRecovery recovery = new InfinispanXAResourceRecovery(cache); if (cache.getCacheConfiguration().transaction().recovery().enabled()) { this.registry.get().addXAResourceRecovery(recovery); } return recovery; }
@Override public String locate(String sessionId) { DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager(); Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : this.cache.getCacheManager().getAddress(); Node node = (address != null) ? this.factory.createNode(address) : null; Map.Entry<String, Void> entry = (node != null) ? this.registry.getEntry(node) : null; if (entry == null) { entry = this.registry.getEntry(this.registry.getGroup().getLocalMember()); } return (entry != null) ? entry.getKey() : null; } }
Node locatePrimaryOwner(I id) { DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager(); Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(id)).primary() : null; Node member = (address != null) ? this.nodeFactory.createNode(address) : null; return (member != null) ? member : this.registry.getGroup().getLocalMember(); }
@Override public <L, C extends Marshallability> SSOManager<A, D, S, L, TransactionBatch> createSSOManager(SSOManagerConfiguration<L, C> configuration) { Cache<Key<String>, ?> cache = this.configuration.getCache(); CacheProperties properties = new InfinispanCacheProperties(cache.getCacheConfiguration()); SessionsFactory<Map<D, S>, D, S> sessionsFactory = new CoarseSessionsFactory<>(this.configuration.getCache(), properties); SSOFactory<Map.Entry<A, AtomicReference<L>>, Map<D, S>, A, D, S, L> factory = new InfinispanSSOFactory<>(this.configuration.getCache(), properties, new MarshalledValueMarshaller<>(configuration.getMarshalledValueFactory(), configuration.getMarshallingContext()), configuration.getLocalContextFactory(), sessionsFactory); IdentifierFactory<String> idFactory = new AffinityIdentifierFactory<>(configuration.getIdentifierFactory(), cache, this.configuration.getKeyAffinityServiceFactory()); Batcher<TransactionBatch> batcher = new InfinispanBatcher(cache); return new InfinispanSSOManager<>(factory, idFactory, batcher); } }
public InfinispanSessionManagerFactory(InfinispanSessionManagerFactoryConfiguration<C, L> config) { this.affinityFactory = config.getKeyAffinityServiceFactory(); this.cache = config.getCache(); this.memberFactory = config.getMemberFactory(); this.batcher = new InfinispanBatcher(this.cache); this.properties = new InfinispanCacheProperties(this.cache.getCacheConfiguration()); SessionMetaDataFactory<InfinispanSessionMetaData<L>, L> metaDataFactory = new InfinispanSessionMetaDataFactory<>(config.getCache(), this.properties); this.factory = new InfinispanSessionFactory<>(metaDataFactory, this.createSessionAttributesFactory(config), config.getSessionManagerFactoryConfiguration().getLocalContextFactory()); CommandDispatcherFactory dispatcherFactory = config.getCommandDispatcherFactory(); ExpiredSessionRemover<?, ?, L> remover = new ExpiredSessionRemover<>(this.factory); this.expirationRegistrar = remover; this.scheduler = new SessionExpirationScheduler(this.batcher, remover); this.dispatcher = dispatcherFactory.createCommandDispatcher(this.cache.getName(), this.scheduler); this.group = dispatcherFactory.getGroup(); this.cache.addListener(this); this.schedule(new SimpleLocality(false), new CacheLocality(this.cache)); }
Cache<BeanKey<I>, BeanEntry<I>> beanCache = this.configuration.getCache(); Cache<BeanGroupKey<I>, BeanGroupEntry<I, T>> groupCache = this.configuration.getCache(); CacheProperties properties = new InfinispanCacheProperties(groupCache.getCacheConfiguration()); String beanName = this.configuration.getBeanContext().getBeanName(); BeanPassivationConfiguration passivationConfig = this.configuration.getPassivationConfiguration();