Example #1
0
  public void updateConfiguration(
      RetentionConfiguration newRetentionConfig, CachingConfiguration newCachingConfig)
      throws InvalidConfigurationException {
    for (Iterator<String> nameIter = caches.keySet().iterator(); nameIter.hasNext(); ) {
      String name = nameIter.next();
      if (!newCachingConfig.findLevelForLevelName(name).isPresent()) {
        caches.get(name).shutdown();
        nameIter.remove();
        if (evictionStrategyMap.containsKey(name)) {
          evictionStrategyMap.remove(name);
        }
        log.debug("Dropped cache for {}", name);
      }
    }
    checkAllLevelCaches();
    updateEvictionStrategies();

    log.debug("finished all updateConfiguration Acitivies!");
  }
Example #2
0
 private void updateCachingLevel(RetentionLevel level) {
   Optional<CachingLevel> cachingLevel =
       environment.cachingConfiguration().findLevelForLevelName(level.name());
   Optional<CachingLevel> oldCachingLevel = cachingConfig.findLevelForLevelName(level.name());
   if (!cachingLevel.isPresent()) {
     log.warn("RetentionLevel with unconfigured Cache " + level.name());
   } else if (!caches.containsKey(level.name()) || !oldCachingLevel.isPresent()) {
     caches.put(level.name(), new LevelCache(environment, cachingLevel.get()));
     if (levelIsAccessLevel(level) && !evictionStrategyMap.containsKey(level.name())) {
       evictionStrategyMap.put(
           level.name(),
           new NaiveLRUStrategy(
               level.name(),
               metricStorage,
               findAllFollowingLevelCaches(level),
               cachingLevel.get().visibleCacheSize()));
     }
     log.debug("created new Cache for " + level.name());
   } else if (oldCachingLevel.get().equals(cachingLevel.get())) {
     log.debug("no changes in cachingLevel " + level.name());
   } else if (oldCachingLevel.get().cacheLineWidth() != cachingLevel.get().cacheLineWidth()) {
     caches.remove(oldCachingLevel.get().name());
     caches.put(level.name(), new LevelCache(environment, cachingLevel.get()));
     log.debug("dropped and created new cache for " + level.name());
   } else {
     log.debug("resizing level cache " + level.name());
     if (levelIsAccessLevel(level)) {
       caches
           .get(oldCachingLevel.get().name())
           .resizeAccessLevel(cachingLevel.get(), evictionStrategyMap.get(level.name()));
       evictionStrategyMap.get(level.name()).resize(cachingLevel.get().visibleCacheSize());
     } else {
       caches.get(oldCachingLevel.get().name()).resize(cachingLevel.get());
     }
   }
 }