public void testRebalancingStatusWhenInternalCacheIsRebalancing() throws Exception { Cache mockedCache = mock(Cache.class); AdvancedCache mockedAdvancedCache = mock(AdvancedCache.class); DistributionManager mockedDistributionManager = mock(DistributionManager.class); when(mockedCacheManager.getCacheNames()).thenReturn(Collections.emptySet()); mockRehashInProgress(INTERNAL_CACHE_NAME, mockedCache, mockedAdvancedCache, mockedDistributionManager); ClusterHealth clusterHealth = new ClusterHealthImpl(mockedCacheManager); assertEquals(HealthStatus.REBALANCING, clusterHealth.getHealthStatus()); }
public void testRebalancingStatusWhenUserCacheIsRebalancing() throws Exception { Cache mockedCache = mock(Cache.class); AdvancedCache mockedAdvancedCache = mock(AdvancedCache.class); DistributionManager mockedDistributionManager = mock(DistributionManager.class); when(mockedCacheManager.getCacheNames()).thenReturn(Collections.singleton(CACHE_NAME)); mockRehashInProgress(CACHE_NAME, mockedCache, mockedAdvancedCache, mockedDistributionManager); ClusterHealth clusterHealth = new ClusterHealthImpl(mockedCacheManager); assertEquals(HealthStatus.REBALANCING, clusterHealth.getHealthStatus()); }
public static CacheFactory buildCacheFactory(String configFile, TransactionManager tm) { try { if (configFile == null) { configFile = "infinispan-config.xml"; // in classpath } DefaultCacheManager cacheManager = new DefaultCacheManager(configFile, true); for(String cacheName:cacheManager.getCacheNames()) { if (tm != null) { cacheManager.getCacheConfiguration(cacheName).transaction().transactionManagerLookup(new TransactionManagerLookup() { @Override public TransactionManager getTransactionManager() throws Exception { return tm; } }); } cacheManager.startCache(cacheName); } return new InfinispanCacheFactory(cacheManager, InfinispanCacheFactory.class.getClassLoader()); } catch (IOException e) { throw new TeiidRuntimeException("Failed to initialize a Infinispan cache factory"); } }