Package org.infinispan.manager

Examples of org.infinispan.manager.DefaultCacheManager


      Properties properties = globalConfiguration.getTransportProperties();
      properties.put(CHANNEL_FACTORY, this.channelFactory);
      properties.setProperty(CHANNEL_ID, globalConfiguration.getClusterName());
      properties.setProperty(JGroupsTransport.CHANNEL_LOOKUP, ChannelFactoryChannelLookup.class.getName());

      EmbeddedCacheManager manager = new DefaultCacheManager(globalConfiguration, configuration.getDefaultConfiguration(), false);

      // Add named configurations
      for (Configuration config: configuration.getConfigurations())
      {
         manager.defineConfiguration(config.getName(), config);
      }
     
      manager.start();
     
      return (aliases != null) && !aliases.isEmpty() ? new AliasAwareCacheContainer(manager, aliases) : manager;
   }
View Full Code Here


   }

   protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
      try {
         String configLoc = ConfigurationHelper.getString(INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
         EmbeddedCacheManager manager = new DefaultCacheManager(configLoc, false);
         String globalStats = ConfigurationHelper.extractPropertyValue(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
         if (globalStats != null) {
            manager.getGlobalConfiguration().setExposeGlobalJmxStatistics(Boolean.parseBoolean(globalStats));
         }
         manager.start();
         return manager;
      } catch (IOException e) {
         throw new CacheException("Unable to create default cache manager", e);
      }
   }
View Full Code Here

               catch (RuntimeException e) //NOSONAR
               {
                  throw new ExoCacheInitException("Cannot parse the configuration '" + cacheConfigTemplate + "'", e);
               }
               configureCacheManager(configBuilder);
               DefaultCacheManager cacheManager;
               try
               {
                  // Create the CacheManager from the new configuration
                  cacheManager = new DefaultCacheManager(configBuilder.build(), config);
               }
               catch (RuntimeException e) //NOSONAR
               {
                  throw new ExoCacheInitException(
                     "Cannot initialize the CacheManager corresponding to the configuration '" + cacheConfigTemplate
                        + "'", e);
               }
               // Register the main cache manager
               mappingGlobalConfigCacheManager.put(cacheManager.getCacheManagerConfiguration().transport().clusterName(),
                  cacheManager);
               return cacheManager;
            }
         });
      }
