&& config.getDefaultCacheConfiguration().isTerracottaClustered() ) { setupHibernateTimeoutBehavior( config.getDefaultCacheConfiguration() if ( cacheConfig.isTerracottaClustered() ) { setupHibernateTimeoutBehavior( cacheConfig.getTerracottaConfiguration().getNonstopConfiguration() );
/** * Accessor */ public boolean isTerracottaClustered() { return cacheConfiguration.isTerracottaClustered(); }
/** * Indicates whether this cache is clustered by Terracotta * * @return {@code true} when the cache is clustered by Terracotta; or {@code false} otherwise */ public boolean isTerracottaClustered() { return configuration.isTerracottaClustered(); }
private boolean hasTerracottaClusteredCaches() { if (defaultCacheConfiguration != null && defaultCacheConfiguration.isTerracottaClustered()) { return true; } else { for (CacheConfiguration config : cacheConfigurations.values()) { if (config.isTerracottaClustered()) { return true; } } } return false; }
/** * {@inheritDoc} */ public boolean isTerracottaHibernateCache(String region) { Cache cache = cacheManager.getCache(region); if (cache != null) { return cache.getCacheConfiguration().isTerracottaClustered(); } else { return false; } }
/** * {@inheritDoc} */ @Override public boolean isTerracottaClustered() { return this.cache.getCacheConfiguration().isTerracottaClustered(); }
/** * Is the cache configured with Terracotta clustering? */ public boolean isTerracottaClustered() { return cache.getCacheConfiguration().isTerracottaClustered(); }
/** * {@inheritDoc} */ public String[] getTerracottaHibernateCacheRegionNames() { ArrayList<String> rv = new ArrayList<String>(); for (String name : cacheManager.getCacheNames()) { Cache cache = cacheManager.getCache(name); if (cache != null) { if (cache.getCacheConfiguration().isTerracottaClustered()) { rv.add(name); } } } return rv.toArray(new String[] {}); }
private void warnSizeOfPolicyConfiguration() { if (isTerracottaClustered() && getSizeOfPolicyConfiguration() != null) { LOG.warn("Terracotta clustered cache: " + getName() + " has a sizeOf policy configuration specificed. " + "SizeOfPolicyConfiguration is unsupported for Terracotta clustered caches."); } }
/** * {@inheritDoc} */ @Override public boolean isNodeBulkLoadEnabled() { return cache.getCacheConfiguration().isTerracottaClustered() && cache.isNodeBulkLoadEnabled(); }
/** * {@inheritDoc} */ public void notifyElementPut(Ehcache cache, Element element) throws CacheException { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyElementPut(cache, element); } }
/** * {@inheritDoc} */ public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyElementUpdated(cache, element); } }
/** * {@inheritDoc} */ public void notifyRemoveAll(Ehcache cache) { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyRemoveAll(cache); } }
/** * {@inheritDoc} */ public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyElementRemoved(cache, element); } }
/** * {@inheritDoc} */ public void notifyElementExpired(Ehcache cache, Element element) { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyElementExpired(cache, element); } }
private CacheLockProvider createCacheLockProvider() { Object context = underlyingCache.getInternalContext(); if (underlyingCache.getCacheConfiguration().isTerracottaClustered() && context != null) { return (CacheLockProvider) context; } else { return new StripedReadWriteLockSync(stripes); } }
/** * {@inheritDoc} */ public void notifyElementEvicted(Ehcache cache, Element element) { if (cache.getCacheConfiguration().isTerracottaClustered()) { createCacheEventReplicator(cache).notifyElementEvicted(cache, element); } }
/** * Create a cache manager configuration from the supplied url, correcting it for Hibernate compatibility. * <p> * Currently correcting for Hibernate compatibility means simply switching any identity based value modes to serialization. */ static Configuration loadAndCorrectConfiguration(URL url) { Configuration config = ConfigurationFactory.parseConfiguration(url); if (config.getDefaultCacheConfiguration() != null && config.getDefaultCacheConfiguration().isTerracottaClustered()) { setupHibernateTimeoutBehavior(config.getDefaultCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration()); } for (CacheConfiguration cacheConfig : config.getCacheConfigurations().values()) { if (cacheConfig.isTerracottaClustered()) { setupHibernateTimeoutBehavior(cacheConfig.getTerracottaConfiguration().getNonstopConfiguration()); } } return config; }
private void verifyClusteredCacheConfiguration(final Collection<ConfigError> errors) { if (!isTerracottaClustered()) { return; } if (getPinningConfiguration() != null && getPinningConfiguration().getStore() == PinningConfiguration.Store.INCACHE && getMaxElementsOnDisk() != 0) { errors.add(new CacheConfigError("maxElementsOnDisk may not be used on a pinned cache.", getName())); } if (maxEntriesLocalDiskExplicitlySet) { errors.add(new CacheConfigError("You can't set maxEntriesLocalDisk when clustering your cache with Terracotta, " + "local disks won't be used! To control elements going in the cache cluster wide, " + "use maxEntriesInCache instead", getName())); } if (maxBytesLocalDiskExplicitlySet) { errors.add(new CacheConfigError("You can't set maxBytesLocalDisk when clustering your cache with Terracotta", getName())); } if (maxElementsOnDisk != DEFAULT_MAX_ELEMENTS_ON_DISK) { errors.add(new CacheConfigError("maxElementsOnDisk is not used with clustered caches. Use maxEntriesInCache " + "to set maximum cache size.", getName())); } }
/** * {@inheritDoc} */ public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } }