org.infinispan.configuration.cache.Configuration类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.infinispan.configuration.cache.Configuration类的一些代码示例,展示了Configuration类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration类的具体详情如下:
包路径:org.infinispan.configuration.cache.Configuration
类名称:Configuration

Configuration介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
  public String locate(String sessionId) {
    DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
    Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : this.cache.getCacheManager().getAddress();
    Node node = (address != null) ? this.factory.createNode(address) : null;
    Map.Entry<String, Void> entry = (node != null) ? this.registry.getEntry(node) : null;
    if (entry == null) {
      entry = this.registry.getEntry(this.registry.getGroup().getLocalMember());
    }
    return (entry != null) ? entry.getKey() : null;
  }
}

代码示例来源:origin: wildfly/wildfly

public InfinispanCacheProperties(Configuration config) {
  this.transactional = config.transaction().transactionMode().isTransactional();
  this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC);
  this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ);
  boolean clustered = config.clustering().cacheMode().needsStateTransfer();
  boolean hasStore = config.persistence().usingStores();
  this.marshalling = clustered || hasStore;
  this.persistent = clustered || (hasStore && !config.persistence().passivation());
}

代码示例来源:origin: org.infinispan/infinispan-core

@SuppressWarnings("unchecked")
@Override
protected void initializeKeyAndCheckData(Object key, Object value) {
 assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores());
 cache.put(key, value);
 DataContainer container = cache.getAdvancedCache().getDataContainer();
 InternalCacheEntry entry = container.get(key);
 CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache);
 assertNotNull("Key " + key + " does not exist in data container.", entry);
 assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue());
 MarshalledEntry<Object, Object> entryLoaded = loader.load(key);
 assertNull("Key " + key + " exists in cache loader.", entryLoaded);
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void call() {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   CacheMode cacheMode = CacheMode.DIST_ASYNC;
   // DIST_ASYNC isn't default so it should stay applied
   builder.clustering().cacheMode(cacheMode);
   String distCacheName = "dist-cache";
   cm.defineConfiguration(distCacheName, builder.build());
   String templateName = "template";
   cm.defineConfiguration(templateName, new ConfigurationBuilder().template(true).build());
   Cache cache = cm.getCache(distCacheName, templateName);
   assertEquals(cacheMode, cache.getCacheConfiguration().clustering().cacheMode());
  }
});

代码示例来源:origin: org.infinispan/infinispan-core

public void testBackwardCompatibility() {
 ConfigurationBuilder c = new ConfigurationBuilder();
 c.memory().storageType(StorageType.BINARY);
 ecm = TestCacheManagerFactory.createCacheManager(c);
 assertEquals(StorageType.BINARY, ecm.getCache().getCacheConfiguration().memory().storageType());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testDelayed(Method m) {
 initAndCheck(m);
 CountDownLatch release = new CountDownLatch(1);
 cache(1).getAdvancedCache().getAsyncInterceptorChain().addInterceptor(new DelayingInterceptor(null, release), 0);
 long requestStart = System.nanoTime();
 assertEquals(m.getName(), cache(0).get(key));
 long requestEnd = System.nanoTime();
 long remoteTimeout = cache(0).getCacheConfiguration().clustering().remoteTimeout();
 long delay = TimeUnit.NANOSECONDS.toMillis(requestEnd - requestStart);
 assertTrue(delay < remoteTimeout);
 release.countDown();
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testRollbackSpanningCaches2() throws Exception {
 startAllCaches();
 Cache<String, String> c1 = cache(0, "c1");
 assertTrue(c1.getCacheConfiguration().clustering().cacheMode().isClustered());
 Cache<String, String> c1Replica = cache(1, "c1");
 assertTrue(c1.isEmpty());
 assertTrue(c1Replica.isEmpty());
 c1.put("c1key", "c1value");
 assertEquals(c1.get("c1key"), "c1value");
 assertEquals(c1Replica.get("c1key"), "c1value");
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void call() {
   ConfigurationBuilder customConfiguration = TestCacheManagerFactory.getDefaultCacheConfiguration(true);
   customConfiguration.transaction().transactionManagerLookup(new TxManagerLookupA());
   Configuration definedConfiguration = cm.defineConfiguration("aCache", customConfiguration.build());
   // verify the setting was not lost:
   assertTrue(definedConfiguration.transaction().transactionManagerLookup() instanceof TxManagerLookupA);
   // verify it's actually being used:
   TransactionManager activeTransactionManager = cm.getCache("aCache").getAdvancedCache().getTransactionManager();
   assertNotNull(activeTransactionManager);
   assertTrue(activeTransactionManager instanceof TmA);
  }
});

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void call() {
   Configuration cfg = cm.getDefaultCacheConfiguration();
   assertTrue(cfg.dataContainer().<byte[]>keyEquivalence() instanceof AnyEquivalence);
   assertTrue(cfg.dataContainer().valueEquivalence() instanceof AnyEquivalence);
   assertEquals(StorageType.OFF_HEAP, cfg.memory().storageType());
   assertEquals(EvictionStrategy.MANUAL, cfg.memory().evictionStrategy());
  }
});

代码示例来源:origin: org.infinispan/infinispan-core

