private static boolean isPinnedInCache(final CacheConfiguration ehcacheConfig) { return ehcacheConfig.getPinningConfiguration() != null && ehcacheConfig.getPinningConfiguration().getStore() == PinningConfiguration.Store.INCACHE; }
private static boolean isPinnedInLocalMemory(CacheConfiguration ehcacheConfig) { return ehcacheConfig.getPinningConfiguration() != null && ehcacheConfig.getPinningConfiguration().getStore() == PinningConfiguration.Store.LOCALMEMORY; }
/** * {@inheritDoc} */ @Override public boolean isPinned() { return cache.getCacheConfiguration().getPinningConfiguration() != null; }
private boolean determineCachePinned(CacheConfiguration cacheConfiguration) { PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); if (pinningConfiguration == null) { return false; } switch (pinningConfiguration.getStore()) { case LOCALMEMORY: return false; case INCACHE: return true; default: throw new IllegalArgumentException(); } }
private void checkIfCachePinned(long maxEntriesInCache) { if (maxEntriesInCache != DEFAULT_MAX_ENTRIES_IN_CACHE && getPinningConfiguration() != null && Store.INCACHE.equals(getPinningConfiguration().getStore())) { throw new InvalidConfigurationException("Setting maxEntriesInCache on an in-cache pinned cache is not legal"); } }
private static boolean determineCachePinned(CacheConfiguration cacheConfiguration) { PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); if (pinningConfiguration == null) { return false; } switch (pinningConfiguration.getStore()) { case LOCALMEMORY: return false; case INCACHE: return cacheConfiguration.isOverflowToDisk(); default: throw new IllegalArgumentException(); } }
private static void addPinningElement(NodeElement element, CacheConfiguration cacheConfiguration) { PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); if (pinningConfiguration != null) { element.addChildElement(new PinningConfigurationElement(element, pinningConfiguration)); } }
private void logOnRemoveAllIfPinnedCache() { PinningConfiguration pinningConfiguration = getCacheConfiguration().getPinningConfiguration(); if (pinningConfiguration != null && PinningConfiguration.Store.INCACHE.equals(pinningConfiguration.getStore())) { LOG.warn("Data availability impacted:\n" + "****************************************************************************************\n" + "************************** removeAll called on a pinned cache **************************\n" + "****************************************************************************************"); } }
private boolean determineCachePinned(CacheConfiguration cacheConfiguration) { PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); if (pinningConfiguration == null) { return false; } switch (pinningConfiguration.getStore()) { case LOCALMEMORY: return false; case INCACHE: return !cacheConfiguration.isOverflowToOffHeap() && !cacheConfiguration.isOverflowToDisk(); default: throw new IllegalArgumentException(); } }
private boolean determineStorePinned(CacheConfiguration cacheConfiguration) { PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); if (pinningConfiguration == null) { return false; } switch (pinningConfiguration.getStore()) { case LOCALMEMORY: return false; case INCACHE: return !cacheConfiguration.isOverflowToOffHeap() && !cacheConfiguration.isOverflowToDisk(); default: throw new IllegalArgumentException(); } }
/** * {@inheritDoc} */ @Override public String getPinnedToStore() { PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration(); return pinningConfig != null ? pinningConfig.getStore().name() : "na"; }
/** * Returns a {@link String} representation of {@link Cache}. */ @Override public String toString() { StringBuilder dump = new StringBuilder(); dump.append("[") .append(" name = ").append(configuration.getName()) .append(" status = ").append(cacheStatus.getStatus()) .append(" eternal = ").append(configuration.isEternal()) .append(" overflowToDisk = ").append(configuration.isOverflowToDisk()) .append(" maxEntriesLocalHeap = ").append(configuration.getMaxEntriesLocalHeap()) .append(" maxEntriesLocalDisk = ").append(configuration.getMaxEntriesLocalDisk()) .append(" memoryStoreEvictionPolicy = ").append(configuration.getMemoryStoreEvictionPolicy()) .append(" timeToLiveSeconds = ").append(configuration.getTimeToLiveSeconds()) .append(" timeToIdleSeconds = ").append(configuration.getTimeToIdleSeconds()) .append(" persistence = ").append(configuration.getPersistenceConfiguration() == null ? "none" : configuration.getPersistenceConfiguration().getStrategy()) .append(" diskExpiryThreadIntervalSeconds = ").append(configuration.getDiskExpiryThreadIntervalSeconds()) .append(registeredEventListeners) .append(" maxBytesLocalHeap = ").append(configuration.getMaxBytesLocalHeap()) .append(" overflowToOffHeap = ").append(configuration.isOverflowToOffHeap()) .append(" maxBytesLocalOffHeap = ").append(configuration.getMaxBytesLocalOffHeap()) .append(" maxBytesLocalDisk = ").append(configuration.getMaxBytesLocalDisk()) .append(" pinned = ") .append(configuration.getPinningConfiguration() != null ? configuration.getPinningConfiguration().getStore().name() : "false") .append(" ]"); return dump.toString(); }
private static void validateConfig(Ehcache ehcache) { CacheConfiguration cacheConfiguration = ehcache.getCacheConfiguration(); final TerracottaConfiguration terracottaConfiguration = cacheConfiguration.getTerracottaConfiguration(); List<ConfigError> errors = new ArrayList<ConfigError>(); if (terracottaConfiguration == null || !terracottaConfiguration.isClustered()) { throw new InvalidConfigurationException( "Cannot create clustered store for non-terracotta clustered caches"); } MemoryStoreEvictionPolicy policy = cacheConfiguration.getMemoryStoreEvictionPolicy(); if (policy == MemoryStoreEvictionPolicy.FIFO || policy == MemoryStoreEvictionPolicy.LFU) { errors.add(new ConfigError("Policy '" + policy + "' is not a supported memory store eviction policy.")); } if (cacheConfiguration.isOverflowToDisk()) { if (LOG.isWarnEnabled()) { LOG.warn("Persistence on disk on the local node is not supported with a Terracotta clustered ehcache store. Configure the Terracotta server array to be persistent instead."); } } boolean cachePinned = cacheConfiguration.getPinningConfiguration() != null && cacheConfiguration.getPinningConfiguration().getStore() == PinningConfiguration.Store.INCACHE; if (cachePinned && cacheConfiguration.getMaxEntriesInCache() != CacheConfiguration.DEFAULT_MAX_ENTRIES_IN_CACHE) { errors.add(new ConfigError("Cache pinning is not supported with maxEntriesInCache")); } if (errors.size() > 0) { throw new InvalidConfigurationException(errors); } }
private static long getCachingTierMaxEntryCount(final Ehcache cache) { final PinningConfiguration pinningConfiguration = cache.getCacheConfiguration().getPinningConfiguration(); if (pinningConfiguration != null && pinningConfiguration.getStore() != PinningConfiguration.Store.INCACHE) { return 0; } return cache.getCacheConfiguration().getMaxEntriesLocalHeap(); }
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())); } }
((TerracottaStore)store).quickClear(); cache.getCacheEventNotificationService().notifyRemoveAll(false); PinningConfiguration pinningConfiguration = cache.getCacheConfiguration().getPinningConfiguration(); if (pinningConfiguration != null && PinningConfiguration.Store.INCACHE.equals(pinningConfiguration.getStore())) { LOG.warn("Data availability impacted:\n" +
/** * {@inheritDoc} */ @Override public boolean isPinned() { return cache.getCacheConfiguration().getPinningConfiguration() != null; }
/** * {@inheritDoc} */ public boolean isPinned() { return cache.getCacheConfiguration().getPinningConfiguration() != null; }
private void checkIfCachePinned(long maxEntriesInCache) { if (maxEntriesInCache != DEFAULT_MAX_ENTRIES_IN_CACHE && getPinningConfiguration() != null && Store.INCACHE.equals(getPinningConfiguration().getStore())) { throw new InvalidConfigurationException("Setting maxEntriesInCache on an in-cache pinned cache is not legal"); } }
/** * {@inheritDoc} */ @Override public String getPinnedToStore() { PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration(); return pinningConfig != null ? pinningConfig.getStore().name() : "na"; }