@Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering().cacheMode(CacheMode.LOCAL); // Auto-enable simple cache optimization if cache is non-transactional and non-persistent builder.simpleCache((this.memory().storageType() == StorageType.OBJECT) && !this.transaction().transactionMode().isTransactional() && !this.persistence().usingStores()); } }
public InfinispanCacheProperties(Configuration config) { this.transactional = config.transaction().transactionMode().isTransactional(); this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC); this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ); boolean clustered = config.clustering().cacheMode().needsStateTransfer(); boolean hasStore = config.persistence().usingStores(); this.marshalling = clustered || hasStore; this.persistent = clustered || (hasStore && !config.persistence().passivation()); }
@Start protected void start() { Set<Class<?>> indexedEntities = cacheConfiguration.indexing().indexedEntities(); this.indexedEntities = indexedEntities.isEmpty() ? null : indexedEntities.toArray(new Class<?>[indexedEntities.size()]); queryKnownClasses = indexedEntities.isEmpty() ? new QueryKnownClasses(cache.getName(), cache.getCacheManager(), internalCacheRegistry) : new QueryKnownClasses(cache.getName(), indexedEntities); searchFactoryHandler = new SearchFactoryHandler(searchFactory, queryKnownClasses, new TransactionHelper(cache.getTransactionManager())); if (this.indexedEntities == null) { queryKnownClasses.start(searchFactoryHandler); Set<Class<?>> classes = queryKnownClasses.keys(); Class<?>[] classesArray = classes.toArray(new Class<?>[classes.size()]); //Important to enable them all in a single call, much more efficient: searchFactoryHandler.enableClasses(classesArray); } isPersistenceEnabled = cacheConfiguration.persistence().usingStores(); stopping.set(false); }
public static <K, V> CacheLoader<K, V> getCacheLoader(Cache<K, V> cache) { if (cache.getCacheConfiguration().persistence().usingStores()) { return TestingUtil.getFirstLoader(cache); } else { return null; } }
if (cache.getCacheConfiguration().persistence().usingStores()) {
@Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering().cacheMode(CacheMode.LOCAL); // Auto-enable simple cache optimization if cache is non-transactional and non-persistent builder.simpleCache((this.memory().storageType() == StorageType.OBJECT) && !this.transaction().transactionMode().isTransactional() && !this.persistence().usingStores()); } }
private static void validateMetadataCache(Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.memory().isEvictionEnabled()) { throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName()); } if (configuration.persistence().usingStores() && !configuration.persistence().preload()) { throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName()); } }
private static void validateMetadataCache(Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.eviction().strategy().isEnabled()) { throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName()); } if (configuration.persistence().usingStores() && !configuration.persistence().preload()) { throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName()); } }
private static void validateMetadataCache(Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.memory().isEvictionEnabled()) { throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName()); } if (configuration.persistence().usingStores() && !configuration.persistence().preload()) { throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName()); } }
public InfinispanCacheProperties(Configuration config) { this.transactional = config.transaction().transactionMode().isTransactional(); this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC); this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ); boolean clustered = config.clustering().cacheMode().needsStateTransfer(); boolean hasStore = config.persistence().usingStores(); this.marshalling = clustered || hasStore; this.persistent = clustered || (hasStore && !config.persistence().passivation()); }
public InfinispanCacheProperties(Configuration config) { this.transactional = config.transaction().transactionMode().isTransactional(); this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC); this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ); boolean clustered = config.clustering().cacheMode().needsStateTransfer(); boolean hasStore = config.persistence().usingStores(); this.marshalling = clustered || hasStore; this.persistent = clustered || (hasStore && !config.persistence().passivation()); }
@SuppressWarnings("unchecked") @Override protected void initializeKeyAndCheckData(Object key, Object value) { assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores()); cache.put(key, value); DataContainer container = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry entry = container.get(key); CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache); assertNotNull("Key " + key + " does not exist in data container.", entry); assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue()); MarshalledEntry<Object, Object> entryLoaded = loader.load(key); assertNull("Key " + key + " exists in cache loader.", entryLoaded); }
@SuppressWarnings("unchecked") @Override protected void initializeKeyAndCheckData(Object key, Object value) { assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores()); cache.put(key, value); DataContainer container = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry entry = container.get(key); CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache); assertNotNull("Key " + key + " does not exist in data container.", entry); assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue()); MarshalledEntry<Object, Object> entryLoaded = loader.load(key); assertNull("Key " + key + " exists in cache loader.", entryLoaded); }
@SuppressWarnings("unchecked") @Override protected void initializeKeyAndCheckData(Object key, Object value) { assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores()); cache.put(key, value); DataContainer container = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry entry = container.get(key); CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache); assertNotNull("Key " + key + " does not exist in data container.", entry); assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue()); MarshalledEntry<Object, Object> entryLoaded = loader.load(key); assertNull("Key " + key + " exists in cache loader.", entryLoaded); }
@SuppressWarnings("unchecked") protected void initializeKeyAndCheckData(Object key, Object value) { assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores()); cache.put(key, value); DataContainer container = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry entry = container.get(key); CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache); assertNotNull("Key " + key + " does not exist in data container.", entry); assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue()); MarshalledEntry<Object, Object> entryLoaded = loader.load(key); assertNotNull("Key " + key + " does not exist in cache loader.", entryLoaded); assertEquals("Wrong value for key " + key + " in cache loader.", value, entryLoaded.getValue()); }