本文整理汇总了Java中com.tangosol.net.CacheFactory.getCache方法的典型用法代码示例。如果您正苦于以下问题:Java CacheFactory.getCache方法的具体用法?Java CacheFactory.getCache怎么用?Java CacheFactory.getCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tangosol.net.CacheFactory
的用法示例。
在下文中一共展示了CacheFactory.getCache方法的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");
}
示例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/";
}
示例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);
}
示例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);
}
示例5: 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);
}
}
示例6: 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;
}
示例7: initializeServices
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
private void initializeServices() {
xddCache = CacheFactory.getCache(CN_XDM_DOCUMENT);
xdmCache = CacheFactory.getCache(CN_XDM_ELEMENT);
//xpvCache = getCache(CN_XDM_PATH_VALUE_INDEX);
dGen = new ClusteredSequenceGenerator(SQN_DOCUMENT, 100);
logger.trace("initialize; got cache: {}", xdmCache);
}
示例8: shouldDoSomething
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
@Test(enabled = false)
public void shouldDoSomething() {
NamedCache cache = CacheFactory.getCache("dist-latest");
assertThat(cache, is(notNullValue()));
cache.put("someKey", "version 1 of value");
}
示例9: shouldThrowExceptionIfNotBinaryCache
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
@Test
public void shouldThrowExceptionIfNotBinaryCache() {
// Given:
NamedCache cache = CacheFactory.getCache("replicated-cache-test");
try {
// When:
cache.aggregate(AlwaysFilter.INSTANCE, new IndexContentExtractor(TestType.INTEGER_PROP_JAVA_EXTRACTOR));
} catch (PortableException e){
assertThat(e.getCause(), instanceOf(PortableException.class));
assertThat(((PortableException)e.getCause()).getName(), containsString(IllegalArgumentException.class.getCanonicalName()));
}
}
示例10: givenSomeDataInCache
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
private static NamedCache givenSomeDataInCache(String cacheName, int count) {
NamedCache cache = CacheFactory.getCache(cacheName);
for (int key = 0; key != count; ++key) {
int value = key % 5;
cache.put(key, new TestType("" + value, value));
}
return cache;
}
示例11: testIndexingCoherenceDefaultIndexConfig
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
@Test
public void testIndexingCoherenceDefaultIndexConfig() 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.endObject();
builder.startObject("index");
builder.field("index", "test_index");
builder.field("type", "test_type");
builder.field("bulkSize", "20");
builder.field("bulkThreadLimit", "1");
builder.field("bulkFlushInterval", "10");
builder.endObject();
builder.endObject();
logger.info("Adding river \n{}", builder.string());
client().prepareIndex(RiverIndexName.Conf.DEFAULT_INDEX_NAME, "coherence_river_2", "_meta")
.setSource(builder).get();
// Add to cache
for (int i = 0; i < 100; i++)
{
cache.put(i, getTestBean(i));
}
checkCount("test_index", 101);
for (int i = 0; i < 100; i++)
{
checkDocument("test_index", "test_type", String.valueOf(i), i);
}
}
示例12: main
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
System.setProperty("tangosol.coherence.cacheconfig", "client-config.xml");
NamedCache cache = CacheFactory.getCache("dist-cache");
int size = 100000;
ValueExtractor extractor = new CacheObjectBloomExtractor();
cache.addIndex(extractor, false, null);
System.out.println("Starting cache puts..");
for (int i = 0; i < size; i++) {
cache.put(UUID.randomUUID().toString(), new CacheObject("Value" + i));
}
Random random = new Random(0L);
System.out.println("Starting random gets..");
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
String key = "Value" + random.nextInt(size);
int test = (Integer) cache.aggregate(new BloomEqualsFilter(extractor, key), new Count());
if (test != 1) {
throw new RuntimeException("Failed count, on key: " + key + ": " + test);
}
}
long end = System.nanoTime();
System.out.println("Get time: " + ((end - start) / NANO_TO_MILLISECONDS));
}
示例13: main
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
System.setProperty("tangosol.coherence.cacheconfig", "client-config.xml");
NamedCache cache = CacheFactory.getCache("dist-cache");
int size = 100000;
ValueExtractor extractor = new CacheObjectExtractor();
cache.addIndex(extractor, false, null);
System.out.println("Starting cache puts..");
for (int i = 0; i < size; i++) {
cache.put(UUID.randomUUID().toString(), new CacheObject("Value" + i));
}
Random random = new Random(0L);
System.out.println("Starting random gets..");
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
String key = "Value" + random.nextInt(size);
int test = (Integer) cache.aggregate(new EqualsFilter(extractor, key), new Count());
if (test != 1) {
throw new RuntimeException("Failed count, on key: " + key + ": " + test);
}
}
long end = System.nanoTime();
System.out.println("Get time: " + ((end - start) / NANO_TO_MILLISECONDS));
}
示例14: main
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
System.setProperty("tangosol.coherence.cacheconfig", "client-config.xml");
NamedCache cache = CacheFactory.getCache("dist-cache");
int size = 100000;
System.out.println("Starting cache puts..");
for (int i = 0; i < size; i++) {
cache.put(UUID.randomUUID().toString(), new CacheObject("Value" + i));
}
Random random = new Random(0L);
ValueExtractor extractor = new CacheObjectExtractor();
System.out.println("Starting random gets..");
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
String key = "Value" + random.nextInt(size);
int test = (Integer) cache.aggregate(new EqualsFilter(extractor, key), new Count());
if (test != 1) {
throw new RuntimeException("Failed count, on key: " + key + ": " + test);
}
}
long end = System.nanoTime();
System.out.println("Get time: " + ((end - start) / NANO_TO_MILLISECONDS));
}
示例15: CoherenceCommandCache
import com.tangosol.net.CacheFactory; //导入方法依赖的package包/类
public CoherenceCommandCache(String cache, CommandCacheConfig config)
{
this(CacheFactory.getCache(cache), config);
}