Package org.jboss.cache.config

Examples of org.jboss.cache.config.EvictionConfig


                  "         <property name=\"minTimeToLive\" value=\"7\"></property>\n" +
                  "      </default>\n" +
                  "   </eviction>";
      try
      {
         EvictionConfig config = getEvictionConfig(xml, false);
         assert false : "Should throw ConfigurationException!";
      }
      catch (ConfigurationException good)
      {
         // expected
View Full Code Here


                  "      <region name=\"/org/jboss/xyz\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\" eventQueueSize=\"21\">\n" +
                  "         <property name=\"maxNodes\" value=\"2103\"></property>\n" +
                  "         <property name=\"timeToLive\" value=\"22\"></property>\n" +
                  "      </region>\n" +
                  "   </eviction>";
      EvictionConfig config = getEvictionConfig(xml, false);
      //tests the defaults
      assert config.getWakeupInterval() == 5;
      assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig;
      assert config.getDefaultEvictionRegionConfig().getEventQueueSize() == 123456;
      assert config.getEvictionRegionConfigs().size() == 2;

      //test first region config
      EvictionRegionConfig erConfig1 = config.getDefaultEvictionRegionConfig();
      erConfig1.getRegionFqn().equals(Fqn.ROOT);
      MRUAlgorithmConfig defaultPolicyConfig = (MRUAlgorithmConfig) erConfig1.getEvictionAlgorithmConfig();
      assert defaultPolicyConfig.getMaxNodes() == 6;
      assert defaultPolicyConfig.getMinTimeToLive() == 7;

      //test second region config
      EvictionRegionConfig erConfig2 = config.getEvictionRegionConfigs().get(0);
      assert erConfig2.getEventQueueSize() == 123456 : "Got " + erConfig2.getEventQueueSize();
      assert erConfig2.getRegionFqn().equals(Fqn.fromString("/org/jboss/data"));
      MRUAlgorithmConfig mruConfiguration = (MRUAlgorithmConfig) erConfig2.getEvictionAlgorithmConfig();
      assert mruConfiguration.getMinTimeToLive() == 1002;
      assert mruConfiguration.getMaxNodes() == 2021;

      //test 3rd region config
      EvictionRegionConfig erConfig3 = config.getEvictionRegionConfigs().get(1);
      assert erConfig3.getEventQueueSize() == 21;
      assert erConfig3.getRegionFqn().equals(Fqn.fromString("/org/jboss/xyz"));
      LRUAlgorithmConfig lruConfiguration = (LRUAlgorithmConfig) erConfig3.getEvictionAlgorithmConfig();
      assert lruConfiguration.getTimeToLive() == 22;
      assert lruConfiguration.getMaxNodes() == 2103;

      assert config.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
   }
View Full Code Here

                  "      <region name=\"/lfu\">\n" +
                  "         <property name=\"maxNodes\" value=\"5000\"></property>\n" +
                  "         <property name=\"timeToLive\" value=\"1000000\"></property>\n" +
                  "      </region>\n" +
                  "   </eviction>";
      EvictionConfig evConfig = getEvictionConfig(xml, false);
      EvictionRegionConfig evictionRegionConfig = evConfig.getDefaultEvictionRegionConfig();
      assert evictionRegionConfig.getRegionName().equals(Fqn.ROOT.toString()) : "Was " + evictionRegionConfig.getRegionName();
      assert ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive() == 1000000;

      assert evConfig.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName());
   }
View Full Code Here

            "   <eviction wakeUpInterval=\"5000\">\n" +
                  "      <region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
                  "         <property name=\"timeToLive\">1002</property>\n" +
                  "      </region>\n" +
                  "   </eviction>";
      EvictionConfig ec = getEvictionConfig(xml, false);
      assert ec.getEvictionRegionConfigs().get(0).getEventQueueSize() == EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
   }
View Full Code Here

      }
      catch (Exception e)
      {
         throw new ConfigurationException(e);
      }
      EvictionConfig cfg = parser.parseEvictionElement(el);
      if (validate)
      {
         cfg.getDefaultEvictionRegionConfig().validate();
         for (EvictionRegionConfig erc : cfg.getEvictionRegionConfigs()) erc.validate();
      }
      return cfg;
   }
View Full Code Here

                  "         <property name=\"minNodes\">1000</property>\n" +
                  "      </region>\n" +
                  "      <region name=\"/two\" actionPolicyClass=\"" + DefaultEvictionActionPolicy.class.getName() + "\">\n" +
                  "      </region>\n" +
                  "   </eviction>";
      EvictionConfig config = getEvictionConfig(xml, false);

      // default region
      assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() instanceof NullEvictionAlgorithmConfig;
      assert config.getDefaultEvictionRegionConfig().getEvictionActionPolicyClassName().equals(RemoveOnEvictActionPolicy.class.getName());

      // region /one
      assert findRegionConfig(config, "/one").getEvictionAlgorithmConfig() instanceof LFUAlgorithmConfig;
      assert findRegionConfig(config, "/one").getEvictionActionPolicyClassName().equals(RemoveOnEvictActionPolicy.class.getName());
View Full Code Here

   }

   void initCaches() throws Exception
   {
      Configuration config = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new FIFOAlgorithmConfig(maxNodes), 2000000), 0);
      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, getClass());// read in generic local xml
   }
View Full Code Here

            "</region></eviction>";
      Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
      boolean caught = false;
      try
      {
         EvictionConfig ec = new EvictionElementParser().parseEvictionElement(element);
         ec.getEvictionRegionConfigs().get(0).validate();
      }
      catch (ConfigurationException ce)
      {
         caught = true;
      }
View Full Code Here

      return cacheLoaderConfig;
   }

   private EvictionConfig buildEvictionConfig()
   {
      return new EvictionConfig(
            new EvictionRegionConfig(
                  Fqn.ROOT,
                  new LRUAlgorithmConfig(1000000, 5000)
            ),
            200);
View Full Code Here

{
   public EvictionAlgorithm createAndAssignToRegion(String fqnString, RegionManager regionManager, EvictionAlgorithmConfig config)
   {
      Fqn fqn = Fqn.fromString(fqnString);
      Configuration c = new Configuration();
      EvictionConfig evictionConfig = new EvictionConfig();
      evictionConfig.setWakeupInterval(-1);
      c.setEvictionConfig(evictionConfig);
      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, config);
      c.getEvictionConfig().addEvictionRegionConfig(erc);
      CacheSPI mockCache = EasyMock.createNiceMock(CacheSPI.class);
      EasyMock.replay(mockCache);
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.