/** * Create a Refresh Ahead Cache Adaptor with the specified configuration. An auxiliary EhCache * Cache will be created for the purposes of synchronization, so only one node * in a clustered environment will refresh a key at a given time. * * @param adaptedCache * @param refreshConfig */ public RefreshAheadCache(Ehcache adaptedCache, RefreshAheadCacheConfiguration refreshConfig) { super(adaptedCache); this.refreshAheadConfig = refreshConfig; // XA transactions cannot actually refresh sensibly. At least not // reasonably. GAE doesn't support threads. Other conditions around? boolean refreshAllowed = !underlyingCache.getCacheConfiguration().isXaStrictTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isXaTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isLocalTransactional(); refreshAllowed = refreshAllowed && !VmUtils.isInGoogleAppEngine(); if (refreshAllowed) { initSupportCache(); initWorkQueue(); } else { throw new UnsupportedOperationException("refresh-ahead not supported under transactions or with GAE"); } }
private AbstractTransactionStore makeTransactional(final Store store) { AbstractTransactionStore wrappedStore; if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName() + " to be transactional, but no TransactionManager could be found!"); } // set xa enabled if (configuration.isTerracottaClustered()) { configuration.getTerracottaConfiguration().setCacheXA(true); } SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, elementValueComparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager().getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); wrappedStore = new JtaLocalTransactionStore(localTransactionStore, transactionManagerLookup, cacheManager.getTransactionController()); } else if (configuration.isLocalTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); wrappedStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager() .getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); } else { throw new IllegalStateException("Method should called only with a transactional configuration"); } return wrappedStore; }
static CopyStrategyHandler getCopyStrategyHandler(final Ehcache cache) { if (cache.getCacheConfiguration().isXaTransactional() || cache.getCacheConfiguration().isXaStrictTransactional() || cache.getCacheConfiguration().isLocalTransactional()) { return new TxCopyStrategyHandler(cache.getCacheConfiguration().isCopyOnRead(), cache.getCacheConfiguration().isCopyOnWrite(), cache.getCacheConfiguration().getCopyStrategy(), cache.getCacheConfiguration().getClassLoader()); } else if (cache.getCacheConfiguration().isCopyOnRead() || cache.getCacheConfiguration().isCopyOnWrite()) { return new CopyStrategyHandler(cache.getCacheConfiguration().isCopyOnRead(), cache.getCacheConfiguration().isCopyOnWrite(), cache.getCacheConfiguration().getCopyStrategy(), cache.getCacheConfiguration().getClassLoader()); } else { return NO_COPY_STRATEGY_HANDLER; } }
if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName()
/** * Create a Refresh Ahead Cache Adaptor with the specified configuration. An auxiliary EhCache * Cache will be created for the purposes of synchronization, so only one node * in a clustered environment will refresh a key at a given time. * * @param adaptedCache * @param refreshConfig */ public RefreshAheadCache(Ehcache adaptedCache, RefreshAheadCacheConfiguration refreshConfig) { super(adaptedCache); this.refreshAheadConfig = refreshConfig; // XA transactions cannot actually refresh sensibly. At least not // reasonably. GAE doesn't support threads. Other conditions around? boolean refreshAllowed = !underlyingCache.getCacheConfiguration().isXaStrictTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isXaTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isLocalTransactional(); refreshAllowed = refreshAllowed && !VmUtils.isInGoogleAppEngine(); if (refreshAllowed) { initSupportCache(); initWorkQueue(); } else { throw new UnsupportedOperationException("refresh-ahead not supported under transactions or with GAE"); } }
/** * Create a Refresh Ahead Cache Adaptor with the specified configuration. An auxiliary EhCache * Cache will be created for the purposes of synchronization, so only one node * in a clustered environment will refresh a key at a given time. * * @param adaptedCache * @param refreshConfig */ public RefreshAheadCache(Ehcache adaptedCache, RefreshAheadCacheConfiguration refreshConfig) { super(adaptedCache); this.refreshAheadConfig = refreshConfig; // XA transactions cannot actually refresh sensibly. At least not // reasonably. GAE doesn't support threads. Other conditions around? boolean refreshAllowed = !underlyingCache.getCacheConfiguration().isXaStrictTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isXaTransactional(); refreshAllowed = refreshAllowed && !underlyingCache.getCacheConfiguration().isLocalTransactional(); refreshAllowed = refreshAllowed && !VmUtils.isInGoogleAppEngine(); if (refreshAllowed) { initSupportCache(); initWorkQueue(); } else { throw new UnsupportedOperationException("refresh-ahead not supported under transactions or with GAE"); } }
private Store makeXaStrictTransactionalIfNeeded(Store clusteredStore, ReadWriteCopyStrategy<Element> copyStrategy) { Store wrappedStore; if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName() + " to be transactional, but no TransactionManager could be found!"); } //set xa enabled if (configuration.isTerracottaClustered()) { configuration.getTerracottaConfiguration().setCacheXA(true); } SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); // this xaresource is for initial registration and recovery xaResource = new EhcacheXAResourceImpl(this, clusteredStore, transactionManagerLookup, softLockManager, transactionIDFactory, copyStrategy); transactionManagerLookup.register(xaResource, true); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, clusteredStore, copyStrategy); } else { wrappedStore = clusteredStore; } return wrappedStore; }
private AbstractTransactionStore makeTransactional(final Store store) { AbstractTransactionStore wrappedStore; if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName() + " to be transactional, but no TransactionManager could be found!"); } // set xa enabled if (configuration.isTerracottaClustered()) { configuration.getTerracottaConfiguration().setCacheXA(true); } SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, elementValueComparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager().getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); wrappedStore = new JtaLocalTransactionStore(localTransactionStore, transactionManagerLookup, cacheManager.getTransactionController()); } else if (configuration.isLocalTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); wrappedStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager() .getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); } else { throw new IllegalStateException("Method should called only with a transactional configuration"); } return wrappedStore; }
private AbstractTransactionStore makeTransactional(final Store store) { AbstractTransactionStore wrappedStore; if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName() + " to be transactional, but no TransactionManager could be found!"); } // set xa enabled if (configuration.isTerracottaClustered()) { configuration.getTerracottaConfiguration().setCacheXA(true); } SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, elementValueComparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager().getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); wrappedStore = new JtaLocalTransactionStore(localTransactionStore, transactionManagerLookup, cacheManager.getTransactionController()); } else if (configuration.isLocalTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); wrappedStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager() .getOrCreateTransactionIDFactory(), softLockManager, this, store, elementValueComparator); } else { throw new IllegalStateException("Method should called only with a transactional configuration"); } return wrappedStore; }
static CopyStrategyHandler getCopyStrategyHandler(final Ehcache cache) { if (cache.getCacheConfiguration().isXaTransactional() || cache.getCacheConfiguration().isXaStrictTransactional() || cache.getCacheConfiguration().isLocalTransactional()) { return new TxCopyStrategyHandler(cache.getCacheConfiguration().isCopyOnRead(), cache.getCacheConfiguration().isCopyOnWrite(), cache.getCacheConfiguration().getCopyStrategy(), cache.getCacheConfiguration().getClassLoader()); } else if (cache.getCacheConfiguration().isCopyOnRead() || cache.getCacheConfiguration().isCopyOnWrite()) { return new CopyStrategyHandler(cache.getCacheConfiguration().isCopyOnRead(), cache.getCacheConfiguration().isCopyOnWrite(), cache.getCacheConfiguration().getCopyStrategy(), cache.getCacheConfiguration().getClassLoader()); } else { return NO_COPY_STRATEGY_HANDLER; } }
if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName()
if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName()