@Override public int hashCode() { return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName().hashCode() ^ this.cache.getName().hashCode(); }
@Override public boolean equals(Object object) { if ((object == null) || !(object instanceof InfinispanXAResourceRecovery)) return false; InfinispanXAResourceRecovery recovery = (InfinispanXAResourceRecovery) object; return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName().equals(recovery.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName()) && this.cache.getName().equals(recovery.cache.getName()); }
@Override public String toString() { return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName() + "." + this.cache.getName(); } }
@Override public void start() { this.executor = Executors.newSingleThreadExecutor(createThreadFactory()); this.affinity.start(); List<Scheduler<I>> schedulers = new ArrayList<>(1); Duration timeout = this.expiration.getTimeout(); if ((timeout != null) && !timeout.isNegative()) { schedulers.add(new BeanExpirationScheduler<>(this.batcher, new ExpiredBeanRemover<>(this.beanFactory), this.expiration)); } this.scheduler = new CompositeScheduler<>(schedulers); this.dispatcher = !schedulers.isEmpty() ? this.dispatcherFactory.createCommandDispatcher(String.join("/", this.cache.getName(), this.filter.toString()), this.scheduler) : null; this.cache.addListener(this, new PredicateCacheEventFilter<>(this.filter), null); this.schedule(new SimpleLocality(false), new CacheLocality(this.cache)); }
ClusteringServerLogger.ROOT_LOGGER.registryListenerFailed(e, this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName(), this.cache.getName(), type, entries);
@CacheEntryCreated @CacheEntryModified public void modified(CacheEntryEvent<T, Set<Address>> event) { if (event.isPre()) return; Map.Entry<Listener, ExecutorService> entry = this.listeners.get(event.getKey()); if (entry != null) { Listener listener = entry.getKey(); if (listener != null) { ExecutorService executor = entry.getValue(); Set<Node> members = new TreeSet<>(); for (Address address : event.getValue()) { members.add(this.group.createNode(address)); } try { executor.submit(() -> { try { listener.providersChanged(members); } catch (Throwable e) { ClusteringServerLogger.ROOT_LOGGER.serviceProviderRegistrationListenerFailed(e, this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName(), this.cache.getName(), members); } }); } catch (RejectedExecutionException e) { // Executor was shutdown } } } } }
@Override public void init(InitializationContext ctx) { this.ctx = ctx; HotRodStoreConfiguration configuration = ctx.getConfiguration(); RemoteCacheContainer remoteCacheContainer = configuration.attributes().attribute(HotRodStoreConfiguration.REMOTE_CACHE_CONTAINER).get(); String cacheConfiguration = configuration.attributes().attribute(HotRodStoreConfiguration.CACHE_CONFIGURATION).get(); String cacheName = ctx.getCache().getName(); try { ProtocolVersion protocolVersion = remoteCacheContainer.getConfiguration().version(); // Administration support was introduced in protocol version 2.7 if (protocolVersion.compareTo(ProtocolVersion.PROTOCOL_VERSION_27) < 0) { this.remoteCache = remoteCacheContainer.getCache(cacheName, false); if (this.remoteCache == null) { throw InfinispanLogger.ROOT_LOGGER.remoteCacheMustBeDefined(protocolVersion.toString(), cacheName); } } else { InfinispanLogger.ROOT_LOGGER.remoteCacheCreated(cacheName, cacheConfiguration); this.remoteCache = remoteCacheContainer.administration().getOrCreateCache(cacheName, cacheConfiguration); } } catch (HotRodClientException ex) { throw new PersistenceException(ex); } }
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)); }
private static <K, V> Object getTaskKey(Cache<K, V> cache, K key) { if (key instanceof String) { return new StringBuilder(cache.getName()) .append("::") .append(key).toString(); } else { return key; } }
public TaskExecutionImpl(String name, String where, Optional<String> who, TaskContext context) { this.uuid = Util.threadLocalRandomUUID(); this.name = name; this.what = context.getCache().map(cache -> cache.getName()); this.where = where; this.who = who; }
private static void warnIfRemoteStoreIsUsed(Cache<String, String[]> ssoCache) { final List<RemoteCacheStore> stores = getRemoteStores(ssoCache); if (stores == null || stores.isEmpty()) { return; } LOG.warnv("Unable to listen for events on remote stores configured for cache {0} (unsupported in this Infinispan limitations), logouts will not be propagated.", ssoCache.getName()); }
private static void validateIndexCaches(String indexName, Cache<?, ?>... caches) { Arrays.stream(caches).filter(Objects::nonNull).forEach(cache -> { ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering(); CacheMode cacheMode = clusteringConfiguration.cacheMode(); if (cacheMode.isClustered() && !cacheMode.isSynchronous()) { throw log.cannotStoreIndexOnAsyncCaches(indexName, cache.getName(), cacheMode); } }); }
protected void init(KeycloakSession session, Cache<K, SessionEntityWrapper<V>> cache, RemoteCache<K, SessionEntityWrapper<V>> remoteCache) { this.cache = cache; this.remoteCache = remoteCache; this.topologyInfo = InfinispanUtil.getTopologyInfo(session); ExecutorService executor = session.getProvider(ExecutorsProvider.class).getExecutor("client-listener-" + cache.getName()); this.executor = new ClientListenerExecutorDecorator<>(executor); }
private static void validateMetadataCache(Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.memory().isEvictionEnabled()) { throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName()); } if (configuration.persistence().usingStores() && !configuration.persistence().preload()) { throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName()); } }
private void verifyUsesInfinispanDirectory(NRTIndexManager nrti, int expectedChunkSize, EmbeddedCacheManager embeddedCacheManager) throws IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException { DirectoryProvider directoryProvider = nrti.getDirectoryProvider(); Assert.assertTrue(directoryProvider instanceof InfinispanDirectoryProvider); InfinispanDirectoryProvider ispn = (InfinispanDirectoryProvider)directoryProvider; Directory infinispanDirectory = ispn.getDirectory(); DirectoryExtensions extended = (DirectoryExtensions)infinispanDirectory; Assert.assertEquals(expectedChunkSize, extended.getChunkSize()); Assert.assertEquals(extended.getMetadataCache().getName(), "LuceneIndexesMetadataOWR"); Assert.assertEquals(extended.getDataCache().getName(), "LuceneIndexesDataOWR"); //And finally check we're running it in the same CacheManager: Assert.assertTrue(extended.getDataCache().getCacheManager() == embeddedCacheManager); }
@Start private void start() { this.cacheName = ByteString.fromString(cache.getName()); this.setStatisticsEnabled(cacheConfiguration.jmxStatistics().enabled()); syncRpcOptions = rpcManager.getRpcOptionsBuilder(ResponseMode.SYNCHRONOUS_IGNORE_LEAVERS, DeliverOrder.NONE).build(); }
public void testRecoveryWithDefaultCache() { Configuration recoveryDefaultCache = cacheManager.getCache("withRecoveryDefaultCache").getCacheConfiguration(); assertTrue(recoveryDefaultCache.transaction().recovery().enabled(), "Recovery is supposed to be enabled."); assertEquals(recoveryDefaultCache.transaction().recovery().recoveryInfoCacheName(), DEFAULT_RECOVERY_INFO_CACHE, "Wrong recovery cache name."); RecoveryManagerImpl recoveryManager = rm(cacheManager.getCache("withRecoveryDefaultCache")); assertNotNull(recoveryManager, "RecoveryManager should be *not* null when recovery is enabled."); Cache<RecoveryInfoKey, RecoveryAwareRemoteTransaction> preparedTransactions = (Cache<RecoveryInfoKey, RecoveryAwareRemoteTransaction>) recoveryManager.getInDoubtTransactionsMap(); assertEquals(preparedTransactions.getName(), DEFAULT_RECOVERY_INFO_CACHE, "Wrong recovery cache name."); }
public void testSiteStatus() throws Exception { Interpreter lonInterpreter = interpreter("LON", 0); String lonCache = cache("LON", 0).getName(); String lonSessionId = lonInterpreter.createSessionId(lonCache); Interpreter nycInterpreter = interpreter("NYC", 0); String nycCache = cache("NYC", 0).getName(); String nycSessionId = nycInterpreter.createSessionId(nycCache); assertInterpreterOutput(lonInterpreter, lonSessionId, "site --status NYC;", "online"); assertInterpreterOutput(nycInterpreter, nycSessionId, format("site --status %s.LON;", lonCache), "online"); assertInterpreterOutput(lonInterpreter, lonSessionId, "site --offline NYC;", "ok"); assertInterpreterOutput(lonInterpreter, lonSessionId, "site --online NYC;", "ok"); }
@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.cacheName = ctx.getCache().getName(); this.globalConfiguration = ctx.getCache().getCacheManager().getCacheManagerConfiguration(); this.marshalledEntryFactory = ctx.getMarshalledEntryFactory(); this.marshaller = ctx.getMarshaller(); this.timeService = ctx.getTimeService(); this.keyPartitioner = configuration.segmented() ? ctx.getKeyPartitioner() : null; this.isDistributedCache = ctx.getCache().getCacheConfiguration() != null && ctx.getCache().getCacheConfiguration().clustering().cacheMode().isDistributed(); }