private static void validateOverAllocation(RuntimeCfg config, Long newValue) { ArrayList<ConfigError> errors = new ArrayList<ConfigError>(); for (Cache cache : getAllActiveCaches(config.cacheManager)) { CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); errors.addAll(cacheConfiguration.validateCachePools(config.getConfiguration())); errors.addAll(cacheConfiguration.verifyPoolAllocationsBeforeAddingTo(config.cacheManager, newValue, config.getConfiguration().getMaxBytesLocalOffHeap(), config.getConfiguration().getMaxBytesLocalDisk(), null)); } if (!errors.isEmpty()) { throw new InvalidConfigurationException("Can't reduce CacheManager byte tuning by so much", errors); } }
errors.addAll(validateCachePools(configuration));
private static void validateOverAllocation(RuntimeCfg config, Long newValue) { ArrayList<ConfigError> errors = new ArrayList<ConfigError>(); for (Cache cache : getAllActiveCaches(config.cacheManager)) { CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); errors.addAll(cacheConfiguration.validateCachePools(config.getConfiguration())); errors.addAll(cacheConfiguration.verifyPoolAllocationsBeforeAddingTo(config.cacheManager, newValue, config.getConfiguration().getMaxBytesLocalOffHeap(), config.getConfiguration().getMaxBytesLocalDisk(), null)); } if (!errors.isEmpty()) { throw new InvalidConfigurationException("Can't reduce CacheManager byte tuning by so much", errors); } }
private static void validateOverAllocation(RuntimeCfg config, Long newValue) { ArrayList<ConfigError> errors = new ArrayList<ConfigError>(); for (Cache cache : getAllActiveCaches(config.cacheManager)) { CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); errors.addAll(cacheConfiguration.validateCachePools(config.getConfiguration())); errors.addAll(cacheConfiguration.verifyPoolAllocationsBeforeAddingTo(config.cacheManager, newValue, config.getConfiguration().getMaxBytesLocalOffHeap(), config.getConfiguration().getMaxBytesLocalDisk(), null)); } if (!errors.isEmpty()) { throw new InvalidConfigurationException("Can't reduce CacheManager byte tuning by so much", errors); } }
/** * Validates the configuration * @param configuration the CacheManager configuration this is going to be used with * @return the errors in the config */ public Collection<ConfigError> validate(final Configuration configuration) { final Collection<ConfigError> errors = new ArrayList<ConfigError>(); verifyClusteredCacheConfiguration(configuration, errors); if (maxEntriesLocalHeap == null && !configuration.isMaxBytesLocalHeapSet() && maxBytesLocalHeap == null) { errors.add(new CacheConfigError("If your CacheManager has no maxBytesLocalHeap set, you need to either set " + "maxEntriesLocalHeap or maxBytesLocalHeap at the Cache level", getName())); } if (configuration.isMaxBytesLocalHeapSet() && Runtime.getRuntime().maxMemory() - configuration.getMaxBytesLocalHeap() < 0) { errors.add(new ConfigError("You've assigned more memory to the on-heap than the VM can sustain, " + "please adjust your -Xmx setting accordingly")); } //commenting this check until fixed for cachemanger is fixed //if (isOverflowToOffHeapSet() && !maxBytesLocalOffHeapExplicitlySet) { // errors.add(new CacheConfigError("\"overFlowToOffHeap\" is set, but \"maxBytesLocalOffHeap\" is not set.", getName())); //} if (persistenceConfiguration != null && persistenceConfiguration.getStrategy() == null) { errors.add(new ConfigError("Persistence configuration found with no strategy set.")); } errors.addAll(validateCachePools(configuration)); return errors; }
errors.addAll(validateCachePools(configuration));
errors.addAll(validateCachePools(configuration));
@Override void applyChange(final PropertyChangeEvent evt, final RuntimeCfg config) { ArrayList<ConfigError> errors = new ArrayList<ConfigError>(); Long newValue = (Long)evt.getNewValue(); if ((Long) evt.getOldValue() > (Long) evt.getNewValue()) { // Double check for over-allocation again for (Cache cache : getAllActiveCaches(config.cacheManager)) { CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); errors.addAll(cacheConfiguration.validateCachePools(config.getConfiguration())); errors.addAll(cacheConfiguration.verifyPoolAllocationsBeforeAddingTo(config.cacheManager, newValue, config.getConfiguration().getMaxBytesLocalOffHeap(), config.getConfiguration().getMaxBytesLocalDisk())); } } if (!errors.isEmpty()) { throw new InvalidConfigurationException("Can't reduce CacheManager byte tuning by so much", errors); } // Recalculate % based caches long cacheAllocated = 0; for (Cache cache : getAllActiveCaches(config.cacheManager)) { cache.getCacheConfiguration().configCachePools(config.getConfiguration()); long bytesLocalHeap = cache.getCacheConfiguration().getMaxBytesLocalHeap(); cacheAllocated += bytesLocalHeap; } config.cacheManager.getOnHeapPool().setMaxSize(newValue - cacheAllocated); } },