Package org.jboss.cache.config

Examples of org.jboss.cache.config.EvictionRegionConfig


   }

   protected EvictionRegionConfig getEvictionRegionConfig(Fqn fqn)
   {
      AbortableLRUAlgorithmConfiguration algoCfg = new AbortableLRUAlgorithmConfiguration();
      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, algoCfg);

      log.debug("Setting time to live to " + cacheConfig.idleTimeoutSeconds() + " seconds and maxNodes to " + cacheConfig.maxSize());

      algoCfg.setTimeToLive((int) cacheConfig.idleTimeoutSeconds(), TimeUnit.SECONDS);
      algoCfg.setMaxNodes(cacheConfig.maxSize());
View Full Code Here


      cacheNode = new Fqn(new Object[] { SFSB, this.ejbContainer.getDeploymentPropertyListString() });
     
      // Try to create an eviction region per ejb
      region = cache.getRegion(cacheNode, true);
      EvictionRegionConfig erc = getEvictionRegionConfig(cacheNode);
      region.setEvictionRegionConfig(erc);

      if (cache.getCacheStatus() != CacheStatus.STARTED)
      {
         if (cache.getCacheStatus() != CacheStatus.CREATED)
View Full Code Here

      config.setInactiveOnStartup(useRegionBased);
      Cache cache = new UnitTestCacheFactory<Object, Object>().createCache(config, false, getClass());

      EvictionConfig ec = new EvictionConfig();
      ec.setWakeupInterval(1000000)// a long time; really disabled
      EvictionRegionConfig erc = new EvictionRegionConfig();
      erc.setRegionFqn(Fqn.ROOT);
      LRUAlgorithmConfig lruAlgorithmConfig = new LRUAlgorithmConfig();
      lruAlgorithmConfig.setMaxNodes(1000);
      lruAlgorithmConfig.setTimeToLive(1000000);
      erc.setEvictionAlgorithmConfig(lruAlgorithmConfig);
      ec.addEvictionRegionConfig(erc);
      config.setEvictionConfig(ec);

      CacheLoaderConfig clc = new CacheLoaderConfig();
      clc.setPassivation(true);
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

      ec.setWakeupInterval(1000);

      LRUAlgorithmConfig lru = new LRUAlgorithmConfig();
      lru.setMaxNodes(0);
      lru.setTimeToLive(5000);
      ec.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn.ROOT, lru));

      lru = new LRUAlgorithmConfig();
      lru.setMaxNodes(0);
      lru.setTimeToLive(1000);
      ec.addEvictionRegionConfig(new EvictionRegionConfig(BASE, lru));

      cache.getConfiguration().setEvictionConfig(ec);
   }
View Full Code Here

    * Setting up a new region for our purposes.
    */
   private void createNewRegion()
   {
      EvictionConfig evConfig = cache.getConfiguration().getEvictionConfig();
      EvictionRegionConfig evRegConfig = new EvictionRegionConfig();
      evRegConfig.setRegionFqn(Fqn.fromString("/" + TEST_NODES_ROOT));
      evRegConfig.setEventQueueSize(100);
      LRUAlgorithmConfig lruConfig = new LRUAlgorithmConfig();
      lruConfig.setMaxAge(100000000);
      lruConfig.setTimeToLive(100000000);
      lruConfig.setMaxNodes(3);
      evRegConfig.setEvictionAlgorithmConfig(lruConfig);
      evConfig.addEvictionRegionConfig(evRegConfig);
      //end setting up region stuff
   }
View Full Code Here

   public void testLocalWithEviction() throws IOException
   {
      Configuration c = new Configuration();
      EvictionConfig ec = new EvictionConfig();
      ec.setWakeupInterval(250, TimeUnit.MILLISECONDS);
      EvictionRegionConfig erc = new EvictionRegionConfig();
      erc.setEvictionAlgorithmConfig(new FIFOAlgorithmConfig(2));
      erc.setRegionFqn(Fqn.ROOT);
      ec.setDefaultEvictionRegionConfig(erc);
      c.setEvictionConfig(ec);
      Cache cache = new DefaultCacheFactory().createCache(c);
      cache.put("/a/b/c", "a", "b");
      cache.put("/a/b/c", "c", "d");
View Full Code Here

   }

   private EvictionConfig getEvictionConfig()
   {
      EvictionConfig c = new EvictionConfig();
      EvictionRegionConfig defaultRegion = new EvictionRegionConfig(Fqn.ROOT, new NullEvictionAlgorithmConfig());
      c.setDefaultEvictionRegionConfig(defaultRegion);
      c.setWakeupInterval(0);

      LRUAlgorithmConfig lru = new LRUAlgorithmConfig(1000, 1000);
      EvictionRegionConfig subregion = new EvictionRegionConfig(fqn, lru);
      c.addEvictionRegionConfig(subregion);
      return c;
   }
View Full Code Here

    * Evicts the given region but only after ensuring that region's TTL passed.
    */
   public void evictRegionWithTimeToLive(String region) throws Exception
   {
      EvictionConfig evConfig = cache.getConfiguration().getEvictionConfig();
      EvictionRegionConfig erConfig = evConfig.getEvictionRegionConfig(region);
      if (erConfig == null)
      {
         throw new IllegalStateException("No such region!");
      }
      long ttl = 0;
      if (erConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig)
      {
         LRUAlgorithmConfig configuration = (LRUAlgorithmConfig) erConfig.getEvictionAlgorithmConfig();
         ttl = configuration.getTimeToLive();
      }
      else
      {
         throw new IllegalArgumentException("Only LRU being handled for now; please add other implementations here");
View Full Code Here

    * null policy regions but was from lru region.
    */
   public void testEviction() throws InterruptedException
   {
      Configuration config = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      EvictionConfig evConfig = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new NullEvictionAlgorithmConfig(), 200000), 200);
      evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/test"), new NullEvictionAlgorithmConfig()));
      evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/lru"), new LRUAlgorithmConfig(1000, 10000)));
      config.setEvictionConfig(evConfig);
      config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
      config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
      cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, getClass());

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.