Package org.infinispan.config

Examples of org.infinispan.config.ConfigurationException


            }
         }
         ParseUtils.requireNoContent(reader);
      }
      if (count > 1)
         throw new ConfigurationException("Only one 'takeOffline' element allowed within a 'backup'");
   }
View Full Code Here


   }

   private void setMode(final ConfigurationBuilder builder, final String clusteringMode, final boolean asynchronous, final boolean synchronous, final XMLExtendedStreamReader reader) {
      if (synchronous && asynchronous) {
         throw new ConfigurationException("Cannot configure <sync> and <async> on the same cluster, " + reader.getLocation());
      }

      if (clusteringMode != null) {
         String mode = clusteringMode.toUpperCase();
         if (ParsedCacheMode.REPL.matches(mode)) {
            if (!asynchronous) {
               builder.clustering().cacheMode(REPL_SYNC);
            } else {
               builder.clustering().cacheMode(REPL_ASYNC);
            }
         } else if (ParsedCacheMode.INVALIDATION.matches(mode)) {
            if (!asynchronous) {
               builder.clustering().cacheMode(INVALIDATION_SYNC);
            } else {
               builder.clustering().cacheMode(INVALIDATION_ASYNC);
            }
         } else if (ParsedCacheMode.DIST.matches(mode)) {
            if (!asynchronous) {
               builder.clustering().cacheMode(DIST_SYNC);
            } else {
               builder.clustering().cacheMode(DIST_ASYNC);
            }
         } else if (ParsedCacheMode.LOCAL.matches(mode)) {
            builder.clustering().cacheMode(LOCAL);
         } else {
            throw new ConfigurationException("Invalid clustering mode " + clusteringMode + ", " + reader.getLocation());
         }
      } else {
         // If no cache mode is given but sync or async is specified, default to DIST
         if (synchronous) {
            builder.clustering().cacheMode(DIST_SYNC);
View Full Code Here

               throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
            }
            try {
               namedCaches.put(configurationName, parseConfiguration(e));
            } catch (ConfigurationException ce) {
               throw new ConfigurationException("Problems configuring named cache '" + configurationName + "'", ce);
            }
         }
      }

      return namedCaches;
View Full Code Here

      return c;
   }

   private void assertInitialized() {
      if (!initialized)
         throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
   }
View Full Code Here

         cacheMode = Configuration.CacheMode.DIST_SYNC; // the default

      Element asyncEl = getSingleElementInCoreNS("async", e);
      Element syncEl = getSingleElementInCoreNS("sync", e);
      if (syncEl != null && asyncEl != null)
         throw new ConfigurationException("Cannot have sync and async elements within the same cluster element!");
      boolean sync = asyncEl == null; // even if both are null, we default to sync
      if (sync) {
         config.setCacheMode(cacheMode);
         configureSyncMode(syncEl, config);
      } else {
         cacheMode = cacheMode.toAsync(); // get the async version of this mode
         config.setCacheMode(cacheMode);
         configureAsyncMode(asyncEl, config);
      }

      if (cacheMode.isDistributed()) {
         // L1 cache
         Element l1 = getSingleElementInCoreNS("l1", e);
         String tmp = getAttributeValue(l1, "enabled");
         if (existsAttribute(tmp)) config.setL1CacheEnabled(getBoolean(tmp));
         tmp = getAttributeValue(l1, "lifespan");
         if (existsAttribute(tmp)) config.setL1Lifespan(getLong(tmp));
         tmp = getAttributeValue(l1, "onRehash");
         if (existsAttribute(tmp)) config.setL1OnRehash(getBoolean(tmp));

         // consistent hash algo
         Element hash = getSingleElementInCoreNS("hash", e);
         tmp = getAttributeValue(hash, "class");
         if (existsAttribute(tmp)) config.setConsistentHashClass(tmp);
         tmp = getAttributeValue(hash, "numOwners");
         if (existsAttribute(tmp)) config.setNumOwners(getInt(tmp));
         tmp = getAttributeValue(hash, "rehashWait");
         if (existsAttribute(tmp)) config.setRehashWaitTime(getLong(tmp));
      } else if (getSingleElementInCoreNS("l1", e) != null || getSingleElementInCoreNS("hash", e) != null) {
         throw new ConfigurationException("l1 and hash elements cannot be used with cache modes 'REPLICATION' and 'INVALIDATION'!");
      }
      configureStateRetrieval(getSingleElementInCoreNS("stateRetrieval", e), config);
   }
View Full Code Here

   public DefaultCacheManager(String configurationFile, boolean start) throws IOException {
      try {
         initialize(new XmlConfigurationParserImpl(configurationFile));
      }
      catch (RuntimeException re) {
         throw new ConfigurationException(re);
      }
      if (start) start();
   }
View Full Code Here

      try {
         initialize(new XmlConfigurationParserImpl(configurationStream));
      } catch (ConfigurationException ce) {
         throw ce;
      } catch (RuntimeException re) {
         throw new ConfigurationException(re);
      }
      if (start) start();
   }
View Full Code Here

      return new AsyncStore(tmpStore, cfg2.getAsyncStoreConfig());
   }

   void assertNotSingletonAndShared(CacheStoreConfiguration cfg) {
      if (cfg.singletonStore().enabled() && clmConfig.shared())
         throw new ConfigurationException("Invalid cache loader configuration!!  If a cache loader is configured as a singleton, the cache loader cannot be shared in a cluster!");
   }
View Full Code Here

         else if (config.index() >= 0)
            interceptorChain.addInterceptor(customInterceptor, config.index());
         else if (config.after() != null) {
            List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClass(config.after());
            if (withClassName.isEmpty()) {
               throw new ConfigurationException("Cannot add after class: " + config.after()
                                                      + " as no such interceptor exists in the default chain");
            }
            interceptorChain.addInterceptorAfter(customInterceptor, withClassName.get(0).getClass());
         } else if (config.before() != null) {
            List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClass(config.before());
            if (withClassName.isEmpty()) {
               throw new ConfigurationException("Cannot add before class: " + config.after()
                                                      + " as no such interceptor exists in the default chain");
            }
            interceptorChain.addInterceptorBefore(customInterceptor, withClassName.get(0).getClass());
         }
      }
View Full Code Here

      try {
         return componentType.cast(buildInterceptorChain());
      } catch (CacheException ce) {
         throw ce;
      } catch (Exception e) {
         throw new ConfigurationException("Unable to build interceptor chain", e);
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.config.ConfigurationException

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.