private CacheCluster getCacheCluster() { CacheCluster cacheCluster; try { cacheCluster = getCacheManager().getCluster(ClusterScheme.TERRACOTTA); } catch (ClusterSchemeNotAvailableException e) { LOG.info("Terracotta ClusterScheme is not available, using ClusterScheme.NONE"); cacheCluster = getCacheManager().getCluster(ClusterScheme.NONE); } return cacheCluster; }
/** * For use by CacheManager. * * @param cacheManager the CacheManager for this cache to use. */ public void setCacheManager(CacheManager cacheManager) { CacheManager oldValue = getCacheManager(); this.cacheManager = cacheManager; firePropertyChange("CacheManager", oldValue, cacheManager); }
@Override public void clusterRejoined(ClusterNode oldNode, ClusterNode newNode) { if (newNode.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { mostRecentRejoinTimeStamp = System.currentTimeMillis(); clusterObserver.end(ClusterEventOutcomes.REJOINED); } }
@Override public void clusterOnline(ClusterNode node) { if (node.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { clusterObserver.end(ClusterEventOutcomes.ONLINE); } }
@Override public void clusterOffline(ClusterNode node) { if (node.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { clusterObserver.end(ClusterEventOutcomes.OFFLINE); } }
private boolean skipUpdateAccessStatistics(Element element) { if (configuration.isFrozen()) { boolean forLifetime = element.isEternal(); boolean forHeap = configuration.getMaxEntriesLocalHeap() > 0 || configuration.getMaxBytesLocalHeap() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalHeapSet(); boolean forDisk = configuration.isOverflowToDisk() && (configuration.getMaxEntriesLocalDisk() > 0 || configuration.getMaxBytesLocalDisk() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()); return !(forLifetime || forHeap || forDisk); } else { return false; } }
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; }
} else if (configuration.isXaTransactional()) { SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); LocalTransactionStore localTransactionStore = new LocalTransactionStore(getCacheManager().getTransactionController(), getCacheManager().getOrCreateTransactionIDFactory(), softLockManager, this, store, comparator); 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, comparator); } else {
/** * Create using the given cache. * * @param cache cache */ public WriteBehindManager(final Cache cache, final Store store) { if (cache.isTerracottaClustered()) { writeBehind = ((TerracottaStore)store).createWriteBehind(); } else if (cache.getCacheConfiguration().getPersistenceConfiguration() != null && cache.getCacheConfiguration().getPersistenceConfiguration().getStrategy() == Strategy.LOCALRESTARTABLE) { writeBehind = cache.getCacheManager().getFeaturesManager().createWriteBehind(cache); } else { writeBehind = new WriteBehindQueueManager(cache.getCacheConfiguration()); } }
/** * For use by CacheManager. * * @param cacheManager the CacheManager for this cache to use. */ public void setCacheManager(CacheManager cacheManager) { CacheManager oldValue = getCacheManager(); this.cacheManager = cacheManager; firePropertyChange("CacheManager", oldValue, cacheManager); }
public void shutdown() { try { dataCache.getCacheManager().shutdown(); } catch ( Exception e ) { logger.debug( "Failed to shut-down cache", e ); // ignore it .. } } }
public void shutdown() { try { dataCache.getCacheManager().shutdown(); } catch ( Exception e ) { logger.debug( "Failed to shut-down cache", e ); // ignore it .. } } }
private CacheCluster getCacheCluster() { CacheCluster cacheCluster; try { cacheCluster = getCacheManager().getCluster(ClusterScheme.TERRACOTTA); } catch (ClusterSchemeNotAvailableException e) { LOG.info("Terracotta ClusterScheme is not available, using ClusterScheme.NONE"); cacheCluster = getCacheManager().getCluster(ClusterScheme.NONE); } return cacheCluster; }
/** * For use by CacheManager. * * @param cacheManager the CacheManager for this cache to use. */ public void setCacheManager(CacheManager cacheManager) { CacheManager oldValue = getCacheManager(); this.cacheManager = cacheManager; firePropertyChange("CacheManager", oldValue, cacheManager); }
SizeOfEngine sizeOfEngine = cacheManager.createSizeOfEngine(this); onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalHeapSet()) { onHeapPool = getCacheManager().getOnHeapPool(); } else { onHeapPool = new UnboundedPool(); PoolEvictor evictor = new FromLargestCachePoolEvictor(); onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) { onDiskPool = getCacheManager().getOnDiskPool(); } else { onDiskPool = new UnboundedPool();
getCacheManager().getClusteredInstanceFactory().unlinkCache(getName());
@Override public void clusterRejoined(ClusterNode oldNode, ClusterNode newNode) { if (newNode.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { mostRecentRejoinTimeStamp = System.currentTimeMillis(); clusterObserver.end(ClusterEventOutcomes.REJOINED); } }
@Override public void clusterRejoined(ClusterNode oldNode, ClusterNode newNode) { if (newNode.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { mostRecentRejoinTimeStamp = System.currentTimeMillis(); clusterObserver.end(ClusterEventOutcomes.REJOINED); } }
@Override public void clusterOffline(ClusterNode node) { if (node.equals(this.cache.getCacheManager().getCluster(ClusterScheme.TERRACOTTA).getCurrentNode())) { clusterObserver.end(ClusterEventOutcomes.OFFLINE); } }
private boolean skipUpdateAccessStatistics(Element element) { if (configuration.isFrozen()) { boolean forLifetime = element.isEternal(); boolean forHeap = configuration.getMaxEntriesLocalHeap() > 0 || configuration.getMaxBytesLocalHeap() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalHeapSet(); boolean forDisk = configuration.isOverflowToDisk() && (configuration.getMaxEntriesLocalDisk() > 0 || configuration.getMaxBytesLocalDisk() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()); return !(forLifetime || forHeap || forDisk); } else { return false; } }