Package org.infinispan.config

Examples of org.infinispan.config.Configuration$DataContainerType


   private Cache createCache(String cacheName) {
      CacheWrapper existingCache = caches.get(cacheName);
      if (existingCache != null)
         return existingCache.getCache();

      Configuration c;
      if (cacheName.equals(DEFAULT_CACHE_NAME) || !configurationOverrides.containsKey(cacheName))
         c = defaultConfiguration.clone();
      else
         c = configurationOverrides.get(cacheName);

      c.setGlobalConfiguration(globalConfiguration);
      c.assertValid();
      Cache cache = new InternalCacheFactory().createCache(c, globalComponentRegistry, cacheName, reflectionCache);
      CacheWrapper cw = new CacheWrapper(cache);
      try {
         existingCache = caches.putIfAbsent(cacheName, cw);
         if (existingCache != null) {
View Full Code Here


    */
   @Start(priority = 14)
   public void start() {
      if (cache == null)
         throw new IllegalStateException("The cache should had been injected before a call to this method");
      Configuration config = cache.getConfiguration();
      if (config.isExposeJmxStatistics()) {
         Set<Component> components = cache.getComponentRegistry().getRegisteredComponents();
         nonCacheComponents = getNonCacheComponents(components);
         registerMBeans(components, cache.getConfiguration().getGlobalConfiguration());
         log.info("MBeans were successfully registered to the platform mbean server.");
      }
View Full Code Here

   @Stop
   public void stop() {
      // This method might get called several times.
      // After the first call the cache will become null, so we guard this
      if (cache == null) return;
      Configuration config = cache.getConfiguration();
      if (config.isExposeJmxStatistics()) {
         // Only unregister the non cache MBean so that it can be restarted
         try {
            unregisterMBeans(nonCacheComponents);
         } catch (Exception e) {
            log.warn("Problems un-registering MBeans", e);
View Full Code Here

   }

   @Override
   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
      super.init(config, cache, m);
      Configuration cacheCfg = cache != null ? cache.getConfiguration() : null;
      concurrencyLevel = cacheCfg != null ? cacheCfg.getConcurrencyLevel() : 16;
      int cacheStopTimeout = cacheCfg != null ? cacheCfg.getCacheStopTimeout() : 30000;
      Long configuredAsyncStopTimeout = asyncStoreConfig.getShutdownTimeout();
      cacheName = cacheCfg != null ? cacheCfg.getName() : null;

      // Async store shutdown timeout cannot be bigger than
      // the overall cache stop timeout, so limit it accordingly.
      if (configuredAsyncStopTimeout >= cacheStopTimeout) {
         shutdownTimeout = Math.round(cacheStopTimeout * 0.90);
 
View Full Code Here

   private void defineGenericDataTypeCacheConfigurations(Settings settings, Properties properties) throws CacheException {
      String[] defaultGenericDataTypes = new String[]{ENTITY_KEY, COLLECTION_KEY, TIMESTAMPS_KEY, QUERY_KEY};
      for (String type : defaultGenericDataTypes) {
         TypeOverrides override = overrideStatisticsIfPresent(typeOverrides.get(type), properties);
         String cacheName = override.getCacheName();
         Configuration newCacheCfg = override.createInfinispanConfiguration();
         // Apply overrides
         Configuration cacheConfig = manager.defineConfiguration(cacheName, cacheName, newCacheCfg);
         // Configure transaction manager
         cacheConfig = configureTransactionManager(cacheConfig, cacheName, properties);
         manager.defineConfiguration(cacheName, cacheName, cacheConfig);
         definedConfigurations.add(cacheName);
         override.validateInfinispanConfiguration(cacheConfig);
View Full Code Here

   private Cache getCache(String regionName, String typeKey, Properties properties) {
      TypeOverrides regionOverride = typeOverrides.get(regionName);
      if (!definedConfigurations.contains(regionName)) {
         String templateCacheName = null;
         Configuration regionCacheCfg = null;
         if (regionOverride != null) {
            if (log.isDebugEnabled()) log.debug("Cache region specific configuration exists: " + regionOverride);
            regionOverride = overrideStatisticsIfPresent(regionOverride, properties);
            regionCacheCfg = regionOverride.createInfinispanConfiguration();
            String cacheName = regionOverride.getCacheName();
View Full Code Here

      return new ClassLoaderAwareCache(cache, Thread.currentThread().getContextClassLoader());
   }

   private Configuration configureTransactionManager(Configuration regionOverrides, String templateCacheName, Properties properties) {
      // Get existing configuration to verify whether a tm was configured or not.
      Configuration templateConfig = manager.defineConfiguration(templateCacheName, new Configuration());
      String ispnTmLookupClassName = templateConfig.getTransactionManagerLookupClass();
      String hbTmLookupClassName = org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup.class.getName();
      if (ispnTmLookupClassName != null && !ispnTmLookupClassName.equals(hbTmLookupClassName)) {
         log.debug("Infinispan is configured [" + ispnTmLookupClassName + "] with a different transaction manager lookup " +
               "class than Hibernate [" + hbTmLookupClassName + "]");
      } else {
View Full Code Here

      markAsOverriden("isExposeStatistics");
      this.isExposeStatistics = isExposeStatistics;
   }

   public Configuration createInfinispanConfiguration() {
      Configuration cacheCfg = new Configuration();
      if (overridden.contains("evictionStrategy")) cacheCfg.setEvictionStrategy(evictionStrategy);
      if (overridden.contains("evictionWakeUpInterval")) cacheCfg.setEvictionWakeUpInterval(evictionWakeUpInterval);
      if (overridden.contains("evictionMaxEntries")) cacheCfg.setEvictionMaxEntries(evictionMaxEntries);
      if (overridden.contains("expirationLifespan")) cacheCfg.setExpirationLifespan(expirationLifespan);
      if (overridden.contains("expirationMaxIdle")) cacheCfg.setExpirationMaxIdle(expirationMaxIdle);
      if (overridden.contains("isExposeStatistics")) cacheCfg.setExposeJmxStatistics(isExposeStatistics);
      return cacheCfg;
   }
View Full Code Here

      final ConfigurationContainer templateConfiguration;
      if (this.configurationFileLocation == null) {
         this.logger
                  .info("No configuration file has been given. Using Infinispan's default settings.");
         final GlobalConfiguration standardGlobalConfiguration = new GlobalConfiguration();
         final Configuration standardDefaultConfiguration = new Configuration();
         templateConfiguration = new ConfigurationContainer(standardGlobalConfiguration,
                  standardDefaultConfiguration, new HashMap<String, Configuration>());
      } else {
         this.logger.info("Using Infinispan configuration file located at ["
                  + this.configurationFileLocation + "]");
View Full Code Here

            if (this.infinispanEmbeddedCacheManager.getCacheNames().contains(cacheName)) {
               throw new IllegalStateException(
                        "Cannot use ConfigurationTemplateMode NONE: a cache named [" + cacheName
                                 + "] has already been defined.");
            }
            final Configuration newConfiguration = new Configuration();
            final Configuration customizedNewConfiguration = this.infinispanEmbeddedCacheManager
                     .defineConfiguration(cacheName, newConfiguration);
            this.configurationOverrides.applyOverridesTo(customizedNewConfiguration);
            break;
         case NAMED:
            this.logger
                     .debug("ConfigurationTemplateMode is NAMED: starting with a named Configuration ["
                              + cacheName + "]");
            final Configuration namedConfiguration = new Configuration();
            final Configuration customizedNamedConfiguration = this.infinispanEmbeddedCacheManager
                     .defineConfiguration(cacheName, cacheName, namedConfiguration);
            this.configurationOverrides.applyOverridesTo(customizedNamedConfiguration);
            break;
         case DEFAULT:
            this.logger
                     .debug("ConfigurationTemplateMode is DEFAULT: starting with default Configuration");
            if (this.infinispanEmbeddedCacheManager.getCacheNames().contains(cacheName)) {
               throw new IllegalStateException(
                        "Cannot use ConfigurationTemplateMode DEFAULT: a cache named [" + cacheName
                                 + "] has already been defined.");
            }
            final Configuration defaultConfiguration = this.infinispanEmbeddedCacheManager
                     .getDefaultConfiguration().clone();
            final Configuration customizedDefaultConfiguration = this.infinispanEmbeddedCacheManager
                     .defineConfiguration(cacheName, defaultConfiguration);
            this.configurationOverrides.applyOverridesTo(customizedDefaultConfiguration);
            break;
         default:
            throw new IllegalStateException("Unknown ConfigurationTemplateMode: "
View Full Code Here

TOP

Related Classes of org.infinispan.config.Configuration$DataContainerType

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.