Package org.jboss.cache.config

Examples of org.jboss.cache.config.EvictionRegionConfig


      EvictionConfig ec = c.getEvictionConfig();
      assertEquals("EC queue size", 1000, ec.getDefaultEvictionRegionConfig().getEventQueueSize());
      assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
      assertEquals("EC default pol", LRUAlgorithm.class.getName(), ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig().getEvictionAlgorithmClassName());
      List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
      EvictionRegionConfig erc = ercs.get(0);
      assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName());
      assertEquals("ERC1 queue size", 1000, erc.getEventQueueSize());
      FIFOAlgorithmConfig fifo = (FIFOAlgorithmConfig) erc.getEvictionAlgorithmConfig();
      assertEquals("EPC1 pol", FIFOAlgorithm.class.getName(), fifo.getEvictionAlgorithmClassName());
      assertEquals("EPC1 maxnodes", 5000, fifo.getMaxNodes());
      erc = ercs.get(1);
      assertEquals("ERC2 name", "/test", erc.getRegionName());
      assertEquals("ERC2 queue size", 1000, erc.getEventQueueSize());
      MRUAlgorithmConfig mru = (MRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
      assertEquals("EPC2 pol", MRUAlgorithm.class.getName(), mru.getEvictionAlgorithmClassName());
      assertEquals("EPC2 maxnodes", 10000, mru.getMaxNodes());
      erc = ercs.get(2);
      assertEquals("ERC3 name", "/maxAgeTest", erc.getRegionName());
      assertEquals("ERC3 queue size", 1000, erc.getEventQueueSize());
      LRUAlgorithmConfig lru = (LRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
      assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
      assertEquals("EPC3 maxage", 10, lru.getMaxAge());
      assertEquals("EPC3 ttl", 8, lru.getTimeToLive());

   }
View Full Code Here


   {
      EvictionConfig cfg = new EvictionConfig();
      cfg.setWakeupInterval(1000);
      cfg.setDefaultEventQueueSize(200000);

      EvictionRegionConfig region1 = new EvictionRegionConfig();
      region1.setRegionFqn(Fqn.ROOT);
      LRUAlgorithmConfig epc1 = new LRUAlgorithmConfig();
      epc1.setMaxNodes(5000);
      epc1.setTimeToLive(3000);
      region1.setEvictionAlgorithmConfig(epc1);
      cfg.setDefaultEvictionRegionConfig(region1);

      EvictionRegionConfig region2 = new EvictionRegionConfig();
      region2.setRegionFqn(base);
      LRUAlgorithmConfig epc2 = new LRUAlgorithmConfig();
      epc2.setMaxNodes(100);
      epc2.setTimeToLive(3000);
      region2.setEvictionAlgorithmConfig(epc2);
      cfg.addEvictionRegionConfig(region2);

      return cfg;
   }
View Full Code Here

      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

      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

         cache = setupCache("configs/policyPerRegion-eviction.xml");
         regionManager = cache.getRegionManager();
         assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());

         Region region = regionManager.getRegion("/org/jboss/data", true);
         EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/data"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LFUAlgorithmConfig);
         assertEquals(5000, ((LFUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000, ((LFUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMinNodes());

         region = regionManager.getRegion("/org/jboss/test/data", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/test/data"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig);
         assertEquals(5, ((FIFOAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         region = regionManager.getRegion("/test", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/test"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig);
         assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         region = regionManager.getRegion("/maxAgeTest", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/maxAgeTest"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

         // test the default region. use a region name that isn't defined explicitly in conf file.
         region = regionManager.getRegion("/a/b/c", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.ROOT, region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

      }
      finally
      {
         TestingUtil.killCaches(cache);
View Full Code Here

         cache = setupCache("configs/mixedPolicy-eviction.xml");
         regionManager = cache.getRegionManager();
         assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());

         Region region = regionManager.getRegion("/org/jboss/data", true);
         EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig);
         assertEquals(5000, ((FIFOAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         region = regionManager.getRegion("/test", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/test/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig);
         assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         // test the default region. use a region name that isn't defined explicitly in conf file.
         region = regionManager.getRegion("/a/b/c", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.ROOT, region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

         region = regionManager.getRegion("/maxAgeTest", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

      }
      finally
      {
         TestingUtil.killCaches(cache);
View Full Code Here

         cache = setupCache("configs/local-lru-eviction.xml");
         regionManager = cache.getRegionManager();
         assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());

         Region region = regionManager.getRegion("/org/jboss/data", false);
         EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/org/jboss/test/data", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/test", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/test/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/maxAgeTest", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

         // test the default region. use a region name that isn't defined explicitly in conf file.
         region = regionManager.getRegion("/a/b/c", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.ROOT, region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

      }
      finally
      {
         TestingUtil.killCaches(cache);
View Full Code Here

      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

                  "         <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

   }

   void initCaches() throws Exception
   {
      Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LFUAlgorithmConfig(maxNodesDefault, minNodesDefault), 200000), 200);
      evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/data"), new LFUAlgorithmConfig(maxNodesR1, minNodesR1)));
      evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new LFUAlgorithmConfig(maxNodesR2, minNodesR2)));
      config.setEvictionConfig(evConfig);
      config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
      config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
      cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, true);
   }
View Full Code Here

TOP

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

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.