Package org.jboss.cache.config

Examples of org.jboss.cache.config.EvictionConfig


                  "               <attribute name=\"maxNodes\">5000</attribute>\n" +
                  "            </region>\n" +
                  "         </config>\n" +
                  "      </attribute>";
      Element oldEl = XmlConfigHelper.stringToElementInCoreNS(oldFormat);
      EvictionConfig oldEvConfig = XmlConfigurationParser2x.parseEvictionConfig(oldEl);
      //this will be transformed in root region, so make sure that the root region will be corectly set up
      MRUAlgorithmConfig defaultAlgorithmConfig = (MRUAlgorithmConfig) oldEvConfig.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig();
      assert oldEvConfig.getDefaultEvictionRegionConfig().getEventQueueSize() == 1234;
      assert defaultAlgorithmConfig.getEvictionAlgorithmClassName().equals("org.jboss.cache.eviction.MRUAlgorithm");
      assert defaultAlgorithmConfig.getMaxNodes() == 5001;
      assert defaultAlgorithmConfig.getMinTimeToLive() == 1001000;


      assert oldEvConfig.getEvictionRegionConfigs().size() == 1;
      EvictionRegionConfig orgJbossData = oldEvConfig.getEvictionRegionConfigs().get(0);
      assert orgJbossData.getRegionFqn().equals(Fqn.fromString("org/jboss/data"));
      assert orgJbossData.getEvictionAlgorithmConfig().getEvictionAlgorithmClassName().equals("org.jboss.cache.eviction.LRUAlgorithm");
      assert orgJbossData.getEventQueueSize() == 200000;
   }
View Full Code Here


                  "     <property name=\"maxNodes\" value=\"5000\"></property>\n" +
                  "  </region>\n" +
                  "</eviction>";
      Element oldEl = XmlConfigHelper.stringToElementInCoreNS(oldFormat);
      Element newEl = XmlConfigHelper.stringToElementInCoreNS(newFormat);
      EvictionConfig oldEvConfig = XmlConfigurationParser2x.parseEvictionConfig(oldEl);
      EvictionConfig newEvConfig = evictionElementParser.parseEvictionElement(newEl);
      assert oldEvConfig.getDefaultEvictionRegionConfig().equals(newEvConfig.getDefaultEvictionRegionConfig());

      EvictionRegionConfig oldRegionConfig = oldEvConfig.getEvictionRegionConfigs().get(0);
      EvictionRegionConfig newRegionConfig = newEvConfig.getEvictionRegionConfigs().get(0);
      EvictionAlgorithmConfig oldEvictionAlgorithmConfig = oldRegionConfig.getEvictionAlgorithmConfig();
      EvictionAlgorithmConfig newEvictionAlgorithmConfig = newRegionConfig.getEvictionAlgorithmConfig();
      assert oldEvictionAlgorithmConfig.equals(newEvictionAlgorithmConfig);

      assert oldEvConfig.equals(newEvConfig);
View Full Code Here

      assert syncConfig.isUseRegionBasedMarshalling();
   }

   public void testEvictionPolicyConfig()
   {
      EvictionConfig evictionConfig = syncConfig.getEvictionConfig();
      assert "org.jboss.cache.eviction.LRUAlgorithm".equals(evictionConfig.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig().getEvictionAlgorithmClassName());
      assert 200000 == evictionConfig.getDefaultEvictionRegionConfig().getEventQueueSize();
      assert 5 == evictionConfig.getWakeupInterval();

      List<EvictionRegionConfig> regionConfigs = evictionConfig.getEvictionRegionConfigs();
      assert regionConfigs.size() == 2;

      EvictionRegionConfig first = evictionConfig.getDefaultEvictionRegionConfig();
      assert first.getRegionName().equals("/");
      assert first.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig;
      LRUAlgorithmConfig firstConfiguration = (LRUAlgorithmConfig) first.getEvictionAlgorithmConfig();
      assert firstConfiguration.getMaxAge() <= 0;
      assert firstConfiguration.getTimeToLive() == 1000;
View Full Code Here


   public void testUsingEvictionPolicy()
   {
      Configuration c = new Configuration();
      c.setEvictionConfig(new EvictionConfig());
      EvictionConfig evConfig = c.getEvictionConfig();
      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.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

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

   }

   public void testControl()
   {
      Configuration c = new Configuration();
      c.setEvictionConfig(new EvictionConfig());
      EvictionRegionConfig defaultRegion = c.getEvictionConfig().getDefaultEvictionRegionConfig();
      defaultRegion.setEvictionAlgorithmConfig(new FIFOAlgorithmConfig(2));
      doTest(c);
   }
View Full Code Here

   private void doTest(String xml, boolean legacy) throws Exception
   {
      if (legacy)
      {
         EvictionConfig ec = XmlConfigurationParser2x.parseEvictionConfig(XmlConfigHelper.stringToElementInCoreNS(xml));
         Configuration c = new Configuration();
         c.setEvictionConfig(ec);
         doTest(c);
      }
      else
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

    */
   protected void cleanConfigurationTemplate(Cache<Serializable, Object> cache, String region)
   {
      final Configuration config = cache.getConfiguration();
      // Reset the eviction policies
      EvictionConfig evictionConfig = config.getEvictionConfig();
      if (evictionConfig == null)
      {
         // If not eviction config exists, we create an empty one
         evictionConfig = new EvictionConfig();
         config.setEvictionConfig(evictionConfig);
      }
      evictionConfig.setEvictionRegionConfigs(new LinkedList<EvictionRegionConfig>());
   }
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.