View Full Code Here

   public ExoCache<Serializable, Object> createCache(final ExoCacheConfig config) throws ExoCacheInitException
   {
      final String region = config.getName();
      final String customConfig = mappingCacheNameConfig.get(region);
      final ExoCache<Serializable, Object> eXoCache;
      final DefaultCacheManager cacheManager;
      try
      {
         final ConfigurationBuilder confBuilder = new ConfigurationBuilder();
         if (customConfig != null)
         {
            try
            {
               cacheManager =
                  SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<DefaultCacheManager>()
                  {
                     public DefaultCacheManager run() throws Exception
                     {
                        // A custom configuration has been set
                        if (LOG.isInfoEnabled())
                           LOG.info("A custom configuration has been set for the cache '" + region + "'.");
                        Parser parser = new Parser(Thread.currentThread().getContextClassLoader());
                        // Load the configuration
                        ConfigurationBuilderHolder holder = parser.parse(configManager.getInputStream(customConfig));
                        GlobalConfigurationBuilder configBuilder = holder.getGlobalConfigurationBuilder();
                        // Configure JGroups and JMX since it could affect the state of the Global Config
                        configureCacheManager(configBuilder);
                        GlobalConfiguration gc = configBuilder.build();

                        // Check if a CacheManager with the same GlobalConfiguration exists
                        DefaultCacheManager currentCacheManager =
                           mappingGlobalConfigCacheManager.get(gc.transport().clusterName());
                        if (currentCacheManager == null)
                        {
                           // Use a different cache manager name to prevent naming conflict
                           configBuilder.globalJmxStatistics().cacheManagerName(
                              gc.globalJmxStatistics().cacheManagerName() + "_" + region + "_" + ctx.getName());
                           // No cache manager has been defined so far for this Cache Configuration
                           currentCacheManager =
                              new DefaultCacheManager(configBuilder.build(), holder.getDefaultConfigurationBuilder()
                                 .build(), false);
                           for (Entry<String, ConfigurationBuilder> entry : holder.getNamedConfigurationBuilders().entrySet())
                           {
                              currentCacheManager.defineConfiguration(entry.getKey(), entry.getValue().build());
                           }
                           currentCacheManager.start();
                           // We register this new cache manager
                           mappingGlobalConfigCacheManager.put(gc.transport().clusterName(), currentCacheManager);
                        }
                        return currentCacheManager;
                     }
View Full Code Here

        }

        SwitchContext switchContext = this.switcher.getSwitchContext(this.getClass().getClassLoader());

        try {
            EmbeddedCacheManager manager = new DefaultCacheManager(this.globalConfiguration, this.defaultConfiguration, false);

            // Add named configurations
            for (Map.Entry<String, Configuration> entry: this.configurations.entrySet()) {
               manager.defineConfiguration(entry.getKey(), entry.getValue());
            }

            this.container = new DefaultCacheContainer(manager, this.defaultCache);
            this.container.start();
        } finally {
View Full Code Here

    assertTrue(cacheLoaderConfig instanceof LevelDBCacheStoreConfiguration);
    LevelDBCacheStoreConfiguration leveldbConfig = (LevelDBCacheStoreConfiguration) cacheLoaderConfig;
    assertEquals(tmpDataDirectory, leveldbConfig.location());
    assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());

    EmbeddedCacheManager cacheManager = new DefaultCacheManager(
        globalConfig);

    cacheManager.defineConfiguration("testCache", cacheConfig);

    cacheManager.start();
    Cache<String, String> cache = cacheManager.getCache("testCache");
   
    cache.put("hello", "there");
    cache.stop();
    cacheManager.stop();
  }
View Full Code Here

        .cacheStore(new LevelDBCacheStore())
        .addProperty("location", tmpDataDirectory)
        .addProperty("expiredLocation", tmpExpiredDirectory)
        .build();

    EmbeddedCacheManager cacheManager = new DefaultCacheManager(
        globalConfig);

    cacheManager.defineConfiguration("testCache", cacheConfig);

      cacheManager.start();
      Cache<String, String> cache = cacheManager.getCache("testCache");
     
      cache.put("hello", "there legacy java");
    cache.stop();
    cacheManager.stop();
  }
View Full Code Here

    cache.stop();
    cacheManager.stop();
  }

  public void textXmlConfigLegacy() throws IOException {
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(
        "config/leveldb-config-legacy.xml");
    Cache<String, String> cache = cacheManager.getCache("testCache");
   
    cache.put("hello", "there legacy xml");
      cache.stop();
      cacheManager.stop();
     
      TestingUtil.recursiveFileRemove("/tmp/leveldb/legacy");
  }
View Full Code Here

     
      TestingUtil.recursiveFileRemove("/tmp/leveldb/legacy");
  }
 
  public void testXmlConfig52() throws IOException {
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(
            "config/leveldb-config-52.xml");
   
    Cache<String, String> cache = cacheManager.getCache("testCache");
   
    cache.put("hello", "there 52 xml");
      cache.stop();
    cacheManager.stop();
   
    TestingUtil.recursiveFileRemove("/tmp/leveldb/52");
  }
View Full Code Here

   }

   protected EmbeddedCacheManager doStandalone() throws IOException
   {
      String configurationFile = System.getProperty("org.jboss.capedwarf.cache.configurationFile", "infinispan-config.xml");
      return new DefaultCacheManager(configurationFile, true);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.manager.DefaultCacheManager

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.