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


Java FactoryBuilder类代码示例

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


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

示例1: doContinuousQuery

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
/**
 * @param cache Ignite cache.
 * @param map Parameters map.
 * @throws Exception If failed.
 */
private void doContinuousQuery(IgniteCache<Object, Object> cache, Map<Object, Object> map) throws Exception {
    List<QueryCursor> cursors = (ArrayList<QueryCursor>)map.get(cache.getName());

    if (cursors == null) {
        cursors = new ArrayList<>(CONTINUOUS_QUERY_PER_CACHE);
        map.put(cache.getName(), cursors);
    }

    if (cursors.size() == CONTINUOUS_QUERY_PER_CACHE) {
        QueryCursor cursor = cursors.get(nextRandom(cursors.size()));
        cursor.close();
        cursors.remove(cursor);
    }

    ContinuousQuery qry = new ContinuousQuery();

    qry.setLocalListener(new ContinuousQueryUpdater());

    qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(new ContinuousQueryFilter()));

    cursors.add(cache.query(qry));
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteCacheRandomOperationBenchmark.java

示例2: createCacheConfiguration

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
/**
 * @param atomicityMode Atomicity mode.
 * @return Cache configuration.
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private CacheConfiguration<String, List<Double>> createCacheConfiguration(CacheAtomicityMode atomicityMode) {
    CacheConfiguration<String, List<Double>> cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cc.setCacheMode(PARTITIONED);
    cc.setAtomicityMode(atomicityMode);
    cc.setWriteSynchronizationMode(FULL_SYNC);

    cc.setReadThrough(true);
    cc.setWriteThrough(true);

    Factory cacheStoreFactory = new FactoryBuilder.SingletonFactory(new DummyCacheStore());

    cc.setCacheStoreFactory(cacheStoreFactory);

    cc.setBackups(2);

    return cc;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:EntryVersionConsistencyReadThroughTest.java

示例3: getConfiguration

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<String, Long> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setReadFromBackup(true);
    ccfg.setCopyOnRead(false);
    ccfg.setName(THROTTLES_CACHE_NAME);

    Duration expiryDuration = new Duration(TimeUnit.MINUTES, 1);

    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
    ccfg.setReadThrough(false);
    ccfg.setWriteThrough(true);

    ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(new TestCacheStore()));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:IgniteCacheWriteBehindNoUpdateSelfTest.java

示例4: cacheConfig

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
/** */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfig(String cacheName) {
    CacheConfiguration ccfg = new CacheConfiguration<>(cacheName);

    ccfg.setCacheMode(cacheMode);
    ccfg.setBackups(backups);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 1));
    ccfg.setReadThrough(true);
    ccfg.setReadFromBackup(true);
    ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(TestStore.class));

    if (near)
        ccfg.setNearConfiguration(new NearCacheConfiguration());

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheStoreReadFromBackupTest.java

示例5: testNoWriteThrough

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
public void testNoWriteThrough() {
    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MockCacheWriter external = new MockCacheWriter();
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheWriterFactory(new FactoryBuilder.SingletonFactory<>(external))
                .setWriteThrough(false);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);
        String key = "key";
        cache.put(key, "some_datum");

        String result = external.database.get(key);
        assertNull(result);
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:21,代码来源:CacheWriterTest.java

示例6: shouldWriteThroughUsingInvoke_remove_nonExistingEntry

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
public void shouldWriteThroughUsingInvoke_remove_nonExistingEntry() {
    RecordingCacheWriter<Integer, String> cacheWriter = new RecordingCacheWriter<>();
    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<Integer, String> config
                = new MutableConfiguration<Integer, String>()
                .setTypes(Integer.class, String.class)
                .setCacheWriterFactory(new FactoryBuilder.SingletonFactory<>(cacheWriter))
                .setWriteThrough(true);

        Cache<Integer, String> cache = cacheManager.createCache("simpleCache", config);
        assertEquals(0, cacheWriter.getWriteCount());
        assertEquals(0, cacheWriter.getDeleteCount());

        cache.invoke(1, new RemoveEntryProcessor<Integer, String, Object>());
        assertEquals(0, cacheWriter.getWriteCount());
        assertEquals(1, cacheWriter.getDeleteCount());
        assertFalse(cacheWriter.hasWritten(1));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:23,代码来源:CacheWriterTest.java

示例7: shouldNotLoadWithNullKeyUsingLoadAll

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
    public void shouldNotLoadWithNullKeyUsingLoadAll() throws Exception {

        HashSet<String> keys = new HashSet<>();
        keys.add(null);

        CachingProvider cachingProvider = Caching.getCachingProvider();
        Properties p = new Properties();
        try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
            MutableConfiguration<String, String> config
                    = new MutableConfiguration<String, String>()
                    .setTypes(String.class, String.class)
                    .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                    .setReadThrough(true);
            Cache<String, String> cache = cacheManager.createCache("test", config);
            CompletionListenerFuture future = new CompletionListenerFuture();
            cache.loadAll(keys, false, future);

            fail("Expected a NullPointerException");
        } catch (NullPointerException e) {
            //SKIP: expected
        } finally {
//            assertThat(cacheLoader.getLoadCount(), is(0));
        }
    }
 
开发者ID:diennea,项目名称:blazingcache,代码行数:26,代码来源:CacheLoaderTest.java

