Examples of EvictionConfig


Examples of org.jboss.cache.config.EvictionConfig

   }

   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

Examples of org.jboss.cache.config.EvictionConfig

      return cacheLoaderConfig;
   }

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

Examples of org.jboss.cache.config.EvictionConfig

{
   public EvictionAlgorithm createAndAssignToRegion(String fqnString, RegionManager regionManager, EvictionAlgorithmConfig config)
   {
      Fqn fqn = Fqn.fromString(fqnString);
      Configuration c = new Configuration();
      c.setEvictionConfig(new EvictionConfig());
      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, config);
      c.getEvictionConfig().addEvictionRegionConfig(erc);
      CacheSPI mockCache = EasyMock.createNiceMock(CacheSPI.class);
      EasyMock.replay(mockCache);
      ((RegionManagerImpl) regionManager).injectDependencies(mockCache, c, null, null, null, new RegionRegistry());
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

   public void setUp() throws Exception
   {
      Configuration conf = new Configuration();
      ExpirationAlgorithmConfig eAC = new ExpirationAlgorithmConfig();
      EvictionRegionConfig eRC = new EvictionRegionConfig(Fqn.ROOT, eAC);
      EvictionConfig econf = new EvictionConfig(eRC);
      econf.setWakeupInterval(100);
      conf.setEvictionConfig(econf);
      cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf, false);
      cache.start();

      future = System.currentTimeMillis() + 500;
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

*/
public class EvictionElementParser extends XmlParserBase
{
   public EvictionConfig parseEvictionElement(Element evictionElement)
   {
      EvictionConfig evictionConfig = new EvictionConfig();
      String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
      if (existsAttribute(wakeUpInterval))
      {
         evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
      }
      else
      {
         throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
      }

      List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
      Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);

      if (defaultRegion != null)
      {
         EvictionRegionConfig defaultRegionConfig = getEvictionRegionConfig(defaultRegion, null, true);
         if (defaultRegionConfig.getEvictionAlgorithmConfig() == null)
            throw new MissingPolicyException("Default eviction region should have an evictionAlgorithmClass defined.");
         evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig);
      }

      NodeList regions = evictionElement.getElementsByTagName("region");
      for (int i = 0; i < regions.getLength(); i++)
      {
         Element regionConfig = (Element) regions.item(i);
         EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
         evictionConfig.applyDefaults(erc);
         evictionRegionConfigs.add(erc);
      }
      evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
      return evictionConfig;
   }
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

      getConfiguration().setClusterConfig(cluster_props);
   }

   public void setEvictionPolicyConfig(Element config)
   {
      EvictionConfig ec = null;
      if (config != null)
      {
         ec = evictionElementParser.parseEvictionElement(config);
      }
      getConfiguration().setEvictionConfig(ec);
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

            conf.setCacheLoaderConfig(clc);
         }
         else if ("EvictionPolicyConfiguration".equals(propname)
               || "EvictionPolicyConfig".equals(propname))
         {
            EvictionConfig ec = parseEvictionConfig(entry.getValue());
            conf.setEvictionConfig(ec);
         }
         else if ("ClusterConfig".equals(propname))
         {
            String jgc = parseClusterConfigXml(entry.getValue());
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

   }

   @SuppressWarnings("unchecked")
   public static EvictionConfig parseEvictionConfig(Element element)
   {
      EvictionConfig evictionConfig = new EvictionConfig();

      if (element != null)
      {
         // If they set the default eviction policy in the element, use that
         // in preference to the external attribute
         String temp = XmlConfigHelper.getTagContents(element, "policyClass", ATTR, NAME);
         String defaultEvPolicyClassName = null;
         if (temp != null && temp.length() > 0)
         {
            defaultEvPolicyClassName = temp;
            EvictionAlgorithmConfig eac = getEvictionAlgorithmConfig(temp);
            evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(eac);
         }

         temp = XmlConfigHelper.getTagContents(element, "wakeUpIntervalSeconds", ATTR, NAME);

         int wakeupIntervalSeconds = 0;
         if (temp != null)
         {
            wakeupIntervalSeconds = Integer.parseInt(temp);
         }

         if (wakeupIntervalSeconds <= 0)
         {
            wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
         }

         evictionConfig.setWakeupInterval(wakeupIntervalSeconds * 1000);

         int eventQueueSize = 0;
         temp = XmlConfigHelper.getTagContents(element, "eventQueueSize", ATTR, NAME);

         if (temp != null)
         {
            eventQueueSize = Integer.parseInt(temp);
         }

         if (eventQueueSize <= 0)
         {
            eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
         }

         evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueSize);

         NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
         if (list != null && list.getLength() > 0)
         {
            List regionConfigs = new ArrayList(list.getLength());
            for (int i = 0; i < list.getLength(); i++)
            {
               org.w3c.dom.Node node = list.item(i);
               if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
               {
                  continue;
               }
               try
               {
                  EvictionRegionConfig evictionRegionConfig = parseEvictionRegionConfig((Element) node, defaultEvPolicyClassName, eventQueueSize);
                  if (!evictionRegionConfig.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
                  {
                     regionConfigs.add(evictionRegionConfig);
                  }
                  else
                  {
                     evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(evictionRegionConfig.getEventQueueSize());
                     evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(evictionRegionConfig.getEvictionAlgorithmConfig());
                  }
               }
               catch (MissingPolicyException missingPolicy)
               {
                  LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
                  throw missingPolicy;
               }
            }

            evictionConfig.setEvictionRegionConfigs(regionConfigs);
         }
      }

      return evictionConfig;

View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

      Configuration config = cache.getConfiguration();
      config.setUseRegionBasedMarshalling(useRegionBased);
      config.setInactiveOnStartup(useRegionBased);

      int wakeupInterval = 1000000; // a long time; really disabled
      EvictionConfig ec = new EvictionConfig(
            new EvictionRegionConfig(
                  Fqn.ROOT,
                  new LRUAlgorithmConfig(1000000, 0, 1000)
            ),
            wakeupInterval
View Full Code Here

Examples of org.jboss.cache.config.EvictionConfig

   /**
    * 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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.