Package org.infinispan.manager

Examples of org.infinispan.manager.DefaultCacheManager


  private EmbeddedCacheManager createCustomCacheManager(URL configUrl, JtaPlatform platform) {
    TransactionManagerLookupDelegator transactionManagerLookupDelegator = new TransactionManagerLookupDelegator( platform );
    try {
      InputStream configurationFile = configUrl.openStream();
      try {
        EmbeddedCacheManager tmpCacheManager = new DefaultCacheManager( configurationFile, false );

        AdvancedExternalizer<?> entityKeyExternalizer = EntityKeyExternalizer.INSTANCE;
        AdvancedExternalizer<?> associationKeyExternalizer = AssociationKeyExternalizer.INSTANCE;
        AdvancedExternalizer<?> rowKeyExternalizer = RowKeyExternalizer.INSTANCE;
        AdvancedExternalizer<?> entityKeyMetadataExternalizer = EntityKeyMetadataExternalizer.INSTANCE;
        AdvancedExternalizer<?> idGeneratorKeyExternalizer = IdSourceKeyExternalizer.INSTANCE;

        // override global configuration from the config file to inject externalizers
        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
          .read( tmpCacheManager.getCacheManagerConfiguration() )
          .serialization()
            .addAdvancedExternalizer( entityKeyExternalizer.getId(), entityKeyExternalizer )
            .addAdvancedExternalizer( associationKeyExternalizer.getId(), associationKeyExternalizer )
            .addAdvancedExternalizer( rowKeyExternalizer.getId(), rowKeyExternalizer )
            .addAdvancedExternalizer( entityKeyMetadataExternalizer.getId(), entityKeyMetadataExternalizer )
            .addAdvancedExternalizer( idGeneratorKeyExternalizer.getId(), idGeneratorKeyExternalizer )
          .build();

        cacheManager = new DefaultCacheManager( globalConfiguration, false );

        // override the named cache configuration defined in the configuration file to
        // inject the platform TransactionManager
        for (String cacheName : tmpCacheManager.getCacheNames() ) {
          Configuration originalCfg = tmpCacheManager.getCacheConfiguration( cacheName );
          Configuration newCfg = new ConfigurationBuilder()
            .read( originalCfg )
              .transaction()
                .transactionManagerLookup( transactionManagerLookupDelegator )
            .build();
View Full Code Here


public class ConfigCacheAPI {

  public static void main(String[] args) {

    Configuration configuration = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).build();
    DefaultCacheManager cacheManager = new DefaultCacheManager();
    String newCacheName = "repl";
    cacheManager.defineConfiguration(newCacheName, configuration);
    Cache<String, String> cache = cacheManager.getCache(newCacheName);
    AdvancedCache advancedCache = cache.getAdvancedCache();
    advancedCache.withFlags(Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_CACHE_LOAD).put("local", "only");
    advancedCache.addInterceptor(new CustomCommandInterceptor(), 0);
    System.out.println(advancedCache.getName());
  }
View Full Code Here

   
//    Cache<Object, Object> c = new DefaultCacheManager("infinispan-replication.xml").getCache();
//    System.out.println(c.getVersion());
//    c.stop();
   
    Cache<Object, Object> c = new DefaultCacheManager("infinispan-invalidation.xml").getCache();
    System.out.println(c.getVersion());
    c.stop();
  }
View Full Code Here

    Map<String, String> map = new HashMap<String, String>();
    map.put("key", "value-previous");
    Object obj = map.put("key", "value-new");
    System.out.println(obj);

    Cache<String, String> cache = new DefaultCacheManager("infinispan-distribution.xml").getCache()
    cache.put("key", "value-previous-cache");
    String previous = cache.put("key", "value");
    System.out.println(previous);

    cache.stop();
View Full Code Here

  protected String getCacheName() {
    return CACHE_NAME;
  }
 
  protected EmbeddedCacheManager createCacheManager() throws IOException {
    return new DefaultCacheManager("infinispan-replication.xml");
  }
View Full Code Here

  protected EmbeddedCacheManager createCacheManager() throws IOException {
    return new DefaultCacheManager("infinispan-replication.xml");
  }

  protected EmbeddedCacheManager initCacheManager() throws IOException {
    return new DefaultCacheManager(GlobalConfigurationBuilder.defaultClusteredBuilder().transport().addProperty("configurationFile", "jgroups.xml").build(),
                     new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC).build());
  }
View Full Code Here

  public DistNode() throws IOException {
    super();
  }
 
  protected EmbeddedCacheManager createCacheManager() throws IOException {
    return new DefaultCacheManager("infinispan-distribution.xml");
  }
View Full Code Here

  protected EmbeddedCacheManager createCacheManager() throws IOException {
    return new DefaultCacheManager("infinispan-distribution.xml");
  }
 
  protected EmbeddedCacheManager initCacheManager() throws IOException {
    return new DefaultCacheManager( GlobalConfigurationBuilder.defaultClusteredBuilder().transport().addProperty("configurationFile", "jgroups.xml").build(),
                                new ConfigurationBuilder().clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(2).build());
  }
View Full Code Here

public class FileCacheLoaderTest {

  public static void main(String[] args) throws IOException {
   
    EmbeddedCacheManager cacheManager = new DefaultCacheManager("infinispan-loaders-file.xml");
   
    Cache<Object, Object> cache = cacheManager.getCache("custom-cache-loader");
   
    for(int i = 1 ; i <= 15 ; i ++){
      cache.put(i, UUID.randomUUID().toString());
    }
   
    log("Total entities in cache: " + cache.size());
   
    printCacheEntities(cache);
   
    cache.stop();
   
    cacheManager.stop();
  }
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

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.