/** * @see org.springframework.cache.Cache#getName() */ @Override public String getName() { return this.nativeCache.getName(); }
@Override public String getName() { return delegate.getName(); }
@Override public String getName() { return cache.getName(); }
public RemoteInfinispanCacheMeterBinder(RemoteCache cache, Iterable<Tag> tags) { super(cache, cache.getName(), tags); this.cache = cache; }
public String getEntityType(RemoteCache<?,?> c) { return getProtobufPackageName() + "." + c.getName(); } }
@Override public String toString() { return "ProtoDataMapper[cacheName='" + delegate.getLinkedCache().getName() + "']"; }
public void testNamedCache() { cache.put("pete", "British"); cache.put("manik", "Sri Lankan"); assertEquals(cache.getName(), "small"); assertEquals(cache.get("pete"), "British"); assertEquals(cache.get("manik"), "Sri Lankan"); // here we check that the cache injection with the @Small qualifier works // like the injection with the @Remote qualifier assertEquals(cacheWithQualifier.getName(), "small"); assertEquals(cacheWithQualifier.get("pete"), "British"); assertEquals(cacheWithQualifier.get("manik"), "Sri Lankan"); }
private String getHashFunctionImplProperty(RemoteCache rc) throws Exception { RemoteCacheImpl rci = (RemoteCacheImpl) rc; OperationsFactory of = getOperationsFactoryField(rci); ChannelFactory ttf = getChannelFactoryField(of); ConsistentHash ch = ttf.getConsistentHash(rc.getName().getBytes()); return ch.getClass().getName(); }
@Test public void testGetName() { // in hotrod protocol specification, the default cache is identified by an empty string assertEquals(testCache, remoteCache.getName()); }
public void testSpecificCacheManager() { cache.put("pete", "British"); cache.put("manik", "Sri Lankan"); assertEquals(cache.getName(), "small"); assertEquals(cache.get("pete"), "British"); assertEquals(cache.get("manik"), "Sri Lankan"); }
public static InfinispanNotificationsManager create(KeycloakSession session, Cache<String, Serializable> workCache, String myAddress, String mySite, Set<RemoteStore> remoteStores) { RemoteCache workRemoteCache = null; if (!remoteStores.isEmpty()) { RemoteStore remoteStore = remoteStores.iterator().next(); workRemoteCache = remoteStore.getRemoteCache(); if (mySite == null) { throw new IllegalStateException("Multiple datacenters available, but site name is not configured! Check your configuration"); } } ExecutorService listenersExecutor = workRemoteCache==null ? null : session.getProvider(ExecutorsProvider.class).getExecutor("work-cache-event-listener"); InfinispanNotificationsManager manager = new InfinispanNotificationsManager(workCache, workRemoteCache, myAddress, mySite, listenersExecutor); // We need CacheEntryListener for communication within current DC workCache.addListener(manager.new CacheEntryListener()); logger.debugf("Added listener for infinispan cache: %s", workCache.getName()); // Added listener for remoteCache to notify other DCs if (workRemoteCache != null) { workRemoteCache.addClientListener(manager.new HotRodListener(workRemoteCache)); logger.debugf("Added listener for HotRod remoteStore cache: %s", workRemoteCache.getName()); } return manager; }
@Test public void testReindexing() { remoteCacheManager.administration().reindexCache(remoteCache.getName()); } }
protected synchronized RemoteCache loadRemoteCache(String cacheName) { RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cacheManager.getCache(cacheName)); Boolean remoteStoreSecurity = config.getBoolean("remoteStoreSecurityEnabled"); if (remoteStoreSecurity == null) { try { logger.debugf("Detecting remote security settings of HotRod server, cache %s. Disable by explicitly setting \"remoteStoreSecurityEnabled\" property in spi=connectionsInfinispan/provider=default", cacheName); remoteStoreSecurity = false; final RemoteCache<Object, Object> scriptCache = remoteCache.getRemoteCacheManager().getCache(SCRIPT_CACHE_NAME); if (scriptCache == null) { logger.debug("Cannot detect remote security settings of HotRod server, disabling."); } else { scriptCache.containsKey(""); } } catch (HotRodClientException ex) { logger.debug("Seems that HotRod server requires authentication, enabling."); remoteStoreSecurity = true; } } if (remoteStoreSecurity) { logger.infof("Remote store security for cache %s is enabled. Disable by setting \"remoteStoreSecurityEnabled\" property to \"false\" in spi=connectionsInfinispan/provider=default", cacheName); RemoteCacheManager securedMgr = getOrCreateSecuredRemoteCacheManager(config, cacheName, remoteCache.getRemoteCacheManager()); return securedMgr.getCache(remoteCache.getName()); } else { logger.infof("Remote store security for cache %s is disabled. If server fails to connect to remote JDG server, enable it.", cacheName); return remoteCache; } }
private void lazyInit(KeycloakSession session) { if (tokenCache == null) { synchronized (this) { if (tokenCache == null) { InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class); Cache cache = connections.getCache(InfinispanConnectionProvider.ACTION_TOKEN_CACHE); RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cache); if (remoteCache != null) { LOG.debugf("Having remote stores. Using remote cache '%s' for single-use cache of token", remoteCache.getName()); this.tokenCache = () -> { // Doing this way as flag is per invocation return remoteCache.withFlags(Flag.FORCE_RETURN_VALUE); }; } else { LOG.debugf("Not having remote stores. Using normal cache '%s' for single-use cache of token", cache.getName()); this.tokenCache = () -> { return cache; }; } } } } }
private void lazyInit(KeycloakSession session) { if (codeCache == null) { synchronized (this) { if (codeCache == null) { InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class); Cache cache = connections.getCache(InfinispanConnectionProvider.ACTION_TOKEN_CACHE); RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cache); if (remoteCache != null) { LOG.debugf("Having remote stores. Using remote cache '%s' for single-use cache of code", remoteCache.getName()); this.codeCache = () -> { // Doing this way as flag is per invocation return remoteCache.withFlags(Flag.FORCE_RETURN_VALUE); }; } else { LOG.debugf("Not having remote stores. Using normal cache '%s' for single-use cache of code", cache.getName()); this.codeCache = () -> { return cache; }; } } } } }
@Override public InfinispanEventListener start(InfinispanConsumer consumer) { if (consumer.getConfiguration().isSync()) { throw new UnsupportedOperationException("Sync listeners not supported for remote caches."); } RemoteCache<?, ?> remoteCache = InfinispanUtil.asRemote(consumer.getCache()); InfinispanConfiguration configuration = consumer.getConfiguration(); InfinispanEventListener listener; if (configuration.hasCustomListener()) { listener = configuration.getCustomListener(); listener.setInfinispanConsumer(consumer); } else { listener = new InfinispanRemoteEventListener(consumer, configuration.getEventTypes()); } remoteCache.addClientListener(listener); listener.setCacheName(remoteCache.getName()); return listener; }
/** * Test method for * {@link org.infinispan.spring.embedded.InfinispanNamedRemoteCacheFactoryBean#setBeanName(java.lang.String)} * . * * @throws Exception */ @Test public final void infinispanNamedRemoteCacheFactoryBeanShouldUseBeanNameAsCacheNameIfNoCacheNameHasBeenSet() throws Exception { final String beanName = TEST_BEAN_NAME; final InfinispanNamedRemoteCacheFactoryBean<String, Object> objectUnderTest = new InfinispanNamedRemoteCacheFactoryBean<String, Object>(); objectUnderTest.setInfinispanRemoteCacheManager(remoteCacheManager); objectUnderTest.setBeanName(beanName); objectUnderTest.afterPropertiesSet(); final RemoteCache<String, Object> cache = objectUnderTest.getObject(); assertEquals("InfinispanNamedRemoteCacheFactoryBean should have used its bean name [" + beanName + "] as the name of the created cache. However, it didn't.", beanName, cache.getName()); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanNamedRemoteCacheFactoryBean#setBeanName(String)} * . * * @throws Exception */ @Test public final void infinispanNamedRemoteCacheFactoryBeanShouldUseBeanNameAsCacheNameIfNoCacheNameHasBeenSet() throws Exception { final String beanName = TEST_BEAN_NAME; final InfinispanNamedRemoteCacheFactoryBean<String, Object> objectUnderTest = new InfinispanNamedRemoteCacheFactoryBean<String, Object>(); objectUnderTest.setInfinispanRemoteCacheManager(remoteCacheManager); objectUnderTest.setBeanName(beanName); objectUnderTest.afterPropertiesSet(); final RemoteCache<String, Object> cache = objectUnderTest.getObject(); assertEquals("InfinispanNamedRemoteCacheFactoryBean should have used its bean name [" + beanName + "] as the name of the created cache. However, it didn't.", beanName, cache.getName()); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanNamedRemoteCacheFactoryBean#setCacheName(String)} * . * * @throws Exception */ @Test public final void infinispanNamedRemoteCacheFactoryBeanShouldPreferExplicitCacheNameToBeanName() throws Exception { final InfinispanNamedRemoteCacheFactoryBean<String, Object> objectUnderTest = new InfinispanNamedRemoteCacheFactoryBean<String, Object>(); objectUnderTest.setInfinispanRemoteCacheManager(remoteCacheManager); objectUnderTest.setCacheName(TEST_CACHE_NAME); objectUnderTest.setBeanName(TEST_BEAN_NAME); objectUnderTest.afterPropertiesSet(); final RemoteCache<String, Object> cache = objectUnderTest.getObject(); assertEquals("InfinispanNamedRemoteCacheFactoryBean should have preferred its cache name [" + TEST_CACHE_NAME + "] as the name of the created cache. However, it didn't.", TEST_CACHE_NAME, cache.getName()); }
/** * Test method for * {@link org.infinispan.spring.embedded.InfinispanNamedRemoteCacheFactoryBean#setCacheName(java.lang.String)} * . * * @throws Exception */ @Test public final void infinispanNamedRemoteCacheFactoryBeanShouldPreferExplicitCacheNameToBeanName() throws Exception { final InfinispanNamedRemoteCacheFactoryBean<String, Object> objectUnderTest = new InfinispanNamedRemoteCacheFactoryBean<String, Object>(); objectUnderTest.setInfinispanRemoteCacheManager(remoteCacheManager); objectUnderTest.setCacheName(TEST_CACHE_NAME); objectUnderTest.setBeanName(TEST_BEAN_NAME); objectUnderTest.afterPropertiesSet(); final RemoteCache<String, Object> cache = objectUnderTest.getObject(); assertEquals("InfinispanNamedRemoteCacheFactoryBean should have preferred its cache name [" + TEST_CACHE_NAME + "] as the name of the created cache. However, it didn't.", TEST_CACHE_NAME, cache.getName()); }