當前位置: 首頁>>代碼示例>>Java>>正文


Java EmbeddedCacheManager類代碼示例

本文整理匯總了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());
}
 
開發者ID:snowdrop,項目名稱:spring-data-snowdrop,代碼行數:18,代碼來源:InfinispanConfiguration.java

示例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; }
		});
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:20,代碼來源:AbstractServer.java

示例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;
		}
	};
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:25,代碼來源:OnlineStudentSchedulingContainerRemote.java

示例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;
		}
	};
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:24,代碼來源:OnlineStudentSchedulingContainer.java

示例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);
}
 
開發者ID:zanata,項目名稱:zanata-mt,代碼行數:23,代碼來源:ResourceProducer.java

示例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));
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:24,代碼來源:TestSimpleCluster.java

示例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();
		}
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:20,代碼來源:SimpleProcess.java

示例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();
		}
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:22,代碼來源:InfinispanClusterProcess.java

示例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;
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:26,代碼來源:JpaMoreInfinispanConfig.java

示例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;
}
 
開發者ID:leads-project,項目名稱:infinispan-avro,代碼行數:17,代碼來源:AvroWrapperIndexingTest.java

示例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);
}
 
開發者ID:wildfly-security,項目名稱:elytron-web,代碼行數:25,代碼來源:FormAuthenticationWithClusteredSSOTest.java

示例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);
	}

}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:24,代碼來源:AbstractInfinispanManagedConnectionFactory.java

示例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");


}
 
開發者ID:VladRodionov,項目名稱:bigbase,代碼行數:19,代碼來源:PerfTest.java

示例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);
}
 
開發者ID:cache2k,項目名稱:cache2k-benchmark,代碼行數:22,代碼來源:InfinispanCacheFactory.java

示例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();
}
 
開發者ID:danberindei,項目名稱:infinispan-cachestore-leveldb,代碼行數:24,代碼來源:ConfigurationTest.java


注:本文中的org.infinispan.manager.EmbeddedCacheManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。