本文整理汇总了Java中org.infinispan.manager.EmbeddedCacheManager类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedCacheManager类的具体用法?Java EmbeddedCacheManager怎么用?Java EmbeddedCacheManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedCacheManager类属于org.infinispan.manager包,在下文中一共展示了EmbeddedCacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCacheManager
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Bean(destroyMethod = "stop")
public EmbeddedCacheManager createCacheManager() {
GlobalConfigurationBuilder globalCfg = new GlobalConfigurationBuilder();
globalCfg.globalJmxStatistics().allowDuplicateDomains(true).disable(); // get rid of this?
ConfigurationBuilder cacheCfg = new ConfigurationBuilder();
cacheCfg.jmxStatistics().disable();
cacheCfg.indexing()
.index(Index.ALL)
.addIndexedEntity(Fruit.class)
.addIndexedEntity(CEntity.class)
.addIndexedEntity(SimpleEntity.class)
.addProperty("default.directory_provider", "local-heap")
.addProperty("lucene_version", "LUCENE_CURRENT");
return new DefaultCacheManager(globalCfg.build(), cacheCfg.build());
}
示例2: releaseMasterLockIfHeld
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
public void releaseMasterLockIfHeld() {
if (iMasterThread != null) {
iMasterThread.release();
} else if (Boolean.TRUE.equals(getProperty("ReloadIsNeeded", Boolean.FALSE))) {
iLog.info("Reloading server...");
final Long sessionId = getAcademicSession().getUniqueId();
loadOnMaster(new OnlineSectioningServerContext() {
@Override
public Long getAcademicSessionId() { return sessionId; }
@Override
public boolean isWaitTillStarted() { return false; }
@Override
public EmbeddedCacheManager getCacheManager() { return null; }
@Override
public LockService getLockService() { return null; }
});
}
}
示例3: getServerContext
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
public OnlineSectioningServerContext getServerContext(final Long academicSessionId) {
return new OnlineSectioningServerContext() {
@Override
public Long getAcademicSessionId() {
return academicSessionId;
}
@Override
public boolean isWaitTillStarted() {
return false;
}
@Override
public EmbeddedCacheManager getCacheManager() {
return OnlineStudentSchedulingContainerRemote.this.getCacheManager();
}
@Override
public LockService getLockService() {
return iLockService;
}
};
}
示例4: getServerContext
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
public OnlineSectioningServerContext getServerContext(final Long academicSessionId) {
return new OnlineSectioningServerContext() {
@Override
public Long getAcademicSessionId() {
return academicSessionId;
}
@Override
public boolean isWaitTillStarted() {
return false;
}
@Override
public EmbeddedCacheManager getCacheManager() {
return null;
}
@Override
public LockService getLockService() {
return null;
}
};
}
示例5: defaultClusteredCacheManager
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Produces
@ApplicationScoped
public EmbeddedCacheManager defaultClusteredCacheManager() {
GlobalConfiguration g = new GlobalConfigurationBuilder()
.clusteredDefault()
.transport()
.clusterName(MACHINE_TRANSLATIONS_CLUSTER)
.globalJmxStatistics()
.allowDuplicateDomains(true)
.build();
Configuration cfg = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.DIST_ASYNC)
.eviction()
.strategy(EvictionStrategy.LRU)
.type(EvictionType.COUNT).size(150)
.transaction()
.transactionMode(TransactionMode.TRANSACTIONAL)
.lockingMode(LockingMode.PESSIMISTIC)
.build();
return new DefaultCacheManager(g, cfg);
}
示例6: testStart
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
/**
* Run multiple instances and check that all instances are online.
*
* @throws ExecutionException
* @throws TimeoutException
*/
@Test
public void testStart() throws IOException, InterruptedException, ExecutionException {
int nodeNumber = 3;
prepareCluster(nodeNumber, null);
// start test instance
EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
this.cacheManager = cacheManager;
cacheManager.start();
LOGGER.debug("waiting nodes");
try {
waitNodes(cacheManager, nodeNumber + 1, 30, TimeUnit.SECONDS);
} catch (TimeoutException e) {
Assert.fail(String.format("Node number %d not reached before timeout", nodeNumber + 1));
}
}
示例7: run
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
public void run() {
final EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder(nodeName, taskName).build();
cacheManager.start();
while (!Thread.currentThread().isInterrupted()) {
try {
Object object = new Object();
// synchronized to become object owner
LOGGER.debug("Start main loop");
synchronized (object) {
object.wait();
}
} catch (InterruptedException e) {
LOGGER.warn("Thread interrupted while wait");
Thread.currentThread().interrupt();
}
}
}
示例8: run
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
public void run() {
final EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder(nodeName, taskName).build();
InfinispanClusterServiceImpl cluster =
new InfinispanClusterServiceImpl(nodeName, cacheManager, new SimpleRolesProvider(), null, null);
cluster.init();
while (!Thread.currentThread().isInterrupted()) {
try {
Object object = new Object();
// synchronized to become object owner
LOGGER.debug("Start main loop");
synchronized (object) {
object.wait();
}
} catch (InterruptedException e) {
LOGGER.warn("Thread interrupted while wait");
Thread.currentThread().interrupt();
}
}
}
示例9: infinispanClusterService
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Bean(destroyMethod = "stop")
public IInfinispanClusterService infinispanClusterService(IPropertyService propertyService, IRolesProvider rolesProvider,
IActionFactory springActionFactory, IInfinispanClusterCheckerService infinispanClusterCheckerService,
EntityManagerFactory entityManagerFactory) {
if (propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_ENABLED)) {
String nodeName = propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_NODE_NAME);
Properties properties = new Properties();
for (String key : propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_TRANSPORT_PROPERTIES)) {
properties.put(key, propertyService.getAsString(JpaMoreInfinispanPropertyIds.transportProperty(key)));
}
GlobalConfiguration globalConfiguration =
new GlobalDefaultReplicatedTransientConfigurationBuilder(properties).nodeName(nodeName).build();
org.infinispan.configuration.cache.Configuration configuration =
new DefaultReplicatedTransientConfigurationBuilder().build();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfiguration, configuration, false);
InfinispanClusterServiceImpl cluster =
new InfinispanClusterServiceImpl(nodeName, cacheManager, rolesProvider, springActionFactory,
infinispanClusterCheckerService);
cluster.init();
return cluster;
} else {
return null;
}
}
示例10: createCacheManager
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
ConfigurationBuilder cfg = getDefaultStandaloneCacheConfig(false);
cfg.indexing().enable()
.addProperty("default.directory_provider", "ram")
.addProperty("lucene_version", "LUCENE_CURRENT");
cfg.validate();
Configuration configuration = cfg.build();
assert cfg.clustering().cacheMode() == CacheMode.LOCAL;
EmbeddedCacheManager cacheManager = new DefaultCacheManager(configuration);
cacheManager.getCache();
return cacheManager;
}
示例11: doCreateHttpServerMechanismFactory
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
@Override
protected HttpServerAuthenticationMechanismFactory doCreateHttpServerMechanismFactory(Map<String, ?> properties) {
HttpServerAuthenticationMechanismFactory delegate = super.doCreateHttpServerMechanismFactory(properties);
String cacheManagerName = UUID.randomUUID().toString();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(
GlobalConfigurationBuilder.defaultClusteredBuilder()
.globalJmxStatistics().cacheManagerName(cacheManagerName)
.transport().nodeName(cacheManagerName).addProperty(JGroupsTransport.CONFIGURATION_FILE, "fast.xml")
.build(),
new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.REPL_SYNC)
.build()
);
Cache<String, SingleSignOnEntry> cache = cacheManager.getCache();
SingleSignOnManager manager = new DefaultSingleSignOnManager(cache, new DefaultSingleSignOnSessionIdentifierFactory(), (id, entry) -> cache.put(id, entry));
SingleSignOnServerMechanismFactory.SingleSignOnConfiguration signOnConfiguration = new SingleSignOnServerMechanismFactory.SingleSignOnConfiguration("JSESSIONSSOID", null, "/", false, false);
SingleSignOnSessionFactory singleSignOnSessionFactory = new DefaultSingleSignOnSessionFactory(manager, this.keyPairSupplier.get());
return new SingleSignOnServerMechanismFactory(delegate, singleSignOnSessionFactory, signOnConfiguration);
}
示例12: createLocalCacheViaJNDI
import org.infinispan.manager.EmbeddedCacheManager; //导入依赖的package包/类
private CacheContainerWrapper createLocalCacheViaJNDI()
throws ResourceException {
String jndiName = getCacheJndiName();
try {
final Object cache = performJNDICacheLookup(jndiName);
LogManager
.logDetail(
LogConstants.CTX_CONNECTOR,
"=== Using CacheContainer (obtained by JNDI:", jndiName, "==="); //$NON-NLS-1 //$NON-NLS-2
return new LocalCacheWrapper((EmbeddedCacheManager) cache);
} catch (ResourceException re) {
throw re;
} catch (Exception err) {
if (err instanceof RuntimeException)
throw (RuntimeException) err;
throw new ResourceException(err);
}
}
示例13: 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");
}
示例14: 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);
}
示例15: 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();
}