@Override public ModelNode execute(Cache<?, ?> cache) { return new ModelNode(cache.getStatus().toString()); } },
private void assertAllTerminated(Cache<?, ?>... caches) { for (Cache<?, ?> cache : caches) { assert cache.getStatus() == ComponentStatus.TERMINATED; } } }
@Override public ModelNode execute(Cache<?, ?> cache) { return new ModelNode(cache.getStatus().toString()); } },
private void updateTitleBar() { String title = "Infinispan GUI Demo"; if (cache != null && cache.getStatus() == ComponentStatus.RUNNING) { title += " (STARTED) " + getLocalAddress() + " Cluster size: " + getClusterSize(); } else { title += " (STOPPED)"; } frame.setTitle(title); }
public void startCache() { if (isStarted.compareAndSet(false, true)) { logger.info("Starting JBoss Cache " + name + " ..."); this.cache.start(); if (logger.isInfoEnabled()) { logger.info("Mobicents Cache " + name + " started, status: " + cache.getStatus() + ", Mode: " + cache.getCacheConfiguration().clustering().cacheMode()); } } }
void detectCrashedMember(ViewChangedEvent e) { try { if (addressCache.getStatus().allowInvocations()) { List<Address> goneMembers = e.getOldMembers().stream().filter(o -> !e.getNewMembers().contains(o)).collect(Collectors.toList()); log.tracef("View change received: %s, removing members %s", e, goneMembers); // Consider doing removeAsync and then waiting for all removals... goneMembers.forEach(addressCache::remove); } } catch (Throwable t) { log.errorDetectingCrashedMember(t); } }
public void startCache() { if(!(jBossDefaultCache.getCache().getStatus() == ComponentStatus.RUNNING)){ logger.info("Starting JBoss Cache..."); jBossDefaultCache.start(); } if (logger.isInfoEnabled()) { logger.info("Mobicents Cache started, status: " + this.jBossDefaultCache.getCache().getStatus() + ", Mode: " + jBossDefaultCache.getCache().getCacheConfiguration().clustering().cacheMode()); } }
public Cache<K, V> run() { Cache<K, V> cache = manager.getCache(regionIdEscaped); if (cache.getStatus() == ComponentStatus.TERMINATED) { cache.start(); LOG.info("The cache corresponding to the region {} was in state Terminated, so it has been restarted", regionIdEscaped); } return cache; } };
private void mockRehashInProgress(String cacheName, Cache mockedCache, AdvancedCache mockedAdvancedCache, DistributionManager mockedDistributionManager) { when(mockedCacheManager.getCache(cacheName, false)).thenReturn(mockedCache); when(mockedCache.getAdvancedCache()).thenReturn(mockedAdvancedCache); when(mockedCache.getStatus()).thenReturn(INSTANTIATED); when(mockedAdvancedCache.getDistributionManager()).thenReturn(mockedDistributionManager); when(mockedDistributionManager.isRehashInProgress()).thenReturn(true); }
public void initialize(Cache infinispanCache, boolean attachLifespanToLeafNodes, long leafNodeLifespan, long staleNodesLinksCleanerDelay) { this.cache = new IDMTreeCacheImpl(infinispanCache, attachLifespanToLeafNodes, leafNodeLifespan, staleNodesLinksCleanerDelay); ComponentStatus status = infinispanCache.getStatus(); if (status.startAllowed()) { this.cache.getCache().start(); } log.info("Infinispan cache for Picketlink IDM created successfuly. cache name: " + cache.getCache().getName()); }
protected boolean shouldUpdateLocalCache(ClientEvent.Type type, K key, boolean commandRetried) { boolean result; // Case when cache is stopping or stopped already if (!cache.getStatus().allowInvocations()) { return false; } if (commandRetried) { result = true; } else { result = topologyInfo.amIOwner(cache, key); } logger.debugf("Received event from remote store. Event '%s', key '%s', skip '%b'", type.toString(), key, !result); return result; }
@Override public void eventReceived(ClusterEvent event) { KeycloakModelUtils.runJobInTransaction(sessionFactory, (KeycloakSession session) -> { InfinispanAuthenticationSessionProvider provider = (InfinispanAuthenticationSessionProvider) session.getProvider(AuthenticationSessionProvider.class, InfinispanAuthenticationSessionProviderFactory.PROVIDER_ID); SE sessionEvent = (SE) event; if (!provider.getCache().getStatus().allowInvocations()) { log.debugf("Cache in state '%s' doesn't allow invocations", provider.getCache().getStatus()); return; } log.debugf("Received authentication session event '%s'", sessionEvent.toString()); eventReceived(session, provider, sessionEvent); }); }
@Override public void stop(StopContext context) { if ((this.cache != null) && this.cache.getStatus().allowInvocations()) { if (this.recovery != null) { this.dependencies.getRecoveryRegistry().removeXAResourceRecovery(this.recovery); } SecurityActions.stopCache(cache); log.debugf("%s cache stopped", this.name); } }
private static Set<Cache> getRunningCaches(EmbeddedCacheManager cacheContainer) { if (cacheContainer == null || !cacheContainer.getStatus().allowInvocations()) return Collections.emptySet(); Set<String> running = new LinkedHashSet<>(getOrderedCacheNames(cacheContainer)); extractGlobalComponent(cacheContainer, InternalCacheRegistry.class).filterPrivateCaches(running); running.addAll(cacheContainer.getCacheNames()); running.add(cacheContainer.getCacheManagerConfiguration().defaultCacheName().orElse(DEFAULT_CACHE_NAME)); return running.stream() .map(s -> cacheContainer.getCache(s, false)) .filter(Objects::nonNull) .filter(c -> c.getStatus().allowInvocations()) .collect(Collectors.toCollection(LinkedHashSet::new)); }
@Override public Cache find(String name) { Cache result = null; if (manager().isRunning(name)) { result = manager().getCache(name); if (!result.getStatus().allowInvocations()) { result.start(); } } return result; }
@Override public void startService() throws Exception { CacheContainer container = this.cacheHandler.getCacheContainer(); this.cache = (this.cacheName != null) ? container.<Serializable, Serializable>getCache(this.cacheName) : container.<Serializable, Serializable>getCache(); if (!this.cache.getStatus().allowInvocations()) { this.cache.start(); } this.cache.addListener(this); }
public void testStopClearsData() { String key = "key", value = "value"; cache.put(key, value); assertEquals(value, cache.get(key)); assertCacheSize(1); assertTrue(cache.keySet().contains(key)); assertTrue(cache.values().contains(value)); cache.stop(); assertEquals(ComponentStatus.TERMINATED, cache.getStatus()); cache.start(); assertFalse(cache.containsKey(key)); assertFalse(cache.keySet().contains(key)); assertFalse(cache.values().contains(value)); assertCacheIsEmpty(); }
public void testDefaultCache() { EmbeddedCacheManager cm = createCacheManager(false); try { assertEquals(ComponentStatus.RUNNING, cm.getCache().getStatus()); assertTrue(cm.getCache().getName().equals(CacheContainer.DEFAULT_CACHE_NAME)); expectException(IllegalArgumentException.class, () -> cm.defineConfiguration(CacheContainer.DEFAULT_CACHE_NAME, new ConfigurationBuilder().build())); } finally { TestingUtil.killCacheManagers(cm); } }
@Test public void testRedeployment() throws Exception { addEntityCheckCache( sessionFactory() ); bindToJndi = false; rebuildSessionFactory(); addEntityCheckCache( sessionFactory() ); TestRegionFactory regionFactory = TestRegionFactoryProvider.load().wrap(sessionFactory().getSettings().getRegionFactory()); Cache cache = regionFactory.getCacheManager().getCache( Item.class.getName() ); assertEquals( ComponentStatus.RUNNING, cache.getStatus() ); }
public void testTransactionalReplace(Method m) throws Exception { assertEquals(ComponentStatus.RUNNING, cache.getStatus()); assertNotInCacheAndStore(k(m, 1)); assertNotInCacheAndStore(k(m, 2)); cache.put(k(m, 2), v(m)); tm.begin(); cache.put(k(m, 1), v(m, 1)); cache.replace(k(m, 2), v(m, 1)); Transaction t = tm.suspend(); assertNotInCacheAndStore(k(m, 1)); assertInCacheAndStore(k(m, 2), v(m)); tm.resume(t); tm.commit(); assertInCacheAndStore(k(m, 1), v(m, 1)); assertInCacheAndStore(k(m, 2), v(m, 1)); }