当前位置: 首页>>代码示例>>Java>>正文


Java CacheFactory类代码示例

本文整理汇总了Java中com.tangosol.net.CacheFactory的典型用法代码示例。如果您正苦于以下问题:Java CacheFactory类的具体用法?Java CacheFactory怎么用?Java CacheFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CacheFactory类属于com.tangosol.net包,在下文中一共展示了CacheFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadCoherence

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
/**
 * Load the cache with 3 trades and 10 legs for each trade.
 * 
 * @throws Exception
 */
private static void loadCoherence() throws Exception {
	NamedCache tradesCache = CacheFactory.getCache(CACHE_NAME);

	// populate the cache
	Map legsMap = new HashMap();
	Trade trade = new Trade();

	for (int i = 1; i <= NUMTRADES; i++) {

		for (int j = 1; j <= NUMLEGS; j++) {
			Leg leg = new Leg();
			leg.setId(j);
			leg.setNotional(i + j);
			legsMap.put(j, leg);
		}
		trade.setId(i);
		trade.setName("NameIs " + i);
		trade.setLegs(legsMap);
		tradesCache.put(i, trade);
	}

	System.out.println("Loaded Coherence");

}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:TestCoherenceConnection.java

示例2: setUpBeforeClass

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
	//System.setProperty("tangosol.coherence.distributed.localstorage", "true");
	//System.setProperty("tangosol.pof.enabled", "true");
	//System.setProperty("tangosol.coherence.cluster", "XDMCacheCluster");
       //System.setProperty("tangosol.coherence.role", "TestCacheServer");
	//System.setProperty("tangosol.coherence.cacheconfig", "coherence/xdm-test-cache-config.xml");
	System.setProperty("tangosol.coherence.cacheconfig", "coherence/xdm-client-cache-config.xml");
	System.setProperty("tangosol.coherence.proxy.address", "localhost");
	System.setProperty("tangosol.coherence.proxy.port", "21000");

	//context = new ClassPathXmlApplicationContext("spring/coh-client-context.xml");

	System.out.println("about to start cluster");
	//CacheFactory.ensureCluster();
	CacheFactory.getCache(CN_XDM_DOCUMENT);
	CacheFactory.getCache(CN_XDM_ELEMENT);
	CacheFactory.getCache(CN_XDM_NAMESPACE_DICT);
	CacheFactory.getCache(CN_XDM_PATH_DICT);
	System.out.println("cluster started");
	sampleRoot = "../../etc/samples/tpox/";
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:23,代码来源:DocumentManagementClientTest.java

示例3: start

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@Override
public void start()
{
	if (!client.admin().indices().prepareExists(index).execute().actionGet().isExists())
	{
		CreateIndexRequestBuilder createIndexRequest = client.admin().indices()
				.prepareCreate(index);
		createIndexRequest.execute().actionGet();
	}

	if (configPath == null)
	{
		cache = CacheFactory.getCache(cacheName);
	}
	else
	{
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		cache = CacheFactory.getCacheFactoryBuilder()
				.getConfigurableCacheFactory(configPath, classLoader)
				.ensureCache(cacheName, classLoader);
	}
	Filter filter = QueryHelper.createFilter(query);
	(synchronizer = new CoherenceSynchronizer(cache, filter, bulkSize)).start();
	service.submit(indexerTask);
}
 
开发者ID:dmcarba,项目名称:elasticsearch-river-coherence,代码行数:26,代码来源:CoherenceRiver.java

示例4: testIndexingCoherenceFilter

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@Test
public void testIndexingCoherenceFilter() throws Exception
{
	NamedCache cache = CacheFactory.getCache("TEST_CACHE");
	// Add to cache
	cache.put(-1, getTestBean(1));
	// River
	XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
	builder.field("type", "coherence");
	builder.startObject("coherence");
	builder.field("cache", "TEST_CACHE");
	builder.field("query", "key() between 500 and 800");
	builder.endObject();
	builder.endObject();

	logger.info("Adding river \n{}", builder.string());
	client().prepareIndex(RiverIndexName.Conf.DEFAULT_INDEX_NAME, "coherence_river_3", "_meta")
			.setSource(builder).get();
	// Add to cache
	for (int i = 0; i < 1000; i++)
	{
		cache.put(i, getTestBean(1));
	}
	checkCount("coherence", 301);
}
 
