Package org.jboss.cache.config

Examples of org.jboss.cache.config.EvictionConfig


      exp.setMaxNodes(maxSize);

      EvictionRegionConfig evictionRegionConfig = new EvictionRegionConfig(RegionManagerImpl.DEFAULT_REGION);
      evictionRegionConfig.setEvictionAlgorithmConfig(exp);

      EvictionConfig evictConfig = new EvictionConfig();
      evictConfig.setDefaultEvictionRegionConfig(evictionRegionConfig);
      evictConfig.setWakeupInterval(wakeupInterval);


      Configuration config = new Configuration();
      config.setCacheMode(Configuration.CacheMode.LOCAL);
      config.setEvictionConfig(evictConfig);
View Full Code Here


        super();
        cacheFactory = new DefaultCacheFactory<String, Object>();
    }

    private void setupMaxSizeEviction(FacesContext facesContext, Cache<String, Object> cache) {
        EvictionConfig evictionConfig = cache.getConfiguration().getEvictionConfig();
        EvictionAlgorithmConfig evictionAlgorithmConfig = evictionConfig.getDefaultEvictionRegionConfig()
            .getEvictionAlgorithmConfig();

        if (evictionAlgorithmConfig instanceof EvictionAlgorithmConfigBase) {
            EvictionAlgorithmConfigBase baseEvicitonConfig = (EvictionAlgorithmConfigBase) evictionAlgorithmConfig;
            if (baseEvicitonConfig.getMaxNodes() <= 0) {
View Full Code Here

            int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize);
            expirationAlgorithm.setMaxNodes(maxCacheSize);

            evictionRegionConfig.setEvictionAlgorithmConfig(expirationAlgorithm);

            EvictionConfig evictionConfig = new EvictionConfig(evictionRegionConfig);

            evictionConfig.setWakeupInterval(1000);
            configuration.setEvictionConfig(evictionConfig);
            cache = cacheFactory.createCache(configuration);
        }

        return new JBossCacheCache(cache);
View Full Code Here

    * @param cache the cache to which we want to add the region
    * @param cfg the configuration from which the Eviction Algorithm Config must be extracted
    */
   private static <K, V> void addEvictionRegion(Fqn<String> fqn, Cache<K, V> cache, Configuration cfg)
   {
      EvictionConfig ec = cfg.getEvictionConfig();
      // Create the region and set the config
      Region region = cache.getRegion(fqn, true);
      if (ec != null && ec.getDefaultEvictionRegionConfig() != null)
      {
         EvictionRegionConfig erc = new EvictionRegionConfig(fqn);
         erc.setDefaults(ec.getDefaultEvictionRegionConfig());
         region.setEvictionRegionConfig(erc);
      }
   }
View Full Code Here

      getConfiguration().setClusterConfig(cluster_props);
   }

   public void setEvictionPolicyConfig(Element config)
   {
      EvictionConfig ec = null;
      if (config != null)
      {
         try
         {
            ec = evictionElementParser.parseEvictionElement(config);
View Full Code Here

   public EvictionConfig parseEvictionElement(Element evictionElement)
   {
      assertNotLegacyElement(evictionElement);
     
      EvictionConfig evictionConfig = new EvictionConfig();

      String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
      if (existsAttribute(wakeUpInterval))
      {
         evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
      }
      else
      {
         throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
      }

      List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
      Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);

      if (defaultRegion != null)
      {
         EvictionRegionConfig defaultRegionConfig = getEvictionRegionConfig(defaultRegion, null, true);
         if (defaultRegionConfig.getEvictionAlgorithmConfig() == null)
            throw new MissingPolicyException("Default eviction region should have an evictionAlgorithmClass defined.");
         evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig);
      }

      NodeList regions = evictionElement.getElementsByTagName("region");
      for (int i = 0; i < regions.getLength(); i++)
      {
         Element regionConfig = (Element) regions.item(i);
         EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
         evictionConfig.applyDefaults(erc);
         evictionRegionConfigs.add(erc);
      }
      evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
      return evictionConfig;
   }
View Full Code Here

    * @param cache the cache to which we want to add the region
    * @param cfg the configuration from which the Eviction Algorithm Config must be extracted
    */
   private static <K, V> void addEvictionRegion(Fqn<String> fqn, Cache<K, V> cache, Configuration cfg)
   {
      EvictionConfig ec = cfg.getEvictionConfig();
      // Create the region and set the config
      Region region = cache.getRegion(fqn, true);
      if (ec != null && ec.getDefaultEvictionRegionConfig() != null)
      {
         EvictionRegionConfig erc = new EvictionRegionConfig(fqn);
         erc.setDefaults(ec.getDefaultEvictionRegionConfig());
         region.setEvictionRegionConfig(erc);
      }
   }
View Full Code Here

   }

   void initCaches() throws Exception
   {
      Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new FIFOAlgorithmConfig(maxNodes), 2000000), 200);
      evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new FIFOAlgorithmConfig(5)));
      config.setEvictionConfig(evConfig);
      config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
      config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
      cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, true);// read in generic local xml
   }
View Full Code Here


   public void testUsingEvictionPolicy()
   {
      Configuration c = new Configuration();
      c.setEvictionConfig(new EvictionConfig());
      EvictionConfig evConfig = c.getEvictionConfig();
      evConfig.setWakeupIntervalSeconds(3);
      evConfig.setDefaultEventQueueSize(20000);
      evConfig.setDefaultEvictionPolicyClass(FIFOPolicy.class.getName());
      List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
      erConfigs.add(createEvictionRegionConfig("/_default_", 2, new FIFOConfiguration()));
      evConfig.setEvictionRegionConfigs(erConfigs);
      doTest(c);
   }
View Full Code Here

   public void testUsingCustomEvictionPolicy()
   {
      try
      {
         Configuration c = new Configuration();
         c.setEvictionConfig(new EvictionConfig());
         EvictionConfig evConfig = c.getEvictionConfig();
         evConfig.setWakeupIntervalSeconds(3);
         evConfig.setDefaultEventQueueSize(20000);
         evConfig.setDefaultEvictionPolicyClass(MyPolicy.class.getName());
         List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
         erConfigs.add(createEvictionRegionConfig("/_default_", 2, new MyPolicyConfig()));
         evConfig.setEvictionRegionConfigs(erConfigs);
         doTest(c);
         assert false : "Should throw exception";
      }
      catch (UnsupportedEvictionImplException ce)
      {
View Full Code Here

TOP

Related Classes of org.jboss.cache.config.EvictionConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.