Package org.infinispan.manager

Examples of org.infinispan.manager.DefaultCacheManager


  @PostConstruct
  protected void init() throws IOException {
    // base configuration from XML file
    if (null != configurationFile) {
      log.debug("Get base configuration from {}", configurationFile);
      manager = new DefaultCacheManager(configurationFile);
    } else {
      manager = new DefaultCacheManager();
    }

    // cache for caching the cache configurations (hmmm, sounds a bit strange)
    Map<String, Map<CacheCategory, CacheService>> cacheCache =
        new HashMap<String, Map<CacheCategory, CacheService>>();
View Full Code Here


         managerConfig.setCacheLoaderConfigs(Collections.<CacheLoaderConfig>singletonList(fileConfig));
        
         config.setCacheLoaderManagerConfig(managerConfig);
      }
     
      final EmbeddedCacheManager sessionContainer = new DefaultCacheManager(global, config, false);
     
      global = local ? GlobalConfiguration.getNonClusteredDefault() : GlobalConfiguration.getClusteredDefault();
      global.setClusterName("testing-jvmroute");
      global.setCacheManagerName("container" + containerIndex++);
      global.setStrictPeerToPeer(false);
     
      config = new Configuration();
      config.setInvocationBatchingEnabled(true);
      config.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
      config.setSyncReplTimeout(20000);
      config.setLockAcquisitionTimeout(15000);
      config.setCacheMode(CacheMode.REPL_SYNC);
      config.setFetchInMemoryState(true);
      config.setSyncCommitPhase(true);
      config.setSyncRollbackPhase(true);
     
      final EmbeddedCacheManager jvmRouteContainer = new DefaultCacheManager(global, config, false);
     
      return new EmbeddedCacheManager()
      {
         @Override
         public <K, V> Cache<K, V> getCache()
         {
            return sessionContainer.getCache();
         }

         @Override
         public <K, V> Cache<K, V> getCache(String cacheName)
         {
            return cacheName.equals("jboss.web") ? jvmRouteContainer.<K, V>getCache() : sessionContainer.<K, V>getCache(cacheName);
         }

         @Override
         public void start()
         {
            jvmRouteContainer.start();
            sessionContainer.start();
         }

         @Override
         public void stop()
         {
            sessionContainer.stop();
            jvmRouteContainer.stop();
         }

         @Override
         public void addListener(Object listener)
         {
            sessionContainer.addListener(listener);
         }

         @Override
         public void removeListener(Object listener)
         {
            sessionContainer.removeListener(listener);
         }

         @Override
         public Set<Object> getListeners()
         {
            return sessionContainer.getListeners();
         }

         @Override
         public Configuration defineConfiguration(String cacheName, Configuration configurationOverride)
         {
            return sessionContainer.defineConfiguration(cacheName, configurationOverride);
         }

         @Override
         public Configuration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride)
         {
            return sessionContainer.defineConfiguration(cacheName, templateCacheName, configurationOverride);
         }

         @Override
         public String getClusterName()
         {
            return sessionContainer.getClusterName();
         }

         @Override
         public List<Address> getMembers()
         {
            return sessionContainer.getMembers();
         }

         @Override
         public Address getAddress()
         {
            return sessionContainer.getAddress();
         }

         @Override
         public boolean isCoordinator()
         {
            return sessionContainer.isCoordinator();
         }

         @Override
         public ComponentStatus getStatus()
         {
            return sessionContainer.getStatus();
         }

         @Override
         public GlobalConfiguration getGlobalConfiguration()
         {
            return sessionContainer.getGlobalConfiguration();
         }

         @Override
         public Configuration getDefaultConfiguration()
         {
            return sessionContainer.getDefaultConfiguration();
         }

         @Override
         public Set<String> getCacheNames()
         {
            return sessionContainer.getCacheNames();
         }

         @Override
         public Address getCoordinator()
         {
            return sessionContainer.getCoordinator();
         }

         @Override
         public boolean isRunning(String cacheName)
         {
            return cacheName.equals("jboss.web") ? jvmRouteContainer.isDefaultRunning() : sessionContainer.isRunning(cacheName);
         }

         @Override
         public boolean isDefaultRunning()
         {
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 = extractProperty(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
         if (globalStats != null) {
            // Hack to enable global JMX stats being enabled in both 5.1 and 5.2

            // 1. Create a configuration builder holder
            ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder();

            // 2. Build global configuration with custom settings
            GlobalConfigurationBuilder globalBuilder = holder.getGlobalConfigurationBuilder();
            globalBuilder.read(manager.getCacheManagerConfiguration());
            globalBuilder.globalJmxStatistics().enabled(Boolean.parseBoolean(globalStats));

            // 3. Build default configuration
            holder.getDefaultConfigurationBuilder().read(manager.getDefaultCacheConfiguration());

            // 4. Build all defined caches
            for (String cacheName : manager.getCacheNames()){
               ConfigurationBuilder builder = holder.newConfigurationBuilder(cacheName);
               builder.read(manager.getCacheConfiguration(cacheName));
            }

            // 5. Discard existing cache manager and create a brand new one
            manager.stop();
            manager = new DefaultCacheManager(holder, false);
         }

         manager.start();
         return manager;
      } catch (IOException e) {
         throw new CacheException("Unable to create default cache manager", e);
      }
   }