protected void checkConsistencyAcrossCluster(String cacheName, Configuration configuration) {
 // Initialize the partitioner to ensure we can compare config equality
 configuration.clustering().hash().keyPartitioner().init(configuration.clustering().hash());
 for (EmbeddedCacheManager m : cacheManagers) {
   Configuration actualConfiguration = m.getCacheConfiguration(cacheName);
   assertNotNull("Cache " + cacheName + " missing from " + m, actualConfiguration);
   assertEquals(configuration, actualConfiguration);
   Cache<Object, Object> cache = m.getCache(cacheName);
   assertEquals(cacheManagers.size(), cache.getAdvancedCache().getRpcManager().getMembers().size());
 }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testDefaultEnlistment() {
 ConfigurationBuilder builder = getLocalBuilder();
 builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
 dcm = new DefaultCacheManager(getGlobalConfig(), builder.build());
 Cache<Object,Object> cache = dcm.getCache();
 assertFalse(cache.getCacheConfiguration().transaction().useSynchronization());
 assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled());
 cache.put("k", "v");
 assertEquals("v", cache.get("k"));
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
public void call() {
 GlobalConfiguration globalCfg = cm.getCacheManagerConfiguration();
 assertFalse(globalCfg.defaultCacheName().isPresent());
 assertNull(cm.getDefaultCacheConfiguration());
 assertEquals(CacheMode.REPL_SYNC, cm.getCacheConfiguration("default").clustering().cacheMode());
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
public void call() {
 GlobalConfiguration globalCfg = cm.getCacheManagerConfiguration();
 assertTrue(globalCfg.transport().transport() instanceof JGroupsTransport);
 assertEquals("demoCluster", globalCfg.transport().clusterName());
 Configuration cfg = cm.getDefaultCacheConfiguration();
 assertEquals(CacheMode.REPL_SYNC, cfg.clustering().cacheMode());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testConfig() {
 assertTrue(cacheManager.getCache("syncEnabled").getCacheConfiguration().transaction().useSynchronization());
 assertFalse(cacheManager.getCache("notSpecified").getCacheConfiguration().transaction().useSynchronization());
 cacheManager.getCache("syncAndRecovery");
}

代码示例来源:origin: org.infinispan/infinispan-core

/**
* Tests that the configuration contains the values expected, as well as immutability of certain elements
*/
public void testConfiguration() {
 Configuration c = cache.getCacheConfiguration();
 assertEquals(CacheMode.LOCAL, c.clustering().cacheMode());
 assertNotNull(c.transaction().transactionManagerLookup());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testConfigOverride() {
   ConfigurationBuilder configuration = getDefaultStandaloneCacheConfig(true);
   configuration.transaction().useSynchronization(true);
   cacheManager.defineConfiguration("newCache", configuration.build());
   assertTrue(cacheManager.getCache("newCache").getCacheConfiguration().transaction().useSynchronization());
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void check(ConfigurationBuilderHolder holder) {
   Configuration local = getConfiguration(holder, "local");
   PersistenceConfiguration persistenceConfiguration = local.persistence();
   assertEquals(5, persistenceConfiguration.connectionAttempts());
   assertEquals(100, persistenceConfiguration.connectionInterval());
   assertEquals(2000, persistenceConfiguration.availabilityInterval());
   assertFalse(persistenceConfiguration.stores().isEmpty());
   AsyncStoreConfiguration asyncConfig = persistenceConfiguration.stores().iterator().next().async();
   assertTrue(asyncConfig.failSilently());
  }
},

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

private CacheTopology getCounterCacheTopology(EmbeddedCacheManager cacheManager) {
 AdvancedCache<?, ?> cache = cacheManager.getCache(CounterModuleLifecycle.COUNTER_CACHE_NAME).getAdvancedCache();
 return cache.getCacheConfiguration().clustering().cacheMode().isClustered() ?
    cache.getComponentRegistry().getDistributionManager().getCacheTopology() :
    null; //local cache
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
 ConfigurationBuilder cb = getDefaultStandaloneCacheConfig(false);
 configurePersistence(cb);
 EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(cb);
 cache = manager.getCache();
 ComponentRegistry componentRegistry = cache.getAdvancedCache().getComponentRegistry();
 PersistenceManagerImpl pm = (PersistenceManagerImpl) componentRegistry.getComponent(PersistenceManager.class);
 sm = pm.getMarshaller();
 store = TestingUtil.getFirstLoader(cache);
 keys = new Set[cache.getCacheConfiguration().clustering().hash().numSegments()];
 return manager;
}

代码示例来源:origin: org.infinispan/infinispan-cdi-embedded

public void testSpecificCacheManager() throws Exception {
   assertEquals(largeCache.getCacheConfiguration().memory().size(), 2000);
   assertEquals(largeCache.getCacheManager().getDefaultCacheConfiguration().memory().size(), 4000);

   assertEquals(smallCache.getCacheConfiguration().memory().size(), 20);
   assertEquals(smallCache.getCacheManager().getDefaultCacheConfiguration().memory().size(), 4000);

   // asserts that the small and large cache are defined in the same cache manager
   assertTrue(smallCache.getCacheManager().equals(largeCache.getCacheManager()));
   assertFalse(smallCache.getCacheManager().equals(cache.getCacheManager()));

   // check that the default configuration has not been modified
   assertEquals(cache.getCacheConfiguration().memory().size(), -1);
  }
}

相关文章