开发者ID:dmcarba,项目名称:elasticsearch-river-coherence,代码行数:26,代码来源:CoherenceRiverTest.java

示例5: add

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
public void add(Object key, Object value) throws ResourceException {
	 
		NamedCache sourceCache =  getCache();
		if (sourceCache.containsKey(key)) {
			throw new ResourceException("Unable to add object for key: " + key + " to cache " + this.cacheName + ", because it already exist");
		}
		
		TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);

		tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
		tmap.setConcurrency(TransactionMap.CONCUR_PESSIMISTIC);
		
		tmap.begin();
		try
		    {
		    tmap.put(key, value);
		    tmap.prepare();
		    tmap.commit();
		    }
		catch (Exception e) {
			throw new ResourceException(e);
		}
		
		sourceCache = getCache();
		if (!sourceCache.containsKey(key)) {
			throw new ResourceException("Problem adding object for key: " + key + " to the cache " + this.cacheName +", object not found after add");
		}
	
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:CoherenceConnectionImpl.java

示例6: update

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
public void update(Object key, Object object) throws ResourceException {
	NamedCache sourceCache =  getCache();
	if (!sourceCache.containsKey(key)) {
		throw new ResourceException("Unable to update object for key: " + key + " to cache " + this.cacheName + ", because it already exist");
	}
	
	TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);

	tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
	tmap.setConcurrency(TransactionMap.CONCUR_PESSIMISTIC);
	
	tmap.begin();
	try
	    {
	    tmap.put(key, object);
	    tmap.prepare();
	    tmap.commit();
	    }
	catch (Exception e) {
		throw new ResourceException(e);
	}
	
	sourceCache = getCache();
	if (!sourceCache.containsKey(key)) {
		throw new ResourceException("Problem updating object for key: " + key + " to the cache " + this.cacheName +", object not found after add");
	}

	
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:CoherenceConnectionImpl.java

示例7: remove

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
public void remove(Object key) throws ResourceException {
	System.out.println("Remove: " + key);
	NamedCache sourceCache =  getCache();
	if (!sourceCache.containsKey(key)) {
		throw new ResourceException("Unable to remove object for key: " + key + " from cache " + this.cacheName + ", because it doesn't exist");
	}
	
	TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);

	tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
	tmap.setConcurrency(TransactionMap.CONCUR_OPTIMISTIC);
	
	tmap.begin();
	try
	    {
	    tmap.remove(key);
	    tmap.prepare();
	    tmap.commit();
	    }
	catch (Exception e) {
		throw new ResourceException(e);

	}
	
	if (getCache().containsKey(key)) {
		throw new ResourceException("Unable to remove object for key: " + key + " from the cache " + this.cacheName );
	}

}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:CoherenceConnectionImpl.java

示例8: loadCoherence

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
/**
	 * Load the cache with 3 trades and 10 legs for each trade.
	 * 
	 * @throws Exception
	 */
	private static void loadCoherence() throws Exception {
		NamedCache tradesCache = CacheFactory.getCache(CACHE_NAME);
		TradesCacheSource translator = new TradesCacheSource();
		
		for (int i = 1; i <= NUMTRADES; i++) {

			Trade trade = (Trade) translator.createObjectFromMetadata("org.teiid.translator.coherence.Trade");
//			execFactory.getCacheTranslator().createObject("org.teiid.translator.coherence.Trade");
			
			Map legsMap = new HashMap();
			for (int j = 1; j <= NUMLEGS; j++) {
	
				Object leg = translator.createObjectFromMetadata("org.teiid.translator.coherence.Leg");
					//createObject("org.teiid.translator.coherence.Leg");
					//new Leg();
				if (leg == null) {
					throw new Exception("Unable to create leg");
				}
				translator.setValue("Trade", "LegId", leg, j, long.class);
				translator.setValue("Trade", "Notational", leg, j, double.class);
				translator.setValue("Trade", "Name", leg, "LegName " + j, String.class);
				
				legsMap.put(j, leg);
			}
			
			translator.setValue("Trade", "TradeId", trade, i, long.class);
			translator.setValue("Trade", "Name", trade, "TradeName " + i, String.class);
			translator.setValue("Trade", "Legs", trade, legsMap, Map.class);
			
			tradesCache.put(i, trade);
		}


	}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:40,代码来源:TradesCacheSource.java

