/** * 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; } }
TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, comparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(),
synchronized public void initialize(String repositoryName, Model model, RowMapper rowMapper, InvalidationsPropagator invalidationsPropagator, Map<String, String> properties) { this.model = model; this.rowMapper = rowMapper; this.invalidationsPropagator = invalidationsPropagator; invalidationsPropagator.addQueue(invalidationsQueue); if (cacheManager == null) { if (properties.containsKey(EHCACHE_FILE_PROP)) { String value = properties.get(EHCACHE_FILE_PROP); log.info("Creating ehcache manager for VCS, using ehcache file: " + value); cacheManager = CacheManager.create(value); } else { log.info("Creating ehcache manager for VCS, No ehcache file provided"); cacheManager = CacheManager.create(); } isXA = cacheManager.getConfiguration().getCacheConfigurations().get(CACHE_NAME).isXaTransactional(); // Exposes cache to JMX MBeanServer mBeanServer = Framework.getService(ServerLocator.class).lookupServer(); ManagementService.registerMBeans(cacheManager, mBeanServer, true, true, true, true); } rowMapperCount.incrementAndGet(); cache = cacheManager.getCache(CACHE_NAME); setMetrics(repositoryName); }
/** * 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 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; } }
TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, comparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(),
TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, store, comparator); } else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(),
if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(),