当前位置: 首页>>代码示例>>Java>>正文


Java DefaultCacheManager.defineConfiguration方法代码示例

本文整理汇总了Java中org.infinispan.manager.DefaultCacheManager.defineConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCacheManager.defineConfiguration方法的具体用法?Java DefaultCacheManager.defineConfiguration怎么用?Java DefaultCacheManager.defineConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.infinispan.manager.DefaultCacheManager的用法示例。


在下文中一共展示了DefaultCacheManager.defineConfiguration方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Store some values
   int range = 10;
   IntStream.range(0, range).boxed().forEach(i -> cache.put(i + "-key", i + "-value"));
   // Map and reduce the keys
   int result = cache.keySet().stream()
      .map((Serializable & Function<String, Integer>) e -> Integer.valueOf(e.substring(0, e.indexOf("-"))))
           .collect(CacheCollectors.serializableCollector(() -> Collectors.summingInt(i -> i.intValue())));
   System.out.printf("Result = %d\n", result);
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:19,代码来源:InfinispanStreams.java

示例2: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Register a listener
   cache.addListener(new MyListener());
   // Store some values
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   cache.put("key1", "newValue");
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:17,代码来源:InfinispanListen.java

示例3: MetadataManager

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public MetadataManager(DefaultCacheManager cacheManager){
   Configuration cacheConfiguration = cacheManager.getCacheConfiguration(Support.AVRO_METADATA_CACHE_NAME);
   if (cacheConfiguration == null) {
      ConfigurationBuilder cfg = new ConfigurationBuilder();
      CacheMode cacheMode =
            cacheManager.getDefaultCacheConfiguration().clustering().cacheMode().equals(CacheMode.LOCAL)
                  ? CacheMode.LOCAL : CacheMode.REPL_SYNC;
      cfg
            .transaction().lockingMode(LockingMode.PESSIMISTIC).syncCommitPhase(true).syncRollbackPhase(true)
            .persistence().addSingleFileStore().location(System.getProperty("java.io.tmpdir") + "/" + cacheManager.getNodeAddress()) // mandatory
            .locking().isolationLevel(IsolationLevel.READ_COMMITTED).useLockStriping(false)
            .clustering().cacheMode(cacheMode)
            .stateTransfer().fetchInMemoryState(true)
            .dataContainer().keyEquivalence(new ByteArrayEquivalence()); // for HotRod compatibility
      if (cacheMode.equals(CacheMode.REPL_SYNC)) cfg.clustering().stateTransfer().awaitInitialTransfer(true);
      cacheManager.defineConfiguration(Support.AVRO_METADATA_CACHE_NAME, cfg.build());
      this.cacheManager = cacheManager;
      this.marshaller= Externalizer.getInstance();
      this.knownSchemas = new ConcurrentHashMap<>();
      knownSchemas.put(Request.getClassSchema().getFullName(), Request.getClassSchema());
      knownSchemas.put(Response.getClassSchema().getFullName(), Response.getClassSchema());
   }
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:24,代码来源:MetadataManager.java

示例4: init

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public synchronized void init() {

        ConfigurationBuilder cfgBuilder = new ConfigurationBuilder();

        //ALERT CHANGING CONF HERE
//        cfgBuilder.persistence().passivation(true).addSingleFileStore().purgeOnStartup(true).location("/tmp/cachefiles/").create();
        cfgBuilder.eviction().strategy(EvictionStrategy.LRU).maxEntries(10)
                .persistence()
                .passivation(false).addSingleFileStore()
                .fetchPersistentState(true)
                .ignoreModifications(false)
                .purgeOnStartup(true).
                location("/tmp/cachefiles/").
                create();

        //cfgBuilder.eviction().create();

        Configuration configuration = cfgBuilder.build();
         manager = new DefaultCacheManager(configuration);
        manager.defineConfiguration("Cache1",configuration);


    }
 
开发者ID:sumanthn,项目名称:hashaggregator,代码行数:24,代码来源:CacheStore.java

示例5: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Store a value
   cache.put("key", "value");
   // Retrieve the value and print it out
   System.out.printf("key = %s\n", cache.get("key"));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:15,代码来源:InfinispanMap.java

示例6: initialize

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public void initialize(Configuration config) {
GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
global.globalJmxStatistics().allowDuplicateDomains(true);
manager = new DefaultCacheManager(global.build());
ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.persistence()
          .addStore(SoftIndexFileStoreConfigurationBuilder.class)
          .indexLocation(config.getDataDir()+"/index")
          .dataLocation(config.getDataDir()+"/data");
      manager.defineConfiguration("raccovery-cache", builder.build(global.build()));
   cache = manager.getCache("raccovery-cache");
   LOG.info("Starting persistence layer");
  }
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:14,代码来源:InfinispanPersistence.java

示例7: setUp

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
@Before
public void setUp() {
    _cacheMgr = new DefaultCacheManager(new GlobalConfigurationBuilder()
        .transport().defaultTransport().build());
    
    _cacheMgr.defineConfiguration("test-cache", 
            new ConfigurationBuilder().invocationBatching().enable().build());
    Cache<String, String> cache = _cacheMgr.getCache("test-cache");
    _registry = new InfinispanRegistry(cache);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:InfinispanRegistryTest.java

示例8: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   AdvancedCache<String, String> cache = cacheManager.<String, String>getCache("local").getAdvancedCache();
   FunctionalMapImpl<String, String> functionalMap = FunctionalMapImpl.create(cache);
   FunctionalMap.WriteOnlyMap<String, String> writeOnlyMap = WriteOnlyMapImpl.create(functionalMap);
   FunctionalMap.ReadOnlyMap<String, String> readOnlyMap = ReadOnlyMapImpl.create(functionalMap);

   // Execute two parallel write-only operation to store key/value pairs
   CompletableFuture<Void> writeFuture1 = writeOnlyMap.eval("key1", "value1",
      (v, writeView) -> writeView.set(v));
   CompletableFuture<Void> writeFuture2 = writeOnlyMap.eval("key2", "value2",
      (v, writeView) -> writeView.set(v));

   // When each write-only operation completes, execute a read-only operation to retrieve the value
   CompletableFuture<String> readFuture1 =
      writeFuture1.thenCompose(r -> readOnlyMap.eval("key1", EntryView.ReadEntryView::get));
   CompletableFuture<String> readFuture2 =
      writeFuture2.thenCompose(r -> readOnlyMap.eval("key2", EntryView.ReadEntryView::get));

   // When the read-only operation completes, print it out
   System.out.printf("Created entries: %n");
   CompletableFuture<Void> end = readFuture1.thenAcceptBoth(readFuture2, (v1, v2) ->
      System.out.printf("key1 = %s%nkey2 = %s%n", v1, v2));

   // Wait for this read/write combination to finish
   end.get();

   // Create a read-write map
   FunctionalMap.ReadWriteMap<String, String> readWriteMap = ReadWriteMapImpl.create(functionalMap);

   // Use read-write multi-key based operation to write new values
   // together with lifespan and return previous values
   Map<String, String> data = new HashMap<>();
   data.put("key1", "newValue1");
   data.put("key2", "newValue2");
   Traversable<String> previousValues = readWriteMap.evalMany(data, (v, readWriteView) -> {
      String prev = readWriteView.find().orElse(null);
      readWriteView.set(v, new MetaLifespan(Duration.ofHours(1).toMillis()));
      return prev;
   });

   // Use read-only multi-key operation to read current values for multiple keys
   Traversable<EntryView.ReadEntryView<String, String>> entryViews =
      readOnlyMap.evalMany(data.keySet(), readOnlyView -> readOnlyView);
   System.out.printf("Updated entries: %n");
   entryViews.forEach(view -> System.out.printf("%s%n", view));

   // Finally, print out the previous entry values
   System.out.printf("Previous entry values: %n");
   previousValues.forEach(prev -> System.out.printf("%s%n", prev));
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:53,代码来源:InfinispanFunctional.java

示例9: initialize

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
/**
 * Carry out any initialization tasks that might be necessary
 */
@Override
public void initialize() {
    cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);

    if(entryCache == null) {
        cacheManager.defineConfiguration(LDCACHE_ENTRY_CACHE, defaultConfiguration);

        entryCache = cacheManager.<String,CacheEntry>getCache(LDCACHE_ENTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
    }


    log.info("initialised cache manager ({})", globalConfiguration.isClustered() ? "cluster name: "+globalConfiguration.transport().clusterName() : "single host");

}
 
开发者ID:apache,项目名称:marmotta,代码行数:18,代码来源:LDCachingInfinispanBackend.java


注:本文中的org.infinispan.manager.DefaultCacheManager.defineConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。