當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。