示例9: getDistributedMap

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
public Map getDistributedMap(String name) {		 
	NamedCache sharedCache = null;
	try {
		sharedCache = CacheFactory.getCache(name);			
	} catch (Exception e) {
		e.printStackTrace();
		throw new IllegalStateException(e.getMessage());
	}
	return sharedCache;
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:11,代码来源:CacheManager.java

示例10: process

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@Override
public Object process(Entry entry) {
	
	//logger.trace("process.enter; entry: {}", entry);
	XDMDocumentManagementServer xdm = ((SpringAwareCacheFactory) CacheFactory.getConfigurableCacheFactory()).getSpringBean("xdmManager", XDMDocumentManagementServer.class);
	if (xdm == null) {
		throw new IllegalStateException("XDM Server Context is not ready");
	}
	xdm.deleteDocument(entry);
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:12,代码来源:DocumentRemover.java

示例11: getBeanOrThrowException

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
/**
 * return non-null bean or throws IllegalStateException
 *
 * @param beanId bean's id
 * @param cl     bean's class
 * @return IllegalStateException if fails to retrieve bean
 */
//@Nonnull
public static <T> T getBeanOrThrowException(String beanId, Class<T> cl) {
    final ConfigurableCacheFactory factory = CacheFactory.getConfigurableCacheFactory();
    if (factory instanceof SpringBeanProvider) {
        final T bean = ((SpringBeanProvider) factory).getSpringBean(beanId, cl);
        if (bean != null) {
            return bean;
        }
    }
    throw new IllegalStateException();
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:19,代码来源:SpringAwareCacheFactory.java

示例12: aggregate

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@Override
  public Object aggregate(Set entries) {
      //logger.trace("aggregate.enter; entries: {}", entries.size());
XDMDocumentManagementServer xdm = ((SpringAwareCacheFactory) CacheFactory.getConfigurableCacheFactory()).getSpringBean("xdmManager", XDMDocumentManagementServer.class);
if (xdm == null) {
	throw new IllegalStateException("XDM Server Context is not ready");
}
//return xdm.buildDocument(docType, template, params, entries);
return xdm.buildDocument(entries, template, params);
  }
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:11,代码来源:DocumentBuilder.java

示例13: process

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
@Override
public Object process(Entry entry) {

	//logger.trace("process.enter; entry: {}", entry);
	XDMDocumentManagementServer xdm = ((SpringAwareCacheFactory) CacheFactory.getConfigurableCacheFactory()).getSpringBean("xdmManager", XDMDocumentManagementServer.class);
	if (xdm == null) {
		throw new IllegalStateException("XDM Server Context is not ready");
	}
	return xdm.createDocument(entry, uri, xml);
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:11,代码来源:DocumentCreator.java

示例14: main

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
       context = new ClassPathXmlApplicationContext("spring/xdm-cache-context.xml");
       //HazelcastInstance hz = context.getBean("hzInstance", HazelcastInstance.class);
       CacheFactory.ensureCluster();
       //logger.debug("Cache started with Config: {}", hz.getConfig());
       //logger.debug("Serialization Config: {}", hz.getConfig().getSerializationConfig());
       
       //XDMDocumentTask task;
   }
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:13,代码来源:XDMCacheServer.java

示例15: DocumentManagementClient

import com.tangosol.net.CacheFactory; //导入依赖的package包/类
public DocumentManagementClient() {
	super();
	//initializeHazelcast();
	mFactory = new CoherenceXDMFactory();
	//CacheFactory.getConfigurableCacheFactory()
	
	mDictionary = new CoherenceSchemaDictionary(CacheFactory.getConfigurableCacheFactory());
	initializeServices();
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:10,代码来源:DocumentManagementClient.java


注:本文中的com.tangosol.net.CacheFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。