public DistributedCacheManager(LocalDistributableSessionManager manager, Cache<String, Map<Object, Object>> cache, Registry<String, Void> registry, SharedLocalYieldingClusterLockManager lockManager, SessionAttributeStorage<T> attributeStorage, BatchingManager batchingManager, CacheInvoker invoker, KeyAffinityServiceFactory affinityFactory) { this.manager = manager; this.lockManager = lockManager; this.cache = cache; this.attributeStorage = attributeStorage; this.batchingManager = batchingManager; this.invoker = new ForceSynchronousCacheInvoker(invoker); this.lockTimeout = this.cache.getCacheConfiguration().locking().lockAcquisitionTimeout(); Configuration configuration = this.cache.getCacheConfiguration(); this.passivationEnabled = configuration.loaders().passivation() && !configuration.loaders().shared() && !configuration.loaders().cacheLoaders().isEmpty(); this.persistenceEnabled = !configuration.loaders().passivation() && !configuration.loaders().cacheLoaders().isEmpty(); this.registry = registry; this.affinity = affinityFactory.createService(cache, this); }
private CacheLoaderConfiguration buildCacheManagerWithCacheStore(final String config) throws IOException { InputStream is = new ByteArrayInputStream(config.getBytes()); cacheManager = TestCacheManagerFactory.fromStream(is); assert cacheManager.getDefaultCacheConfiguration().loaders().cacheLoaders().size() == 1; return cacheManager.getDefaultCacheConfiguration().loaders().cacheLoaders().get(0); } }
public void testBdbjeCacheStoreConfigurationAdaptor() { ConfigurationBuilder b = new ConfigurationBuilder(); b.loaders().addStore(BdbjeCacheStoreConfigurationBuilder.class).location("/tmp/bdbje").cacheDbNamePrefix("myprefix").catalogDbName("mycatalog").fetchPersistentState(true).async().enable(); Configuration configuration = b.build(); BdbjeCacheStoreConfiguration store = (BdbjeCacheStoreConfiguration) configuration.loaders().cacheLoaders().get(0); assert store.location().equals("/tmp/bdbje"); assert store.cacheDbNamePrefix().equals("myprefix"); assert store.catalogDbName().equals("mycatalog"); assert store.fetchPersistentState(); assert store.async().enabled(); b = new ConfigurationBuilder(); b.loaders().addStore(BdbjeCacheStoreConfigurationBuilder.class).read(store); Configuration configuration2 = b.build(); BdbjeCacheStoreConfiguration store2 = (BdbjeCacheStoreConfiguration) configuration2.loaders().cacheLoaders().get(0); assert store2.location().equals("/tmp/bdbje"); assert store2.cacheDbNamePrefix().equals("myprefix"); assert store2.catalogDbName().equals("mycatalog"); assert store2.fetchPersistentState(); assert store2.async().enabled(); BdbjeCacheStoreConfig legacy = store.adapt(); assert legacy.getLocation().equals("/tmp/bdbje"); assert legacy.getCacheDbNamePrefix().equals("myprefix"); assert legacy.getCatalogDbName().equals("mycatalog"); assert legacy.isFetchPersistentState(); assert legacy.getAsyncStoreConfig().isEnabled(); } }