示例8: testReadThrough

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
public void testReadThrough() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(true);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        String result = cache.get(key);
        assertEquals("LOADED_" + key, result);
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:20,代码来源:CacheLoaderTest.java

示例9: testReadThroughGetAll

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
public void testReadThroughGetAll() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(true);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        Map<String, String> result = cache.getAll(new HashSet<>(Arrays.asList(key)));
        assertEquals("LOADED_" + key, result.get(key));
        assertEquals("LOADED_" + key, cache.get(key));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:21,代码来源:CacheLoaderTest.java

示例10: testNoReadThrough

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Test
public void testNoReadThrough() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(false);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        String result = cache.get(key);
        assertNull(result);
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:20,代码来源:CacheLoaderTest.java

示例11: produces

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Produces
@CustomCache
public Cache<Integer, Person> produces() {
	CacheManager manager = Caching.getCachingProvider().getCacheManager();
	
	Cache<Integer, Person> cache = manager.getCache(CACHE_NAME, Integer.class, Person.class);
	if(cache == null) {
		MutableConfiguration<Integer, Person> configuration = new MutableConfiguration<>();
		configuration.setTypes(Integer.class, Person.class);
		configuration.setStatisticsEnabled(true);
			
		cache = manager.createCache(CACHE_NAME, configuration);
		
		CacheEntryListenerConfiguration<Integer, Person> listenersConfiguration
			= new MutableCacheEntryListenerConfiguration<>(FactoryBuilder.factoryOf(CacheModificationListener.class), null, false, true);
		cache.registerCacheEntryListener(listenersConfiguration);
	}
	
	return cache;
}
 
开发者ID:wesleyegberto,项目名称:javaee_projects,代码行数:21,代码来源:CacheProducer.java

示例12: produce

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Produces
@LimitedCache
public Cache<Integer, Person> produce() {
	CacheManager manager = Caching.getCachingProvider().getCacheManager();

	Cache<Integer, Person> cache = manager.getCache(CACHE_NAME, Integer.class, Person.class);
	if(cache == null) {
		MutableConfiguration<Integer, Person> configuration = new MutableConfiguration<>();
		configuration.setTypes(Integer.class, Person.class);
		configuration.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));

		cache = manager.createCache(CACHE_NAME, configuration);

		CacheEntryListenerConfiguration<Integer, Person> listenersConfiguration = new MutableCacheEntryListenerConfiguration<>(
				FactoryBuilder.factoryOf(CacheModificationListener.class), null, false, true);
		cache.registerCacheEntryListener(listenersConfiguration);
	}

	return cache;
}
 
开发者ID:wesleyegberto,项目名称:javaee_projects,代码行数:21,代码来源:LimitedCacheExposer.java

示例13: setup

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Setup
public void setup() {
    results = targetInstance.getList(name);
    listeners = targetInstance.getList(name + "listeners");

    cache = CacheUtils.getCache(targetInstance, name);
    listener = new ICacheEntryListener<Integer, Long>();
    filter = new ICacheEntryEventFilter<Integer, Long>();

    threadsRemaining.set(threadCount);

    CacheEntryListenerConfiguration<Integer, Long> config = new MutableCacheEntryListenerConfiguration<Integer, Long>(
            FactoryBuilder.factoryOf(listener),
            FactoryBuilder.factoryOf(filter),
            false, syncEvents);
    cache.registerCacheEntryListener(config);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:18,代码来源:ListenerICacheTest.java

示例14: setup

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Setup
public void setup() {
    counters = targetInstance.getList(name + "counters");

    RecordingCacheLoader<Integer> loader = new RecordingCacheLoader<Integer>();
    loader.loadDelayMs = getDelayMs;

    RecordingCacheWriter<Integer, Integer> writer = new RecordingCacheWriter<Integer, Integer>();
    writer.writeDelayMs = putDelayMs;
    writer.deleteDelayMs = removeDelayMs;

    config = new CacheConfig<Integer, Integer>();
    config.setReadThrough(true);
    config.setWriteThrough(true);
    config.setCacheLoaderFactory(FactoryBuilder.factoryOf(loader));
    config.setCacheWriterFactory(FactoryBuilder.factoryOf(writer));

    CacheManager cacheManager = createCacheManager(targetInstance);
    cacheManager.createCache(name, config);
    cache = cacheManager.getCache(name);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:22,代码来源:ReadWriteICacheTest.java

示例15: extraSetup

import javax.cache.configuration.FactoryBuilder; //导入依赖的package包/类
@Override
protected MutableConfiguration<Integer, String> extraSetup(MutableConfiguration<Integer, String> cfg) {
  // cfg.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 5)));
  cacheEntryListenerServer = new CacheEntryListenerServer<>(10011, Integer.class, String.class);
  try {
    cacheEntryListenerServer.open();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  listener = new RecordingListener<>();
  cacheEntryListenerServer.addCacheEventListener(listener);
  CacheEntryListenerClient<Integer, String> clientListener =
    new CacheEntryListenerClient<>(cacheEntryListenerServer.getInetAddress(), cacheEntryListenerServer.getPort());
  boolean _isSynchronous = false;
  listenerConfiguration = new MutableCacheEntryListenerConfiguration<>(
    FactoryBuilder.factoryOf(clientListener), null, true, _isSynchronous);
  return cfg.addCacheEntryListenerConfiguration(listenerConfiguration);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:19,代码来源:AdditionalCacheListenerTest.java


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