Java Code Examples for org.infinispan.Cache#stop()
The following examples show how to use
org.infinispan.Cache#stop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplicatedServerWithMaster.java From unitime with Apache License 2.0 | 5 votes |
protected void removeCache(Cache<?,?> cache) { iCacheManager.getGlobalComponentRegistry().removeCache(cache.getName()); CacheJmxRegistration jmx = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheJmxRegistration.class); cache.stop(); if (jmx != null) jmx.unregisterCacheMBean(); }
Example 2
Source File: ReplicatedServer.java From unitime with Apache License 2.0 | 5 votes |
protected void removeCache(Cache<?,?> cache) { iCacheManager.getGlobalComponentRegistry().removeCache(cache.getName()); CacheJmxRegistration jmx = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheJmxRegistration.class); cache.stop(); if (jmx != null) jmx.unregisterCacheMBean(); }
Example 3
Source File: DistributedCacheWriteSkewTest.java From keycloak with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { Cache<String, UserSessionEntity> cache1 = createManager("node1").getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME); Cache<String, UserSessionEntity> cache2 = createManager("node2").getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME); // Create initial item UserSessionEntity session = new UserSessionEntity(); session.setId("123"); session.setRealmId("foo"); session.setBrokerSessionId("!23123123"); session.setBrokerUserId(null); session.setUser("foo"); session.setLoginUsername("foo"); session.setIpAddress("123.44.143.178"); session.setStarted(Time.currentTime()); session.setLastSessionRefresh(Time.currentTime()); AuthenticatedClientSessionEntity clientSession = new AuthenticatedClientSessionEntity(UUID.randomUUID()); clientSession.setAuthMethod("saml"); clientSession.setAction("something"); clientSession.setTimestamp(1234); session.getAuthenticatedClientSessions().put(CLIENT_1_UUID.toString(), clientSession.getId()); cache1.put("123", session); //cache1.replace("123", session); // Create 2 workers for concurrent write and start them Worker worker1 = new Worker(1, cache1); Worker worker2 = new Worker(2, cache2); long start = System.currentTimeMillis(); System.out.println("Started clustering test"); worker1.start(); //worker1.join(); worker2.start(); worker1.join(); worker2.join(); long took = System.currentTimeMillis() - start; session = cache1.get("123"); System.out.println("Took: " + took + " ms. Notes count: " + session.getNotes().size() + ", failedReplaceCounter: " + failedReplaceCounter.get()); // JGroups statistics JChannel channel = (JChannel)((JGroupsTransport)cache1.getAdvancedCache().getRpcManager().getTransport()).getChannel(); System.out.println("Sent MB: " + channel.getSentBytes() / 1000000 + ", sent messages: " + channel.getSentMessages() + ", received MB: " + channel.getReceivedBytes() / 1000000 + ", received messages: " + channel.getReceivedMessages()); // Kill JVM cache1.stop(); cache2.stop(); cache1.getCacheManager().stop(); cache2.getCacheManager().stop(); System.out.println("Managers killed"); }
Example 4
Source File: InfinispanSessionCacheIdMapperUpdater.java From keycloak with Apache License 2.0 | 4 votes |
public static SessionIdMapperUpdater addTokenStoreUpdaters(ServletContext servletContext, SessionIdMapper mapper, SessionIdMapperUpdater previousIdMapperUpdater) { String containerName = servletContext.getInitParameter(AdapterConstants.REPLICATION_CONFIG_CONTAINER_PARAM_NAME); String cacheName = servletContext.getInitParameter(AdapterConstants.REPLICATION_CONFIG_SSO_CACHE_PARAM_NAME); // the following is based on https://github.com/jbossas/jboss-as/blob/7.2.0.Final/clustering/web-infinispan/src/main/java/org/jboss/as/clustering/web/infinispan/DistributedCacheManagerFactory.java#L116-L122 String contextPath = servletContext.getContextPath(); if (contextPath == null || contextPath.isEmpty() || "/".equals(contextPath)) { contextPath = "/ROOT"; } String deploymentSessionCacheName = contextPath; if (containerName == null || cacheName == null) { LOG.warnv("Cannot determine parameters of SSO cache for deployment {0}.", contextPath); return previousIdMapperUpdater; } String cacheContainerLookup = DEFAULT_CACHE_CONTAINER_JNDI_NAME + "/" + containerName; try { EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) new InitialContext().lookup(cacheContainerLookup); Configuration ssoCacheConfiguration = cacheManager.getCacheConfiguration(cacheName); if (ssoCacheConfiguration == null) { Configuration cacheConfiguration = cacheManager.getCacheConfiguration(deploymentSessionCacheName); if (cacheConfiguration == null) { LOG.debugv("Using default configuration for SSO cache {0}.{1}.", containerName, cacheName); ssoCacheConfiguration = cacheManager.getDefaultCacheConfiguration(); } else { LOG.debugv("Using distributed HTTP session cache configuration for SSO cache {0}.{1}, configuration taken from cache {2}", containerName, cacheName, deploymentSessionCacheName); ssoCacheConfiguration = cacheConfiguration; cacheManager.defineConfiguration(cacheName, ssoCacheConfiguration); } } else { LOG.debugv("Using custom configuration of SSO cache {0}.{1}.", containerName, cacheName); } CacheMode ssoCacheMode = ssoCacheConfiguration.clustering().cacheMode(); if (ssoCacheMode != CacheMode.REPL_ASYNC && ssoCacheMode != CacheMode.REPL_SYNC) { LOG.warnv("SSO cache mode is {0}, it is recommended to use replicated mode instead.", ssoCacheConfiguration.clustering().cacheModeString()); } Cache<String, String[]> ssoCache = cacheManager.getCache(cacheName, true); final SsoSessionCacheListener listener = new SsoSessionCacheListener(ssoCache, mapper); ssoCache.addListener(listener); addSsoCacheCrossDcListener(ssoCache, listener); LOG.debugv("Added distributed SSO session cache, lookup={0}, cache name={1}", cacheContainerLookup, cacheName); SsoCacheSessionIdMapperUpdater updater = new SsoCacheSessionIdMapperUpdater(ssoCache, previousIdMapperUpdater) { @Override public void close() throws Exception { ssoCache.stop(); } }; return updater; } catch (NamingException ex) { LOG.warnv("Failed to obtain distributed session cache container, lookup={0}", cacheContainerLookup); return previousIdMapperUpdater; } }