本文整理汇总了Java中org.infinispan.manager.EmbeddedCacheManager.defineConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedCacheManager.defineConfiguration方法的具体用法?Java EmbeddedCacheManager.defineConfiguration怎么用?Java EmbeddedCacheManager.defineConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.infinispan.manager.EmbeddedCacheManager
的用法示例。
在下文中一共展示了EmbeddedCacheManager.defineConfiguration方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCacheInfinispan
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
* Inits the cache infinispan.
*/
private static void initCacheInfinispan() {
EmbeddedCacheManager manager = new DefaultCacheManager();
Configuration config = new Configuration().fluent()
.eviction()
.maxEntries((int)sCacheItemsLimit).strategy(EvictionStrategy.LRU)
/*.wakeUpInterval(5000L)*/ // TODO - fix it
.expiration()
.maxIdle(120000L)
.build();
manager.defineConfiguration("name", config);
ispnCache = manager.getCache("name");
}
示例2: create
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Override
public BenchmarkCache<Integer, Integer> create(int _maxElements) {
EmbeddedCacheManager m = getCacheMangaer();
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.eviction().maxEntries(_maxElements);
cb.storeAsBinary().disable();
if (!withExpiry) {
cb.expiration().disableReaper().lifespan(-1);
} else {
cb.expiration().lifespan(5 * 60, TimeUnit.SECONDS);
}
switch (algorithm) {
case LRU: cb.eviction().strategy(EvictionStrategy.LRU); break;
case LIRS: cb.eviction().strategy(EvictionStrategy.LIRS); break;
case UNORDERED: cb.eviction().strategy(EvictionStrategy.UNORDERED); break;
}
m.defineConfiguration(CACHE_NAME, cb.build());
Cache<Integer, Integer> _cache = m.getCache(CACHE_NAME);
return new MyBenchmarkCache(_cache);
}
示例3: testConfigBuilder
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).location(tmpDataDirectory)
.expiredLocation(tmpExpiredDirectory).implementationType(LevelDBStoreConfiguration.ImplementationType.AUTO).build();
StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
assertTrue(cacheLoaderConfig instanceof LevelDBStoreConfiguration);
LevelDBStoreConfiguration leveldbConfig = (LevelDBStoreConfiguration) cacheLoaderConfig;
assertEquals(tmpDataDirectory, leveldbConfig.location());
assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there");
cache.stop();
cacheManager.stop();
}
示例4: testLegacyJavaConfig
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Test(enabled = false, description = "ISPN-3388")
public void testLegacyJavaConfig() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).addProperty("location", tmpDataDirectory)
.addProperty("expiredLocation", tmpExpiredDirectory).addProperty("implementationType", LevelDBStoreConfiguration.ImplementationType.AUTO.toString()).build();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there legacy java");
cache.stop();
cacheManager.stop();
}
示例5: testConfigBuilder
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(MapDBStoreConfigurationBuilder.class)
.location(tmpDirectory)
.compression(true)
.build();
StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
assertTrue(cacheLoaderConfig instanceof MapDBStoreConfiguration);
MapDBStoreConfiguration config = (MapDBStoreConfiguration) cacheLoaderConfig;
assertEquals(true, config.compression());
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there");
cache.stop();
cacheManager.stop();
}
示例6: testConfigBuilder
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(OffheapStoreConfigurationBuilder.class)
.compression(true)
.build();
StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
assertTrue(cacheLoaderConfig instanceof OffheapStoreConfiguration);
OffheapStoreConfiguration config = (OffheapStoreConfiguration) cacheLoaderConfig;
assertEquals(true, config.compression());
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there");
cache.stop();
cacheManager.stop();
}
示例7: getCache
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public static synchronized Cache<String, String> getCache() {
if (INSTANCE == null) {
GlobalConfiguration gc = GlobalConfigurationBuilder.defaultClusteredBuilder()
// Use this line for testing in Kubernetes. But it requires
// additional configuration:
// oc policy add-role-to-user view
// system:serviceaccount:$(oc
// project -q):default -n $(oc project -q)
// And setting OPENSHIFT_KUBE_PING_NAMESPACE env variable to
// your namespace
.transport().defaultTransport()
.addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml")
// Or use, multicast stack to simplify local testing:
// .transport().defaultTransport().addProperty("configurationFile",
// "default-configs/default-jgroups-udp.xml")
.build();
EmbeddedCacheManager manager = new DefaultCacheManager(gc);
// And here are per-cache configuration, e.g. eviction, replication
// scheme etc.
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.clustering().cacheMode(CacheMode.REPL_ASYNC);
manager.defineConfiguration("default", configurationBuilder.build());
INSTANCE = manager.getCache("default");
}
return INSTANCE;
}
示例8: infinispanCacheManager
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Bean(destroyMethod = "stop")
@ConditionalOnMissingBean
public EmbeddedCacheManager infinispanCacheManager() throws IOException {
EmbeddedCacheManager cacheManager = createEmbeddedCacheManager();
List<String> cacheNames = this.cacheProperties.getCacheNames();
if (!CollectionUtils.isEmpty(cacheNames)) {
for (String cacheName : cacheNames) {
cacheManager.defineConfiguration(cacheName,
getDefaultCacheConfiguration());
}
}
return cacheManager;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:InfinispanCacheConfiguration.java
示例9: createCache
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Override
public ConcurrentMap<?, ?> createCache(String containerName,
String cacheName, Set<cacheMode> cMode) throws CacheExistException,
CacheConfigException {
EmbeddedCacheManager manager = this.cm;
Cache<Object,Object> c;
String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
if (manager == null) {
return null;
}
if (manager.cacheExists(realCacheName)) {
throw new CacheExistException();
}
// Sanity check to avoid contrasting parameters
if (cMode.containsAll(EnumSet.of(
IClusterServices.cacheMode.NON_TRANSACTIONAL,
IClusterServices.cacheMode.TRANSACTIONAL))) {
throw new CacheConfigException();
}
if (cMode.contains(IClusterServices.cacheMode.NON_TRANSACTIONAL)) {
c = manager.getCache(realCacheName);
return c;
} else if (cMode.contains(IClusterServices.cacheMode.TRANSACTIONAL)) {
Configuration rc = manager
.getCacheConfiguration("transactional-type");
manager.defineConfiguration(realCacheName, rc);
c = manager.getCache(realCacheName);
return c;
}
return null;
}
示例10: cacheManager
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
static EmbeddedCacheManager cacheManager(String cacheName, Configuration configuration) {
EmbeddedCacheManager manager = cacheManager();
manager.defineConfiguration(cacheName, configuration);
return manager;
}
示例11: initCacheInfinispanKoda
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
* Inits the cache infinispan.
*
* @throws NativeMemoryException the native memory exception
* @throws KodaException the koda exception
*/
// private static void initCacheInfinispanKoda() {
// LOG.info("Initializing ISPN - Koda ...");
// EmbeddedCacheManager manager = new DefaultCacheManager();
//
// KodaCacheStoreConfig cfg = new KodaCacheStoreConfig();
// cfg.setBucketNumber(N);
// cfg.setCacheNamespace("ns");
// cfg.setEvictionPolicy("LRU");
// cfg.setMaxMemory(sMemoryLimit);
// cfg.setDefaultExpireTimeout(6000);
// cfg.setKeyClass(ByteArrayWritable.class);
// cfg.setValueClass(ByteArrayWritable.class);
//
// Configuration config = new Configuration().fluent()
// .eviction()
// .maxEntries(20).strategy(EvictionStrategy.LRU)
// .wakeUpInterval(5000L)
// .expiration()
// .maxIdle(120000L)
// .loaders()
// .shared(false).passivation(false).preload(false)
// .addCacheLoader(
// cfg
// )/*.locking().useLockStriping(true).concurrencyLevel(256)*/.build();
//
// manager.defineConfiguration("name", config);
// ispnCacheKoda = manager.getCache("name");
// List<CommandInterceptor> chain = ispnCacheKoda.getAdvancedCache().getInterceptorChain();
// //ispnCacheKoda.getAdvancedCache().addInterceptor( new KodaInterceptor(), chain.size()-1);
// mCache = getISPNOffHeapCache();
//
// }
private static void initCacheInfinispanKoda() throws NativeMemoryException, KodaException {
LOG.info("Initializing ISPN - Koda ...");
initCacheKoda();
OffHeapDataContainer dc = new OffHeapDataContainer(mCache);
EmbeddedCacheManager manager = new DefaultCacheManager();
Configuration config = new Configuration().fluent().
dataContainer().
dataContainer(dc).
build();
manager.defineConfiguration("name", config);
ispnCacheKoda = manager.getCache("name");
// org.infinispan.Cache<byte[], byte[]> cache = ispnCacheKoda;
LOG.info("Done");
}
示例12: buildServer
import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
private static HotRodServer buildServer(int port) {
HotRodServer hotRodServer = new HotRodServer() {
@Override
public ConfigurationBuilder createTopologyCacheConfig(long distSyncTimeout) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
ConfigurationBuilder c = super.createTopologyCacheConfig(distSyncTimeout);
c.transaction().syncCommitPhase(false).syncRollbackPhase(false);
return c;
}
};
HotRodServerConfiguration hotrodConfig = new HotRodServerConfigurationBuilder()
.host("127.0.0.1")
.port(port)
.proxyHost("127.0.0.1")
.proxyPort(port)
.topologyStateTransfer(false)
.defaultCacheName(BasicCacheContainer.DEFAULT_CACHE_NAME)
.recvBufSize(4096)
.sendBufSize(4096)
//.idleTimeout(0)
.workerThreads(2)
.build(true);
GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
.classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
.globalJmxStatistics()
.jmxDomain("org.apache.marmotta.kiwi")
.allowDuplicateDomains(true)
.build();
Configuration defaultConfiguration = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.LOCAL)
.sync()
.dataContainer()
.keyEquivalence(ByteArrayEquivalence.INSTANCE)
.valueEquivalence(ByteArrayEquivalence.INSTANCE)
.build();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
cacheManager.defineConfiguration(CacheManager.NODE_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.TRIPLE_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.URI_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.BNODE_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.LITERAL_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.NS_PREFIX_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.NS_URI_CACHE, defaultConfiguration);
cacheManager.defineConfiguration(CacheManager.REGISTRY_CACHE, defaultConfiguration);
cacheManager.getCache(CacheManager.NODE_CACHE, true);
cacheManager.getCache(CacheManager.TRIPLE_CACHE, true);
cacheManager.getCache(CacheManager.URI_CACHE, true);
cacheManager.getCache(CacheManager.BNODE_CACHE, true);
cacheManager.getCache(CacheManager.LITERAL_CACHE, true);
cacheManager.getCache(CacheManager.NS_PREFIX_CACHE, true);
cacheManager.getCache(CacheManager.NS_URI_CACHE, true);
cacheManager.getCache(CacheManager.REGISTRY_CACHE, true);
hotRodServer.start(hotrodConfig, cacheManager);
return hotRodServer;
}