View Full Code Here

        LOGGER.info("Configuring Cache from {} ",
            configFile.getAbsolutePath());
        InputStream in = null;
        try {
          in = processConfig(new FileInputStream(configFile), properties);
          cacheManager  = new DefaultCacheManager(in);
        } finally {
          if (in != null) {
            in.close();
          }
        }
      } else {
        LOGGER.info("Configuring Cache from Classpath Default {} ",
            CONFIG_PATH);
        InputStream in = processConfig(this.getClass().getClassLoader()
            .getResourceAsStream(CONFIG_PATH), properties);
        if (in == null) {
          throw new IOException(
              "Unable to open config at classpath location "
                  + CONFIG_PATH);
        }
        cacheManager  = new DefaultCacheManager(in);
        in.close();
      }
    } finally {
      Thread.currentThread().setContextClassLoader(cl);
    }
View Full Code Here

  @Override
  public void before() throws Throwable {
    InputStream inputStream = FileLookupFactory.newInstance().lookupFileStrict( configurationFile, InfinispanNode.class.getClassLoader() );
    ConfigurationBuilderHolder cfgBuilder = new ParserRegistry().parse( inputStream );
    cfgBuilder.getGlobalConfigurationBuilder().globalJmxStatistics().cacheManagerName( cacheManagerName );
    manager = new DefaultCacheManager( cfgBuilder, true );
    System.out.println( "Started CacheManager" );
    //Now *Actually* start it:
    manager.getCache();
    started = true;
  }
View Full Code Here

public class JDBCCacheLoaderTest {

  public static void main(String[] args) throws Exception {

    EmbeddedCacheManager cacheManager = new DefaultCacheManager("infinispan-loaders-mysql.xml");
   
    stringBasedTest(cacheManager);
   
    Cache<Object, Object> cache = cacheManager.getCache("custom-cache-loader");
   
    for(int i = 1 ; i <= 15 ; i ++){
      cache.put(i, UUID.randomUUID().toString());
    }
   
View Full Code Here

               .clustering().cacheMode(CacheMode.DIST_SYNC//Set Cache mode to DISTRIBUTED with SYNCHRONOUS replication
               .hash().numOwners(2) //Keeps two copies of each key/value pair
               .expiration().lifespan(ENTRY_LIFESPAN) //Set expiration - cache entries expire after some time (given by
                     // the lifespan parameter) and are removed from the cache (cluster-wide).
               .build();
         manager = new DefaultCacheManager(glob, loc, true);
      }
      return manager;
   }
View Full Code Here

   
    return configuration ;
  }
 
  public EmbeddedCacheManager getEmbeddedCacheManager() {
    return new DefaultCacheManager(initGlobalConfiguration(), initConfiguration());
  }
View Full Code Here

public class ProgrammaticConfiguration {

  public static void main(String[] args) throws IOException {

    EmbeddedCacheManager manager = new DefaultCacheManager();
//    Cache defaultCache = manager.getCache();
   
    Configuration c = new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC).build();
   
    String newCacheName = "repl";
    manager.defineConfiguration(newCacheName, c);
    Cache<String, String> cache = manager.getCache(newCacheName);
  }
View Full Code Here

public class HelloWorldDefaultCache {

  public static void main(String[] args) throws InterruptedException {

    DefaultCacheManager cacheManager = new DefaultCacheManager();

    Cache<Object, Object> cache = cacheManager.getCache();
    Cache<Object, Object> cache01 = cacheManager.getCache("0001");
    Cache<Object, Object> cache02 = cacheManager.getCache("0002");
    Cache<Object, Object> cache03 = cacheManager.getCache("0003");
   
    System.out.println("name = " + cache.getName() + ", version = " + cache.getVersion() + ", status = " + cache.getStatus());
    System.out.println("name = " + cache01.getName() + ", version = " + cache01.getVersion() + ", status = " + cache01.getStatus());
    System.out.println("name = " + cache02.getName() + ", version = " + cache02.getVersion() + ", status = " + cache02.getStatus());
    System.out.println("name = " + cache03.getName() + ", version = " + cache03.getVersion() + ", status = " + cache03.getStatus());
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.