Package org.jboss.cache.eviction

Examples of org.jboss.cache.eviction.FIFOAlgorithmConfig


   {
      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");
View Full Code Here


   @Override
   protected EvictionAlgorithmConfigBase getEvictionAlgorithmConfig()
   {
      startBusyThread();
      FIFOAlgorithmConfig cfg = new FIFOAlgorithmConfig();
      cfg.setMaxNodes(1);
      return cfg;
   }
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 ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache,
            int maxNodes, long minTimeToLive)
      throws ExoCacheInitException
   {
      final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
      fifo.setMinTimeToLive(minTimeToLive);
      Fqn<String> rooFqn = addEvictionRegion(config, cache, fifo);
      return new AbstractExoCache<Serializable, Object>(config, cache, rooFqn)
      {

         public void setMaxSize(int max)
         {
            fifo.setMaxNodes(max);
         }

         public void setLiveTime(long period)
         {
            fifo.setMinTimeToLive(period);
         }

         @ManagedName("MaxNodes")
         @ManagedDescription("This is the maximum number of nodes allowed in this region. " +
               "0 denotes immediate expiry, -1 denotes no limit.")
         public int getMaxSize()
         {
            return fifo.getMaxNodes();
         }

         @ManagedName("MinTimeToLive")
         @ManagedDescription("the minimum amount of time a node must be allowed to live after " +
               "being accessed before it is allowed to be considered for eviction. 0 denotes that " +
               "this feature is disabled, which is the default value.")
         public long getLiveTime()
         {
            return fifo.getMinTimeToLive();
         }
      };
   }
View Full Code Here

               .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
            useExpiration = true;
         }
         else if (config instanceof FIFOAlgorithmConfig)
         {
            FIFOAlgorithmConfig fifoConfig = (FIFOAlgorithmConfig)config;
            if (fifoConfig.getMinTimeToLive() > 0)
            {
               LOG.warn("The FIFO algorithm with a minTimeToLive greater than 0 can cause a memory leak, "
                  + "please use another eviction algorithm or set the minTimeToLive to 0.");
            }
         }
View Full Code Here

               .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
            useExpiration = true;
         }
         else if (config instanceof FIFOAlgorithmConfig)
         {
            FIFOAlgorithmConfig fifoConfig = (FIFOAlgorithmConfig)config;
            if (fifoConfig.getMinTimeToLive() > 0)
            {
               LOG.warn("The FIFO algorithm with a minTimeToLive greater than 0 can cause a memory leak, "
                  + "please use another eviction algorithm or set the minTimeToLive to 0.");
            }
         }
View Full Code Here

    */
   private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
      throws ExoCacheInitException
   {
      final Configuration configuration = cache.getConfiguration();
      final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
      fifo.setMinTimeToLive(minTimeToLive);
      // Create an eviction region config
      final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, fifo);

      final EvictionConfig evictionConfig = configuration.getEvictionConfig();
      evictionConfig.setDefaultEvictionRegionConfig(erc);

      return new AbstractExoCache<Serializable, Object>(config, cache)
      {

         public void setMaxSize(int max)
         {
            fifo.setMaxNodes(max);
         }

         public void setLiveTime(long period)
         {
            fifo.setMinTimeToLive(period);
         }

         @ManagedName("MaxNodes")
         @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
         public int getMaxSize()
         {
            return fifo.getMaxNodes();
         }

         @ManagedName("MinTimeToLive")
         @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
         public long getLiveTime()
         {
            return fifo.getMinTimeToLive();
         }
      };
   }
View Full Code Here

               .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
            useExpiration = true;
         }
         else if (config instanceof FIFOAlgorithmConfig)
         {
            FIFOAlgorithmConfig fifoConfig = (FIFOAlgorithmConfig)config;
            if (fifoConfig.getMinTimeToLive() > 0)
            {
               LOG.warn("The FIFO algorithm with a minTimeToLive greater than 0 can cause a memory leak, "
                  + "please use another eviction algorithm or set the minTimeToLive to 0.");
            }
         }
View Full Code Here

               .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
            useExpiration = true;
         }
         else if (config instanceof FIFOAlgorithmConfig)
         {
            FIFOAlgorithmConfig fifoConfig = (FIFOAlgorithmConfig)config;
            if (fifoConfig.getMinTimeToLive() > 0)
            {
               LOG.warn("The FIFO algorithm with a minTimeToLive greater than 0 can cause a memory leak, "
                  + "please use another eviction algorithm or set the minTimeToLive to 0.");
            }
         }
View Full Code Here

               .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
            useExpiration = true;
         }
         else if (config instanceof FIFOAlgorithmConfig)
         {
            FIFOAlgorithmConfig fifoConfig = (FIFOAlgorithmConfig)config;
            if (fifoConfig.getMinTimeToLive() > 0)
            {
               LOG.warn("The FIFO algorithm with a minTimeToLive greater than 0 can cause a memory leak, "
                  + "please use another eviction algorithm or set the minTimeToLive to 0.");
            }
         }
View Full Code Here

TOP

Related Classes of org.jboss.cache.eviction.FIFOAlgorithmConfig

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.